Skip to content

Fix repeated steering and reliable stop#3903

Open
Quicksaver wants to merge 40 commits into
pingdotgg:mainfrom
Quicksaver:fix/repeated-steering-and-stop
Open

Fix repeated steering and reliable stop#3903
Quicksaver wants to merge 40 commits into
pingdotgg:mainfrom
Quicksaver:fix/repeated-steering-and-stop

Conversation

@Quicksaver

@Quicksaver Quicksaver commented Jul 12, 2026

Copy link
Copy Markdown

Summary

Allow users to send consecutive steering prompts while a conversation is running and reliably stop the active Codex turn after any number of steers. Steering dispatches clear as soon as the server projects the exact submitted user message, even when the frozen dispatch snapshot has stale or absent session status, while root interruption resolves the provider's live active turn instead of relying on potentially stale projected state.

Explicit child-turn interruptions continue to target the requested child directly. Root lookup is bounded and failure-tolerant: typed failures, timeouts, and unexpected defects fall back to the cached active turn, while a successful read with no active turn suppresses a stale interrupt.

The workspace configuration also enables pnpm's global virtual store and makes the prerelease @effect/vitest package extension resolve vite-plus consistently.

What Changed

  • Track the expected user-message id for each local dispatch and acknowledge only that exact projected message, independently of the frozen dispatch snapshot's session status.
  • Wire generated message ids through new-thread, follow-up, and in-turn steering send paths so the composer can re-enable after an acknowledged steer without waiting for a turn or session transition.
  • Resolve root Codex interruptions from a live thread/read request with turns included, selecting the newest in-progress turn by timestamp and falling back to provider response order when timestamps are absent.
  • Honor explicitly requested child turn ids directly without performing root active-turn lookup or fallback.
  • Bound active-turn lookup time, log typed failures and unexpected defects, and fall back to the cached session turn only when the lookup fails.
  • Suppress stale interrupts when a successful live lookup reports no active turn.
  • Add focused regression coverage for consecutive steering, exact-message acknowledgement, timestamp and response-order turn selection, timeout/failure/defect fallback, and successful empty live reads.
  • Enable pnpm's global virtual store, correct the prerelease @effect/vitest package extension, and refresh the lockfile.

Why

Running conversations could leave the composer busy after steering because acknowledgement depended on turn or session transitions that do not occur for an in-turn steer. After steering, stop could also target a stale cached turn rather than the provider's actual active turn. Together, these behaviors prevented repeated steering and made interruption unreliable precisely when users needed it most.

The pnpm workspace update keeps dependency resolution stable across worktrees and ensures the patched Effect Vitest package receives the runtime dependency it imports.

Validation

  • pnpm exec vp test apps/web/src/components/ChatView.logic.test.ts apps/server/src/provider/Layers/CodexInterruptResolution.test.ts apps/server/src/orchestration/Layers/ProviderCommandReactor.test.ts (71 tests passed)
  • (cd apps/web && pnpm exec vp test run --passWithNoTests --project unit src/components/ChatView.logic.test.ts) (27 tests passed)
  • pnpm exec vp fmt --check apps/web/src/components/ChatView.logic.ts apps/web/src/components/ChatView.logic.test.ts BRANCH_DETAILS.md
  • pnpm exec vp lint apps/web/src/components/ChatView.logic.ts apps/web/src/components/ChatView.logic.test.ts
  • Playwright on isolated ports 5738/13778: two consecutive exact-id steers each re-enabled the composer while the turn remained running, and Stop after two later steers settled the thread without a stale completion reply.
  • pnpm --filter @t3tools/web typecheck remains blocked by existing errors in unrelated web files; neither changed source file appears in the failure list.
  • pnpm exec vp test run apps/server/src/provider/Layers/CodexInterruptResolution.test.ts (13 tests passed)
  • pnpm exec vp fmt --check apps/server/src/provider/Layers/CodexSessionRuntime.ts apps/server/src/provider/Layers/CodexInterruptResolution.test.ts BRANCH_DETAILS.md
  • pnpm exec vp lint apps/server/src/provider/Layers/CodexSessionRuntime.ts apps/server/src/provider/Layers/CodexInterruptResolution.test.ts
  • pnpm --filter t3 typecheck passed with pre-existing suggestion-level diagnostics

Proof

  • Automated regression coverage in the changed web and server test suites.

Note

Medium Risk
Changes live conversation send acknowledgement and Codex interrupt targeting; regression tests cover the new paths but mistakes could leave the composer busy or stop the wrong turn.

Overview
Repeated steering no longer leaves the composer stuck in a sending state. Local dispatch now records the exact outbound user message id and hasServerAcknowledgedLocalDispatch treats server acknowledgement as seeing that id in projected messages—even when turn/session fields are stale—so consecutive in-turn steers can re-enable the composer without waiting for a new turn. Send paths call beginLocalDispatch only after newMessageId() so the snapshot matches what was sent.

