Repository navigation
fix(agent-status): reconcile stale pane status - #17619
brennanb2025 wants to merge 8 commits into
Conversation
Greptile SummaryThe PR reconciles stale pane-level agent status by combining hook state with bounded, PTY-bound process and title observations.
Confidence Score: 5/5The PR appears safe to merge because no blocking failure remains in the eligible follow-up review scope. No blocking failure remains.
|
| Filename | Overview |
|---|---|
| src/main/agent-hooks/server.ts | Bounds suppression of same-prompt post-interrupt tool progress so sufficiently late resumed work can publish a working state. |
| src/renderer/src/store/slices/pane-foreground-agent.ts | Separates pane process identity from PTY-bound observation freshness and adds move, refresh, and cleanup operations. |
| src/renderer/src/components/sidebar/worktree-agent-process-evidence.ts | Centralizes fresh process-evidence resolution for layout leaves and live PTY bindings. |
| src/renderer/src/components/sidebar/worktree-agent-rows.ts | Synthesizes process-derived rows and permits fresh same-pane evidence to replace stale terminal rows. |
| src/renderer/src/components/sidebar/worktree-agent-activity-summary.ts | Projects process identity and observation maps into worktree-scoped activity summaries. |
| src/renderer/src/lib/worktree-status.ts | Extends worktree status-dot resolution to use full layouts and PTY-fenced process observations. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
H[Hook-derived agent status] --> R[Pane status reconciliation]
T[Terminal title evidence] --> R
P[PTY process identity] --> O[PTY-bound freshness observation]
O -->|Fresh and PTY matches| R
O -->|Expired or PTY changed| X[Ignore process evidence]
R --> S{Fresh pane evidence?}
S -->|Yes| L[Render live pane state]
S -->|No| C[Retain terminal completion history]
L --> D[Sidebar row and status dot]
C --> D
Reviews (7): Last reviewed commit: "fix(agent-status): consolidate title age..." | Re-trigger Greptile
|
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 separates pane foreground-agent identity from freshness observations that include timestamps and PTY IDs. It propagates both maps through worktree summaries, sidebar row construction, and worktree status evaluation. Fresh process evidence can create working rows and replace stale completed rows. Terminal title attribution now uses per-leaf process identity. Agent inspection refreshes eligible observations, while pane cleanup and authority transfer maintain observation state. Server interrupt suppression is limited to its configured late-working window, with tests for Claude and Codex recovery. Merge Risk: 🟡 Moderate · up to This PR improves pane status reconciliation, but current paths can still duplicate rows, misattribute activity after a PTY rebind, or leave an agent shown as working after its evidence expires. These bounded correctness issues can mislead users, so the PR is not merge-ready until they are fixed or explicitly accepted. 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
Full details: Description checkExplanation The description provides a detailed problem statement, behavior changes, scope limits, and verification details. However, it does not follow the required template because the linked issue is blank, visual proof or an explicit N/A statement is missing, and several required sections and checklist items are absent. Resolution Add the required template sections and information: provide a linked issue after
✨ 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 new issues found.
Reviewed changes
Bounded the post-interrupt tool-progress suppression in the agent-hook server to the existing 15-second late-hook window, and added regression coverage for the Codex request_user_input interruption sequence.
- Suppression bound —
isToolProgressWorkingAfterInterruptinsrc/main/agent-hooks/server.tsnow additionally requiresDate.now() - previous.receivedAt <= INTERRUPTED_DONE_LATE_WORKING_SUPPRESSION_MS, so a same-prompt Claude/Codex tool-progressworkingevent arriving after the window restoresworkinginstead of being suppressed indefinitely. - Claude regression test — the "after the stale suppression window" case now asserts the row returns to
working(at 16,501 ms) rather than stayingdone/interrupted. - Codex regression test — a new HTTP-path test covers the captured
request_user_inputwait → answer → inferred interrupt → later same-promptPreToolUsesequence and asserts the row returns toworking.
The isReplay === true clause stays unbounded, which is correct for replaying old records, and the within-window suppression is still exercised by the existing "does not let late Claude/Codex tool hooks ... resurrect" tests.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
The second commit adds a bounded, PTY-bound process-observation path in the renderer so fresh pane evidence can supersede stale terminal outcomes, surfaced in both the sidebar rows and the worktree status dot.
- Process identity slice —
paneForegroundAgentByPaneKeyentries now carryobservedAt/ptyId, refreshed on each coordinator inspection (5s quantum) and bounded by a 30s TTL throughresolveFreshPaneForegroundAgent. - PTY-rebind fencing — observations are published with the inspected
ptyId, and the row path rejects identity whose PTY no longer matches the pane's bound PTY. - Identity-only rows —
appendProcessDerivedAgentRowssynthesizesidlerows for fresh process observations with no hook/title, andresolveTitleDerivedAgentTypenow accepts Claude's neutral spinner when a process observation names it. - Stale completion replacement — stale
done/interruptedrows yield to a fresh title/process row for the same pane; terminal history is retained otherwise.
ℹ️ Status-dot process attribution uses a weaker rebind guard than the rows
useWorktreeActivityStatus threads paneForegroundAgentByPaneKey into resolveWorktreeStatus but not the full terminalLayoutsByTabId, so freshProcessAgentForLeaf in the dot path resolves with paneBoundPtyId === undefined and falls back to entry.ptyId membership in liveTabPtyIds. The sidebar row path enforces entry.ptyId === paneBoundPtyId. The divergence only bites when a pane's PTY is rebound while the old PTY is still live in the tab, which is narrow enough to be non-blocking, but worth an explicit comment if the roots-only selector is intentional.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
Actionable comments posted: 4
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: ced23443-efa9-4fca-83c0-d35010200539
📒 Files selected for processing (17)
src/renderer/src/components/sidebar/use-worktree-activity-status.tssrc/renderer/src/components/sidebar/use-worktree-activity-statuses.tssrc/renderer/src/components/sidebar/useWorktreeAgentRows.test.tssrc/renderer/src/components/sidebar/useWorktreeAgentRows.tssrc/renderer/src/components/sidebar/worktree-agent-activity-summary.tssrc/renderer/src/components/sidebar/worktree-agent-process-evidence.tssrc/renderer/src/components/sidebar/worktree-agent-rows.tssrc/renderer/src/components/sidebar/worktree-title-agent-type.tssrc/renderer/src/components/sidebar/worktree-title-derived-agent-rows.test.tssrc/renderer/src/components/sidebar/worktree-title-derived-agent-rows.tssrc/renderer/src/components/terminal-pane/agent-completion-coordinator-types.tssrc/renderer/src/components/terminal-pane/agent-completion-process-monitor.tssrc/renderer/src/components/terminal-pane/pty-connection/pane-agent-identity.tssrc/renderer/src/components/terminal-pane/pty-connection/sleeping-record-access.tssrc/renderer/src/components/terminal-pane/pty-connection/terminal-keydown-fit.tssrc/renderer/src/lib/worktree-status.tssrc/renderer/src/store/slices/pane-foreground-agent.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.
| const paneForegroundAgentByPaneKey = useAppStore((s) => | ||
| active | ||
| ? selectWorktreeAgentActivitySummary(s, worktreeId).paneForegroundAgentByPaneKey | ||
| : EMPTY_PANE_FOREGROUND_AGENTS |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
printf '%s\n' '--- repository conventions ---'
find /tmp/coderabbit-repo-knowledge/stablyai-orca-89dc44e4 -maxdepth 2 -type f -name '*.md' -print
printf '%s\n' '--- target file symbols ---'
ast-grep outline src/renderer/src/components/sidebar/useWorktreeAgentRows.ts
printf '%s\n' '--- target implementation ---'
sed -n '1,180p' src/renderer/src/components/sidebar/useWorktreeAgentRows.ts
printf '%s\n' '--- bound symbols ---'
rg -n -S 'createWorktreeAgentFreshnessSelector|resolveFreshPaneForegroundAgent|agentFreshnessSignature|PANE_FOREGROUND_AGENT_EVIDENCE_TTL_MS|selectWorktreeAgentActivitySummary' src/renderer/srcRepository: stablyai/orca
Length of output: 15225
🏁 Script executed:
printf '%s\n' '--- renderer conventions ---'
cat /tmp/coderabbit-repo-knowledge/stablyai-orca-89dc44e4/conventions/src-renderer.md
printf '%s\n' '--- freshness selector ---'
cat -n src/renderer/src/components/sidebar/worktree-agent-freshness-selector.ts
printf '%s\n' '--- process evidence ---'
cat -n src/renderer/src/components/sidebar/worktree-agent-process-evidence.ts
printf '%s\n' '--- activity summary ---'
sed -n '1,230p' src/renderer/src/components/sidebar/worktree-agent-activity-summary.ts
printf '%s\n' '--- pane foreground agent store contract ---'
sed -n '1,230p' src/renderer/src/store/slices/pane-foreground-agent.ts
printf '%s\n' '--- freshness tests ---'
sed -n '1,150p' src/renderer/src/components/sidebar/worktree-agent-freshness-selector.test.tsRepository: stablyai/orca
Length of output: 27076
Add a deadline-driven refresh for foreground observations.
If process inspection stops before another store update, createWorktreeAgentFreshnessSelector can keep the same signature. resolveFreshPaneForegroundAgent applies PANE_FOREGROUND_AGENT_EVIDENCE_TTL_MS only during row construction, so the expired process-derived row may remain visible.
| state.consecutiveInspectionErrors = 0 | ||
| const recognized = recognizeAgentProcess(result.foregroundProcess) | ||
| if (recognized) { | ||
| options.onForegroundAgentInspected?.(recognized) |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
printf '%s\n' '--- repository guidance ---'
find /tmp/coderabbit-repo-knowledge/stablyai-orca-89dc44e4 -type f -name '*.md' -maxdepth 3 -print
printf '%s\n' '--- target symbols ---'
rg -n -C 12 'onForegroundAgentInspected|requestInspection|inspectProcess|ptyId|generation' src/renderer/src/components/terminal-pane/agent-completion-process-monitor.ts src/renderer/src/components/terminal-pane/pty-connection/terminal-keydown-fit.ts
printf '%s\n' '--- scoped guidance content ---'
for f in /tmp/coderabbit-repo-knowledge/stablyai-orca-89dc44e4/*/*.md; do
printf '\n--- %s ---\n' "$f"
head -200 "$f"
doneRepository: stablyai/orca
Length of output: 50369
🏁 Script executed:
printf '%s\n' '--- monitor state and callback contract ---'
sed -n '1,220p' src/renderer/src/components/terminal-pane/agent-completion-process-monitor.ts
printf '%s\n' '--- generation and PTY-binding mutations ---'
rg -n -C 8 'inspectionGeneration|activePanePtyBinding|setPanePtyFitBinding|clearPanePtyFitBinding|onForegroundAgentInspected' src/renderer/src/components/terminal-pane src/renderer/src
printf '%s\n' '--- process-inspection binding ---'
rg -n -C 10 'function inspectRuntimeTerminalProcess|const inspectRuntimeTerminalProcess|inspectRuntimeTerminalProcess|RuntimeTerminalProcessInspection' src/renderer/src src/sharedRepository: stablyai/orca
Length of output: 50370
🏁 Script executed:
printf '%s\n' '--- monitor implementation ---'
cat -n src/renderer/src/components/terminal-pane/agent-completion-process-monitor.ts | sed -n '1,220p'
printf '%s\n' '--- inspectionGeneration references ---'
rg -n -C 5 'inspectionGeneration' src/renderer/src --glob '*.ts' --glob '*.tsx'
printf '%s\n' '--- PTY binding and coordinator lifecycle ---'
rg -n -C 8 'setPanePtyFitBinding|clearPanePtyFitBinding|agentCompletionCoordinator|activePanePtyBinding' src/renderer/src/components/terminal-pane/pty-connection/terminal-keydown-fit.ts src/renderer/src/components/terminal-pane/pty-connection --glob '*.ts'
printf '%s\n' '--- inspection API definition and consumer ---'
rg -n -C 12 'export .*inspectRuntimeTerminalProcess|inspectRuntimeTerminalProcess\s*=|async function inspectRuntimeTerminalProcess|inspectProcess:' src/renderer/src/runtime/runtime-terminal-inspection.ts src/shared --glob '*.ts'Repository: stablyai/orca
Length of output: 50369
🏁 Script executed:
printf '%s\n' '--- generation API callers ---'
rg -n -C 6 'incrementGeneration' src/renderer/src --glob '*.ts' --glob '*.tsx'
printf '%s\n' '--- callback and monitor option types ---'
cat -n src/renderer/src/components/terminal-pane/agent-completion-process-types.ts | sed -n '1,100p'
printf '%s\n' '--- coordinator lifecycle methods ---'
cat -n src/renderer/src/components/terminal-pane/agent-completion-coordinator.ts | sed -n '1,180p'
printf '%s\n' '--- PTY binding callers and transport identity changes ---'
rg -n -C 8 'bindPanePtyId|setPtyId|getPtyId\s*\(\)|getPtyId\s*:' src/renderer/src/components/terminal-pane/pty-connection --glob '*.ts'Repository: stablyai/orca
Length of output: 50370
🏁 Script executed:
printf '%s\n' '--- lifecycle reset callers ---'
cat -n src/renderer/src/components/terminal-pane/agent-completion-lifecycle.ts | sed -n '1,180p'
printf '%s\n' '--- coordinator public lifecycle wiring ---'
cat -n src/renderer/src/components/terminal-pane/agent-completion-coordinator.ts | sed -n '175,330p'
printf '%s\n' '--- bind implementation around rebind path ---'
cat -n src/renderer/src/components/terminal-pane/pty-connection/pane-pty-visibility-bind.ts | sed -n '1,125p'
printf '%s\n' '--- transport identity implementation ---'
rg -n -C 10 'getPtyId\s*\(\)|ptyId\s*=' src/renderer/src/components/terminal-pane/pty-connection/pty-transport.ts src/renderer/src/components/terminal-pane/pty-connection --glob '*transport*.ts'Repository: stablyai/orca
Length of output: 16449
🏁 Script executed:
printf '%s\n' '--- resetCompletionState callers ---'
rg -n -C 8 'resetCompletionState' src/renderer/src/components/terminal-pane --glob '*.ts' --glob '*.tsx'
printf '%s\n' '--- coordinator option and callback contract ---'
cat -n src/renderer/src/components/terminal-pane/agent-completion-coordinator-types.ts | sed -n '1,130p'
printf '%s\n' '--- observation store action ---'
rg -n -C 12 'refreshPaneForegroundAgentObservation' src/renderer/src
printf '%s\n' '--- transport files and PTY identity methods ---'
fd -i 'pty.*transport|transport.*pty' src/renderer/src
rg -n -C 8 'getPtyId\s*\(\)|getPtyId\s*:' src/renderer/src --glob '*.ts' --glob '*.tsx' | head -240Repository: stablyai/orca
Length of output: 50369
🏁 Script executed:
printf '%s\n' '--- foreground observation action ---'
cat -n src/renderer/src/store/slices/pane-foreground-agent.ts | sed -n '88,145p'
printf '%s\n' '--- foreground tracking guard ---'
rg -n -C 12 'isForegroundTrackingAllowed|sampleVisiblePaneForegroundAgent|onForegroundAgentInspected' src/renderer/src/components/terminal-pane/pty-connection --glob '*.ts'
printf '%s\n' '--- PTY transport implementation ---'
cat -n src/renderer/src/components/terminal-pane/pty-transport.ts | sed -n '1,180p'
printf '%s\n' '--- PTY identity assignment sites ---'
rg -n -C 8 'ptyId\s*=|getPtyId' src/renderer/src/components/terminal-pane/pty-transport.ts src/renderer/src/components/terminal-pane/remote-runtime-pty-transport.tsRepository: stablyai/orca
Length of output: 50369
Preserve the inspected PTY ID across the callback.
requestInspection passes the captured ptyId to inspectProcess, but onForegroundAgentInspected reads the current transport PTY ID. Rebinding does not increment inspectionGeneration, so an old result can reach this callback. The callback can then refresh or replace the current PTY's foreground-agent entry with stale process evidence. Pass the captured ptyId to the callback and reject stale bindings.
| layout: options.terminalLayoutsByTabId?.[tab.id], | ||
| livePtyIds: ptyIdsByTabId[tab.id], | ||
| paneForegroundAgentByPaneKey: options.paneForegroundAgentByPaneKey, | ||
| now: options.now ?? Date.now() |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
#!/bin/bash
set -e
printf '%s\n' '--- repository conventions ---'
find /tmp/coderabbit-repo-knowledge/stablyai-orca-89dc44e4 -maxdepth 2 -type f -name '*.md' -print
printf '%s\n' '--- relevant convention and architecture headers ---'
for f in /tmp/coderabbit-repo-knowledge/stablyai-orca-89dc44e4/*/*.md; do
case "$f" in
*renderer*|*worktree*|*status*|*frontend*|*architecture*) head -40 "$f";;
esac
done
printf '%s\n' '--- changed hunk ---'
git diff -- src/renderer/src/lib/worktree-status.ts
printf '%s\n' '--- file outline ---'
ast-grep outline src/renderer/src/lib/worktree-status.ts --view expanded
printf '%s\n' '--- relevant source ---'
cat -n src/renderer/src/lib/worktree-status.ts | sed -n '1,180p'
printf '%s\n' '--- direct callers and hook ---'
rg -n -C 4 'tabHasStatus|useWorktreeActivityStatus|PANE_FOREGROUND_AGENT_EVIDENCE_TTL_MS|observedAt|worktree-status' src/renderer/srcRepository: stablyai/orca
Length of output: 50370
🏁 Script executed:
#!/bin/bash
set -e
printf '%s\n' '--- direct definition of freshProcessAgentForLeaf ---'
rg -n -C 8 'function freshProcessAgentForLeaf|export .*freshProcessAgentForLeaf|freshProcessAgentForLeaf' src
printf '%s\n' '--- status resolver remainder ---'
cat -n src/renderer/src/lib/worktree-status.ts | sed -n '164,260p'
printf '%s\n' '--- terminal activity status consumer ---'
cat -n src/renderer/src/components/tab-bar/terminal-tab-activity-status.ts | sed -n '1,240p'
printf '%s\n' '--- pane evidence contract and TTL ---'
rg -n -C 12 'PANE_FOREGROUND_AGENT_EVIDENCE_TTL_MS|is.*Fresh|freshProcessAgentForLeaf|PaneForegroundAgentEntry' src/renderer/src shared src/shared
printf '%s\n' '--- history context for the target line ---'
git status --short
git diff --stat
git show HEAD^:src/renderer/src/lib/worktree-status.ts 2>/dev/null | sed -n '78,102p' || trueRepository: stablyai/orca
Length of output: 50370
🏁 Script executed:
#!/bin/bash
set -e
printf '%s\n' '--- exact freshProcessAgentForLeaf locations ---'
rg -l 'freshProcessAgentForLeaf' src/renderer/src
printf '%s\n' '--- exact useWorktreeActivityStatus locations ---'
rg -l 'useWorktreeActivityStatus' src/renderer/src
printf '%s\n' '--- TTL declarations and consumers ---'
rg -n -C 5 'PANE_FOREGROUND_AGENT_EVIDENCE_TTL_MS' src/renderer/src src/shared
printf '%s\n' '--- narrow activity-summary implementation ---'
cat -n src/renderer/src/components/sidebar/worktree-agent-activity-summary.ts | sed -n '80,175p'
printf '%s\n' '--- status consumer implementation ---'
cat -n src/renderer/src/components/tab-bar/terminal-tab-activity-status.ts | sed -n '1,180p'Repository: stablyai/orca
Length of output: 17133
🏁 Script executed:
#!/bin/bash
set -e
printf '%s\n' '--- freshProcessAgentForLeaf implementation ---'
cat -n src/renderer/src/components/sidebar/worktree-title-derived-agent-rows.ts | sed -n '1,220p'
printf '%s\n' '--- process evidence helper ---'
cat -n src/renderer/src/components/sidebar/worktree-agent-process-evidence.ts | sed -n '1,220p'
printf '%s\n' '--- worktree activity hook ---'
cat -n src/renderer/src/components/sidebar/use-worktree-activity-status.ts | sed -n '1,260p'
printf '%s\n' '--- foreground-agent slice and scheduler/invalidation ---'
cat -n src/renderer/src/store/slices/pane-foreground-agent.ts | sed -n '1,230p'
rg -n -C 8 'createFreshnessScheduler|agentStatusEpoch|paneForegroundAgentByPaneKey' src/renderer/src/store src/renderer/src/components/sidebarRepository: stablyai/orca
Length of output: 50370
🏁 Script executed:
#!/bin/bash
set -e
printf '%s\n' '--- title-derived process resolver ---'
rg -n 'freshProcessAgentForLeaf' src/renderer/src/components/sidebar/worktree-title-derived-agent-rows.ts
cat -n src/renderer/src/components/sidebar/worktree-title-derived-agent-rows.ts | sed -n '1,80p'
printf '%s\n' '--- foreground resolver exact body ---'
cat -n src/renderer/src/store/slices/pane-foreground-agent.ts | sed -n '1,25p;155,184p'
printf '%s\n' '--- activity hook exact body ---'
cat -n src/renderer/src/components/sidebar/use-worktree-activity-status.ts | sed -n '1,240p'
printf '%s\n' '--- activity statuses selector and hook ---'
cat -n src/renderer/src/components/sidebar/use-worktree-activity-statuses.ts | sed -n '1,220p'Repository: stablyai/orca
Length of output: 13543
🏁 Script executed:
#!/bin/bash
set -e
printf '%s\n' '--- process-evidence implementation ---'
cat -n src/renderer/src/components/sidebar/worktree-agent-process-evidence.ts | sed -n '1,150p'
printf '%s\n' '--- foreground-agent slice actions and all timer references ---'
cat -n src/renderer/src/store/slices/pane-foreground-agent.ts | sed -n '25,165p'
rg -n -C 5 'OBSERVATION_REFRESH_QUANTUM_MS|setTimeout|setInterval|PANE_FOREGROUND_AGENT_EVIDENCE_TTL_MS|resolveFreshPaneForegroundAgent' src/renderer/src/store/slices/pane-foreground-agent.ts src/renderer/src/components/sidebar/worktree-agent-process-evidence.ts src/renderer/src
printf '%s\n' '--- hook usage ---'
rg -n -C 3 'useWorktreeActivityStatus\\(' src/renderer/src/componentsRepository: stablyai/orca
Length of output: 50370
🏁 Script executed:
#!/bin/bash
set -e
printf '%s\n' '--- process-evidence implementation ---'
cat -n src/renderer/src/components/sidebar/worktree-agent-process-evidence.ts | sed -n '1,130p'
printf '%s\n' '--- foreground-agent slice implementation ---'
cat -n src/renderer/src/store/slices/pane-foreground-agent.ts | sed -n '25,165p'
printf '%s\n' '--- freshness scheduler implementation ---'
cat -n src/renderer/src/store/slices/agent-status-freshness-scheduler.ts | sed -n '1,180p'
printf '%s\n' '--- hook usage ---'
rg -n -C 4 'useWorktreeActivityStatus\\(' src/renderer/src/components --glob '*.tsx' --glob '*.ts'Repository: stablyai/orca
Length of output: 15790
Invalidate status when foreground evidence expires.
useWorktreeActivityStatus memoizes resolveWorktreeStatus without a time dependency. If no store update occurs after observedAt + PANE_FOREGROUND_AGENT_EVIDENCE_TTL_MS, resolveFreshPaneForegroundAgent is not called again, so the status can remain working after its evidence expires. Add expiry-driven recalculation or clear expired observations, with a regression test.
| return { | ||
| paneForegroundAgentByPaneKey: { | ||
| ...s.paneForegroundAgentByPaneKey, | ||
| [paneKey]: { ...current, observedAt: now } |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Persist the PTY on every process observation.
Line 120 refreshes only observedAt when the agent is unchanged. Line 128 drops ptyId for a new entry. After a PTY rebind, this can hide a current agent or accept an old unbound observation for the new pane during the evidence TTL. Update ptyId on refresh and bypass the refresh throttle when the supplied PTY changes.
Proposed fix
+ const nextPtyId = ptyId ?? current.ptyId
if (
current.observedAt !== undefined &&
- now - current.observedAt < OBSERVATION_REFRESH_QUANTUM_MS
+ now - current.observedAt < OBSERVATION_REFRESH_QUANTUM_MS &&
+ current.ptyId === nextPtyId
) {
return s
}
return {
paneForegroundAgentByPaneKey: {
...s.paneForegroundAgentByPaneKey,
- [paneKey]: { ...current, observedAt: now }
+ [paneKey]: { ...current, observedAt: now, ptyId: nextPtyId }
}
}
...
- [paneKey]: { agent, shellForeground: false, observedAt: now }
+ [paneKey]: { agent, shellForeground: false, observedAt: now, ptyId }Also applies to: 128-128
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: ef966911-c99d-4860-86cf-1ad0b91dff2e
📒 Files selected for processing (6)
src/renderer/src/components/terminal-pane/pty-connection/pane-agent-identity.tssrc/renderer/src/components/terminal-pane/pty-connection/sleeping-record-access.tssrc/renderer/src/components/terminal-pane/pty-connection/terminal-keydown-fit.tssrc/renderer/src/store/slices/pane-foreground-agent.test.tssrc/renderer/src/store/slices/pane-foreground-agent.tssrc/shared/pane-agent-identity-inventory.test.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 6 remain after this review.
| } | ||
| useAppStore | ||
| .getState() | ||
| .refreshPaneForegroundAgentObservation?.(session.cacheKey, process.agent, inspectedPtyId) |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
#!/bin/bash
set -eu
printf '%s\n' '--- applicable repository conventions ---'
find /tmp/coderabbit-repo-knowledge/stablyai-orca-89dc44e4 -maxdepth 2 -type f -name '*.md' -print
printf '%s\n' '--- target outline ---'
ast-grep outline src/renderer/src/components/terminal-pane/pty-connection/terminal-keydown-fit.ts
printf '%s\n' '--- target context ---'
sed -n '150,235p' src/renderer/src/components/terminal-pane/pty-connection/terminal-keydown-fit.ts
printf '%s\n' '--- related symbols ---'
rg -n -C 5 'refreshPaneForegroundAgentObservation|onForegroundAgentInspected|agentInspected|inspect.*Pty|inspectedPtyId|getPtyId' src/renderer/srcRepository: stablyai/orca
Length of output: 50370
🏁 Script executed:
#!/bin/bash
set -eu
printf '%s\n' '--- convention and learning files ---'
find /tmp/coderabbit-repo-knowledge/stablyai-orca-89dc44e4 -maxdepth 2 -type f -name '*.md' \
| sort | sed -n '1,80p'
printf '%s\n' '--- direct coordinator bindings ---'
rg -l 'refreshPaneForegroundAgentObservation|onForegroundAgentInspected|inspectRuntimeTerminalProcess' \
src/renderer/src/components/terminal-pane \
| sort
printf '%s\n' '--- coordinator implementation and relevant tests ---'
for f in $(rg -l 'onForegroundAgentInspected|inspectRuntimeTerminalProcess' src/renderer/src/components/terminal-pane | sort | head -20); do
echo "### $f"
rg -n -C 12 'onForegroundAgentInspected|inspectRuntimeTerminalProcess|inspectProcess|refreshPaneForegroundAgentObservation|getPtyId' "$f"
done
printf '%s\n' '--- target callback and coordinator setup ---'
sed -n '160,225p' src/renderer/src/components/terminal-pane/pty-connection/terminal-keydown-fit.tsRepository: stablyai/orca
Length of output: 43282
🏁 Script executed:
#!/bin/bash
set -eu
printf '%s\n' '--- coordinator source ---'
wc -l src/renderer/src/components/terminal-pane/agent-completion-process-monitor.ts
sed -n '1,285p' src/renderer/src/components/terminal-pane/agent-completion-process-monitor.ts
printf '%s\n' '--- coordinator factory and lifecycle ---'
rg -n -C 8 'createAgentCompletionCoordinator|inspectionGeneration|requestInspection|dispose|observeTitle|observeClassifiedTitleCompletion' \
src/renderer/src/components/terminal-pane/agent-completion-coordinator.ts \
src/renderer/src/components/terminal-pane/agent-completion-process-monitor.ts \
src/renderer/src/components/terminal-pane/agent-completion-coordinator-types.ts
printf '%s\n' '--- observation store contract and tracking guard ---'
rg -n -C 12 'refreshPaneForegroundAgentObservation|isForegroundTrackingAllowed' src/renderer/srcRepository: stablyai/orca
Length of output: 50369
🏁 Script executed:
#!/bin/bash
set -eu
printf '%s\n' '--- PTY-rebind generation callers ---'
rg -n -C 8 'incrementGeneration|agentCompletionCoordinator\??\.|startProcessTracking|resetCompletionState' \
src/renderer/src/components/terminal-pane/pty-connection \
src/renderer/src/components/terminal-pane/agent-completion*
printf '%s\n' '--- observation refresh implementation ---'
sed -n '1,145p' src/renderer/src/store/slices/pane-foreground-agent.ts
printf '%s\n' '--- identity tracker publish path ---'
sed -n '120,195p' src/renderer/src/components/terminal-pane/pty-connection/pane-agent-identity.ts
printf '%s\n' '--- renderer conventions and scoped learning ---'
cat /tmp/coderabbit-repo-knowledge/stablyai-orca-89dc44e4/conventions/src-renderer.md
cat /tmp/coderabbit-repo-knowledge/stablyai-orca-89dc44e4/learnings/src-renderer-src-components-terminal-pane.mdRepository: stablyai/orca
Length of output: 50370
🏁 Script executed:
#!/bin/bash
set -eu
printf '%s\n' '--- every generation reference ---'
rg -n 'incrementGeneration|inspectionGeneration' src/renderer/src/components/terminal-pane
printf '%s\n' '--- coordinator lifecycle wiring ---'
sed -n '280,320p' src/renderer/src/components/terminal-pane/agent-completion-coordinator.ts
sed -n '1,120p' src/renderer/src/components/terminal-pane/agent-completion-lifecycle.ts
printf '%s\n' '--- observation refresh implementation ---'
sed -n '70,125p' src/renderer/src/store/slices/pane-foreground-agent.ts
printf '%s\n' '--- tracking guard and tracker publish ---'
sed -n '125,175p' src/renderer/src/components/terminal-pane/pty-connection/pane-agent-identity.tsRepository: stablyai/orca
Length of output: 9613
🏁 Script executed:
#!/bin/bash
set -eu
printf '%s\n' '--- full refresh implementation ---'
rg -n -A 45 -B 3 'refreshPaneForegroundAgentObservation:' \
src/renderer/src/store/slices/pane-foreground-agent.ts
printf '%s\n' '--- process inspection API binding ---'
rg -n -A 35 -B 8 'export (async )?function inspectRuntimeTerminalProcess|function inspectRuntimeTerminalProcess|inspectRuntimeTerminalProcess' \
src/renderer/src/runtime/runtime-terminal-inspection.ts
printf '%s\n' '--- PTY bind/rebind paths and reset calls ---'
rg -n -C 10 'resetCompletionState\(|getPtyId\(\).*pty|ptyId.*getPtyId|bind.*Pty|transport.*ptyId|startProcessTracking' \
src/renderer/src/components/terminal-pane/pty-connection \
| sed -n '1,260p'Repository: stablyai/orca
Length of output: 39949
Keep inspection results bound to their requested PTY.
agent-completion-process-monitor.ts captures PTY A before awaiting inspectProcess, but terminal-keydown-fit.ts reads the current PTY in onForegroundAgentInspected. The completion guard checks only inspectionGeneration, so an A result can reach refreshPaneForegroundAgentObservation with PTY B and be stored as B evidence. Pass the captured PTY ID through the callback and reject mismatched results. Add a regression test for this rebind sequence.
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
The new commit preserves the pre-existing pane identity record shape by routing every store write through createPaneForegroundAgentEntry, which keeps the process freshness metadata readable but non-enumerable, and tightens setPaneForegroundAgent so identity-only republishes no longer refresh the process-freshness clock.
- Non-enumerable freshness metadata —
createPaneForegroundAgentEntryhidesobservedAt/ptyIdbehindObject.defineProperties({ enumerable: false }), soObject.keys, spreads, JSON, andstructuredClonesee only the long-standingagent/shellForeground/routing shape, whileresolveFreshPaneForegroundAgentstill reads the values from the live store. - Value-bail tightening — the unchanged-identity bail now requires
normalizedEntry.observedAt === undefined, so display-only republishes (e.g. sleeping-record launch identity) no longer refresh the freshness clock; only observed process evidence does. - Coverage — a new slice test pins the exact enumerable shape (
['agent', 'shellForeground']) while asserting the non-enumerable values stay readable, and the pre-existing "lands the publish that clears a pending confirmation" test confirms the value-bail does not swallow the routing flag change.
I verified the two cross-boundary consumers of paneForegroundAgentByPaneKey (the dashboard popout snapshot and web-session sync) read only enumerable fields, so the non-enumerable freshness metadata being dropped across IPC/wire is harmless today and consistent with the stated intent.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
ℹ️ No critical issues — the dot path now applies the same pane-bound PTY fence as sidebar rows, resolving the prior review note. One minor suggestion inline plus a cleanup note.
Reviewed changes
The new commits thread full per-tab layout snapshots and live PTY ids into the status-dot path so it fences process evidence by the pane's bound PTY, matching the sidebar-row behavior.
- Full-layout status selectors —
useWorktreeActivityStatusanduseWorktreeActivityStatusesnow selectselectTerminalLayoutsForWorktreeandselectLivePtyIdsForWorktreeinstead of roots-only, and pass both intoresolveWorktreeStatus, sofreshProcessAgentForLeafresolvespaneBoundPtyIdfromptyIdsByLeafId. - Rebind regression test — a new
worktree-status.test.tscase pins that process evidence bound topty-oldis rejected when the layout bindspty-new, yieldingactiverather thanworking.
ℹ️ Orphaned roots selectors are now production-dead
After this switch, selectTerminalLayoutRootsForWorktree and selectTerminalLayoutRootsForWorktrees have no production importers left — only worktree-card-status-inputs.test.ts exercises them, and resolveWorktreeStatus's terminalLayoutRootsByTabId option is no longer passed by any caller outside tests. They are cleanup candidates unless a follow-up consumer is planned.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
| return out | ||
| } | ||
|
|
||
| export function selectTerminalLayoutsForWorktree( |
There was a problem hiding this comment.
selectTerminalLayoutsForWorktree already exists in worktree-agent-row-selectors.ts (imported by useWorktreeAgentRows.ts and build-dashboard-snapshot.ts). This is a second, slightly different definition — narrower input type and no ?? EMPTY_RECORD null-safety fallback. Prefer importing the existing selector (or moving the canonical one here and re-exporting) so the two copies can't drift.
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/renderer/src/components/sidebar/worktree-agent-rows.ts (1)
232-234: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick winMark title-derived panes as seen.
Lines 232-234 restore
titleSeenPaneKeys, but they do not add the pane keys emitted bytitleRows. If a stale live completion is replaced by a title-derived row andretainedhas history for the same pane, the retained loop adds a duplicate row.Proposed fix
- for (const paneKey of titleSeenPaneKeys) { - seenPaneKeys.add(paneKey) + for (const row of titleRows) { + seenPaneKeys.add(row.paneKey) }
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Team
Run ID: aad0ed92-d48c-401c-a12a-0c63bf3e9013
📒 Files selected for processing (20)
src/renderer/src/components/sidebar/use-worktree-activity-status.tssrc/renderer/src/components/sidebar/use-worktree-activity-statuses.tssrc/renderer/src/components/sidebar/useWorktreeAgentRows.tssrc/renderer/src/components/sidebar/worktree-agent-activity-summary-equality.tssrc/renderer/src/components/sidebar/worktree-agent-activity-summary.tssrc/renderer/src/components/sidebar/worktree-agent-process-evidence.tssrc/renderer/src/components/sidebar/worktree-agent-rows.tssrc/renderer/src/components/sidebar/worktree-agent-state-flags.tssrc/renderer/src/components/sidebar/worktree-title-derived-agent-rows.test.tssrc/renderer/src/components/sidebar/worktree-title-derived-agent-rows.tssrc/renderer/src/components/terminal-pane/pty-connection-foreground-agent-sampling.test.tssrc/renderer/src/components/terminal-pane/pty-connection/pane-agent-identity.tssrc/renderer/src/lib/worktree-status.test.tssrc/renderer/src/lib/worktree-status.tssrc/renderer/src/runtime/web-session-tabs-sync.tssrc/renderer/src/store/slices/agent-status.tssrc/renderer/src/store/slices/pane-foreground-agent.test.tssrc/renderer/src/store/slices/pane-foreground-agent.tssrc/renderer/src/store/slices/retired-terminal-tab-state-sweep.tssrc/renderer/src/store/slices/worktrees/teardown/worktree-purge-state.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 5 remain after this review.
There was a problem hiding this comment.
ℹ️ The
ed5c485refactor itself is clean — no new issues in this delta. I'd approve, but one prior Pullfrog thread is still open.
Reviewed changes
Replaced the non-enumerable property approach from the prior commit with an explicit, enumerable observation map, so the pane identity record returns to its long-standing shape while process freshness lives in a separate keyed store map.
- Split process evidence into its own map —
PaneForegroundAgentEntryis back toagent/shellForegroundplus routing flags, andpaneForegroundAgentObservationByPaneKeynow holds{ observedAt, ptyId }.setPaneForegroundAgentgains anobservationargument;resolveFreshPaneForegroundAgenttakes the entry and observation separately. - Extended every lifecycle path — the retired-tab sweep,
transferAgentPaneAuthoritymove, worktree purge, and tab-prefix clear now carry the observation map alongside the identity map. - Threaded the map through projections — the worktree activity summary (now cache-keyed on the observation map with reference-equality checks), sidebar rows, and the status dot all pass the observation map so fresh evidence is fenced by the pane-bound PTY.
- Synced the observation map —
paneForegroundAgentObservationByPaneKeyis added to the web-session sync pick.
ℹ️ Observation map now crosses the web-session boundary
Adding paneForegroundAgentObservationByPaneKey to WebSessionTabsSyncState means mirrored sessions will resolve process-derived rows from the host's synced observedAt timestamps against the mirror's local Date.now(). This is consistent with how agentStatusByPaneKey freshness already behaves on mirrors, and is a behavioral widening not called out in the PR description — worth a quick confirm that it's intended if the mirror can ever run on a different machine clock.
ℹ️ Open thread blocks approval
The prior review's note that selectTerminalLayoutsForWorktree in worktree-card-status-inputs.ts duplicates the existing selector in worktree-agent-row-selectors.ts is still unaddressed. It's a minor "prefer importing the existing selector" nit and not a correctness issue — but it remains open on the PR, which is the only thing keeping this review from approving the otherwise-clean delta.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
Closing — verified not to fix any of the three cases it was written forAdversarial validation ran real codex panes against both this branch and
Why the premise was wrongThe motivating case turned out not to be a suppression problem at all. A real end-to-end reproduction (isolated instance, real codex pane, So this is "never updated because no hook arrived", not "latched against arriving events." Bounding a suppression cannot help when nothing is being suppressed. The real gap: answering an agent question emits no hook, and the existing answer-inference fallback is hard-gated to Claude ( What was genuinely good here, and should be re-proposed on its own meritsTwo pieces are real improvements that simply address a different situation, and shouldn't be lost:
Also worth carrying forward: the enumerable observation map that replaced an earlier non-enumerable-metadata workaround, with sweep/purge wiring — that part was done properly. Closing so this doesn't read as "agent status is fixed" when the three reported failures are untouched. A replacement targeting the actual mechanism, covering Claude as well as codex, is being planned. |

What this fixes, in plain English
Orca's sidebar tells you what each agent is doing. It learns that from "hooks" — little messages the
agent fires as it works ("I started", "I'm running a tool", "I'm done").
The problem: the sidebar was showing the last message it accepted, not what the agent is
actually doing right now. If the right message never arrived, the dot just froze — and it kept
looking confident while being wrong. Three ways that went wrong in the wild:
waiting on you — for 18 minutes, while the agent had been working for over an hour.
The fix does two things. First, once an agent resumes after a question or an interruption, its
progress is allowed through again instead of being suppressed forever. Second, the sidebar now
double-checks against the actual running process: if a row says
donebut the process is plainlyworking, the live evidence wins. Completion history is still kept when there's nothing newer to
replace it with.
Net effect: the dot follows the agent instead of getting stuck on the last thing it heard.
Before / after
Still not fixed by this PR: an agent the process monitor never samples (hidden or remote panes)
can still show no row at all. That needs a cross-host process inventory and is deliberately out of
scope — see "Evidence directions", direction 4.
Mechanism
Agent status remains a hook-derived record. This change adds a bounded, PTY-bound process observation path in the renderer: process identity and observation freshness are stored in separate keyed maps, so the long-standing pane identity record remains enumerable and serializable while observations expire after 30 seconds or a PTY rebind. Fresh title/process evidence supersedes stale terminal outcomes, while terminal history remains when no newer evidence exists. The inherited same-prompt interrupted/done suppression remains bounded to the existing 15-second late-work window so resumed tool progress can publish
working.Evidence directions
request_user_input/interrupt is admitted after the bounded late-work window.idle, and stale process evidence expires after 30 seconds.done/interruptedrow for that pane; terminal completion history is retained otherwise.Renderer decay decision
The exclusions at
worktree-agent-rows.ts:237andworktree-agent-freshness-selector.ts:24remain intentional. They apply to retained completion history and the live-state freshness clock; completion rows are replaced only by fresh same-pane title/process evidence, while adding terminal outcomes to the live freshness signature would create rerenders without changing retained-history semantics.The status-dot path receives full per-tab layout snapshots and live PTY IDs, applying the same pane-bound PTY rebind fence as sidebar rows. Observations are moved and cleared with pane identity, including tab/worktree teardown, and are carried in an explicit store map rather than hidden properties that object spread or JSON serialization would discard.
Verification
pnpm tc:node,pnpm tc:web, changed-filenpx oxlint, and changed-filenpx oxfmt --checkpass locally.