Skip to content

refactor(coding-agent): derive available connection models on read - #1741

Closed
snimu wants to merge 6 commits into
snimu/use-message-countfrom
snimu/derive-connection-models
Closed

refactor(coding-agent): derive available connection models on read#1741
snimu wants to merge 6 commits into
snimu/use-message-countfrom
snimu/derive-connection-models

Conversation

@snimu

@snimu snimu commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

What was wrong

The TUI stored connectionModels — a filtered copy of the model catalog x configured providers — with its own assignment, clearing, and versioned return paths. A pure function of two other fields, stored, and therefore synchronizable and driftable (audit: duplicate sources of truth, dup-truth.md finding 4).

The fix

The stored copy and its sync paths are deleted; the available-model list derives on read with the identical predicate (catalog.filter(m => providers.has(m.provider))). The catalog, provider set, and async-refresh generation guard remain — they are source data and stale-request protection, not copy-sync. +17/−22.

How it's verified

Reviewer confirmed all 4 former field sites converted (zero references remain), predicate character-identical including the invalidate and stale-generation cases, derivation off any render hot path, and the retained machinery guards source data only. 174/174 focused; full CI-style suite identical failing set to stack base. Two-model implement/review loop, approved first pass.

Stacked on #1739 (test the whole stack at the leaf; merge base-first).

Note: intentionally no Linear ticket for this cleanup stack, so that check stays red.


Note

Low Risk
Internal refactor with identical filtering logic and in-tree test updates; no auth or API surface changes beyond removing a private field.

Overview
InteractiveMode no longer keeps a separate cached connectionModels list. Available models are derived on read via getAvailableConnectionModels(), filtering connectionModelCatalog by connectionConfiguredProviders with the same predicate as before.

applyConnectionModelCatalog only updates catalog and provider set; invalidateConnectionModels clears providers (so derived availability is empty) instead of wiping a duplicate array. Async catalog refresh and stale-request handling still use the getter after fetch or on version mismatch.

Tests and harnesses assert through getAvailableConnectionModels() instead of the removed field. Changelog notes keeping available lists aligned with catalog and configured providers.

Reviewed by Cursor Bugbot for commit 63cbcd3. Bugbot is set up for automated code reviews on this repo. Configure here.

Note

Derive available connection models on read in InteractiveMode

  • Removes the cached connectionModels field from InteractiveMode; availability is now computed on demand from connectionModelCatalog and connectionConfiguredProviders via the new getAvailableConnectionModels accessor.
  • applyConnectionModelCatalog no longer populates a separate cache; invalidateConnectionModels relies on clearing connectionConfiguredProviders to make available models empty.
  • getConnectionAvailableModels uses the new getter in both the version-mismatch path and after fetching a catalog.
  • Tests in interactive-mode-status.test.ts and 4575-model-auth-selection.test.ts are updated to assert via getAvailableConnectionModels() instead of the removed field.
  • Risk: any external caller reading connectionModels directly will break; all known in-tree callers are updated.

Macroscope summarized 63cbcd3.

Linear ticket: ENG-5660
(ticket linked above)

@snimu

snimu commented Aug 27, 2026

Copy link
Copy Markdown
Contributor Author

Superseded by #1826: GitHub's stack lock prevents retargeting stacked PRs, so this PR was recreated as a plain PR against main (same branch, same content, all review threads here are resolved). Please review/merge #1826 instead.

@snimu snimu closed this Aug 27, 2026
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