Repository navigation
fix(native-chat): bring back Working-only-while-held (#30134) without shutting down Claude chat workers - #30577
Conversation
…nowledges its task Claude's adapter dropped an echoed send from the sends it holds before reporting the send's answer to the host, and emitting the echo's turn can publish at once. That publish read the still-pending send as held by nobody, so it read as "couldn't confirm": orchestration worker-start then closed the new Claude worker, and every other answer wait and client saw a one-frame doubt. A frame's settled sends now stay held until their answers are reported, when the host's handover window takes them over; a Stop's rejected sends are released and reported one at a time, as Pi and ACP already do. Tracked in STA-11160.
…orker-start-ack # Conflicts: # src/main/claude/claude-command-lifecycle.ts
…es the host, on the reapplied held-sends read
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Priority: ➖ Normal Merge Risk: ⚪ Minimal · up to
|
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
- Configuration used: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
6e2a5d80-387c-4cc4-917b-76a61e90f23c
📒 Files selected for processing: 5
src/main/claude/claude-command-lifecycle.tssrc/main/claude/claude-structured-dispatch.tssrc/main/claude/claude-structured-session-acquisition.tssrc/main/claude/claude-structured-session-state.tssrc/main/native-chat/agent-session-wire/structured-agent-session-claude-opening-send-hold.test.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review.
…Stop is still ending its CLI
Review loop status (head
|
…orker-start-ack # Conflicts: # src/main/native-chat/agent-session-wire/structured-agent-session-host.ts
…orker-start-ack # Conflicts: # src/main/acp/acp-structured-acquire.ts # src/main/acp/acp-structured-session.ts # src/main/claude/claude-structured-session-adapter.ts # src/main/codex/codex-structured-session-acquire.ts # src/main/native-chat/agent-session-wire/structured-agent-session-attach-orchestration.ts # src/main/native-chat/agent-session-wire/structured-agent-session-late-dispatch.ts # src/main/native-chat/agent-session-wire/structured-agent-session-surface-lifetime.test.ts # src/main/pi/rpc-configured-default.test.ts # src/main/pi/rpc-session-adapter.test.ts # src/main/pi/rpc-session-adapter.ts # src/main/pi/rpc-session.ts # src/main/runtime/structured-agent-session-failure-logging.test.ts
There was a problem hiding this comment.
🧹 Nitpick comments: 1
src/main/acp/acp-structured-host-lifecycle.test.ts: 1
297-297: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winTest the handover while
acceptLateis pending.
mockRejectedValuerejects immediately. The working-state assertion runs while Grok still holds the send, so this test cannot detect a regression that drops the handover during a pending journal write. Use a deferredacceptLateresult. Assertworking()after Grok releases the send but before the write settles, then reject the write and retain the final assertions.Based on learnings: use a controllable settlement when a test must assert an intermediate asynchronous state.
Source: Learnings
ℹ️ Review info
⚙️ Run configuration
- Configuration used: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
6874ae72-455b-4583-a571-a40651822a97
📒 Files selected for processing: 28
src/main/acp/acp-structured-acquire.tssrc/main/acp/acp-structured-child.tssrc/main/acp/acp-structured-host-lifecycle.test.tssrc/main/acp/acp-structured-host.test-support.tssrc/main/acp/acp-structured-session-adapter.tssrc/main/acp/acp-structured-session.tssrc/main/claude/claude-structured-dispatch.tssrc/main/claude/claude-structured-session-acquisition.tssrc/main/claude/claude-structured-session-adapter.tssrc/main/claude/claude-structured-session-state.tssrc/main/codex/codex-structured-session-start.tssrc/main/codex/codex-structured-session-state.tssrc/main/native-chat/agent-session-wire/structured-agent-session-adapter.tssrc/main/native-chat/agent-session-wire/structured-agent-session-attach-publish.tssrc/main/native-chat/agent-session-wire/structured-agent-session-child-exit.tssrc/main/native-chat/agent-session-wire/structured-agent-session-claude-stop-exit-ends-record.test.tssrc/main/native-chat/agent-session-wire/structured-agent-session-event-recovery.tssrc/main/native-chat/agent-session-wire/structured-agent-session-handing-over.tssrc/main/native-chat/agent-session-wire/structured-agent-session-host-mutations.tssrc/main/native-chat/agent-session-wire/structured-agent-session-host.tssrc/main/native-chat/agent-session-wire/structured-agent-session-late-dispatch.tssrc/main/native-chat/agent-session-wire/structured-agent-session-mutation-context.tssrc/main/pi/rpc-message-dispatch.tssrc/main/pi/rpc-runtime-registration.tssrc/main/pi/rpc-session-adapter.test-fixture.tssrc/main/pi/rpc-session-adapter.test.tssrc/main/pi/rpc-session-adapter.tssrc/main/pi/rpc-session.ts
💤 Files with no reviewable changes: 3
- src/main/pi/rpc-runtime-registration.ts
- src/main/native-chat/agent-session-wire/structured-agent-session-host.ts
- src/main/pi/rpc-session-adapter.test-fixture.ts
🚧 Files skipped from review as they are similar to previous changes: 1
- src/main/native-chat/agent-session-wire/structured-agent-session-adapter.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 3 remain after this review.
…orker-start-ack # Conflicts: # src/main/pi/rpc-session.ts
…orker-start-ack # Conflicts: # src/main/claude/claude-structured-session-acquisition.ts






ELI5
#30134 made Claude, Pi and ACP chats show "Working" only while the agent actually holds a message, but it also broke starting a Claude chat as an orchestration worker: the moment Claude acknowledged its task, Orca decided it could not confirm the task was received and shut the new chat down. #30134 was reverted on main (#30572) as a stopgap. This PR brings #30134 back with the timing mistake fixed, so both work: chats stop showing Working when the agent holds nothing, and Claude chat workers keep running.
What Changed
The bug this fixes (main with #30134, and the 1.4.230 ad hoc before its revert):
orca orchestration worker-start --agent claudefailed with "The dispatch preamble was submitted but not acknowledged (unknown): provider_ended_before_acknowledgement", and the chat said "closed by Orca", usually before Claude had replied. On one Mac, 90 of 92 Claude chat workers started after 10-18 17:00 UTC died this way (Codex workers: 242 of 242 fine).After this PR:
Mechanism:
Why
The one structural fact behind the bug: Claude's adapter changed what it holds at a different moment than it handed the answer to the host. Fixing that ordering removes the gap for every reader at once (worker start, every other answer wait, and what clients are shown), with no host, saved-data or wire change. The common pattern does the same: set the new state before clearing the old, so a reader can see both but never neither. Codex already had no gap (its echo hands the answer over in the same step; its republish waits a microtask).
Alternatives considered:
Differences from the common pattern:
Linked Issue
Tracked in STA-11160 (Linear). Re-lands #30134 (reverted in #30572).
Visual Proof
To follow: a real Orca build where a Claude chat worker started with
worker-startcompletes two turns, main versus this branch.Testing
structured-agent-session-claude-opening-send-hold.test.ts): a message's answer across Claude's echo reads "received", never "unknown". Fails without the fix (unknown), passes with it.Review
Agent skill upstream boundary
Notes
Host-local: no wire, saved-data or cross-version effect; runs wherever the agent runs (macOS, Linux, Windows, SSH and WSL hosts).
Author: @BrennanKB5
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)