fix(composer): drafts follow model changes made on other clients #20886
main fromrefs/pull/20886/head·merged by juliusmarminge View on GitHubA saved composer model pick kept overriding later model changes made from another client. Clearing it only in the selected composer missed a matching transition while another thread was open; web provider fallback could also erase a different unsent pick.
Reconcile saved picks against durable thread shells for every thread with an override. Compare the actual stored provider, model, and options, then clear only the matching model fields. Keep draft content and other settings, differing picks, local new drafts, and queued-edit drafts. Require a live shell and compare status/model from the same authoritative emission, so cached or synchronizing state cannot discard an unsent pick. Treat an omitted fast-mode toggle as off. Web and mobile share the comparison; both mount reconciliation for the app lifetime.
Maintainer takeover of #20886, preserving @none23’s commits and credit. Merged main without rewriting contributor history.
Verification at 66069a3d74:
- Replaced three original clear-operation/comparator tests with four store scenarios that drive real shell transitions, then added one cached-to-live regression per client after review. Original: 261 passing. Initial regressions: 258 passing, 4 failing. Before the live-shell guard: 262 passing, 2 failing. Rebuilt: 264 passing across the existing web/mobile draft-store and shared model test files.
- Web, mobile, and shared typechecks passed. Targeted lint passed with one existing mobile hydration warning; formatting and diff checks passed.
- Linux headless web: selected a draft pick through the app’s store, switched threads through the UI, and applied model-only commands through the running server RPC. With another conversation selected, Sonnet → Opus consumes the saved Opus pick; a later Haiku change is followed on return, with the draft text intact. No provider run was started. A different unavailable-provider pick also remained stored while the visible composer fell back to the thread model.
- Independent full-diff Claude Opus 5.5 and Codex GPT-6-Sol reviews: two rounds. Round 1 caught stale-cache consumption; the fix also handles status/snapshot delivery ordering. Both round 2 reviews found no blockers.
Same isolated data and 1280 × 800 viewport, integrated main 5cda25e72b versus rebuilt head. The server’s final model is Haiku in both images.
| Before: stale Opus pick | After: follows Haiku, keeps draft |
|---|---|
![]() | ![]() |
Recording: switch away, consume the matching pick, and return to the later model
Not verified here: macOS, Windows, iOS, Android, Electron desktop shell, a second physical client, relay/tunnel connections, or live multi-model submission. Cached/reconnecting shell transitions were verified in state tests; a disconnected UI flow was not captured. Mobile behavior is covered by state tests and typechecking; the original author’s device captures predate this rebuild and are not current-head proof. Matching the current durable model releases the pick immediately, including re-picking that model while another model is queued.
Implementation: GPT-6.1-Sol in the Codex harness through T3 Code. Tests: GPT-6-Astra; independent reviews: Claude Opus 5.5 and GPT-6-Sol, delegated through T3 Code.
- 1
github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:M
- apps/web/src/components/chat/ChatComposer.tsx line 2362OutdatedResolvedby none23(GitHub profile, opens in a new tab)@@ -2347,3 +2351,12 @@23472351 selectedModel,23482352 selectedModelOptionsForDispatch,23492353 );2354+ // A model pick overrides the thread only until the thread runs on it. Dropping the pick2355+ // then lets this composer follow model changes made later from other clients.2356+ const draftModelPickInUse =2357+ isServerThread &&2358+ multipleModelSelections === null &&2359+ (composerDraft.activeProvider !== null ||2360+ Object.keys(composerDraft.modelSelectionByProvider).length > 0) &&2361+ activeThreadModelSelection != null &&2362+ draftModelPickMatchesThread(selectedModelSelection, activeThreadModelSelection);
🟡 Medium
chat/ChatComposer.tsx:2362A draft pick for provider B is permanently erased when B is unavailable: the resolved selection falls back to the thread's provider A, so this comparison matches A's thread selection and
clearModelSelectionremoves B's unsent pick. Only clear the draft pick when the comparison uses the actual draft selection, or when resolution did not fall back from its active provider.🤖 Copy this AI Prompt to have your agent fix this:
In file @apps/web/src/components/chat/ChatComposer.tsx around line 2362: A draft pick for provider B is permanently erased when B is unavailable: the resolved selection falls back to the thread's provider A, so this comparison matches A's thread selection and `clearModelSelection` removes B's unsent pick. Only clear the draft pick when the comparison uses the actual draft selection, or when resolution did not fall back from its active provider.COMMENT FROM claude-opus-5-5
Not changing this. The fallback only happens when the picked provider is disabled in settings or its driver is unavailable. While the provider catalog is still loading,
selectedInstanceIdis the no-provider sentinel, so nothing matches and nothing is cleared.In the fallback case the composer already shows and sends the thread's model, so the B pick does nothing. Losing it matters only if B comes back before the user sends, and then they pick B again. Guarding that would add a second comparison path for a rare state, and this PR stays small on purpose.
Sorry, I'm unable to act on this request because you do not have permissions within this repository.
Approvability#
Verdict: Needs Human Approval
Macroscope's review found this PR requires human approval — This is a focused web/mobile composer bug fix with tests and no schema, infrastructure, security, billing, or configuration-default changes. An unresolved Medium-severity finding identifies a concrete case where an unavailable provider can cause an unsent draft selection to be erased, requiring human review.
Adjust the Minimum Blocking Severity for this repo — including turning it Off — in [Settings](https://app.macroscope.com/pingdotgg/settings#Repos). You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).Warning
Review limit reached#
Only developers with an assigned seat can use this organization's usage-based review budget, and seats here are assigned manually. Ask an admin to assign a seat, or change the review continuation mode in Billing.
Next included review available in 1 minute.
View limit details
-
Limit details: You’ve used all 10 included reviews currently available.
Review configuration:
⚙️ Run configuration
-
- Configuration used: Path: .coderabbit.config.ts
- Review profile: CHILL
- Plan: Advanced
- Run ID:
48e64e44-7397-4971-ade8-b1264e873fa3
📥 Commits
-
Reviewing files that changed from the base of the PR and between 70bdc9a047eafce2bc0097dcca6a4052162989e2 and 13d054565714056374bd862163dec18dafe4d9ab.
📒 Files selected for processing: 7
-
apps/mobile/src/App.tsxapps/mobile/src/state/use-composer-drafts.test.tsapps/mobile/src/state/use-composer-drafts.tsapps/web/src/AppRoot.tsxapps/web/src/composerDraftStore.test.tsapps/web/src/composerDraftStore.tspackages/shared/src/model.ts
-
No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
-
⚙️ Run configuration
-
- Configuration used: Path: .coderabbit.config.ts
- Review profile: CHILL
- Plan: Advanced
- Run ID:
15d67d81-03e7-4e02-ade4-b5cb14cc2f06
📥 Commits
-
Reviewing files that changed from the base of the PR and between 89b42bfeb4f79408af72fc7bb7a4482e22bb9493 and 70bdc9a047eafce2bc0097dcca6a4052162989e2.
📒 Files selected for processing: 8
-
apps/mobile/src/state/use-composer-drafts.test.tsapps/mobile/src/state/use-composer-drafts.tsapps/mobile/src/state/use-thread-composer-state.tsapps/web/src/components/chat/ChatComposer.tsxapps/web/src/composerDraftStore.test.tsapps/web/src/composerDraftStore.tspackages/shared/src/model.test.tspackages/shared/src/model.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.
-
📝 Walkthrough
-
Mobile and web composers now clear draft model overrides that match the selected thread model. A shared comparison helper treats an omitted
fastModeoption as equivalent tofastMode: false. Clearing a model selection preserves remaining draft content and removes the draft when it becomes empty.Changes: Composer model reconciliation
Layer / File(s) Summary Draft and thread model comparison
packages/shared/src/model.ts,packages/shared/src/model.test.tsAdds draftModelPickMatchesThread, which ignoresfastMode: falsewhen comparing selections. Tests cover omitted and explicit false options, and confirm thatfastMode: trueremains distinct.Draft model-selection clearing
apps/mobile/src/state/use-composer-drafts.ts,apps/mobile/src/state/use-composer-drafts.test.ts,apps/web/src/composerDraftStore.ts,apps/web/src/composerDraftStore.test.tsAdds mobile and web operations that clear draft model-selection state. Both retain other draft content and remove the draft when it becomes empty. Tests cover these outcomes. Mobile and web composer reconciliation
apps/mobile/src/state/use-thread-composer-state.ts,apps/web/src/components/chat/ChatComposer.tsxThe mobile composer clears a draft override when it matches the selected thread model. The web composer does so for a server thread when multi-model selection is inactive and the draft pick matches the active thread model. Priority: ➖ Normal
Estimated code review effort: 3 (Moderate) | ~20 minutes
Change: Bug fix · Severity of issue fixed: Medium
Sequence Diagram(s)#
sequenceDiagram participant MobileComposer as use-thread-composer-state participant MobileDrafts as clearComposerDraftModelSelection participant WebComposer as ChatComposer participant WebDrafts as ComposerDraftStoreState participant Matcher as draftModelPickMatchesThread par Mobile composer MobileComposer->>Matcher: Compare draft pick with thread selection Matcher-->>MobileComposer: Return match result MobileComposer->>MobileDrafts: Clear matching draft model selection and Web composer WebComposer->>Matcher: Compare draft pick with active thread model Matcher-->>WebComposer: Return match result WebComposer->>WebDrafts: Clear matching draft model selection endSuggested reviewers:
juliusmarminge
Merge Risk: ⚪ Minimal · up to
70bdc-
Composers now follow model changes made on other clients while keeping unsent model picks that differ from the thread. No concrete merge-blocking risk was found. Fast-mode behavior has not been checked on a device.
Security architecture risk: 🔵 Low · up to
70bdc-
The change affects when a saved draft preference stops overriding a conversation. No new access path or increased privilege was established. Risk is low, with concurrent updates and restart recovery not fully verified.
Retained concerns No architecture-level concerns identified.
Security review details
-
Security Blast Radius
- inferred — The directly demonstrated mutation scope is one resolved client draft per invocation. Web resolves scoped thread or draft-session ownership; mobile constructs the selected key from environment and thread identity. The inspected clearing operations do not mutate provider configuration or credentials.
Trust Boundaries and Controls
- observed — The comparator cannot equate selections from different provider instances. Existing web resolution filters provider compatibility and availability, and its send path rejects an unavailable provider. Mobile retains environment-operation and connected-provider availability checks before normal enqueueing. These are client-side counterevidence to a newly introduced control bypass, not verification of downstream authorization.
Resilience and Maintainability Implications
- observed — Mobile clearing uses the existing synchronous draft update and persistence scheduler. Persistence serializes writes, invokes atomic file writing and records failed writes for later retry. This establishes reuse of existing recovery machinery, not complete interruption or restart correctness.
-
Pre-merge checks:
3 · 1-
Failed checks: 1 warningCheck name Status Explanation Resolution Description check The description thoroughly documents the problem, implementation, verification, test results, screenshots, recording, limitations, and agent usage. However, it does not provide the required triaged bu… Add the relevant triaged issue or maintainer discussion link with the approval comment. If no prior approval is required, explain why this focused fix qualifies for the exemption. Passed checks: 3 passed-
Check name Status Explanation Linked Issues check #15195requires the desktop composer to follow server model changes, including same-provider-instance changes, while retaining a newer draft pick.ChatComposernow compares the draft pick with `acti…Out of Scope Changes check The changes stay within the composer model-pick behavior described by #15195. Web and mobile clear only the model pick, shared comparison logic supports both clients, and the added tests verify preser…Title check The title clearly and concisely describes the primary change: composer drafts now follow model changes made on other clients. Full details: Linked Issues check
-
Explanation
#15195requires the desktop composer to follow server model changes, including same-provider-instance changes, while retaining a newer draft pick.ChatComposernow compares the draft pick withactiveThreadModelSelectionand clears only a matching pick. A differing pick remains.draftModelPickMatchesThreadcompares the model selection, instance, and options while treatingfastMode: falseas unset. Web and shared tests cover draft preservation and the comparison rule. The mobile counterpart uses the same rule for cross-client consistency.
Full details: Out of Scope Changes check
-
Explanation
The changes stay within the composer model-pick behavior described by
#15195. Web and mobile clear only the model pick, shared comparison logic supports both clients, and the added tests verify preservation and comparison behavior. No unrelated settings, server, contract, or infrastructure changes appear in the whole-PR diff.
-
Full details: Description check
-
Explanation
The description thoroughly documents the problem, implementation, verification, test results, screenshots, recording, limitations, and agent usage. However, it does not provide the required triaged bug link or explicit maintainer approval of the direction and scope, and it does not explain why the change qualifies for an approval exemption.
Resolution
Add the relevant triaged issue or maintainer discussion link with the approval comment. If no prior approval is required, explain why this focused fix qualifies for the exemption.
-
✨ Finishing Touches
-
🧪 Generate unit tests (beta)
-
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
-
juliusmarminge assignedjuliusmarminge
Taking over this one as maintainer. I will preserve your commits and credit, reconcile matching model changes even when another thread is selected, and retain unsent picks when a provider is unavailable. I will push the finished change here without merging.
github-actions[bot](GitHub profile, opens in a new tab) removed labelssize:M
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:L
juliusmarminge merged this2767012
juliusmarminge closed this
Sign in to join this conversation.


macroscopeapp[bot](GitHub profile, opens in a new tab) reviewed