Skip to content

Address code review feedback for model get/list commands.#20

Merged
github-actions[bot] merged 1 commit intomainfrom
pr-feedback-fixes
Jan 29, 2026
Merged

Address code review feedback for model get/list commands.#20
github-actions[bot] merged 1 commit intomainfrom
pr-feedback-fixes

Conversation

@stack72
Copy link
Copy Markdown
Contributor

@stack72 stack72 commented Jan 29, 2026

  • Extract shared UUID handling and model lookup utilities to src/domain/models/model_lookup.ts
  • Fix model_get_output.tsx to use ink's render instead of ink-testing-library
  • Memoize fzf instances in model_list_output.tsx and type_search_output.tsx to avoid recreation on every render
  • Fix missing space in KeyValue display (now shows ID: value instead of ID:value)
  • Add unit tests for isUuid() and filterModels() functions
  • Export filterModels from model_list.ts to enable direct testing

Changes

File Change
src/domain/models/model_lookup.ts New shared utility with isUuid() and findInputByIdGlobal()
src/domain/models/model_lookup_test.ts Tests for UUID validation
src/cli/commands/model_get.ts Import from shared utility
src/cli/commands/model_validate.ts Import from shared utility
src/cli/commands/model_list.ts Export filterModels for testing
src/cli/commands/model_list_test.ts Add tests for filterModels()
src/presentation/output/model_get_output.tsx Use ink render, fix KeyValue spacing
src/presentation/output/model_list_output.tsx Memoize fzf instance
src/presentation/output/type_search_output.tsx Memoize fzf instance

###Test plan

  • Run deno run test - all 317 tests pass
  • Run deno lint - no issues
  • Run deno fmt --check - properly formatted

- Extract shared UUID handling and model lookup utilities to src/domain/models/model_lookup.ts
- Fix model_get_output.tsx to use ink's render instead of ink-testing-library
- Memoize fzf instances in model_list_output.tsx and type_search_output.tsx to avoid recreation on every render
- Fix missing space in KeyValue display (now shows ID: value instead of ID:value)
- Add unit tests for isUuid() and filterModels() functions
- Export filterModels from model_list.ts to enable direct testing

### Changes
┌────────────────────────────────────────────────┬────────────────────────────────────────────────────────────┐
│                      File                      │                           Change                           │
├────────────────────────────────────────────────┼────────────────────────────────────────────────────────────┤
│ src/domain/models/model_lookup.ts              │ New shared utility with isUuid() and findInputByIdGlobal() │
├────────────────────────────────────────────────┼────────────────────────────────────────────────────────────┤
│ src/domain/models/model_lookup_test.ts         │ Tests for UUID validation                                  │
├────────────────────────────────────────────────┼────────────────────────────────────────────────────────────┤
│ src/cli/commands/model_get.ts                  │ Import from shared utility                                 │
├────────────────────────────────────────────────┼────────────────────────────────────────────────────────────┤
│ src/cli/commands/model_validate.ts             │ Import from shared utility                                 │
├────────────────────────────────────────────────┼────────────────────────────────────────────────────────────┤
│ src/cli/commands/model_list.ts                 │ Export filterModels for testing                            │
├────────────────────────────────────────────────┼────────────────────────────────────────────────────────────┤
│ src/cli/commands/model_list_test.ts            │ Add tests for filterModels()                               │
├────────────────────────────────────────────────┼────────────────────────────────────────────────────────────┤
│ src/presentation/output/model_get_output.tsx   │ Use ink render, fix KeyValue spacing                       │
├────────────────────────────────────────────────┼────────────────────────────────────────────────────────────┤
│ src/presentation/output/model_list_output.tsx  │ Memoize fzf instance                                       │
├────────────────────────────────────────────────┼────────────────────────────────────────────────────────────┤
│ src/presentation/output/type_search_output.tsx │ Memoize fzf instance                                       │
└────────────────────────────────────────────────┴────────────────────────────────────────────────────────────┘

###Test plan

