Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(composer): drafts follow model changes made on other clients #20886

Mergednone23(GitHub profile, opens in a new tab)merged 7 commits intomain fromrefs/pull/20886/headmerged by juliusmarminge View on GitHub

A 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 pickAfter: follows Haiku, keeps draft
Before: composer retains Opus after the server has changed to HaikuAfter: composer follows Haiku and retains the draft text

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

    2. macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      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).
    3. coderabbitai[bot](GitHub profile, opens in a new tab)commented
      Review in Change Stack →

      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.

      Check out review usage here.

      View limit details

      Limit details: You’ve used all 10 included reviews currently available.

      Learn how review limits work.

      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.tsx
      • apps/mobile/src/state/use-composer-drafts.test.ts
      • apps/mobile/src/state/use-composer-drafts.ts
      • apps/web/src/AppRoot.tsx
      • apps/web/src/composerDraftStore.test.ts
      • apps/web/src/composerDraftStore.ts
      • packages/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.ts
      • apps/mobile/src/state/use-composer-drafts.ts
      • apps/mobile/src/state/use-thread-composer-state.ts
      • apps/web/src/components/chat/ChatComposer.tsx
      • apps/web/src/composerDraftStore.test.ts
      • apps/web/src/composerDraftStore.ts
      • packages/shared/src/model.test.ts
      • packages/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 fastMode option as equivalent to fastMode: 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.ts
      Adds draftModelPickMatchesThread, which ignores fastMode: false when comparing selections. Tests cover omitted and explicit false options, and confirm that fastMode: true remains 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.ts
      Adds 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.tsx
      The 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
        end

      Suggested 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: Passed 3 · Failed 1
      Failed Failed checks: 1 warning
      Check nameStatusExplanationResolution
      Description checkWarningThe 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 Passed checks: 3 passed
      Check nameStatusExplanation
      Linked Issues checkPassed#15195 requires the desktop composer to follow server model changes, including same-provider-instance changes, while retaining a newer draft pick. ChatComposer now compares the draft pick with `acti…
      Out of Scope Changes checkPassedThe 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 checkPassedThe title clearly and concisely describes the primary change: composer drafts now follow model changes made on other clients.
      Full details: Linked Issues check

      Explanation

      #15195 requires the desktop composer to follow server model changes, including same-provider-instance changes, while retaining a newer draft pick. ChatComposer now compares the draft pick with activeThreadModelSelection and clears only a matching pick. A differing pick remains. draftModelPickMatchesThread compares the model selection, instance, and options while treating fastMode: false as 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
      Comment `@coderabbitai help` to get the list of available commands.
    4. juliusmarminge assignedjuliusmarminge

    5. 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.

    6. juliusmarminge merged this2767012

    7. juliusmarminge closed this

Sign in to join this conversation.