Skip to content

fix(web): scope resume compaction to the selected provider conversation - #26142

Closed
Alb11747 wants to merge 2 commits into
pingdotgg:mainfrom
Alb11747:fix/25943-provider-scoped-resume-compaction
Closed

Alb11747 wants to merge 2 commits into
pingdotgg:mainfrom
Alb11747:fix/25943-provider-scoped-resume-compaction

Conversation

@Alb11747

@Alb11747 Alb11747 commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Problem

After a long Claude conversation becomes cold, selecting Codex can leave Compact next enabled and send an automatic /compact on Codex before queueing the actual message. The parent chat view keeps the conversation's provider lock while the composer permits handoff, so the recommendation and live send destination disagree.

Reproduce with a stopped Claude conversation containing 250k tokens past its cache TTL: select Codex and send an ordinary message. The expected result is one normal handoff/message dispatch. The affected source instead dispatches Codex /compact with idleCompaction: "onReturn", then queues the message.

Fixes #25943. Related: #23086, which concerns evaluating the saved Claude destination when switching back.

Change

Resolve the parent's selection the same way as the composer, and bind resume-compaction recommendations to the selected provider instance, saved conversation, and observed context. The composer hides recommendations that do not match its selection. The send handler checks the live destination again after uploads/settings preparation, so a replaced, refreshed, or compacted conversation cannot reuse an older recommendation. The optimistic message's queue/steer classification and scroll anchor follow that final send plan.

Returning to a saved long, cold Claude conversation still offers compaction using that destination's context. Manual /compact, full-history choices, warm-cache behavior, original message/attachments, and normal dispatch modes retain their existing behavior.

Scope and approval

The issue has not received maintainer triage; no prior approval is claimed. This is submitted under the focused obvious-bug exception: an existing Claude-only recommendation is being applied to a different provider or conversation. The changes carry that existing eligibility through its UI and send boundary, without introducing a setting, workflow, or product default. All eight files address this same mismatch and its regression coverage.

Web and desktop share this composer path. Native mobile, agent/MCP sends, and scheduled sends do not inject this web on-return compaction. The separate before-cache-expiry service already checks its Claude provider/conversation and is unchanged.

Verification

  • vp run check:changed upstream/main: formatting, lint, knip, affected typechecks, and all 65 tests across three files passed on the upstream-only branch.
  • The failing regression and full AppRoot fixture reproduced the original behavior on affected source 54aeb9ba2df2. The fixture recorded Codex /compact followed by the queued message before the fix, versus exactly one Codex message after it. The source/fixture details are in [Bug]: Switching from an idle Claude thread to Codex still triggers automatic /compact #25943.
  • Actual send-hook browser tests cover stale parent Claude eligibility with live Codex selection, preserving uploaded attachments and one actual message. Deferred uploads cover conversation replacement, context refresh, usage refresh, and compaction with an unchanged conversation ID; these cases send directly and clear the optimistic queued marker when the recommendation becomes stale. Controls preserve explicit queue/steer intent and anchoring, same-Claude and Codex-to-saved-Claude compaction, manual commands, opt-outs, and warm/small context.
  • Exact-commit fork CI passed on current head bc2ce013fdf27d591919c8cc52d5b8d1f022fe50: Quality, Web tests, Tests, and all three server shards are green. The preceding revision's full CI passed on 1fe0a60a58fcbb11e3f52663abf06ef91a9bdf98, based on upstream 5e9d56416f6b: Quality, Web tests, Tests, and all three server shards were green.
  • Earlier CI and a focused local check on the earlier upstream base exposed an unrelated storageCleanup.test.ts invalid-gitfile diagnostic failure. The subsequent full run above passed. The server/package trees are unchanged from upstream in this PR; the separate fork cleanup compatibility fix is excluded.

Integrated UI captures use a synthetic full-AppRoot environment with mocked providers. No provider CLI, paid model call, or live database was used. The captures were made on the affected/fixed fork source before the upstream-only port; the port contains the same production fix. Slow-request toasts in the fixed fixture are caused by deliberately unanswered mock RPCs. Packaged desktop, native mobile, and post-install live-provider execution were not tested.