- Run deno run test - all 317 tests pass
- Run deno lint - no issues
- Run deno fmt --check - properly formatted
@github-actions
Copy link
Copy Markdown

PR Review: Address code review feedback for model get/list commands

Overall this is a solid refactoring PR that improves code quality through DRY principles, performance optimizations, and better test coverage. Here's my detailed feedback:


✅ Strengths

1. Good DRY Refactoring

  • Extracting isUuid() and findInputByIdGlobal() into src/domain/models/model_lookup.ts removes duplication from model_get.ts and model_validate.ts
  • The new ModelLookupResult interface provides a clear return type

2. Proper Domain Placement

  • Placing model_lookup.ts in src/domain/models/ is appropriate from a DDD perspective - UUID validation and model lookup are domain concerns

3. Performance Improvements

  • Memoizing the Fzf instances in model_list_output.tsx and type_search_output.tsx is correct - recreating the fzf index on every render was unnecessary work
  • The useMemo dependency arrays are correct ([models] and [types])

4. Correct Ink Usage

  • Switching from ink-testing-library's render to ink's render in model_get_output.tsx is the right fix for production use

5. Good Test Coverage

  • model_lookup_test.ts covers valid UUIDs, case insensitivity, various invalid formats, and edge cases (empty string)
  • model_list_test.ts covers filterModels with various scenarios (empty query, name/type/id filtering, no matches, empty list)
  • Tests follow the project convention: foo.tsfoo_test.ts

6. Code Style Compliance

  • Uses named exports (not default exports) ✓
  • No any types introduced (the existing AnyOptions type alias is pre-existing and has a lint ignore comment) ✓

🔍 Minor Observations

1. Missing test for findInputByIdGlobal()

The model_lookup_test.ts only tests isUuid(). The findInputByIdGlobal() function is not directly tested. This is understandable given it requires mocking YamlInputRepository and modelRegistry, but worth noting for future consideration.

2. Infrastructure dependency in domain layer

model_lookup.ts imports YamlInputRepository as a type:

import type { YamlInputRepository } from "../../infrastructure/persistence/yaml_input_repository.ts";

While this is only a type import (not a runtime dependency), in strict DDD the domain layer typically shouldn't depend on infrastructure. Consider defining an InputRepository interface in the domain layer that YamlInputRepository implements. This would allow findInputByIdGlobal() to accept the interface rather than the concrete implementation. This is a minor architectural suggestion, not a blocker.

3. The // deno-lint-ignore no-explicit-any comments

These exist in model_get.ts, model_list.ts, and model_validate.ts for AnyOptions. This is pre-existing and not introduced by this PR, but worth cleaning up in a future PR to satisfy the "no any types" guideline.


🧪 Verification

The PR description states:

  • deno run test - all 317 tests pass ✓
  • deno lint - no issues ✓
  • deno fmt --check - properly formatted ✓

✅ Verdict

Approve - This is a well-structured refactoring PR that:

  • Reduces code duplication
  • Improves performance with proper memoization
  • Adds good test coverage
  • Follows project conventions

The minor observations above are suggestions for future improvements, not blockers for this PR.

@github-actions github-actions Bot merged commit 6f50220 into main Jan 29, 2026
3 checks passed
@adamhjk adamhjk deleted the pr-feedback-fixes branch January 29, 2026 06:36
stack72 added a commit that referenced this pull request Apr 8, 2026
The _swampClub module-level singleton was keyed on nothing — once created
for issue #N, every subsequent getSwampClub() call returned the same
client regardless of the new issueNumber in globalArgs. Since user models
are loaded via dynamic import() in the same process, the module stays
cached across method calls, so running start for issue #10 and then
issue #20 in the same session silently sent #20's lifecycle entries,
type updates, and status transitions to #10.

Drop the cache entirely and call createSwampClubClient directly at each
use. The reachability check is a single 5s-timeout HTTP GET and runs
once per method invocation — negligible next to the lifecycle POST
already happening on the same code path.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant