Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(orchestration): queue follow-ups sent while a thread compacts #20184

Mergedmaria-rcksmerged 4 commits intomain fromrefs/pull/20184/headmerged by maria-rcks View on GitHub

maria-rckscommented

With "Follow-up behavior" set to Steer, sending a message while /compact ran failed with "Wait for context compaction to finish before steering the thread." The message stayed stuck in the composer.

Now it queues and runs after compaction, the same as with the queue default. The server decides this in resolveMessageDispatchIntent: a steer aimed at a /compact or /logout run becomes queue_after_active. That covers web, mobile, MCP t3_thread_send, and older clients that send steer_active directly. The web and mobile composers also show the queue action while compacting, including with Ctrl/⌘ held, so the button matches what will happen.

Before:

before: steering during /compact shows "Wait for context compaction to finish before steering the thread." and the draft stays in the composer

before recording: /compact, then Enter with steer default fails

After:

after: during compaction, a ctrl+Enter steer lands in the queue and the send button shows the queue icon

after recording: /compact, a steer and a normal send both queue, then run in order after compaction

I verified this in a web dev build on Codex with steer as the default. The new CommandPolicy test covers /compact and /logout for auto, steer, and legacy steer_active, and confirms restart is unchanged. The existing ThreadLaunchService maintenance test now expects those two steer scenarios to queue. Not verified: the mobile composer change in a native client, and auto-compaction that starts in the middle of a turn. That case still steers as before.

🤖 Generated with Claude Code

