Repository navigation
fix(native-chat): show Claude working from the send, not the provider echo - #19822
Conversation
… echo A structured session read as working only once a turnLifecycle row existed. Codex writes that row ~150ms after the send; Claude cannot write it until the SDK echoes the user message back, measured at a 3.4s median and 18s at p90, so the chat and every session list read idle for the whole wait. The journalled submission is the host's own evidence a turn is owed, so the shared projection reads it too. `unknown` still counts -- the ack budget elapsing answers delivery, not whether work is owed -- while a recovered `unknown` does not, which needed the existing row flag carried onto the projected submission. Claude's activity line now stays the generic fallback. Its only turn-wide frame carries a bare token, and its task_* prose describes a spawned task rather than this turn; compaction is kept because it explains an otherwise silent wait.
📝 WalkthroughWalkthroughThe change adds dispatch-aware session status projection for pending and unrecovered unknown submissions. Journal reduction preserves crash-recovery metadata. Renderer and mobile hooks report unanswered submissions as working, while the stop control remains tied to an active provider turn. Status-feed tests cover pending-to-idle transitions. Claude activity output now reports only conversation compaction status. Merge Risk: 🟡 Moderate · up to This change makes unanswered submissions appear as working before provider acknowledgement, but a provider-exit cleanup failure can leave that status stuck after the provider is gone. Recovery handling and its failure-path coverage should be corrected before merge. 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
Full details: Description checkExplanation The description is detailed and covers the change, rationale, visual proof, testing, limitations, review notes, and checklist. However, the required Linked Issue section does not contain an issue link, and the AI Disclosure section is omitted.
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
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.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: f7150ad4-ceb6-4e7a-a547-928271f8dd9b
📒 Files selected for processing (15)
mobile/src/session/use-mobile-structured-agent-session.tssrc/main/native-chat/agent-session-journal/journal-crash-boundary.test.tssrc/main/native-chat/agent-session-journal/journal-reducer.tssrc/main/native-chat/agent-session-wire/provider-frame-activity.test.tssrc/main/native-chat/agent-session-wire/provider-frame-activity.tssrc/main/native-chat/agent-session-wire/provider-turn-activity-routing.test.tssrc/main/native-chat/agent-session-wire/structured-agent-session-status-feed.test.tssrc/main/native-chat/agent-session-wire/structured-agent-session-status-feed.tssrc/renderer/src/components/native-chat/NativeChatStructuredSession.tsxsrc/renderer/src/components/native-chat/use-structured-agent-session.test.tsxsrc/renderer/src/components/native-chat/use-structured-agent-session.tssrc/shared/agent-session-journal-schemas.tssrc/shared/agent-session-journal-types.tssrc/shared/structured-agent-session-projection.test.tssrc/shared/structured-agent-session-projection.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 7 remain after this review.
| expect(events.at(-1)).toEqual({ | ||
| type: 'status', | ||
| session: expect.objectContaining({ status: 'idle' }) | ||
| }) |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
Expect null until the provider turn is persisted.
After resolveDispatch() accepts this submission, it is no longer unanswered. The test still has no replayed journal item. projectStructuredAgentSessionStatusSummary() therefore returns status: null, not status: 'idle'. Change this expectation to null, or persist a provider turn before asserting idle.
Proposed fix
- session: expect.objectContaining({ status: 'idle' })
+ session: expect.objectContaining({ status: null })📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| expect(events.at(-1)).toEqual({ | |
| type: 'status', | |
| session: expect.objectContaining({ status: 'idle' }) | |
| }) | |
| expect(events.at(-1)).toEqual({ | |
| type: 'status', | |
| session: expect.objectContaining({ status: null }) | |
| }) |
There was a problem hiding this comment.
ℹ️ No critical issues — one minor suggestion inline.
Reviewed changes
This PR makes a structured session read as working from the moment a message is sent, keying the shared status projection off the journal's own submission row rather than the provider's later echo. One predicate (hasUnansweredStructuredAgentSessionDispatch) now feeds the desktop hook, the mobile hook, and the host status feed, so the chat, sidebar, worktree ps, and mobile all agree.
- New shared predicate —
hasUnansweredStructuredAgentSessionDispatchtreatspendingand non-recoveredunknownsubmissions as work owed; a recoveredunknown(outlived its writer) does not. - Projection plumbing —
projectStructuredAgentSessionStatus/projectStructuredAgentSessionStatusSummarygain an optionalsubmissionsarg and thread it through the status feed. - Reducer propagates
recovered—applyDispatchcopiesrow.recoveredonto the projected submission, with a matching optional field on the schema (strip-safe for older clients). - Claude activity line collapses to the fallback —
claudeProviderFrameActivitykeeps only compaction copy and returnsnullfor task/control frames, whose prose belongs to spawned tasks. - Stop stays turn-keyed — the composer's
isWorkingis decoupled from the broadened hookisWorkingand pinned tocontroller.turnId !== null, so the button still only flips for a cancellable turn.
The change is minimal, well-documented, and the added tests are real (they exercise the new predicate and would fail if reverted). Wire compatibility checks out: AgentJournalSubmissionSchema is a plain z.object (strip, not strict), and the reducer merges submissions by id so the optional field survives the client round-trip.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
|
Rendered QA on Claude displayed Working… in a screenshot completed 210 ms after Send, while the journal contained only the submission; the provider running lifecycle arrived 1,727 ms after submission. During a real bounded Explicit Claude: before provider echo Claude: generic activity during real tool call Claude: completion clears activity Codex: command activity preserved Codex: completion clears activity |
There was a problem hiding this comment.
Actionable comments posted: 2
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: 599e054d-2841-40f7-bd2d-0c87e68e1d39
📒 Files selected for processing (23)
mobile/src/session/MobileNativeChatOverlay.tsxmobile/src/session/MobileNativeChatView.test.tsmobile/src/session/MobileNativeChatView.tsxmobile/src/session/mobile-native-chat-controller-contract.tsmobile/src/session/use-mobile-native-chat-controller.test.tsmobile/src/session/use-mobile-native-chat-controller.tsmobile/src/session/use-mobile-structured-agent-session.tssrc/main/native-chat/agent-session-journal/journal-crash-boundary.test.tssrc/main/native-chat/agent-session-journal/journal-pending-submission-recovery.tssrc/main/native-chat/agent-session-journal/journal-reducer.tssrc/main/native-chat/agent-session-journal/journal-store.tssrc/main/native-chat/agent-session-wire/structured-agent-session-host-handoff.tssrc/main/native-chat/agent-session-wire/structured-agent-session-send-idempotency.test.tssrc/main/native-chat/agent-session-wire/structured-agent-session-status-feed.test.tssrc/main/native-chat/agent-session-wire/structured-agent-session-status-feed.tssrc/main/native-chat/agent-session-wire/structured-agent-session-surface-lifetime.test.tssrc/main/native-chat/agent-session-wire/structured-agent-session-turns.tssrc/main/native-chat/agent-session-wire/structured-agent-session-unexpected-exit.test.tssrc/main/native-chat/agent-session-wire/structured-agent-session-unexpected-exit.tssrc/renderer/src/components/native-chat/use-structured-agent-session.tssrc/shared/agent-session-journal-types.tssrc/shared/structured-agent-session-projection.test.tssrc/shared/structured-agent-session-projection.ts
🚧 Files skipped from review as they are similar to previous changes (1)
- src/shared/agent-session-journal-types.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 5 remain after this review.
| const session = host.session(sessionId) | ||
| await session.journal.markPendingSubmissionsUnknown( | ||
| session.fence, | ||
| 'provider_exited_before_acknowledgement' | ||
| ) | ||
| host.subscribers.publish(sessionId, session.journal) | ||
| host.publishStatus?.(sessionId) |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
🔎 Supported by static analysis
🤖 get_repo_knowledge executed:
get_repo_knowledge stablyai/orca /tmp/coderabbit-repo-knowledge/stablyai-orca-89dc44e4/learnings /tmp/coderabbit-repo-knowledge/stablyai-orca-89dc44e4/conventions
Length of output: 26764
🏁 Script executed:
#!/bin/bash
set -e
file='src/main/native-chat/agent-session-wire/structured-agent-session-host-handoff.ts'
printf '%s\n' '--- target outline ---'
ast-grep outline "$file" || true
printf '%s\n' '--- target excerpt ---'
sed -n '1,180p' "$file"
printf '%s\n' '--- symbols and result strings ---'
rg -n -C 4 'stopped-cleanup-failed|markPendingSubmissionsUnknown|host\.flush|closeSession|dispatch|publishStatus|hasProviderChild' src/main/native-chatRepository: stablyai/orca
Length of output: 50370
🏁 Script executed:
#!/bin/bash
set -e
printf '%s\n' '--- relevant file list ---'
git ls-files 'src/main/native-chat' | sed -n '1,200p'
printf '%s\n' '--- exact target callers ---'
rg -n -C 6 'structured-agent-session-host-handoff|stopped-cleanup-failed|provider_exited_before_acknowledgement|markPendingSubmissionsUnknown' srcRepository: stablyai/orca
Length of output: 47181
🏁 Script executed:
#!/bin/bash
set -e
for f in \
src/main/native-chat/agent-session-wire/structured-agent-session-host-handoff.ts \
src/main/native-chat/agent-session-wire/structured-agent-session-handoff-forward.ts \
src/main/native-chat/agent-session-wire/structured-agent-session-handoff-recover.ts \
src/main/native-chat/agent-session-wire/structured-agent-session-manual-recovery.ts \
src/main/native-chat/agent-session-wire/structured-agent-session-status-feed.ts \
src/main/native-chat/agent-session-journal/journal-pending-submission-recovery.ts
do
echo "--- $f ---"
sed -n '1,240p' "$f"
doneRepository: stablyai/orca
Length of output: 31852
🏁 Script executed:
#!/bin/bash
set -e
printf '%s\n' '--- host handoff tests around cleanup failure ---'
rg -n -C 12 'cleanup|flush|stopped-cleanup-failed|markPendingSubmissionsUnknown|Working|working' \
src/main/native-chat/agent-session-wire/structured-agent-session-host-handoff.test.ts \
src/main/native-chat/agent-session-wire/structured-agent-session-status-feed.test.ts \
src/main/native-chat/agent-session-wire/structured-agent-session-handoff-forward.test.ts \
src/main/native-chat/agent-session-wire/structured-agent-session-handoff-flow-runner.test.ts 2>/dev/null || true
printf '%s\n' '--- status constructors and working predicate ---'
rg -n -C 8 'status:.*working|working|hasUnansweredStructuredAgentSessionDispatch|pendingSubmissions|dispatchState' \
src/main/native-chat/agent-session-wire/structured-agent-session-status-feed.ts \
src/main/native-chat/agent-session-wire/agent-session-journal-batch.ts \
src/main/native-chat/agent-session-journal/journal-pending-submission-recovery.tsRepository: stablyai/orca
Length of output: 45883
🏁 Script executed:
#!/bin/bash
set -e
printf '%s\n' '--- all stopped-cleanup-failed consumers ---'
rg -n -C 10 'stopped-cleanup-failed|markStructuredHandoffManualRecovery' src/main/native-chat/agent-session-wire
printf '%s\n' '--- exact host handoff implementation ---'
sed -n '1,125p' src/main/native-chat/agent-session-wire/structured-agent-session-host-handoff.tsRepository: stablyai/orca
Length of output: 33888
Recover pending submissions when host.flush fails.
If host.flush(sessionId) rejects after closeSession returns true, markPendingSubmissionsUnknown is skipped. hasProviderChild is already false, but the status feed still projects Working while the submission remains pending. Run the journal recovery in a separate error-handled step after the confirmed provider exit, including when cleanup fails.
| recoveredHistory.ok && | ||
| hasUnansweredStructuredAgentSessionDispatch(recoveredHistory.page.submissions) | ||
| ).toBe(false) |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Fail when host.history returns an error.
If recoveredHistory.ok is false, this conjunction evaluates to false and satisfies toBe(false). The test then passes without validating recovery state. Assert recoveredHistory.ok before reading recoveredHistory.page.submissions.
Proposed fix
const recoveredHistory = host.history({ sessionId: SESSION, direction: 'tail' })
- expect(
- recoveredHistory.ok &&
- hasUnansweredStructuredAgentSessionDispatch(recoveredHistory.page.submissions)
- ).toBe(false)
+ if (!recoveredHistory.ok) {
+ throw new Error('Expected recovered session history')
+ }
+ expect(hasUnansweredStructuredAgentSessionDispatch(recoveredHistory.page.submissions)).toBe(
+ false
+ )There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
This delta hardens the original fix's "working from the send" predicate and splits the mobile Stop button from the broadened working state. The prior review's single finding (a live dispatch_result_persistence_failed write carrying recovered, which would have read a still-running turn as idle) is addressed here.
- Fence-gated the working predicate —
hasUnansweredStructuredAgentSessionDispatchnow takescurrentFenceand only counts a submission whosefence >= currentFence, so a staleunknownfrom a prior host generation reads idle instead of resurrecting, even when recovery never marked itrecovered. - Broadened restart/exit recovery —
markPendingSubmissionsUnknownnow also retires non-recoveredunknown(ack-timeout) sends and takes a callerreason; the handoffsuspendNativeand both unexpected-exit paths mark outstanding sendsrecoveredwithprovider_exited_before_acknowledgement. - Retry resumes as live work —
performSend's retry branch re-resolves a recovered submission tounknownat the current fence before re-dispatching, so a retried send reads working immediately (covered by the new idempotency test). - Mobile Stop decoupled from working —
MobileNativeChatViewgains acanStopprop, keyed toturnId !== nullfor structured lanes, matching desktop's Stop/turn separation. - Prior feedback addressed — the
dispatch_result_persistence_failedpath no longer setsrecovered; the flag now only marks a send that outlived its writer.
The fence mechanism is the notable design win here: because the execution fence advances on every restart, handoff, and observed provider exit — each of which also marks outstanding sends recovered — the fence gate is a robust fallback that keeps a stale submission from reading working even if recovery itself fails. New tests (retires an ack timeout on restart, stops projecting an old-host unknown submission after the owner fence advances, the recovered-retry idempotency case, and the mobile Stop-separation tests) each fail if their behavior is reverted.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
|
Review/fix completed on
Final readiness: independent end-of-review checklist found zero remaining proven in-scope findings. Initial counsel attempted four seats; two completed and agreed on the three original P2 findings, while quota/gateway failures prevented the others. Rendered QA: a rebuilt isolated background Electron instance at this head showed Claude Working 210 ms after Send, before its provider lifecycle arrived at +1727 ms; the line remained generic during execution and cleared on completion. Codex still showed Running a command during execution and cleared on completion. Full surrounding-app screenshots are attached in the QA comment. The requested Grok worker hit its weekly limit, so Codex performed QA. Remaining gaps: native mobile send/Stop UI could not run because the simulator lacks the Orca dev client; Windows/Linux/WSL/SSH live UI was not exercised. Explicit compaction completed, but no provider compaction-status frame was emitted, so that visual exception was not reproduced. Permission/interruption journeys and release-scale profiling were not run. The intentionally unbounded live delivery ambiguity and older-host retry limitation remain as described above. Final-head screenshot evidence. At completion, all GitHub Actions checks passed; the separate Pullfrog review was still running. No merge performed. |






ELI5
You send a message to Claude in native chat and nothing happens on screen for a few seconds — no spinner, no "Working", and the worktree sidebar still looks idle. Claude is working; Orca just wasn't willing to say so until Claude echoed your message back. This makes Orca say it as soon as it sends the message.
What Changed
1. A session reads as working from the send, not from the provider echo.
isWorkingkeyed solely on a runningturnLifecyclerow. Codex writes that row ~150ms after a send. Claude cannot write it until the SDK echoes the user message back, so the chat, the sidebar,worktree psand mobile all read idle for the whole wait.The journalled submission row is the host's own evidence that a turn is owed, so the shared projection now reads it too — one predicate, so every surface still agrees.
unknowncounts as work owed. The ack budget elapsing (DISPATCH_ACK_TIMEOUT_MS, 10s) answers delivery, not whether work is owed, and it fires on 30% of Claude sends whose turn then arrives anyway.unknowndoes not count — that send outlived the host generation that issued it. This needed the existing row-levelrecoveredflag carried onto the projected submission (one line in the reducer, one optional wire field).turnIdand behaves exactly as before.2. Claude's activity line stays the generic
⟳ Working….Claude's only turn-wide frame carries a bare status token; every sentence Orca put on that line was Orca's own wording for it. Its
task_*frames do carry prose, but they are keyed by task id and subagent type — they describe a spawned task, not this turn, and the background-tasks strip already owns that surface. Compaction is kept, because it explains an otherwise silent long wait and the Codex map reports it too. Codex's activity line is unchanged.Why
Measured across 34 real Claude sessions and ~280 Codex sessions in the local journal store, submission row → running lifecycle row:
The asymmetry is structural, not a bug in the Claude adapter: Codex declares turn start, Claude does not, so Orca infers it from a dispatch↔replay join. Every failure or delay of that join silently reads as idle.
Linked Issue
No existing issue — found while investigating the reported "Claude native chat doesn't show Working" behaviour. Happy to file one if preferred.
Visual Proof
Isolated background dev instance, real Claude session, driven through the actual composer. Both frames are the same prompt at the same moment: immediately after Enter on a fresh session's first send.
Before — message sent, composer cleared, nothing below it:
After —
⟳ Working…with the spinner:Same rig, same session, A/B by reverting only the
isWorkingline:⟳ Working…The journal for that reverted turn corroborates independently:
lifecycle running +18.85safter the submission row. Across the QA turns the lifecycle row landed at +3.34s, +1.95s and +18.85s.Sidebar was sampled through the same run and transitions
Done → Working → Done. Across every sample of every turn the indicator text was only everWorking…— never a provider-derived sentence.Testing
pnpm vitest— 9,917 tests green acrosssrc/shared,src/main/native-chat,src/renderer/src/components/native-chat; fullsrc/main/claude+src/main/codex+src/main/runtimealso green.tsc --noEmitclean ontsconfig.node,tsconfig.tc.cli,tsconfig.tc.web.pnpm run check:code-quality:changed— 0 findings across 15 files (incl. React Doctor).Not covered: mobile's own suite and typecheck (deps not installed in this worktree); Windows and Linux; SSH/remote hosts.
Review
Deviation worth a reviewer's attention: if a send genuinely never reaches the provider and the host never restarts, the indicator stays on. This is bounded in practice — a late replay upgrades the submission to
acceptedviasettleLateDispatch, a restart marks itrecovered, and an observed provider exit settles the turn — but there is no timer that ends it. I chose not to add one: a timeout is what caused the original bug class, and re-introducing one here would recreate it.Second judgement call: compaction is the one provider string kept on Claude's activity line. If you'd rather Claude be unconditionally
Working…, it is a one-line change.Agent skill upstream boundary
Notes
AgentJournalSubmission.recoveredis a new optional field, which older clients strip — safe underdocs/reference/remote-wire-compatibility.md. No new stream opcodes. Note it does change what the host publishes for status, so an old client paired with a new host sees the earlierworkingtransition; that is the intended behaviour and is not a decode break..some()over the submission list, evaluated where the journal was already being projected.Checklist