Skip to content

fix(native-chat): a running Claude chat keeps its model when two Claude Code versions list differently - #30022

Merged
brennanb2025 merged 4 commits into
mainfrom
brennanb2025/claude-model-switch
Oct 17, 2026
Merged

brennanb2025 merged 4 commits into
mainfrom
brennanb2025/claude-model-switch

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

ELI5

After Claude Code updated, three running chats quietly switched from Opus to Sonnet on the next message. Orca combined the running chat’s model rows with another process’s saved list, removed the default row, and picked Sonnet. This change keeps a running chat’s model whenever its own Claude Code still offers it; when that model is gone, the send uses that chat’s own default.

What Changed

Claude Code 2.1.280 lists opus[1m], while 2.1.302 lists opus. Chats on both versions ran together after the update. Orca previously took model rows and their default from the chat but filtered those rows using an account list that another process could replace. Filtering away Opus made the first remaining row, Sonnet, win.

The options answer now includes an optional listedModelIds field alongside its rows and default. A current client selects a substitute using those facts from one answer. For a running chat, they come from its own process; at rest, they come from the same saved catalog. Ordinary rows are preserved. A launch-only row counts only when the catalog store’s existing retention rule would keep it, checked before saving so a launch cannot verify itself.

Live options reads continue saving newly learned model rows and menus through the existing non-failing wrapper. This preserves models learned after an empty startup and effort menus learned after a model change, including other agent providers, when the chat stops and reopens. Saving account discovery does not filter the running chat’s own rows.

Expected behavior stays: if the chat’s own Claude Code no longer offers opus[1m], the next send can move to opus. Opus 5.5 has a fixed 1M context window under either alias.

Mixed versions: a current desktop or phone client talking to an older host may substitute only the chat’s own default, and only when that host’s saved list also names it; it never chooses the first row. An older desktop or phone client still uses its old filtering logic and can still switch a chat. Updating the host alone cannot fix that client behavior. The new field is optional and result-only, so existing paired and SSH hosts remain supported.

Differences from the common pattern:

  • D1 — Intended: the substitute comes from the running chat’s own list. Orca’s Claude host refuses models that process does not list, and its picker shows that process’s rows; an older process can lack a model offered by the installed CLI.
  • D2 — Temporary: CLI aliases remain model identity. Canonical resolved identities, with aliases accepted at the boundary and changes based on a CLI-established mapping, are tracked in STA-10954. This incident also changed the full model id, so canonical identity alone would not have prevented it.
  • D3 — Temporary: starts, probes and live reads still replace the account list in receipt order. An older running process can overwrite newer rows, order or default. Source ordering and coherent account snapshots are tracked in STA-10951; this PR isolates running-chat selection from that shared list.
  • D4 — Intended: the background refresh interval remains ten minutes; this is an interval policy difference.
  • D5 — Intended: the conservative older-host fallback preserves existing default substitution where the host also lists it and otherwise keeps the current model.
  • D6 — Intended: context suffixes remain part of the CLI’s opaque row id; Orca follows the CLI’s rows.
  • D7 — Intended: there is no model manifest that must be updated for each release.

Why

The bug class is filtering one process’s listing with another process’s membership. Keeping rows, default and membership together removes that cross-filter while retaining account discovery needed for new and stopped chats. Restricting account saves to startup would lose models and effort menus learned later. Ordering discovery writes and canonicalizing identity are separate follow-ups rather than extra persisted fields in this fix.

Tracked in STA-10947.

Visual Proof

Real signed-in Claude Code 2.1.302 passed all four Electron flows on the M4Air: new chat/two sends, same-profile app reopen/send, selecting Sonnet/two sends, and Stop/resume. The accepted sends and real Claude transcript confirm Opus, then Sonnet after the explicit pick, with the same result on main and branch. Main was built at fa962dd1cdec9e545fd3e4baf10fae3cfd9aa1df (before the later main sync); branch was built at the exact final head. Real config hashes were unchanged; all recorded test processes exited and the admitted ports are clear.