Reliable stop for root Codex turns replaces interrupting the cached activeTurnId with resolveCodexInterruptTurnId: a live thread/read with turns (2s timeout), picking the newest inProgress turn (timestamps, else provider order). Explicit child turn ids still pass through unchanged. Failed or timed-out lookups fall back to the session’s projected turn; a successful read with no active turn skips interrupt so a stale id is not revived.

Adds BRANCH_DETAILS.md, CodexInterruptResolution.test.ts, and expanded ChatView.logic tests; minor pnpm workspace/lockfile tweaks for @effect/vitest resolution.

Reviewed by Cursor Bugbot for commit d8b15e2. Bugbot is set up for automated code reviews on this repo. Configure here.

Note

Fix repeated steering and reliable stop by improving interrupt resolution and dispatch acknowledgement

  • resolveCodexInterruptTurnId now performs a live provider thread read (with a 2s timeout via CODEX_INTERRUPT_THREAD_READ_TIMEOUT) to find the most recent in-progress turn, falling back to the cached activeTurnId only when the live read fails or times out. A successful empty read no longer revives a stale projected turn id.
  • interruptTurn exits early if no effective turn id is resolved, preventing spurious interrupts.
  • Client-side dispatch acknowledgement in hasServerAcknowledgedLocalDispatch now triggers when the server projects a user message matching the exact expectedUserMessageId stored at send time, enabling steers to re-enable the composer without waiting for a turn/session change.
  • Sending in ChatViewContent generates the message id before calling beginLocalDispatch and ties acknowledgement to that exact id rather than a latest-message heuristic.
  • Behavioral Change: consecutive steers now require the next steer's message id to appear in projected messages before acknowledging, rather than relying on any latest-user-message change.

Macroscope summarized d8b15e2.

- Resolve the provider runtime’s authoritative active Codex turn
- Treat projected steer messages as server dispatch acknowledgement
- Avoid stale root turn IDs when interrupting for steering
- Cover active-turn lookup and running-thread steer behavior
- Resolve active Codex turns from timed, observable thread reads
- Match projected steer acknowledgements to the dispatched message
- Add realistic regression coverage for interrupt and steer paths
@coderabbitai

coderabbitai Bot commented Jul 12, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 7f0709ea-e055-4671-93e5-a65a068e14e4

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added vouch:unvouched PR author is not yet trusted in the VOUCHED list. size:L 100-499 changed lines (additions + deletions). labels Jul 12, 2026
Comment thread apps/server/src/provider/Layers/CodexSessionRuntime.ts
@macroscopeapp

macroscopeapp Bot commented Jul 12, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Needs human review

This PR modifies core runtime behavior for steering acknowledgement and interrupt resolution, including new RPC calls with timeout/fallback logic and changed dispatch acknowledgement criteria. These are significant behavioral changes to user-facing interaction flows that warrant careful review.

You can customize Macroscope's approvability policy. Learn more.

- Fall back to provider response order when start times are absent
- Cover both mixed timestamp ordering cases
- Merge upstream/main through Android mobile support
- Keep Quicksaver Expo ownership in the mobile config
- Preserve repeated steering and live Codex interruption behavior
- Extract and test active turn ordering and interrupt fallbacks
Comment thread apps/mobile/app.config.ts
- Use the Quicksaver EAS project id for the OTA endpoint
Comment thread apps/mobile/app.config.ts Outdated
- Capture exact message acknowledgement and interrupt routing contracts
- Record Codex live-turn selection and fallback safeguards
- Reserve branch-specific web and server development ports
…ng-and-stop

# Conflicts:
#	apps/server/src/provider/Layers/CodexSessionRuntime.test.ts
#	apps/web/src/components/ChatView.logic.ts
#	apps/web/src/components/ChatView.tsx
- Match dispatched steering IDs across all projected user messages
- Read the session fallback only after live Codex lookup failures
- Cover multi-client steering and timeout races with regression tests
- Make timeout tests wait for the live lookup explicitly
- Clarify replacement and dispatch snapshot naming
- Scan projected messages from the latest entry first
- Record assessment fixes and review outcomes
- Update validation counts and branch divergence
- Document conflict-resolution guidance for web and Codex runtime changes
- Preserve dispatch-correlation and interruption-resolution coverage
- Enable the global virtual store
- Correct prerelease package extensions and refresh the lockfile
Comment thread apps/web/src/components/ChatView.logic.ts

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit c3852d1. Configure here.

Comment thread apps/server/src/provider/Layers/CodexSessionRuntime.ts
- Log unexpected live thread lookup defects
- Fall back to the latest projected active turn
- Cover defect recovery in focused interrupt tests
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.

1 participant