After selecting Codex: affected source After selecting Codex: fixed source
Codex selected with stale Compact next pill Codex selected with compaction pill hidden

Returning to the saved cold Claude destination restores the intended suggestion:

Saved cold Claude destination offers Compact next

Model/harness: GPT-6.1 Sol through Codex in T3 Code; independent reviews by GPT-6.1 Sol at xhigh effort. OpenAI/Codex models only.

Use the handoff-aware composer selection and the destination conversation context for cold-cache recommendations. Hide mismatched suggestions and revalidate the recommendation after send preparation, preserving direct sends, attachments, and deliberate compaction.

Co-Authored-By: GPT-6.1 Sol at high effort <noreply@openai.com>
Co-Authored-By: GPT-6.1 Sol at xhigh effort, review subagents <noreply@openai.com>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ⚠️ Failed 2026-10-27T21:30:19.669117Z
We couldn’t complete this review. Comment @codex review to try again.
bc2ce01 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions github-actions Bot added the vouch:unvouched PR author is not yet trusted in the VOUCHED list. label Oct 27, 2026
@github-actions github-actions Bot added the size:L 100-499 changed lines (additions + deletions). label Oct 27, 2026
@macroscopeapp

macroscopeapp Bot commented Oct 27, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Would Approve

Macroscope's review found this PR approvable — Resume compaction is scoped to the selected Claude conversation and revalidated after uploads, reducing unintended compaction when switching providers. The reported temporary queue-display issue remains covered by the separate correctness gate.

Needs human approval because:

  • 1 blocking correctness issue found at or above your repo's Minimum Blocking Severity

Adjust the Minimum Blocking Severity for this repo — including turning it Off — in Settings. You can add or adjust custom eligibility rules. Learn more.

@coderabbitai

coderabbitai Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between 1fe0a60 and bc2ce01.

Files selected for processing: 2
  • apps/web/src/components/chat/useComposerSend.browser.test.tsx
  • apps/web/src/components/chat/useComposerSend.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.

Walkthrough

Resume-compaction recommendations now include provider instance, destination thread, usage, and update-time data. ChatView resolves recommendations from matching Claude provider threads. The planner, composer, and send hook verify the selection and current context before compaction.

Changes: Resume compaction selection and dispatch

Layer / File(s) Summary
Resolve provider-thread context
apps/web/src/components/chat/ContextWindowMeter.logic.ts, apps/web/src/components/chat/ContextWindowMeter.logic.test.ts
New helpers derive context from provider-thread turns, select the latest matching root thread, and return tokens only for the matching Claude instance. Tests cover thread resolution, selection, and offer conditions.
Resolve and pass the recommendation
apps/web/src/components/ChatView.tsx
ChatView resolves recommendations from the matching Claude provider thread and passes structured data to the composer and send hook. Provider selection uses the handoff-aware locked provider.
Scope compaction to the selection
apps/web/src/components/ChatView.logic.ts, apps/web/src/components/chat/ChatComposer.tsx, apps/web/src/components/ChatView.logic.test.ts
The planner checks the selected provider, instance, and destination thread. The composer derives eligible tokens from the recommendation. Tests cover provider switches, destination changes, and full-history mode.
Revalidate before dispatch
apps/web/src/components/chat/useComposerSend.ts, apps/web/src/components/chat/useComposerSend.browser.test.tsx
The send hook checks saved eligibility against current context and rereads the turn plan after upload and settings persistence. Browser tests cover stale context and Claude destination dispatch.

Priority: Normal

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Bug fix · Severity of issue fixed: Medium

Sequence Diagram(s)

sequenceDiagram
  participant ChatView
  participant ChatComposer
  participant useComposerSend
  participant ProviderThread
  ChatView->>ProviderThread: Resolve matching Claude thread and context
  ChatView->>ChatComposer: Pass structured resume-compaction recommendation
  ChatComposer->>useComposerSend: Send with selected provider and destination
  useComposerSend->>ProviderThread: Revalidate source timestamp and token usage
  useComposerSend->>useComposerSend: Replan after uploads and settings persistence