Closes #20169

    1. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted

    2. juliusmarminge added labelsmacroscope-review

    3. coderabbitai[bot](GitHub profile, opens in a new tab)commented
      Review in Change Stack →

      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: 770993e9-43e7-4247-8887-26f81265e6c9
      📥 Commits

      Reviewing files that changed from the base of the PR and between 2577baf8b0dc541283fa93d6919b0e354effadf4 and f8f572cf5420c4ada5fd2cdea0b0dd6a4ffcbb0d.

      📒 Files selected for processing: 11
      • apps/mobile/src/state/use-thread-composer-state.ts
      • apps/server/src/orchestration-v2/CommandPolicy.test.ts
      • apps/server/src/orchestration-v2/CommandPolicy.ts
      • apps/server/src/orchestration-v2/Orchestrator.ts
      • apps/server/src/orchestration-v2/RestartContinuation.ts
      • apps/server/src/orchestration-v2/ThreadLaunchService.test.ts
      • apps/web/src/components/ChatView.tsx
      • apps/web/src/components/chat/ChatComposer.tsx
      • apps/web/src/components/chat/ComposerPrimaryActions.tsx
      • packages/client-runtime/src/state/composerDispatch.test.ts
      • packages/client-runtime/src/state/composerDispatch.ts

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

      📝 Walkthrough

      Server dispatch now queues steering messages that target /compact or /logout runs. Web and mobile composers disable steering while a thread is compacting, so follow-up messages use queue behavior.

      Changes: Queue maintenance and compaction behavior

      Layer / File(s)Summary
      Queue native maintenance commands
      apps/server/src/orchestration-v2/CommandPolicy.ts, apps/server/src/orchestration-v2/Orchestrator.ts, apps/server/src/orchestration-v2/RestartContinuation.ts, apps/server/src/orchestration-v2/CommandPolicy.test.ts
      The shared classifier identifies attachment-free /compact and /logout messages. When a resolved steer targets one of those runs, dispatch changes to queue_after_active. Tests cover automatic and explicit steer intents, as well as restart intent.
      Queue follow-ups while compacting
      packages/client-runtime/src/state/composerDispatch.ts, packages/client-runtime/src/state/composerDispatch.test.ts, apps/web/src/components/ChatView.tsx, apps/web/src/components/chat/ChatComposer.tsx, apps/web/src/components/chat/ComposerPrimaryActions.tsx, apps/mobile/src/state/use-thread-composer-state.ts
      The dispatch-mode resolver selects queue when steering is unavailable. Web and mobile composers use compaction state to disable steering. The web primary-action tooltip also uses the submit label when steering is unavailable.

      Priority: ⬇️ Low

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

      Change: Bug fix · Severity of issue fixed: Low

      Suggested reviewers: juliusmarminge

      Merge Risk: ⚪ Minimal · up to f8f57

      Follow-ups targeting /compact or /logout queue rather than being rejected. No actionable issue remains before merge.

      Security architecture risk: 🔵 Low · up to f8f57

      The change reuses the existing message queue rather than introducing new execution privileges or storage formats. No introduced security issue was established, but deferred execution across sign-out was not fully verified.

      Retained concerns No architecture-level concerns identified.

      Security review details

      Security Blast Radius

      • inferred — The demonstrated exposure change is that messages already reaching thread dispatch can become durable future provider work instead of being rejected during maintenance. The resolver selects the target from the supplied thread projection and does not introduce a new cross-thread destination. Explicit queueing already reached this execution path before the PR.

      Trust Boundaries and Controls

      • observed — Before promoting queued work, the existing scheduler rejects progression for archived or deleted threads, blocking runs, or held queues, and rereads project and machine provider-enable settings. These are meaningful deferred-execution controls, but are not proof of provider credential revocation enforcement after logout.

      Resilience and Maintainability Implications

      • observed — Dispatch and terminal-triggered queue promotion use the existing per-thread serialization mechanism, limiting concurrent mutation of the queue. Promotion retains the queued run’s identity rather than creating another submission.
      Pre-merge checks: Passed 4
      Check nameStatusExplanation
      Title checkPassedThe title clearly describes the main change: queueing follow-ups while a thread compacts.
      Description checkPassedThe description explains the problem, implementation, affected clients, verification, limitations, screenshots, recordings, linked issue, and agent attribution. It is complete despite not using the te…
      Linked Issues checkPassedThe description links issue #20169, and the requested behavior matches the pull request changes and stated objectives.
      Out of Scope Changes checkPassedThe changes stay focused on queueing steer follow-ups during native maintenance commands and updating related composer behavior. The description identifies auto-compaction during an active turn as int…
      Full details: Description check

      Explanation

      The description explains the problem, implementation, affected clients, verification, limitations, screenshots, recordings, linked issue, and agent attribution. It is complete despite not using the template section headings explicitly.

      Full details: Out of Scope Changes check

      Explanation

      The changes stay focused on queueing steer follow-ups during native maintenance commands and updating related composer behavior. The description identifies auto-compaction during an active turn as intentionally unchanged.

      ✨ Finishing Touches
      📝 Generate docstrings
      • Commit to this branch
      • Create a new PR
      🧪 Generate unit tests (beta)
      • Commit to this branch
      • 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. macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      Approvability

      Verdict: Approved at f8f572c

      Macroscope's review found this PR approvable — This is a narrowly scoped orchestration bug fix that queues follow-ups during active compaction or sign-out while preserving normal steering behavior elsewhere. The web, mobile, shared dispatch logic, and server policy changes are small and covered by targeted tests.

      You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    5. github-actions[bot](GitHub profile, opens in a new tab)commented

      Thread transfer impact

      ✅ Thread transfer remains within every enforced ceiling.

      ProviderMetricMain baselineThis PRImpactPR ceiling
      CodexTotal thread wire4.9 KiB5.0 KiB+23 B (+0.5%)6.8 KiB✅
      CodexThread snapshot wire3.8 KiB3.8 KiB0 B (0.0%)4.9 KiB✅
      CodexLive turn WebSocket wire1.2 KiB1.2 KiB+23 B (+1.9%)2.0 KiB✅
      CodexLive turn WebSocket decoded20.8 KiB20.9 KiB+41 B (+0.2%)29.3 KiB✅
      CodexLive turn messages12+1 (+100.0%)8✅
      ClaudeTotal thread wire5.0 KiB5.0 KiB0 B (0.0%)6.8 KiB✅
      ClaudeThread snapshot wire3.8 KiB3.8 KiB0 B (0.0%)4.9 KiB✅
      ClaudeLive turn WebSocket wire1.2 KiB1.2 KiB0 B (0.0%)2.0 KiB✅
      ClaudeLive turn WebSocket decoded21.2 KiB21.2 KiB0 B (0.0%)29.3 KiB✅
      ClaudeLive turn messages220 (0.0%)8✅

      Baseline: 2577baf · PR result: f8f572c · Source CI: success

      Scenario and decoded snapshot size

      10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.

      • Codex decoded thread snapshot: 108.5 KiB
      • Claude decoded thread snapshot: 108.8 KiB

      Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed.

    6. maria-rcks merged thisa54a44c

    7. maria-rcks closed this

Sign in to join this conversation.