Skip to content

fix(agent-status): reconcile stale pane status - #17619

Closed
brennanb2025 wants to merge 8 commits into
mainfrom
brennanb2025/sta5679-status-latch
Closed

brennanb2025 wants to merge 8 commits into
mainfrom
brennanb2025/sta5679-status-latch

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Aug 31, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 8 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​272 $\color{#cf222e}{\Huge{\mathbf{−}}}$​21 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​251
Prod 22 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​717 $\color{#cf222e}{\Huge{\mathbf{−}}}$​159 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​558

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:

  • You answered an agent's question, it went back to work, and the sidebar still said it was
    waiting on you — for 18 minutes, while the agent had been working for over an hour.
  • An agent finished and sat idle, and the sidebar said it was still working — for 73 minutes.
  • An agent was visibly working, and the sidebar said it was done.

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 done but the process is plainly
working, 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

You do this Before After
Agent asks a question, you answer, it keeps working Sidebar stays "waiting" indefinitely — until you start a brand-new turn Returns to "working" once progress resumes
Agent finishes and goes idle Can stay stuck on "working" (seen: 73 min) Settles to the correct state
Agent is working, but an earlier turn ended Can show "done" while it's visibly working Live process evidence replaces the stale row
Agent genuinely finished Shows "done" Unchanged — completion history is kept

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

  • 1 (waiting while working): fixed. Same-prompt tool progress after request_user_input/interrupt is admitted after the bounded late-work window.
  • 2 (working while idle): fixed in the renderer. Existing freshness decay remains in place; process-only rows are identity-only idle, and stale process evidence expires after 30 seconds.
  • 3 (done while working): fixed when fresh pane evidence is available. A fresh title or PTY process observation replaces a stale done/interrupted row for that pane; terminal completion history is retained otherwise.
  • 4 (live process with no row): partial only. A row is synthesized when a pane has a fresh local PTY process observation, even with no hook/title. Agents never sampled by the existing process monitor (including unsampled hidden/remote panes) can still be rowless; a complete fix needs a separate cross-host process inventory and cadence design, intentionally out of scope.

Renderer decay decision

The exclusions at worktree-agent-rows.ts:237 and worktree-agent-freshness-selector.ts:24 remain 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

  • Failing-first: reversing the inherited suppression bound made the Claude and Codex resurrection tests fail; restoring it made them pass. Disabling the process-row, stale-terminal-precedence, and status-dot PTY-fence paths made their focused tests fail, then pass with the change.
  • Regression follow-up: the CI foreground-agent failures were coupled to this PR. The widened identity shape was removed in favor of the separate observation map, and the affiliate-list sidebar fixture now passes with the selector's missing optional maps handled safely.
  • Focused status/process suites pass, including pane-foreground-agent routing, command cleanup, sampling, completion side effects, inventory, pane identity, sidebar/title rows, affiliate-list mode, and worktree status.
  • pnpm tc:node, pnpm tc:web, changed-file npx oxlint, and changed-file npx oxfmt --check pass locally.
  • The prior CI run had a pre-existing static-analysis max-lines failure and environment failures in unrelated Windows Cursor and SSH watcher tests; the new HEAD check is the source of truth and must complete before merge.

@greptile-apps

greptile-apps Bot commented Aug 31, 2026 •

Copy link
Copy Markdown

Greptile Summary

The PR reconciles stale pane-level agent status by combining hook state with bounded, PTY-bound process and title observations.

  • Stores process identity and freshness in separate pane-keyed maps.
  • Expires process observations after 30 seconds and fences them across PTY rebinds.
  • Allows fresh pane evidence to replace stale terminal outcomes while retaining completion history otherwise.
  • Adds hook resurrection handling, lifecycle cleanup, status-dot integration, and focused regression coverage.

Confidence Score: 5/5

The PR appears safe to merge because no blocking failure remains in the eligible follow-up review scope.

No blocking failure remains.

Important Files Changed

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
Loading

Reviews (7): Last reviewed commit: "fix(agent-status): consolidate title age..." | Re-trigger Greptile

@coderabbitai

coderabbitai Bot commented Aug 31, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It 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 reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

The 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 ed5c4

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)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 26.83% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 41 functions across 31 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ⚠️ Warning 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, vi… Add the required template sections and information: provide a linked issue after Fixes #, add before-and-after visual attachments or write N/A with a reason, complete the Testing checklist with platforms tested, add AI Disclosure, Revie…
✅ Passed checks (3 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly identifies the main change: reconciling stale agent status in the agent-status area.
Full details: Description check

Explanation

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 Fixes #, add before-and-after visual attachments or write N/A with a reason, complete the Testing checklist with platforms tested, add AI Disclosure, Review, Agent skill upstream boundary, Notes, and Checklist entries, and confirm the required validation commands.

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

✅ 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 — isToolProgressWorkingAfterInterrupt in src/main/agent-hooks/server.ts now additionally requires Date.now() - previous.receivedAt <= INTERRUPTED_DONE_LATE_WORKING_SUPPRESSION_MS, so a same-prompt Claude/Codex tool-progress working event arriving after the window restores working instead 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 staying done/interrupted.
  • Codex regression test — a new HTTP-path test covers the captured request_user_input wait → answer → inferred interrupt → later same-prompt PreToolUse sequence and asserts the row returns to working.

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.

Pullfrog  | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

@brennanb2025 brennanb2025 changed the title fix(agent-status): bound interrupted tool-progress suppression fix(agent-status): reconcile stale pane status Aug 31, 2026

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

✅ 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 — paneForegroundAgentByPaneKey entries now carry observedAt/ptyId, refreshed on each coordinator inspection (5s quantum) and bounded by a 30s TTL through resolveFreshPaneForegroundAgent.
  • 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 — appendProcessDerivedAgentRows synthesizes idle rows for fresh process observations with no hook/title, and resolveTitleDerivedAgentType now accepts Claude's neutral spinner when a process observation names it.
  • Stale completion replacement — stale done/interrupted rows 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.

Pullfrog  | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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

📥 Commits

Reviewing files that changed from the base of the PR and between 92470aa and 27702f1.

📒 Files selected for processing (17)
  • src/renderer/src/components/sidebar/use-worktree-activity-status.ts
  • src/renderer/src/components/sidebar/use-worktree-activity-statuses.ts
  • src/renderer/src/components/sidebar/useWorktreeAgentRows.test.ts
  • src/renderer/src/components/sidebar/useWorktreeAgentRows.ts
  • src/renderer/src/components/sidebar/worktree-agent-activity-summary.ts
  • src/renderer/src/components/sidebar/worktree-agent-process-evidence.ts
  • src/renderer/src/components/sidebar/worktree-agent-rows.ts
  • src/renderer/src/components/sidebar/worktree-title-agent-type.ts
  • src/renderer/src/components/sidebar/worktree-title-derived-agent-rows.test.ts
  • src/renderer/src/components/sidebar/worktree-title-derived-agent-rows.ts
  • src/renderer/src/components/terminal-pane/agent-completion-coordinator-types.ts
  • src/renderer/src/components/terminal-pane/agent-completion-process-monitor.ts
  • src/renderer/src/components/terminal-pane/pty-connection/pane-agent-identity.ts
  • src/renderer/src/components/terminal-pane/pty-connection/sleeping-record-access.ts
  • src/renderer/src/components/terminal-pane/pty-connection/terminal-keydown-fit.ts
  • src/renderer/src/lib/worktree-status.ts
  • src/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.

Comment on lines +83 to +86
const paneForegroundAgentByPaneKey = useAppStore((s) =>
active
? selectWorktreeAgentActivitySummary(s, worktreeId).paneForegroundAgentByPaneKey
: EMPTY_PANE_FOREGROUND_AGENTS

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🎯 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/src

Repository: 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.ts

Repository: 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)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🎯 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"
done

Repository: 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/shared

Repository: 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 -240

Repository: 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.ts

Repository: 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()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🎯 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/src

Repository: 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' || true

Repository: 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/sidebar

Repository: 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/components

Repository: 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 }

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🎯 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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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

📥 Commits

Reviewing files that changed from the base of the PR and between 27702f1 and 3815253.

📒 Files selected for processing (6)
  • src/renderer/src/components/terminal-pane/pty-connection/pane-agent-identity.ts
  • src/renderer/src/components/terminal-pane/pty-connection/sleeping-record-access.ts
  • src/renderer/src/components/terminal-pane/pty-connection/terminal-keydown-fit.ts
  • src/renderer/src/store/slices/pane-foreground-agent.test.ts
  • src/renderer/src/store/slices/pane-foreground-agent.ts
  • src/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)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🎯 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/src