The optional unlisted-alias transition was infeasible through the available picker, and Claude Code 2.1.280 was unavailable for a live mixed-version reproduction. Those cases use captured-listing regression tests rather than live QA. Phone, Windows and SSH runtime flows were source-reviewed rather than exercised on those devices. Normal interruption timing differed, and the branch reopen screenshot includes an unrelated notification-permission toast; no unexpected model change was observed.

Flow Main Branch
New chat / two sends Main Branch
Same-profile app reopen / send Main Branch
Explicit Sonnet / two sends Main Branch
Stop / resume Main Branch

Testing

  • Captured old/new Claude listings cover both directions of the unintended Sonnet switch, the expected alias transition, and older-host compatibility through the real shared selection functions.
  • Catalog integration covers late model rows and model-specific menus surviving stop/reopen. Service tests cover known and unknown launch-only ids. Malformed older-host fixtures are repaired.
  • CI is the lint, typecheck and full-suite gate. The full PR workflow passed on 4a10752bb824cd8cee4f6d323222e28293d5a66f, including its aggregate gate.

Review

Full review path: saved catalog behavior, cross-version options and desktop/phone selection are in scope. Two review rounds found and corrected lost live-read discovery, overly broad launch-only exclusion and malformed fixtures. Final commit reconciliation and CI passed on 4a10752bb824cd8cee4f6d323222e28293d5a66f; branch QA passed on that same head. Account ordering and canonical identity remain explicitly tracked follow-ups.

Agent skill upstream boundary

  • Not applicable: no upstream skill-installer source is copied or translated.

Notes

No persisted fields, new operation, UI notice or minimum host version. Folder workspaces remain supported. The options field and shared selection logic apply to desktop, phone and remote hosts.

Checklist

  • Focused on preventing the unintended model switch while retaining later model discovery
  • Problem, user-facing change, mechanism and alternatives explained
  • Real main-versus-branch screenshots attached
  • Source reviewed for correctness and performance
  • Cross-platform and mixed client/server behavior considered
  • Full PR workflow passes on the final head

Author: Brennan Benson (@BrennanKB5)

…de Code versions list differently

A send's stand-in for a model the list lacks took its rows and default from the
chat's own answer but kept only rows the account's saved list names, and every
running chat rewrote that list whatever CLI version it ran. After Claude Code
2.1.280 -> 2.1.302 the filter dropped the default row and sends moved to Sonnet.

- The options answer names the ids its agent listed (listedModelIds); a live
  catalog is verified only by its own listing. An older host's answer may move
  only to the chat's own default row, and only where the host's list names it.
- Only a session's start (and the probe) writes the account's list; later reads
  no longer do, so an older running CLI can't replace a newer start's list.

Tracked in STA-10947.
@brennanb2025
brennanb2025 marked this pull request as ready for review October 17, 2026 07:55
@coderabbitai

coderabbitai Bot commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

📝 Walkthrough

Session option results now include IDs from completed model listings. Shared option state tracks host-listed IDs separately from IDs verified by a live listing. Model selection uses session-verified IDs when available and otherwise applies the host-listing fallback. Live option reads retain eligible model IDs and save listings through the shared listing-saver path. Tests cover catalog retention, option reads, and model selection.

Priority: ⬇️ Low

Merge Risk: 🟡 Moderate · up to 4a107

Model selection can accept unavailable models or fall back incorrectly after listing changes, so the selection logic should be corrected before merge.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 57.14% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 21 functions across 22 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Title check Passed The title clearly and concisely identifies the primary fix: preventing a running Claude chat from changing models when Claude Code versions list models differently.
Description check Passed The description is detailed and covers the user impact, implementation, rationale, testing, visual proof, compatibility, and follow-up issues. It references STA-10947, although the required Fixes # …
Full details: Description check

Explanation

The description is detailed and covers the user impact, implementation, rationale, testing, visual proof, compatibility, and follow-up issues. It references STA-10947, although the required Fixes # field is left empty.

  • Fix all pre-merge checks with AI
