feat: add active-turn message delivery controls
What Changed
Adds a Messages while working setting to web and mobile with two delivery behaviors:
- Steer (the default) sends the message into the active turn.
- Queue stores follow-ups per thread and sends them FIFO, one turn at a time, after the current turn finishes.
The running web composer now keeps Stop generation visible beside the mode-specific send action. Mobile uses the same preference and snapshots it onto each outbox entry so existing queued work keeps its intended delivery behavior.
Codex sessions now use turn/steer when a turn is active, matching the steering behavior already supported by the other provider adapters. A successful steer reaffirms the running turn to orchestration so no stale pending-turn projection is left behind.
Why
While an agent was working, the composer only exposed Stop and did not let users choose whether a follow-up should affect the current turn or wait for the next one. That made rapid follow-ups awkward and left queue semantics inconsistent between web and mobile.
Delivery safeguards
- Queues are durable per thread and preserve FIFO order without an artificial message cap.
- Stable message and command IDs make retries idempotent.
- Only one dispatcher may own a queued web message at a time.
- The next queued message pauses after a non-interruption send failure and requires an explicit retry.
- Mobile retains its bounded exponential retry delay and sends only the head of each thread queue.
- Queue drain waits for a ready, connected thread, preventing overlapping turns and token-burning retry loops.
Verification
vp test run packages/contracts/src/settings.test.ts apps/mobile/src/state/thread-outbox.test.ts apps/server/src/provider/Layers/CodexSessionRuntime.test.ts apps/server/src/provider/Layers/CodexAdapter.test.ts apps/server/src/orchestration/Layers/ProjectionPipeline.test.ts apps/web/src/webThreadOutbox.test.ts apps/web/src/components/settings/settingsSearch.test.ts— 137 tests passedvp lintacross all 23 changed TypeScript files with--report-unused-disable-directivesvp fmtacross all 23 changed TypeScript files- Package type checks passed for contracts, web, mobile, and server
- Isolated T3 Code web environment:
- Queue mode drained two follow-ups FIFO exactly once and cleared persisted outbox storage
- Steer mode injected the follow-up into the active Codex turn exactly once
- Running composer exposed Stop beside Queue/Steer
- T3 Code Dev on iOS Simulator: Queue and Steer flows verified
git diff --check
Model: GPT-5.6 Sol | Harness: Codex in T3 Code
[!NOTE]
Add active-turn message delivery controls with 'steer' and 'queue' modes
- Introduces
ActiveTurnMessageBehavior('steer' or 'queue', default 'steer') to contracts, client settings, and mobile preferences, controlling what happens when a user sends a message while a thread is actively running.- In 'steer' mode, the message is sent directly into the active Codex turn via a new
turn/steerAPI call; in 'queue' mode, the message is held in a local outbox and delivered once the thread is idle.- Adds a persistent web thread outbox (webThreadOutbox.ts) with per-thread FIFO queues, cross-tab localStorage sync, deduplication, and pause/retry controls; mobile outbox gains a matching
activeTurnMessageBehaviorfield on queued messages.- The web composer (ChatComposer.tsx) and mobile composer (ThreadComposer.tsx) update their primary action labels and enabled state based on the current behavior and phase ('Queue message', 'Steer active turn', or 'Send message').
- Settings UIs on both web (SettingsPanels.tsx) and mobile (SettingsRouteScreen.tsx) expose a 'Messages while working' control that persists the user's choice.
- Risk: sends during an active turn now have a brief async delay on mobile while
awaitActiveTurnMessageBehaviorwaits for preferences to settle before enqueuing.Macroscope summarized 56e5d17.
[!NOTE] Medium Risk Changes orchestration-facing Codex turn start/steer paths and multi-client message delivery timing; mistakes could duplicate turns, drop queued messages, or mis-steer active work, though stable command IDs and explicit deferral logic mitigate this.
Overview Adds
activeTurnMessageBehavior(steer|queue, default steer) to contracts and surfaces it as Messages while working in web and mobile settings.Steer sends follow-ups into the running turn; queue holds per-thread FIFO outboxes until the turn is idle. Web gets a new
webThreadOutboxstore (localStorage, cross-tab merge, single-dispatcher guard, pause/retry on failure). Mobile persists the preference, waits for preferences to settle before send, snapshots behavior on each outbox entry, and only defers delivery while busy when behavior is queue (or omitted on legacy entries).While a turn is running, web and mobile composers show Stop alongside a send action labeled Steer or Queue instead of blocking send entirely. Web drains the outbox when the thread is ready and shows a queued-count row with Retry when delivery is paused.
Codex
turn/steeris used when the session is already running; a syntheticturn/startedreaffirms the active turn so orchestration projection does not leave a stale pending turn. Tests cover outbox rules, Codex steer mapping, and steer reconciliation in the projection pipeline.Reviewed by Cursor Bugbot for commit 56e5d17e0e3b0ff48f14bcaecc451e65c69d4233. Bugbot is set up for automated code reviews on this repo. Configure here.
[!IMPORTANT]
Review skipped
Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
.coderabbit.yamlfile in this repository. To trigger a single review, invoke the@coderabbitai reviewcommand.⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID:
ac86a13d-ec76-4645-90ea-a069ce49ce97You can disable this status message by setting the
reviews.review_statustofalsein the CodeRabbit configuration file.Use the checkbox below for a quick retry:
- [ ] 🔍 Trigger review
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 @coderabbitai help to get the list of available commands.
Approvability
Verdict: Needs human review
1 blocking correctness issue found. New feature introducing active-turn message delivery controls with 'steer' and 'queue' modes. Adds significant new state management (web outbox store), server protocol changes (turn/steer API), and cross-platform behavior changes. Multiple open review comments identify potential bugs including outbox deadlock and image persistence loss.
You can customize Macroscope's approvability policy. Learn more.
@ClapFy this is a great start are you in a position to continue working on this until the AI reviews are clean?
Some additional feedback:
- 🟠 starting is treated as steerable, but codex only steers once running. concurrent sends can issue a second turn/start. mobile server
- 🟠 a turn completing between the runtime snapshot and turn/steer loses the already-persisted prompt as a session error. code
- 🟠 simultaneous cross-tab queue writes can overwrite each other and silently drop a prompt. the merge and full-key write are not atomic. code
- 🟠 web defaults to steer before settings hydration. a user configured for queue can accidentally steer immediately after reload. settings send
- 🟠 mobile and web snapshot drafts after editable awaits. content typed after tapping send can be consumed or cleared. mobile web
- 🟠 web only drains the currently mounted thread. navigating away leaves queued messages unsent until that thread is revisited.
- 🟠 failed-message pause state is memory-only. reload or another tab automatically retries despite the explicit retry contract. code
@chrisdeeming i fixed the issues but the ai checks are stick on the "Pending" status.
@ClapFy it looks like the functionality from this PR is actually covered by a future rewrite of the T3 Code orchestrator.
See #2829 for that work and #4245 which implemented the same feature as this PR but closed in favour of waiting for the orchestrator v2 to land.
@ClapFy it looks like the functionality from this PR is actually covered by a future rewrite of the T3 Code orchestrator.
See #2829 for that work and #4245 which implemented the same feature as this PR but closed in favour of waiting for the orchestrator v2 to land.
The PR also contains a fix for a chat bug with Codex where you sometimes just can't stop the agent
[!NOTE] 🤖 GPT-5.6 Sol responding on behalf of Theo
Closing this PR after an automated pass over open pull requests. A trusted reviewer said the planned orchestration rewrite already covers this feature.