Loading

Possibly related issues

  • pingdotgg/t3code#23086 — This change evaluates resume-compaction eligibility against the selected Claude instance and saved destination context.

Possibly related PRs

  • pingdotgg/t3code#24008 — Both changes govern automatic compaction in planComposerTurn; that PR preserves the exclusion for explicit /compact commands with instructions.
  • pingdotgg/t3code#25986 — Both changes address stale resume-compaction eligibility during provider switches. This PR also resolves and revalidates destination context.
  • pingdotgg/t3code#24334 — Both changes use the web on-return compaction path. That PR changes the generated /compact turn’s presentation and idle-compaction marker.

Suggested labels: bugfix

Suggested reviewers: juliusmarminge

Merge Risk: Minimal · up to bc2ce

No merge-blocking issue is established; the change is ready to merge after normal checks.

Pre-merge checks: Passed 4
Check name Status Explanation
Title check Passed The title clearly and concisely describes the main fix: scoping resume compaction to the selected provider conversation.
Linked Issues check Passed Issue [#25943] requires normal dispatch after switching from Claude to Codex, while preserving deliberate /compact, and compaction when returning to an eligible saved Claude conversation. ChatView…
Out of Scope Changes check Passed The production changes and tests address the stale on-return compaction path described by [#25943]. They do not add unrelated settings, workflows, provider integrations, native-mobile paths, scheduled…
Description check Passed The pull request description follows the required template. It clearly states the problem, expected behavior, reproduction steps, implementation, scope and approval rationale, verification results, li…
Full details: Linked Issues check

Explanation

Issue [#25943] requires normal dispatch after switching from Claude to Codex, while preserving deliberate /compact, and compaction when returning to an eligible saved Claude conversation. ChatView and ChatComposer now use matching provider selection. ContextWindowMeter.logic.ts scopes eligibility to the provider instance, provider thread, and context. planComposerTurn and useComposerSend recheck eligibility at send time. Tests cover Codex handoff, saved-Claude return, stale context, attachments, dispatch modes, manual commands, full-history choices, and warm context.

Full details: Out of Scope Changes check

Explanation

The production changes and tests address the stale on-return compaction path described by [#25943]. They do not add unrelated settings, workflows, provider integrations, native-mobile paths, scheduled sends, or before-cache-expiry service changes. Related issue [#23086] remains contextual and is not treated as an additional objective.

Full details: Description check

Explanation

The pull request description follows the required template. It clearly states the problem, expected behavior, reproduction steps, implementation, scope and approval rationale, verification results, limitations, UI evidence, and model/harness details.

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.

Keep the optimistic message classification and anchoring consistent with the send plan rechecked after preparation. Extend the paused-upload regression to verify optimistic state, direct-send anchoring, and explicit queue and steer controls.

Co-Authored-By: GPT-6.1 Sol at high effort <noreply@openai.com>

Copy link
Copy Markdown
Contributor Author

@codex review

Retrying the hosted review once after its previous failure to complete. Current head: bc2ce013fdf27d591919c8cc52d5b8d1f022fe50. The optimistic queue-state finding is fixed, and local checks pass with 65 focused tests.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Something went wrong. Try again later by commenting “@codex review”.

An unknown error occurred
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Copy link
Copy Markdown
Member

Thank you @Alb11747 for the careful reproduction and fix. #25986 fixes the same issue (#25943) with a smaller change: the resume-compaction offer now also requires that the send resumes the current conversation, reusing the handoff rule ChatView already computes, with a browser test that fails on main. We're keeping that one to keep the diff small and closing this as a duplicate. Your write-up and the send-time recheck idea are noted on the issue's record; if a stale-recommendation case shows up after https://git.cafe/pingdotgg/t3code/pulls/25986 lands, this PR is where we'll start.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L 100-499 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Switching from an idle Claude thread to Codex still triggers automatic /compact

2 participants