fix(orchestrator): keep stop and steer responsive#3865
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 2 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Want fixes drafted automatically? Bugbot Autofix can create code changes for findings. A team admin can enable Autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit a43c69b. Configure here.
ApprovabilityVerdict: Needs human review This PR adds significant new concurrency coordination logic for start/interrupt race conditions, introduces new command lanes, error types, and timeout handling across multiple layers. The scope and complexity of these changes - including new control flow patterns and UI behavior changes - warrant human review. You can customize Macroscope's approvability policy. Learn more. |
Interrupting a Codex turn now registers its terminal waiter before re-checking the active set, and turn completion retires the active turn before draining waiters, so a completion landing between the interrupt's lookup and registration resolves immediately instead of timing out. On the client, an interrupt that finds no active run while a start for the same thread is still in flight waits for that start to settle and retries once, so a quick Stop after Send targets the run the send creates while staying on the fast control lane.
|
Caution Review failedAn error occurred during the review process. Please try again later. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
The mutation lane is serial per thread, so only the earliest pending start is executing. Waiting for every captured start made Stop drain the whole queued send backlog before retrying; retry now fires as soon as the first start settles.
The dispatch snapshot could capture a start whose settlement cleanup was still queued, making a Stop with nothing in flight retry against a later, unrelated start. Snapshot after one microtask yield so earlier settlements drain first and only genuinely in-flight starts count.

Summary
Validation
vp checkvp run typecheckAddresses #3607 and is stacked on #2829.
Note
Medium Risk
Changes interrupt dispatch, concurrency lanes, and Codex turn-interrupt synchronization; incorrect retry or timeout handling could mis-target runs or surface spurious errors, though behavior is heavily covered by new tests.
Overview
Makes Stop and steer Send usable without waiting behind other thread mutations, and tightens interrupt behavior end-to-end when sends and stops race.
Client runtime:
interruptTurnandstopSessionrun on a per-thread control lane separate from mutation commands.interruptThreadTurnnow fails withThreadTurnNotInterruptibleErrorwhen there is no interruptible run (instead of returning a no-op success), skips a projection fetch when the caller passes an explicitrunId, and is wrapped bycoordinateInterruptWithPendingStartsso a quick Stop after Send retries once after the in-flightstartTurnsettles.Codex: Turn completion uses shared
settleCodexTurnTerminal/registerCodexTurnTerminalWaiterso interrupt can wait for terminal confirmation (10s cap) without losing to completion-vs-interrupt races.UI: While a turn is running and the composer has text, Stop stays visible next to steer Send; interrupt includes
activeRuntime.activeRunIdwhen known.Reviewed by Cursor Bugbot for commit ccd1303. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Fix stop and steer responsiveness by coordinating interrupt with pending turn starts
controlconcurrency lane (separate frommutation), preventing them from being blocked by queued sends.coordinateInterruptWithPendingStartsinthreadCommands.ts: if an interrupt fails withThreadTurnNotInterruptibleErrorwhile a start is in flight for the same thread, it waits for the start to settle and retries once.CodexAdapterV2.tsnow registers a terminal waiter, sendsturn/interrupt, and waits up to 10 seconds for the turn to reach a terminal state before returning a protocol error on timeout.ComposerPrimaryActions.tsxis now always visible when a turn is running, even when the composer has sendable content.Macroscope summarized ccd1303.