✨ Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 85637f9f-d8c4-406a-9767-16112d391a10
📥 Commits

Reviewing files that changed from the base of the PR and between 6c7ed18 and 5de175f.

📒 Files selected for processing: 12
  • mobile/src/session/use-mobile-structured-agent-session-send.test.tsx
  • src/main/acp/acp-structured-host-live-listing.test.ts
  • src/main/native-chat/agent-model-catalog/agent-model-catalog-fingerprint.ts
  • src/main/native-chat/agent-model-catalog/agent-model-catalog-service.ts
  • src/main/native-chat/agent-model-catalog/agent-model-catalog-store.ts
  • src/main/native-chat/agent-session-wire/structured-agent-session-options-read.ts
  • src/main/native-chat/agent-session-wire/structured-agent-session-provider-started.test.ts
  • src/shared/agent-session-wire.ts
  • src/shared/structured-agent-session-model-catalog-application.test.ts
  • src/shared/structured-agent-session-option-view.test.ts
  • src/shared/structured-agent-session-option-view.ts
  • src/shared/structured-agent-session-options.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review.

m4air added 2 commits October 17, 2026 01:50
Preserve learned model menus on later reads and check launch-added model membership before saving.

Tracked in STA-10947.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to GitHub limitations.

⚠️ Outside diff range comments (1)

🟠 Major · Do not report account catalog rows as this chat’s… · structured-agent-session-options-read.ts:128

src/main/native-chat/agent-session-wire/structured-agent-session-options-read.ts:128
🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

Do not report account catalog rows as this chat’s verified listing.

When a stopped chat reads options after a probe or another chat updates its account catalog, catalog.models contains merged account rows, not necessarily rows this chat listed. finishedListingIds(catalog) reports those rows as listedModelIds. The client can then treat a newly discovered model as session-verified and select it instead of limiting the fallback to the chat’s own default. Persist listing IDs per session, or omit listedModelIds from at-rest answers when the chat’s own listing is unavailable. See src/main/native-chat/agent-model-catalog/agent-model-catalog-entry.ts Lines 146–183 and src/shared/structured-agent-session-option-view.ts Lines 111–149.


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 3bdb7e79-e77d-42c3-9713-25973906d698
📥 Commits

Reviewing files that changed from the base of the PR and between 5de175f and 01516b2.

📒 Files selected for processing: 18
  • src/main/acp/acp-structured-host-live-listing.test.ts
  • src/main/native-chat/agent-model-catalog/agent-model-catalog-entry.ts
  • src/main/native-chat/agent-model-catalog/agent-model-catalog-fingerprint.ts
  • src/main/native-chat/agent-model-catalog/agent-model-catalog-prewarm.test.ts
  • src/main/native-chat/agent-model-catalog/agent-model-catalog-service.ts
  • src/main/native-chat/agent-model-catalog/agent-model-catalog-store.ts
  • src/main/native-chat/agent-session-wire/structured-agent-session-launch-permission.test.ts
  • src/main/native-chat/agent-session-wire/structured-agent-session-options-read.test.ts
  • src/main/native-chat/agent-session-wire/structured-agent-session-options-read.ts
  • src/main/native-chat/agent-session-wire/structured-agent-session-outgrown-child.test.ts
  • src/main/native-chat/agent-session-wire/structured-agent-session-provider-started-catalog.test.ts
  • src/main/native-chat/agent-session-wire/structured-agent-session-provider-started.test.ts
  • src/main/native-chat/agent-session-wire/structured-agent-session-provider-started.ts
  • src/main/native-chat/agent-session-wire/structured-agent-session-start-listing.ts
  • src/main/native-chat/agent-session-wire/structured-agent-session-startup-attempt-host.test.ts
  • src/main/runtime/structured-agent-session-runtime-model-catalog-lifetime.test.ts
  • src/shared/agent-session-wire.ts
  • src/shared/structured-agent-session-option-view.test.ts