Repository: 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.ts

Repository: 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/src

Repository: 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.md

Repository: 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.ts

Repository: 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.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

✅ 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 — createPaneForegroundAgentEntry hides observedAt/ptyId behind Object.defineProperties({ enumerable: false }), so Object.keys, spreads, JSON, and structuredClone see only the long-standing agent/shellForeground/routing shape, while resolveFreshPaneForegroundAgent still 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.

Pullfrog  | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ℹ️ 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 — useWorktreeActivityStatus and useWorktreeActivityStatuses now select selectTerminalLayoutsForWorktree and selectLivePtyIdsForWorktree instead of roots-only, and pass both into resolveWorktreeStatus, so freshProcessAgentForLeaf resolves paneBoundPtyId from ptyIdsByLeafId.
  • Rebind regression test — a new worktree-status.test.ts case pins that process evidence bound to pty-old is rejected when the layout binds pty-new, yielding active rather than working.

ℹ️ 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.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

return out
}

export function selectTerminalLayoutsForWorktree(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 win

Mark title-derived panes as seen.

Lines 232-234 restore titleSeenPaneKeys, but they do not add the pane keys emitted by titleRows. If a stale live completion is replaced by a title-derived row and retained has 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

📥 Commits

Reviewing files that changed from the base of the PR and between 4a56dc8 and ed5c485.

📒 Files selected for processing (20)
  • src/renderer/src/components/sidebar/use-worktree-activity-status.ts
  • src/renderer/src/components/sidebar/use-worktree-activity-statuses.ts
  • src/renderer/src/components/sidebar/useWorktreeAgentRows.ts
  • src/renderer/src/components/sidebar/worktree-agent-activity-summary-equality.ts
  • src/renderer/src/components/sidebar/worktree-agent-activity-summary.ts
  • src/renderer/src/components/sidebar/worktree-agent-process-evidence.ts
  • src/renderer/src/components/sidebar/worktree-agent-rows.ts
  • src/renderer/src/components/sidebar/worktree-agent-state-flags.ts
  • src/renderer/src/components/sidebar/worktree-title-derived-agent-rows.test.ts
  • src/renderer/src/components/sidebar/worktree-title-derived-agent-rows.ts
  • src/renderer/src/components/terminal-pane/pty-connection-foreground-agent-sampling.test.ts
  • src/renderer/src/components/terminal-pane/pty-connection/pane-agent-identity.ts
  • src/renderer/src/lib/worktree-status.test.ts
  • src/renderer/src/lib/worktree-status.ts
  • src/renderer/src/runtime/web-session-tabs-sync.ts
  • src/renderer/src/store/slices/agent-status.ts
  • src/renderer/src/store/slices/pane-foreground-agent.test.ts
  • src/renderer/src/store/slices/pane-foreground-agent.ts
  • src/renderer/src/store/slices/retired-terminal-tab-state-sweep.ts
  • src/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.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ℹ️ The ed5c485 refactor 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 — PaneForegroundAgentEntry is back to agent/shellForeground plus routing flags, and paneForegroundAgentObservationByPaneKey now holds { observedAt, ptyId }. setPaneForegroundAgent gains an observation argument; resolveFreshPaneForegroundAgent takes the entry and observation separately.
  • Extended every lifecycle path — the retired-tab sweep, transferAgentPaneAuthority move, 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 — paneForegroundAgentObservationByPaneKey is 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.

Pullfrog  | Fix it ➔ | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Closing — verified not to fix any of the three cases it was written for

Adversarial validation ran real codex panes against both this branch and main, diffing row transitions from each instance's own last-status.json. Result: this PR changes nothing for any of the three captured failures.

Case Captured row Effect of this PR
A — waiting while working 1h+ waiting, PreToolUse/request_user_input, 18 min None. Stale-row replacement fires only for !isFresh && state === 'done'; this row is waiting and fresh (18 min < 30 min AGENT_STATUS_STALE_AFTER_MS). The worktree dot cannot change either — resolveWorktreeStatus returns 'permission' unconditionally when hasPermission is set, before any heuristic.
B — working while idle working, UserPromptSubmit, 73 min None. Reproduced live on this branch by killing codex mid-turn (real crash path, no Stop): the row latches working and nothing here clears it.
C — done while visibly working done, Stop, 92 s None for this case. The server bound requires interrupted === true; case C was a plain sibling Stop. The renderer replacement requires a stale done row; this one was fresh.

Why the premise was wrong

The motivating case turned out not to be a suppression problem at all. A real end-to-end reproduction (isolated instance, real codex pane, --enable default_mode_request_user_input, question answered in the TUI) showed the row leaving waiting as soon as the next real hook arrived, and every later event being accepted:

16:37:01  PreToolUse request_user_input  -> waiting
16:37:42  answer submitted in the TUI    -> still waiting   (no hook emitted)
16:37:51  PreToolUse Bash                -> working         (accepted)
16:39:29  Stop                           -> done

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 (agent-question-answered-inference.ts:31-36, server.ts:1012-1019, server.ts:1075-1097) with no equivalent for other providers.

What was genuinely good here, and should be re-proposed on its own merits

Two pieces are real improvements that simply address a different situation, and shouldn't be lost:

  1. Stale-done replacement — a >30-min-old done row for a pane with fresh title/process evidence is replaced. Pinned by its own test.
  2. Title attribution via process evidence — a bare spinner title (e.g. ⠙ pacu) can be attributed to an agent through foreground-process identity instead of requiring a provider token in the title or tab.launchAgent.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant