Repository navigation
fix(native-chat): render the terminal-backed chat through the structured chat's turn status - #22090
Conversation
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. 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:
📝 WalkthroughWalkthroughThe change replaces typing-indicator behavior and turn-status visibility flags with explicit awaiting-input state. Live-session state now identifies hook waits that remain open in the transcript, and terminal-turn helpers derive active state, start times, and settled-turn durations. The message list renders activity or awaiting-input tail rows. Prompt-card derivation moves to a hook, while the resolved and structured chat views pass derived state to child components. Host turn-start timestamps now flow through status persistence, IPC, renderer state, and turn-timing calculations. Tests cover the updated behavior, and translations add an unnamed awaiting-input label. Priority: ➖ Normal Merge Risk: 🔵 Low · up to Some terminal-backed chats can briefly show or fold the wrong turn duration, and the timing tests can fail intermittently. These are bounded issues, but the timing fixes should be considered before merging. Security Architecture ReviewSecurity architecture risk: 🟡 Moderate · up to The updated chat can associate one turn’s timing with another turn, giving misleading progress or completion cues. The review did not establish a new access-control bypass. Retained concerns
Security review detailsSecurity Blast Radius
Trust Boundaries and Controls
Resilience and Maintainability Implications
Hardening Proposals
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ 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.
ℹ️ No critical issues — minor suggestions inline.
Reviewed changes
- Agent-state resolver — new
native-chat-agent-state-row.tskeepsisWorking(the reconciled hook + transcript turn truth) as the only working authority and mapsblocked/waitingto'waiting-for-user',done/null to nothing. - Lane split in the message list —
showTurnStatusis replaced by the three facts it conflated:agentState(lane-independent),providerTurnTiming, andstructuredActivityUi. The tail renders the existingNativeChatTurnActivityLineforworking, a newNativeChatAgentWaitingRowforwaiting-for-user. - Resolved-view wiring —
useNativeChatHookStatusnow supplieshookState, andworkingStartedAt(hoststateStartedAt) reaches the turn-status hook on the terminal-backed lane, so the working row shows the host clock instead of discarding it. - Typing indicator deleted —
shouldShowNativeChatTypingIndicator,NativeChatTypingIndicatorRow, and their tests are removed; the working row subsumes them. Scroll-hook propshowTypingIndicator→showAgentStateRow. - i18n — one new key,
components.native-chat.status.waitingForUser.
The behavioral test drives the real store → view → list tail wire and fails at main, so the core claim is genuinely pinned.
ℹ️ Nitpicks
NativeChatResolvedView.tsx:113— "Freshness-gated" reads as if it covers the epoch too, butuseNativeChatHookStatusreturnsstateStartedAtraw; onlyhookStatepasses throughresolveNativeChatHookState's freshness gate.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
…red chat's turn status
A terminal-backed chat (grok and omp always; Claude and Codex whenever the
structured lane is refused) could not say what its agent was doing. A
working agent drew three bouncing dots with no elapsed time, and an agent
stopped on a prompt that only its terminal showed drew nothing, so it looked
idle. A pending AskUserQuestion row read "Asked:" while the agent was still
waiting, because the pane treated the wait as the end of the turn.
The pane already held the facts: the host-stamped working epoch and the
hook's waiting/blocked state. It now feeds them to the same message list
props and components the structured lane uses, instead of opting out with
showTurnStatus={false}:
- The turn runs on while the agent waits on the reader, as a structured turn
does behind its prompt card, so the "Working for" bar keeps counting and
the live line yields to the wait.
- A wait the pane can draw as a card (approval or question) is shown by the
card; a wait only the terminal shows is reported by the tail row the
structured lane already uses for a pending question
(NativeChatAwaitingInputRow).
- The hook wait is reconciled against the transcript's terminal marker, like
hook 'working' is, because an interrupt at the prompt fires no hook.
showTurnStatus meant nothing once both lanes passed it, so it is gone, along
with showLiveTurnActivity (replaced by the awaitingInput fact), the
structuredActivityUi flag it fed to tool rows, and the transcript-guessing
typing indicator (native-chat-typing-indicator.ts,
NativeChatTypingIndicatorRow.tsx), which had no other consumer.
The interactive card's derivation moved into
useNativeChatInteractivePromptCard so the view can tell a wait the card
answers from one it cannot.
971a413 to
630bf29
Compare
…hat-show-agent-state
|
| session={sessionWithPending} | ||
| isVisible={isVisible} | ||
| isWorking={isWorking} | ||
| isWorking={turnActive} |
There was a problem hiding this comment.
Paused tool appears running During an approval wait,
turnActive stays true so the turn clock can continue. Passing it as isWorking also marks the trailing approval tool run as live. Its label pulses and says “Running …” even though the agent is paused for approval, giving the reader a false account of what the tool is doing. Keep the clock active without treating the paused tool as executing.
Knowledge Base Used: Agent workspaces and sessions
… question is named A wait the pane cannot draw as a card, and a question whose text could not be parsed, both drew "Awaiting user input:" with nothing after the colon. The row now reads "Awaiting user input" when it has no question to name, in both chat lanes. The pending-question view test now counts awaiting rows by attribute so a second, unnamed row cannot slip past it.
… pending Deriving the prompt card moved from the card into the pane's view, and with it a store read of the status row's tool name, which changes on every tool call. Every tool call therefore re-rendered the whole terminal-backed pane and its transcript list, where before only the card re-rendered. The tool name only matters beside a prompt, so read it only then.
…s a remount Answering a prompt only the terminal shows means switching the pane to its terminal, which unmounts the chat. On return the "Working for" clock restarted from the agent's current state (seconds after the answer), and every turn the pane had folded behind "Worked for N" came back unfolded with no bar. - The running turn now counts from the start of the hook's unbroken run of mid-turn states under the current prompt (read from the status row's state history), not the current state's own start. - Finished turns take their duration from the transcript's own timestamps (prompt to the agent's last row or its interruption), so history turns fold like a structured chat's. The latest turn still relies on what the pane saw.
| if (turn?.startedAt != null && turn.endedAt != null) { | ||
| settled.set(turn.id, { | ||
| startedAt: turn.startedAt, | ||
| workedSeconds: Math.max(0, Math.floor((turn.endedAt - turn.startedAt) / 1000)) | ||
| }) | ||
| } | ||
| turn = { id: message.id, startedAt: message.timestamp, endedAt: null } |
There was a problem hiding this comment.
Turn duration ends too early When a terminal-backed turn has a timestamped tool call or early assistant message but no later timestamped agent row, the next user message makes this code treat that earlier row as the end of the turn. A long approval wait can therefore appear as “Worked for 0s,” and the turn can be folded despite remaining active during the wait. The next user message marks a turn boundary, not the preceding turn’s finish time.
Knowledge Base Used: Agent workspaces and sessions
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
Changes since the prior pullfrog review (fc53a73 → 841dca1, two commits; the full 43-file diff was also read):
- Unnamed wait reads as a whole phrase —
NativeChatAwaitingInputRownow selectsask.awaitingUnnamed("Awaiting user input", no colon) whensubject === null, so the transcript tail row and a payload-less ask tool call no longer end on a dangling colon. NewNATIVE_CHAT_ASK_ROW_COPYentry plusen.json,en-runtime-required.json, and the fr/ja/ko/zh catalogs. - Prompt-card hook no longer re-renders on every tool call —
useNativeChatInteractivePromptCardreads the status entry'stoolNameonly whileinteractivePromptis present, so a tool-call-only status change no longer re-renders the whole pane. Newuse-native-chat-interactive-prompt-card.test.tspins both the no-re-render case and that the prompt still parses.
The prior review's one open thread (a possible duplicate pane-level waiting row) is addressed by the rebuilt design: the tail awaiting row is suppressed whenever a prompt card or the transcript's own ask row already speaks for the wait, and NativeChatResolvedView.turn-status.test.tsx asserts exactly one awaiting row. Both localization gates pass, and the changed test files pass.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
Changes since the previous pullfrog review (841dca1 → 03c6367, one commit):
- Turn clock and folds survive a remount on the terminal lane — new
useNativeChatTerminalTurnTimingfeedsNativeChatMessageListaworkingStartedAtdrawn from the hook's unbroken mid-turn run under the current prompt (nativeChatHookTurnStartedAt) rather than the current state's own start, plus transcript-derivedsettledTurns(nativeChatTranscriptSettledTurns). A pane that remounts after answering a terminal-only prompt now keeps counting from the turn start, and finished historical turns still show and fold their durations.
Both helpers are pure and pinned by exact-assertion unit tests, and the view tests cover the remount-after-wait clock and the historical fold. tc:web is clean and the changed test files pass.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
…d skip harness notices Two ways the terminal-backed chat showed a wrong turn status: - A background task or subagent keeps the status row 'working' after the main agent finishes, so the row's own start time carries into the next turn. A prompt sent while a background dev server ran showed "Working for" counted from the earlier turn. The clock now reads the main agent's own state and start time where the row carries them. - Harness notices (task notifications, reminders) are user-role rows in the transcript that the chat does not draw. The finished-turn derivation treated them as new prompts, so a running turn was reported settled and folded its steps while it still ran, and a finished turn's "Worked for" stopped at the notice. They no longer start or end a turn.
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: 60b410fa-d1f4-4f74-9413-8820c5718130
📒 Files selected for processing (3)
src/renderer/src/components/native-chat/NativeChatResolvedView.turn-status.test.tsxsrc/renderer/src/components/native-chat/native-chat-terminal-turn.test.tssrc/renderer/src/components/native-chat/native-chat-terminal-turn.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 1 remain after this review.
| retained.session = transcript('working', false) | ||
| setStatus({ state: 'working' }) | ||
| const live = useAppStore.getState().agentStatusByPaneKey[paneKey]! | ||
| const now = Date.now() |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Freeze the clock for exact elapsed-time assertions.
If rendering takes one second after now is sampled, the expected Working for 5s can become Working for 6s. The test then fails while the UI is correct. Freeze Date.now() before setting the status and restore the clock after the test. Apply the same fix to the Working for 30s assertion. The test setup does not currently freeze the clock. (raw.githubusercontent.com)
Based on learnings: Tests that depend on Date.now() should use a fake clock for deterministic assertions.
Source: Learnings
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
Changes since the previous pullfrog review (03c6367 → 4fcf36e, one commit):
- Turn clock now dates from the main agent, not the row —
nativeChatHookTurnStartedAttakes the entry'smainAgentclock while the main agent is notdoneand walksstateHistoryby each leg'smainAgentstart. A background task that held the rowworkingacross the last turn's end no longer stretches the new turn's clock back to that task's start; once the main agent isdone, the row's own run is read as the turn's tail. - Harness notices no longer split a turn —
nativeChatTranscriptSettledTurnsskipsisNoiseMessageuser rows, so a task notification or reminder injected mid-turn neither ends the current turn nor starts a new one. This matches the main process's own rule intranscript-turn-lifecycle.ts. - Tests — three exact-assertion unit cases for the main-agent/row clock and one for a mid-turn notice, plus a view-level case asserting the main-agent clock wins over a 45-minute-old row epoch. All pin the new behavior (the old code produces
Working for 45m 0sand a folded turn in those cases).
Verified locally at this head: the two changed test files pass (28 tests) and pnpm tc:web is clean.
ℹ️ Nitpicks
- The PR description is stale against this head. It states "No locale keys are added or removed", but
1da494cfaddedcomponents.native-chat.ask.awaitingUnnamedtoen.json,en-runtime-required.json, and the fr/ja/ko/zh catalogs; and it says turns loaded from history "show no bar and stay unfolded", while03c6367'snativeChatTranscriptSettledTurnsfolds them (pinned by the "folds finished turns from history behind their transcript duration" view test). A one-line body correction keeps the description aligned with what ships.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
The hook server now records turnStartedAt on a status row when the main agent's own turn-opening event arrives (the per-provider new-turn classifier the observation boundary already uses; not a replay, a child event or an identity-only row). Other events carry it; a session boundary clears it, and a settled main agent running again with no opening event drops it rather than count from the finished turn. It rides the snapshot and the live push as an optional field, persists with the row, lands on the renderer entry (kept within one state for writers with no turn clock), and is part of the paired-client projection key and equality. Old hosts send nothing; readers fall back to stateStartedAt.
… stamp The running clock reads the host's turnStartedAt, so a remount, a reload (which starts with no state history) and child work holding the row open no longer move it, and the same prompt sent again is a new turn. The stateHistory walk and its prompt-equality rule are gone; an old host falls back to the current state's start. The latest turn is settled from host facts: once the main agent is done (outside a session boundary) its duration is the done stamp minus the turn start, so it folds after a remount. When the host went quiet mid-turn (the store's staleness dropped the row) the pane passes null, so a still-waiting turn no longer reads "Worked for 30m" and folds. Older turns keep their transcript durations.
| const settledTurns = useMemo(() => { | ||
| if (turnActive || latestWorkedSeconds === undefined || latestTurnId === null) { | ||
| return transcriptSettled | ||
| } | ||
| return new Map(transcriptSettled).set( | ||
| latestTurnId, | ||
| latestWorkedSeconds === null || turnStartedAt === null | ||
| ? null | ||
| : { startedAt: turnStartedAt, workedSeconds: latestWorkedSeconds } |
There was a problem hiding this comment.
Duration attaches to wrong prompt When a new message appears optimistically before its hook status arrives, the hook still describes the preceding completed turn. This code assigns that turn’s duration to the newest prompt without checking whether they belong together. The new message can show “Worked for” and fold its steps before the agent has begun or finished it.
Knowledge Base Used: Agent workspaces and sessions
There was a problem hiding this comment.
Actionable comments posted: 3
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: b734459a-9aae-448c-84f4-5df0104ce37c
📒 Files selected for processing (23)
src/main/agent-hooks/server-turn-started-at.test.tssrc/main/agent-hooks/server/server-persistence-validation.tssrc/main/agent-hooks/server/server-status-application.tssrc/main/agent-hooks/server/server-status-identity.tssrc/main/agent-hooks/server/server-types.tssrc/main/startup/main-window-agent-status.tssrc/main/startup/main-window-structured-status-filter.test.tssrc/renderer/src/components/native-chat/NativeChatResolvedView.turn-status.test.tsxsrc/renderer/src/components/native-chat/native-chat-terminal-turn.test.tssrc/renderer/src/components/native-chat/native-chat-terminal-turn.tssrc/renderer/src/components/native-chat/use-native-chat-terminal-turn-timing.tssrc/renderer/src/hooks/ipc-events-agent-status-store-test-fixtures.tssrc/renderer/src/hooks/ipc-events/agent-status-event-applicator.tssrc/renderer/src/hooks/useIpcEvents-agent-status-snapshot-replay.test.tssrc/renderer/src/runtime/sync-runtime-graph-agent-status-projection.test.tssrc/renderer/src/runtime/sync-runtime-graph/agent-status-projection.tssrc/renderer/src/runtime/web-session-tabs-sync/state-equality-core.test.tssrc/renderer/src/runtime/web-session-tabs-sync/state-equality-core.tssrc/renderer/src/store/slices/agent-status-contract.tssrc/renderer/src/store/slices/agent-status-live-entry-builder.tssrc/renderer/src/store/slices/agent-status-turn-started-at.test.tssrc/shared/agent-status-ipc-payload.tssrc/shared/agent-status-types.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.
| const agentStatusEpoch = useAppStore((s) => s.agentStatusEpoch) | ||
| void agentStatusEpoch | ||
| const turnStartedAt = useAppStore((s) => | ||
| nativeChatHookTurnStartedAt(s.agentStatusByPaneKey[paneKey]) | ||
| ) | ||
| const latestWorkedSeconds = useAppStore((s) => { | ||
| const entry = s.agentStatusByPaneKey[paneKey] | ||
| return nativeChatHookLatestTurnWorkedSeconds(entry, resolveNativeChatHookState(entry) === null) | ||
| }) | ||
| const transcriptSettled = useMemo(() => nativeChatTranscriptSettledTurns(messages), [messages]) | ||
| const latestTurnId = useMemo(() => nativeChatLatestTurnId(messages), [messages]) | ||
| const settledTurns = useMemo(() => { | ||
| if (turnActive || latestWorkedSeconds === undefined || latestTurnId === null) { | ||
| return transcriptSettled | ||
| } | ||
| return new Map(transcriptSettled).set( | ||
| latestTurnId, | ||
| latestWorkedSeconds === null || turnStartedAt === null | ||
| ? null |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
sed -n '1,85p' src/renderer/src/components/native-chat/use-native-chat-terminal-turn-timing.ts
sed -n '73,133p' src/renderer/src/components/native-chat/native-chat-terminal-turn.ts
sed -n '310,335p' src/renderer/src/components/native-chat/NativeChatResolvedView.tsxRepository: stablyai/orca
Length of output: 6090
🏁 Script executed:
set -e
printf '%s\n' '--- candidate symbols and usages ---'
rg -n --glob '*.ts' --glob '*.tsx' 'resolveNativeChatTerminalTurn|nativeChatHookLatestTurnWorkedSeconds|sessionBoundary|turnStartedAt|agentStatusByPaneKey|nativeChatLatestTurnId|useNativeChatTerminalTurnTiming' src/renderer/src/components/native-chat src/renderer/src/store src/shared
printf '%s\n' '--- terminal turn file outline and relevant source ---'
ast-grep outline src/renderer/src/components/native-chat/native-chat-terminal-turn.ts
sed -n '1,180p' src/renderer/src/components/native-chat/native-chat-terminal-turn.ts
printf '%s\n' '--- hook status source ---'
sed -n '1,240p' src/renderer/src/components/native-chat/use-native-chat-hook-status.tsRepository: stablyai/orca
Length of output: 41888
🏁 Script executed:
set -e
printf '%s\n' '--- changed files and diff summary ---'
git diff --stat bd5dca4406ff6b755474474625af8177b5821c36 bc250cd5a74ade7ee4b222a8b05f8230f09dff2d
git diff --unified=35 bd5dca4406ff6b755474474625af8177b5821c36 bc250cd5a74ade7ee4b222a8b05f8230f09dff2d -- src/renderer/src/components/native-chat/use-native-chat-terminal-turn-timing.ts src/renderer/src/components/native-chat/native-chat-terminal-turn.ts
printf '%s\n' '--- status bridge ---'
sed -n '55,155p' src/renderer/src/components/native-chat/StructuredAgentSessionStatusBridge.tsx
printf '%s\n' '--- status live reducer ---'
sed -n '1,145p' src/renderer/src/store/slices/agent-status-live-reducer.ts
printf '%s\n' '--- interactive send ---'
sed -n '80,180p' src/renderer/src/components/native-chat/use-native-chat-interactive-send.ts
printf '%s\n' '--- relevant turn timing tests ---'
sed -n '1,280p' src/renderer/src/components/native-chat/native-chat-terminal-turn.test.ts
rg -n --glob '*turn*timing*' --glob '*.test.*' --glob '*.tsx' 'settledTurns|workedSeconds|turnStartedAt|latestTurnId|timing' src/renderer/src/components/native-chatRepository: stablyai/orca
Length of output: 42791
🏁 Script executed:
set -e
printf '%s\n' '--- latestPrompt and transcript ingestion ---'
rg -n --glob '*.ts' --glob '*.tsx' 'latestPrompt|messages:|setMessages|append.*message|add.*message|NativeChatMessage|transcript' src/renderer/src/components/native-chat/use-native-chat-live-session.ts src/renderer/src/components/native-chat/native-chat-live-session-contract.ts src/renderer/src/components/native-chat/NativeChatResolvedView.tsx src/renderer/src/components/native-chat/NativeChatStructuredSession.tsx src/renderer/src/components/native-chat src/shared | head -240
printf '%s\n' '--- live session implementation ---'
sed -n '1,260p' src/renderer/src/components/native-chat/use-native-chat-live-session.ts
printf '%s\n' '--- resolved view status/turn inputs ---'
sed -n '80,140p' src/renderer/src/components/native-chat/NativeChatResolvedView.tsx
sed -n '280,345p' src/renderer/src/components/native-chat/NativeChatResolvedView.tsx
printf '%s\n' '--- structured status projection continuation ---'
sed -n '85,175p' src/renderer/src/components/native-chat/StructuredAgentSessionStatusBridge.tsxRepository: stablyai/orca
Length of output: 41917
🏁 Script executed:
set -e
printf '%s\n' '--- status prompt fields and producers ---'
rg -n --glob '*.ts' --glob '*.tsx' '\bprompt\b|latestPrompt|turnStartedAt' src/shared/agent-status-types.ts src/shared/agent-status-ipc-payload.ts src/main src/renderer/src/store/slices src/renderer/src/components/native-chat | head -260
printf '%s\n' '--- transcript message shape and text helpers ---'
rg -n --glob '*.ts' --glob '*.tsx' 'export type NativeChatMessage|interface NativeChatMessage|message\.blocks|blocks.*text|text.*blocks|settledTurns\.get|settledTurns\?' src/shared/native-chat-types.ts src/renderer/src/components/native-chat/NativeChatMessageList.tsx src/renderer/src/components/native-chat/NativeChatTranscriptRow.tsx src/renderer/src/components/native-chat/native-chat-transcript-slots.ts src/renderer/src/components/native-chat/NativeChatMessageRow.tsx
printf '%s\n' '--- message list timing path ---'
sed -n '50,125p' src/renderer/src/components/native-chat/NativeChatMessageList.tsx
sed -n '160,230p' src/renderer/src/components/native-chat/NativeChatMessageList.tsx
sed -n '1,115p' src/renderer/src/components/native-chat/NativeChatTranscriptRow.tsx
printf '%s\n' '--- live session status derivation ---'
sed -n '320,375p' src/renderer/src/components/native-chat/use-native-chat-live-session.tsRepository: stablyai/orca
Length of output: 41531
🏁 Script executed:
set -e
printf '%s\n' '--- exact status and message types ---'
sed -n '65,105p' src/shared/agent-status-types.ts
sed -n '185,225p' src/shared/native-chat-types.ts
printf '%s\n' '--- message content helpers ---'
rg -n --glob '*.ts' --glob '*.tsx' 'function deriveNativeChatRowContent|export .*deriveNativeChatRowContent|deriveNativeChatRowContent' src/shared src/renderer/src/components/native-chat
printf '%s\n' '--- turn status hook and slot status assignment ---'
rg -n --glob '*.ts' --glob '*.tsx' 'function useNativeChatTurnStatus|useNativeChatTurnStatus|settledTurns\.get|workedSeconds' src/renderer/src/components/native-chat/use-native-chat-turn-status.ts src/renderer/src/components/native-chat/native-chat-transcript-slots.ts src/renderer/src/components/native-chat
sed -n '1,180p' src/renderer/src/components/native-chat/use-native-chat-turn-status.ts
sed -n '135,180p' src/renderer/src/components/native-chat/native-chat-transcript-slots.tsRepository: stablyai/orca
Length of output: 14141
Guard host timing against a newer transcript prompt.
When the transcript receives a new user prompt before the pane status advances, latestWorkedSeconds can still contain the previous completed turn. The hook then assigns that duration and turnStartedAt to latestTurnId. The new prompt can therefore show the previous turn's duration and become foldable as settled.
Add a status-to-prompt or equivalent turn-ID guard before applying host timing. Do not solve this by changing the omitted turnStartedAt branch; this case has a valid old host stamp.
| const turnStartedAt = | ||
| timing?.turnStartedAt ?? | ||
| (existing && existing.state === payload.state ? existing.turnStartedAt : undefined) |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
sed -n '75,135p' src/renderer/src/store/slices/agent-status-live-entry-builder.ts
sed -n '185,222p' src/renderer/src/store/slices/agent-status-live-entry-builder.ts
sed -n '70,110p' src/renderer/src/store/slices/agent-status-contract.ts
sed -n '200,238p' src/renderer/src/hooks/ipc-events/agent-status-event-applicator.tsRepository: stablyai/orca
Length of output: 7044
🏁 Script executed:
set -e
sed -n '1,220p' src/renderer/src/hooks/ipc-events/normalize-agent-status-event.ts
sed -n '1,280p' src/renderer/src/hooks/ipc-events/agent-status-event-applicator.ts
sed -n '1,180p' src/renderer/src/store/slices/agent-status-live-entry-builder.ts
rg -n -C 8 'mainAgent|sessionBoundary' src/renderer/src src/main/agent-hooks/server src/main/startup/main-window-agent-status.tsRepository: stablyai/orca
Length of output: 45663
🏁 Script executed:
set -e
printf '%s\n' '--- shared payload and main-agent types ---'
rg -n -C 12 'type AgentMainAgentStatus|interface AgentMainAgentStatus|mainAgent|sessionBoundary|type ParsedAgentStatusPayload|interface ParsedAgentStatusPayload' src/shared/agent-status-types.ts src/shared
printf '%s\n' '--- main-agent resolver ---'
sed -n '1,240p' src/renderer/src/store/slices/agent-status-live-entry-main-agent.ts
printf '%s\n' '--- builder tests and boundary tests ---'
rg -n -C 10 'sessionBoundary|mainAgent|turnStartedAt|OSC|repaint|done.*working|working.*done' src/renderer/src/store/slices/*agent-status*test* src/main/agent-hooks/*test* 2>/dev/nullRepository: stablyai/orca
Length of output: 45651
<final_review_comment>
Clear the inherited clock from existing payload metadata.
mainAgent and sessionBoundary already reach buildAgentStatusLiveEntry. When the existing main agent is done and the incoming mainAgent is non-done, or when sessionBoundary is true, clear turnStartedAt before applying the same-state fallback. An OSC repaint has no mainAgent fact and can retain the existing clock.
🐛 Suggested fix
+ const hostClearedTurn =
+ payload.sessionBoundary === true ||
+ (payload.mainAgent !== undefined &&
+ existing?.mainAgent?.state === 'done' &&
+ payload.mainAgent.state !== 'done')
// Why: a writer with no turn clock (an OSC repaint) keeps the host's stamp only within one state;
// a state change it cannot date must not inherit another turn's start.
const turnStartedAt =
timing?.turnStartedAt ??
- (existing && existing.state === payload.state ? existing.turnStartedAt : undefined)
+ (hostClearedTurn
+ ? undefined
+ : existing && existing.state === payload.state
+ ? existing.turnStartedAt
+ : undefined)</final_review_comment>
…ool call The terminal-backed chat settles a hook 'working' turn when the transcript's last row is an assistant row written after the turn began, a recovery for a Stop hook the host can miss. omp writes a timestamp on every row and has no transcript turn markers, so every tool call mid-turn tripped it: the pane dropped its "Working for" bar and showed Send instead of Stop while the command ran. omp's own runtime delivers its turn end (agent_end, retried until the host takes it and held back while the run continues), so its hook 'working' is never a dropped Stop. The prose recovery now skips it.
The test stamped the row's done time and the turn start from two separate Date.now() reads, so whenever a millisecond passed between them the expected "Worked for 1m 30s" came out as 1m 29s. It failed that way once under load.
| if ( | ||
| transcriptLifecycle?.state !== 'working' && | ||
| !hookDeliversTurnEnd(agent) && | ||
| trailingAssistantPostDates(statusTailMessage, stateStartedAt) | ||
| ) { | ||
| return undefined |
There was a problem hiding this comment.
OMP completion can appear stuck If OMP's completion hook fails delivery, this change stops the latest assistant transcript row from settling a stale
working status. OMP transcripts have no turn-end marker, and hook delivery stops retrying after three attempts. A finished turn can therefore keep showing “Working” and Stop until the status expires. Please preserve a fallback that can distinguish a finished answer from a tool call made mid-run.
Knowledge Base Used: Agent integrations and hooks
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
Changes since the prior pullfrog review (4fcf36e → bc250cd, three commits; the full 64-file diff was also read):
- Host-stamped turn start — the hook server now stamps
turnStartedAtfrom the main agent's own turn-opening event (isNewTurnEvent), clears it on a session boundary and on adone→non-doneedge with no opening event, and propagates it otherwise. Only the server can write it, so a producer cannot declare it (the parsed payload whitelist drops the field). It is persisted, pushed onagentStatus:set, and carried through the IPC payload, renderer store, client-sync equality, and mobile projection. - Terminal lane times from the host stamp —
nativeChatHookTurnStartedAtprefersentry.turnStartedAt, falling back to the main agent's then the row'sstateStartedAton an older host. NewnativeChatHookLatestTurnWorkedSeconds/nativeChatLatestTurnIdletuseNativeChatTerminalTurnTimingfold the host's finished-turn duration intosettledTurns, and hide a locally measured end when the host went quiet mid-turn. - Tests — a new host suite (7 cases: tools/wait/answer, child and relayed-replay exclusion, session boundary, OSC-race clear, producer-supplied stamp, live push + restart hydration) plus store/equality/projection/live-push cases and updated view/unit cases with exact assertions.
Verified at this head: the changed test suites pass (48 view/store/equality/live-session + 28 host/terminal-turn) and pnpm tc:web is clean. The prior review's one open thread (duplicate waiting row) is already resolved.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
Changes since the prior pullfrog review (bc250cd → 702a784, two commits; read the range-diff):
- omp keeps working through mid-run tool calls —
mergeNativeChatLiveSessionnow passes the pane's agent intoliveStatusOverride, andhookDeliversTurnEnd(agent)(omp only) skips the assistant-prose recovery that would otherwise settle the turn when the transcript's trailing assistant row — an omp tool call written mid-run — postdates the current state. omp's ownagent_endis the settle signal; the extension retries it and holds it back while the run continues, and grok keeps prose recovery. The new unit case fails without the guard. - Test-only — the host-ended remount view test now reads
Date.now()once so both stamps share a single clock, removing a timing race between the two reads.
Verified at this head: native-chat-live-status.test.ts (23) and the turn-status view test (16) pass, and pnpm tc:web is clean.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
…tion reference The hot-path suite compares the agent-status projection against its own copy of the serializer; that copy lacked the new turnStartedAt key.
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
Changes since the prior pullfrog review (702a784 → a884f86, one commit; the delta is a single test-only line, read against the full 65-file diff from prior runs):
- Hot-path projection fixture carries the turn stamp —
referenceAgentStatusProjectioninsync-runtime-graph-projection-hot-path.test.tsnow mirrors the production serializer'sturnStartedAtkey, so the byte-for-byte and ordering equivalence cases stay green after502c42cadded the field. The reference lacked the key while production always emits it, so those cases were red; the siblingsync-runtime-graph-agent-status-projection.test.tsalready carried it. Verified red without the line (turnStartedAt: nullon the production side only) and green with it.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
Review status: ready for a merge decision (not merged)The problem this fixes: a native chat backed by an agent's terminal (grok and omp always; Claude and Codex when the structured chat is refused) showed three bouncing dots while working, nothing when the agent was blocked on a prompt only its terminal showed, and never "Worked for N". For omp even the dots vanished during every tool call. What you see now: the terminal-backed chat looks and acts like the structured chat in all three moments, checked side by side against a real structured Claude chat on a remote Mac at 702a784 (the head since then only adds a test fix): What changed during review (head a884f86):
Checks: Decisions for you (not changed here):
Follow-ups found, not caused by this PR:
Not merged and auto-merge not enabled. |
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
Changes since the prior pullfrog review (a884f86 → 123bbdf, the merge of origin/main @ b7e3bbf):
- Merge reconciliation of main's
#23573—NativeChatMessageListnow derives the running turn's key asselectNativeChatActiveTurnKey(messages, activeTurnOpenedBy)(the host's opener, else the latest user message) and passes it touseNativeChatTurnStatusandbuildNativeChatTranscriptSlots; the privatelatestUserIndexkey is gone.NativeChatStructuredSessionforwardscontroller.activeTurnOpenedBy. The terminal lane passes none, so its key remains the latest user prompt — behavior unchanged for this PR's lane. - Merge reconciliation of main's
#23765—NativeChatStructuredSessionadoptsuseStructuredAgentSessionHostExecution(.phase/.childKey) in place ofuseStructuredAgentSessionHostExecutionPhase. - PR's removal preserved — no reference to
showTurnStatus,showLiveTurnActivity, the typing indicator, orstructuredActivityUisurvives at this head; the terminal lane still renders throughawaitingInput/tailRow.
The true branch delta also absorbs main's shared native-chat-turn-status.ts, structured-agent-session-turn-timing.ts, use-structured-agent-turn-timing.ts, and the status-bridge changes; no conflicting intent was dropped by the resolution.
Verified at this head: the whole src/renderer/src/components/native-chat/ suite plus structured-agent-session-turn-bars / -turn-timing passes (201 files, 2071 tests), pnpm tc:web is clean, and check:code-quality:changed reports 0 new findings. Both prior pullfrog threads are resolved; none remain open.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
Changes since the prior pullfrog review (123bbdf → 535cd07, the merge of origin/main @ b6c2de9f):
- Main's turn-grouping refactor adopted —
NativeChatMessageListnow resolves each row's owning turn through the sharednativeChatRowTurnKeys(messages, turnKeysByItemId), andnative-chat-transcript-slots.tsusesnativeChatSelfAnchoredTurnRows/statusAbove/lastRowByTurnso a provider-opened turn anchors its bar at its first row instead of every run boundary.NativeChatStructuredSessionforwardscontroller.turnKeysByItemId. - Terminal lane behavior unchanged — the terminal-backed lane passes no
turnKeysByItemId, so the shared helper reproduces the previous preceding-user grouping exactly.activeTurnIsWorkingnow keys offactiveTurnKey; for this lane that is the same latest-user-message key the removedcurrentTurnKeyheld, and the unanchored case (no user message yet) is preserved byNATIVE_CHAT_UNANCHORED_TURN_KEY. - Removed UI stays removed — no
showTurnStatus,showLiveTurnActivity,structuredActivityUi,NativeChatTypingIndicatorRow, ornative-chat-typing-indicatorreference survives at this head. - Absorbed main work — the merge also brings in main's sidebar subagent-row refactor (
#22565) and codex account-home index heal (#22971).
Verified at this head: the whole src/renderer/src/components/native-chat/ suite (199 files, 2047 tests) passes, pnpm tc:web is clean, and the one prior pullfrog thread is [RESOLVED].
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
Main now groups chat rows by the turn the host's turn records say produced them (#23671), anchors a provider-opened turn's bar on its first row, and renders the terminal-backed chat through the structured turn status (#22090). This branch moves each subagent's rows out of the conversation into its own section under its roster entry. Conflicts, resolved so both hold: - Slots: main's owning-turn liveness, statusAbove and last-row rollup placement, on this branch's message/section/entries slot union. - Message list: main's nativeChatRowTurnKeys and active-turn key feed the slots; this branch's rollup still merges subagent rows into turn order. - Transcript row: main's bar-above on this branch's section-indented wrapper. - Slot tests: main's turn-owned grouping tests kept; the inline subagent caption tests stay removed with the caption. Subagent rows now take their turn from the same rule: the transcript projection runs nativeChatRowTurnKeys over every row with the host's attribution, and only a user row the conversation draws opens a turn by position. The positional rule it replaces put an edit made after a send queued mid-turn into that send's turn, and never used a turn keyed to its own record, so the edit counted in the wrong turn's changed files.
…3745, #23783, #22971, #22565, #22846, #23724, #23721, #23693, #23810) into #23059 #23671 (group chat rows by the turn that produced them) is ported onto #23059's turn-scope model, so there is one grouping mechanism, not two: - A host that states each row's turn scope groups by that scope, as before. #23671's journal-order derivation (rows between one turn record and the next belong to it) moves from the timing selector into src/shared/native-chat-turn-grouping.ts and runs only for a host that states no scope, replacing the positional fallback there. - #23671's anchor rules live in structuredAgentTurnAnchors, which membership, settled timing and the live clock all read: a turn whose opener key nothing resolves yet takes the send still in flight ahead of its record (Codex before its echo), else its own record. - The live turn is one key again. #23671 made row liveness follow the owning turn, so the bar key and the liveness key are always the same; nativeChatTurnMembership now returns only liveTurnKey (barTurnKey, activeTurnOpenedBy and turnKeysByItemId are gone). - A turn with no user bubble draws its bar above its first row (nativeChatTurnBarRows, desktop and mobile), and a turn's diff rollup goes under its last row. - The Codex full-history restore writes each record ahead of its items; that also fixes the derived turn scope on #23059's journal. #23026 (Stop from the moment a message is sent) is ported onto #23059's command turns: the cancel paths ask the translator for a command's provider turn instead of the removed compaction tracker, and a Stop that names no turn still ends a running /compact through its child. performCancel moved to structured-agent-session-turns-cancel.ts to keep the turns module under the line limit. #22090's awaitingInput replaces showTurnStatus/showLiveTurnActivity; the waiting-behind-/compact rows are kept.




What was wrong
A native chat pane backed by an agent's terminal could not tell you what its agent was doing. This lane is permanent: grok and omp only ever use it, and Claude and Codex fall back to it whenever the structured chat is refused (remote host, reused terminal, floating workspace, launch-command override, WSL).
Why: the pane opted out of the structured chat's turn-status UI with
showTurnStatus={false}. That one flag swapped in the dots, dropped the working clock, and switched tool rows to older chrome. The pane also never read the hook'swaiting/blockedstate, so while the agent waited it treated the turn as over. And nothing recorded when a terminal agent's turn began, so there was nothing to count from.Scope: the terminal-backed native chat pane on desktop (and paired desktop clients). The structured chat looks and behaves exactly as before. Mobile is unchanged. Sidebar,
worktree psand notifications read the same status row and are unchanged.What you see now
Live QA on a remote Mac, this PR's build: left, a terminal-backed grok chat (driven by a scripted grok stand-in that posts grok's real hook events and writes a grok-format transcript with no row timestamps, as real grok does); right, a real structured Claude chat, at the same moment.
How
One UI, two lanes. Both lanes pass the same props to
NativeChatMessageList, which draws the same components for both:useNativeChatTurnStatus,NativeChatWorkingStatus(the "Working for / Worked for" bar and fold caret),NativeChatTurnActivityLine(the spinner line),NativeChatAwaitingInputRow, the turn fold, and the tool-run chrome. They lose only their lane switch. The terminal lane's facts come from one pure function,resolveNativeChatTerminalTurn, so the Send/Stop "generating" fact and the "turn running" fact cannot drift apart.The host records when a turn began. The hook server (the execution host's agent-status store) now stamps
turnStartedAton the status row when the main agent's own turn opens: the prompt event each provider already classifies as a new turn (Claude and CodexUserPromptSubmit, grokuser_prompt_submit, ompbefore_agent_start). Child-agent events, replays and identity-only rows never stamp it; a session start clears it; producers cannot declare it. It is carried across tools, waits and answers, persisted with the row, and delivered on the snapshot and live push to the renderer and paired clients. The pane's clock reads it. The latest turn's "Worked for" comes from the host too: the main agent's done time minus the turn start.What each lane feeds in.
isWorking: the structured chat passes its running turn. The terminal lane passes "the agent is generating, or stopped mid-turn waiting on you", because a structured turn also keeps running behind its prompt card. Local Stop still ends it.workingStartedAt: the structured chat passes its journal's turn start; the terminal lane passes the host'sturnStartedAt.settledTurns: the structured chat passes its journal's durations; the terminal lane passes durations derived from the transcript's own timestamps for older turns and the host's verdict for the latest one. If the host's row has gone quiet mid-turn (the store drops rows silent for 30 minutes), the latest turn gets no duration rather than a false "Worked for 30m".awaitingInput(replacesshowLiveTurnActivity):'shown'when a prompt card on screen asks,'unshown'when the agent waits on a prompt the pane cannot draw,nullotherwise. The structured chat passes'shown'while its card is up, exactly whatshowLiveTurnActivity={prompt === null}did.Supporting changes.
waiting/blockedstate is reconciled against the transcript's end-of-turn marker, the same rule the pane already applies toworking, so an interrupt at a prompt (which fires no hook) does not leave "Awaiting user input" up.workingpane whenever the newest transcript row was an assistant row written after the working state began; it stands in for a Stop hook the host can miss. omp writes a timestamped assistant row for every tool call and reports its own turn end reliably (retried until the host takes it), so the fallback is now off for omp. That is what made omp look idle during every tool call.useNativeChatInteractivePromptCard, so the view can tell a wait the card answers from one it cannot; it reads the status row's tool name only while a prompt is pending, so tool calls do not re-render the pane.components.native-chat.ask.awaitingUnnamed, hand-added to fr, ja, ko and zh; es has no ask section).Why this is better than the alternatives.
Wire compatibility.
turnStartedAtis one new optional field on existing shapes; nothing is moved or removed and no stream opcode changes. A host that predates it sends nothing, and the pane falls back to the current state's start (the clock then restarts after each wait, as the first version of this PR did). An older client ignores it. SSH relays need no change because the stamp is made in the desktop hook server.What the terminal-backed chat still lacks
Identical in both lanes: the bar and its clock format, the spinner line, the prompt-pending rule, the awaiting row, the fold, and the tool-run chrome. Not identical, because this lane has no structured journal; in each case the shared UI degrades as it does for a structured turn missing the same fact:
orca servehost does not receive the turn stamp yet, so there the clock falls back to the current state's start.Deleted
Counts are
git grep -coversrc mobile tests configatorigin/mainand at this head.showTurnStatus: 32 references on main, 0 here.showLiveTurnActivity: 11 on main, 0 here (replaced byawaitingInput).structuredActivityUiprop onNativeChatMessageRowandNativeChatToolRun: always true once both lanes drew the structured chrome, so it and its off-branches are gone. Mobile's own prop of the same name is untouched.native-chat-typing-indicator.ts, its test, andNativeChatTypingIndicatorRow.tsx(the three dots).Evidence
server-turn-started-at.test.tsposts real hook bodies over HTTP and through the SSH relay path: stamped on a new main-agent turn, carried across tools, waits and answers, not stamped by child events or replays, cleared by a session start, dropped when a finished agent reopens without a prompt event, not declarable by producers, and carried through the live push, persistence and hydration.tc:nodeandtc:web: clean. CI: all eight test shards, typecheck and verify pass on this head. oxlint, oxfmt, the changed-code quality gate, React Doctor and the localization checks pass.pnpm-lock.yamlis not in the diff.Not in this PR
Addresses the agent-state half of STA-6980 and STA-6222's elapsed-time and no-false-running criteria on this lane.