🚧 Files skipped from review as they are similar to previous changes: 2
  • src/main/native-chat/agent-model-catalog/agent-model-catalog-store.ts
  • src/main/native-chat/agent-model-catalog/agent-model-catalog-fingerprint.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

Use the protocol schema for config options and supply the catalog row default flag.

Tracked in STA-10947.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments: 1
src/main/native-chat/agent-session-wire/structured-agent-session-options-read.test.ts: 1

121-135: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Assert listedModelIds on the live options result.

The live read result is discarded at structured-agent-session-options-read.test.ts:137. The following read is at rest and can rebuild IDs from the saved catalog, so the test passes if the live response omits or returns stale listedModelIds.

Suggested fix
        record.options = { model: 'grok-4.6', effort: 'high' }
        live = true
-        await read()
+        const liveAnswer = await read()
+        expect(liveAnswer.listedModelIds).toEqual(reader.read().models.map(({ id }) => id))
        live = false

ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: b4339578-28e3-4f1b-8cdf-123d572ba536
📥 Commits

Reviewing files that changed from the base of the PR and between 01516b2 and 4a10752.

📒 Files selected for processing: 1
  • src/main/native-chat/agent-session-wire/structured-agent-session-options-read.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.

@brennanb2025

Copy link
Copy Markdown
Contributor Author

After Claude Code updated while older chats were still running, three chats switched from Opus to Sonnet on their next message. Orca filtered one process’s model rows using another process’s saved membership, which removed the default row.

A current desktop or phone client now keeps a model that its own running process still lists, and chooses a replacement from that process’s own answer when the model is gone. Older hosts use the conservative own-default-only fallback. Older desktop or phone clients can still switch chats; updating only the host cannot repair their filtering logic.

The review corrected lost live-read discovery of later model rows and effort menus, preserved the store’s existing rule for launch-only model rows, and repaired malformed older-host test fixtures. The normal commit hook also caught a file-length failure; moving an unchanged catalog-result function into the existing catalog-entry module resolved it without suppressing the check.

Account catalog ordering and incremental snapshot retention remain temporary differences tracked in STA-10951. Canonical model identity is tracked in STA-10954. The PR body labels all seven differences from the common pattern. Opus 5.5 remains fixed at 1M under either alias.

Final head 4a10752bb824cd8cee4f6d323222e28293d5a66f passed the full PR workflow, including its aggregate gate, static analysis, types, node tests, relay and cross-version checks. Source reconciliation and performance/readiness review found no remaining proven defect. The bot’s cached-default concern was traced through the actual host producer: the claimed cached default is absent from that live answer’s rows, so its substitution was not established; preserving an explicit empty membership remains a deferred cleanup concern.

Real signed-in Claude Code 2.1.302 passed all four Electron flows on the M4Air: new chat/two sends, same-profile app reopen/send, selecting Sonnet/two sends, and Stop/resume. The accepted sends and real Claude transcript confirm Opus, then Sonnet after the explicit pick, with the same result on main and branch. Main was built at fa962dd1cdec9e545fd3e4baf10fae3cfd9aa1df (before the later main sync); branch was built at the exact final head. Real config hashes were unchanged; all recorded test processes exited and the admitted ports are clear.

The optional unlisted-alias transition was infeasible through the available picker, and Claude Code 2.1.280 was unavailable for a live mixed-version reproduction. Those cases use captured-listing regression tests rather than live QA. Phone, Windows and SSH runtime flows were source-reviewed rather than exercised on those devices. Normal interruption timing differed, and the branch reopen screenshot includes an unrelated notification-permission toast; no unexpected model change was observed.

For Brennan’s review

Flow Main Branch
New chat / two sends Main Branch
Same-profile app reopen / send Main Branch
Explicit Sonnet / two sends Main Branch
Stop / resume Main Branch

Judgment points: the older-host fallback, the child’s listing and pre-save launch-only check, and account snapshots still replaced in receipt order, tracked in STA-10951.

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