Repository navigation
Conversation
|
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:
📝 WalkthroughWalkthroughAdds TTL-based foreground-agent evidence tracking for keep-awake eligibility, including per-PTY reporting, renewal, stale-cap expiry, and timer scheduling. Runtime PTY scans and inspections now emit or refresh PTY-bound evidence, while stopped PTYs clear it. Renderer state records timestamps and PTY identity, filters stale or mismatched evidence, scopes it to worktrees, and uses it to attribute title-derived agent activity. Expiry-driven hooks recompute worktree statuses and agent rows when evidence becomes stale. 🚥 Pre-merge checks | ✅ 1 | ❌ 4❌ Failed checks (4 warnings)
✅ Passed checks (1 passed)
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 |
|
Taking a look! |
15aa992 to
607f130
Compare
|
Thanks for the thoughtful fix. I rebased the branch onto current |
607f130 to
9d0b62d
Compare
|
@brennanb2025 Rebased onto current `origin/main` and force-pushed (`bbingz/unknown-busy-and-wrapper-visibility` → `$(git rev-parse HEAD)`). Conflict resolution in title-derived agent rows:
|
|
@brennanb2025 Correction: rebased head is Conflict resolution summary stands: main's braille → launchAgent fallback kept; PR process-identity attribution re-applied; your inspection-reuse commit preserved. |
|
@brennanb2025 Rebased onto current Ready for re-review / merge. |
9d0b62d to
7bc527a
Compare
Restack + review guide (community, awaiting maintainer)Rebased onto latest Partial supersession noteMain already treats unrecognized non-shell FG as busy (hook-status gate). One commit in this series still carries that theme — reviewers: prefer keep-awake + sidebar attribution; busy predicate may be redundant with main and can be dropped in a follow-up trim if desired. Unique residual (primary value)
StackTests (local)
Community author cannot merge. |
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: e74ac69a-3324-4df2-9f16-5caae87e4d7e
📥 Commits
Reviewing files that changed from the base of the PR and between 9d0b62d3c5234023a71c59d3b1540715852d7a04 and 7bc527a46749e3bc3a467ef64ce3d5f6248ba302.
📒 Files selected for processing (8)
src/main/agent-awake-foreground-evidence.tssrc/main/agent-awake-service.test.tssrc/main/agent-awake-service.tssrc/main/index.tssrc/main/ipc/pty.test.tssrc/main/ipc/pty.tssrc/main/runtime/orca-runtime.test.tssrc/main/runtime/orca-runtime.ts
🚧 Files skipped from review as they are similar to previous changes (6)
- src/main/index.ts
- src/main/agent-awake-service.test.ts
- src/main/runtime/orca-runtime.ts
- src/main/runtime/orca-runtime.test.ts
- src/main/agent-awake-service.ts
- src/main/agent-awake-foreground-evidence.ts
7bc527a to
9c8d7c8
Compare
9c8d7c8 to
2d6164a
Compare
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: 1a434da9-9611-48c3-acdf-cf2a460ac617
📒 Files selected for processing (8)
src/main/agent-awake-foreground-evidence.tssrc/main/agent-awake-service.test.tssrc/main/agent-awake-service.tssrc/main/index.tssrc/main/ipc/pty.test.tssrc/main/ipc/pty.tssrc/main/runtime/orca-runtime.test.tssrc/main/runtime/orca-runtime.ts
🚧 Files skipped from review as they are similar to previous changes (7)
- src/main/ipc/pty.ts
- src/main/runtime/orca-runtime.ts
- src/main/agent-awake-foreground-evidence.ts
- src/main/index.ts
- src/main/runtime/orca-runtime.test.ts
- src/main/agent-awake-service.ts
- src/main/agent-awake-service.test.ts
2d6164a to
0a4d8ee
Compare
ab6c43b to
beacf35
Compare
Greptile SummaryThis PR adds two capabilities: (1) keep-awake evidence sourced from foreground-process scans (with TTL + revalidation) for agents that emit no hook statuses, and (2) sidebar/worktree ring attribution from the same process-identity evidence for wrapper-launched agents (e.g., Claude without a stable title). It also tightens
Confidence Score: 5/5
|
| Filename | Overview |
|---|---|
| src/main/agent-awake-foreground-evidence.ts | New file: ForegroundAgentEvidenceLedger with quantum-guarded report, TTL-based pruneAndCount with revalidation, and nextExpiry. Logic is correct. The null-agent path bypasses the quantum guard (intentional: clear immediately), but this means any unrecognized subprocess seen during a scan will drop evidence without a debounce window. |
| src/main/agent-awake-service.ts | Adds foreground-agent evidence support: reportForegroundAgentEvidence delegates to the new ledger, and refresh sums eligibleForegroundAgentCount alongside existing hook-based running count. scheduleStaleTimer now also consults ledger nextExpiry. Looks correct. |
| src/main/ipc/pty.ts | pty:inspect and pty:confirmForeground IPC handlers now call runtime.recordPtyForegroundProcessObservation with incarnation-guarded results. Correctly skips reporting if the PTY was respawned between capture and resolution. Any unrecognized foreground process (subprocess) will fire a null observation, immediately dropping keep-awake evidence. |
| src/main/runtime/orca-runtime.ts | Adds recordPtyForegroundProcessObservation (now public), hasWakeEligibleForegroundAgent, and onPtyForegroundAgentEvidence callback. confirmPtyForegroundProcessIsShell changed from recognizeAgentProcess === null to isShellProcess — correctly narrows the "agent exited" proof so wrapper/fork agents are no longer treated as shells. |
| src/renderer/src/store/slices/pane-foreground-agent.ts | Adds ptyId field to entries and refreshPaneForegroundAgentObservation; resolveFreshPaneForegroundAgent uses pane-bound PTY for precise attribution, falling back to live-tab PTYs. The ptyId backfill branch (line 117) was flagged in a prior review thread for not doing a full identity rebind on first ptyId assignment. |
| src/renderer/src/components/sidebar/worktree-agent-activity-summary.ts | Adds paneForegroundAgentByPaneKey to WorktreeAgentActivitySummary and the per-worktree narrowing loop. paneForegroundAgentsEqual uses reference identity for entries, which correctly invalidates on observedAt bumps. Module-level agentActivityCache will invalidate on every quantum bump, but the per-worktree reuse optimization keeps render amplification bounded. |
| src/renderer/src/components/sidebar/worktree-title-derived-agent-rows.ts | Adds freshProcessAgentForLeaf helper and threads paneForegroundAgentByPaneKey through buildTitleDerivedAgentRows for wrapper identity; resolveTitleDerivedAgentType now falls back to process identity for title-less Claude rows. Logic is clean. |
| src/renderer/src/lib/worktree-status.ts | tabHasStatus now resolves process identity per-leaf via freshProcessAgentForLeaf for more precise Claude attribution. Uses options.terminalLayoutsByTabId for pane-bound PTY checking, but use-worktree-activity-status.ts only passes terminalLayoutRootsByTabId — meaning the pane-bound PTY check is unavailable from that call site and falls through to the tab-level liveness fallback. |
| src/renderer/src/components/terminal-pane/agent-completion-coordinator.ts | Adds onForegroundAgentInspected callback called on every successful recognized-agent inspection; passes the inspected PTY ID to prevent cross-pane attribution. No logic changes to completion/attention flow. |
| src/renderer/src/components/terminal-pane/pty-connection.ts | Three locations now stamp ptyId on setPaneForegroundAgent entries; onForegroundAgentInspected is wired to refreshPaneForegroundAgentObservation with PTY-identity guard. isForegroundTrackingAllowed check prevents SSH/WSL evidence from binding to local panes. |
Sequence Diagram
sequenceDiagram
participant Coord as Renderer Coordinator
participant IPC as pty.ts IPC Handler
participant Runtime as OrcaRuntime
participant Ledger as ForegroundAgentEvidenceLedger
participant Awake as AgentAwakeService
participant Store as Renderer Store
Coord->>IPC: pty:inspect(ptyId)
IPC->>Runtime: getForegroundProcess(ptyId)
Runtime-->>IPC: ""claude" | "git" | null"
IPC->>Runtime: recordPtyForegroundProcessObservation(ptyId, process)
Runtime->>Awake: "onPtyForegroundAgentEvidence(ptyId, agent|null)"
Awake->>Ledger: "report(ptyId, agent|null)"
Note over Ledger: null → delete immediately<br/>agent → quantum-guarded upsert
Ledger-->>Awake: changed?
Awake->>Awake: refresh() → pruneAndCount() → startBlocker/stop
IPC-->>Coord: RuntimeTerminalProcessInspection
alt recognized agent
Coord->>Store: onForegroundAgentInspected(process, ptyId)
Store->>Store: refreshPaneForegroundAgentObservation(paneKey, agent, ptyId)
end
Note over Ledger,Awake: TTL expiry (5 min)
Ledger->>Runtime: revalidate(ptyId) → hasWakeEligibleForegroundAgent
Runtime-->>Ledger: "pty.connected && foregroundAgent !== null"
alt still eligible
Ledger->>Ledger: "evidence.observedAt = now"
else expired
Ledger->>Ledger: delete entry
Awake->>Awake: stopBlocker
end
Reviews (2): Last reviewed commit: "fix(agents): stabilize foreground eviden..." | Re-trigger Greptile
…-status gate A confirmed foreground that is neither a shell nor a recognized agent (wrapper/fork agent binaries) previously counted as "shell only", which suppressed fresh hook state and reported the pane idle. Only a confirmed real shell (or an unavailable confirmation, matching the fail-closed catch path) may now suppress explicit hook status.
…L + revalidation Hook 'working' statuses were the only wake evidence, so wrapper-launched or manually-run recognized agents (resolved by the existing foreground scans) let the machine sleep mid-run. The runtime now reports each completed scan's recognized-agent-or-null result; AgentAwakeService holds wake eligibility per PTY while that evidence is fresh (5 min TTL), renews it at expiry via a cache-only revalidation callback (never a new scan, 2h hard cap), and drops it on a null report or PTY stop. Arbitrary non-shell processes never grant wake. No new scans or cadences are added.
…rocess identity Wrapper-launched claude (a shell function exec'ing the real binary) emits Claude activity titles without the literal 'claude' token, so the row builder and worktree ring rejected the pane as unattributable — invisible while working. The paneForegroundAgent slice already resolves the recognized foreground process; surface it as identity attribution: - Slice entries now carry observedAt (stamped centrally) and the publishing PTY; resolveFreshPaneForegroundAgent gates consumers on a 30s TTL plus pane/tab PTY liveness so stale evidence after agent exit cannot fake a working state. The completion coordinator's existing inspections re-arm the observation (no new scans, no new cadence). - resolveTitleDerivedAgentType/resolveAgentTypeFromTerminalTitle accept the process agent so a token-less Claude title yields a Claude row and an attributable working ring. State still comes from title activity or hooks; process identity alone never invents 'working'. Hook rows keep precedence. - worktree-agent-activity-summary narrows the slice per worktree with stable references; card status, agent rows, and section activity consume it.
…to PTY, expire attribution on wall clock Review fixes for the busy/visibility PR: - agent-awake-foreground-evidence: enforce the 2h reportedAt cap unconditionally in pruneAndCount and align boundary comparisons with nextExpiry, so a stale timer firing at the cap (or exactly at the TTL) can no longer keep the power-save blocker held forever with no timer rescheduled. New test drives revalidation-renewed evidence to the cap and asserts the blocker stops with no timer left. - onForegroundAgentInspected now carries the PTY the inspection ran against; pty-connection only accepts it while the pane still owns that PTY, and refreshPaneForegroundAgentObservation stamps it on created entries and rebinds (identity-only) evidence held for a previous PTY instead of keeping it fresh across a respawn. - new usePaneForegroundAgentEvidenceExpiryTick schedules a one-shot re-render at the earliest evidence expiry for the worktree ring and agent rows, so a past-TTL working ring/row drops without unrelated store churn. - restore the Claude-glyph regression fixture alongside the braille variant (it.each) in worktree-title-derived-agent-rows.test. - update terminal-pane-detach-agent-identity.test for the central observedAt stamping introduced by this branch (was failing).
Known launch agents skip runtime foreground probes, so feed existing renderer inspections into runtime identity and wake evidence. Keep the review-driven rationale comments concise.
7781050 to
60457b2
Compare
UNION rebase kept PR's ptyId stamping on setPaneForegroundAgent publishes; two main-era expectations lagged. Align them with the PR field and nearby tests. Cosmetic indent fix on the revoke path.
Introduce ForegroundProcessResolution { engine, rawProcessName, isShell }
so an unrecognized live foreground is no longer collapsed to a bare shell.
The deployed-relay wire contract stays string|null; consumers rebuild the
structure locally via resolveForegroundProcess (degrade old-relay strings).
Thread it only along the renderer path: the pane-foreground-agent tracker
publishes rawProcessName on the command-path entry for a live, non-shell,
unrecognized foreground (recognized agents publish their engine; shells need
no raw name). The store slice gains an optional rawProcessName and a new
resolveFreshPaneForegroundRawProcess that reuses stablyai#9415's TTL/PTY freshness
gate (extracted into one shared helper — existing resolveFreshPaneForegroundAgent
behavior unchanged).
|
Closing as part of fork PR backlog cleanup. This branch is long-conflicted (DIRTY) against current |
Part of #9414
Keep-awake and sidebar attribution now follow foreground-process evidence, so the machine is less likely to sleep and a tab is less likely to read idle while a real agent is still the process in front — including wrapper-launched agents with no recognizable title.
Status (2026-08-06 restack note)
An earlier note here said the busy half was fully superseded by main. Re-checked against main (79896cb): only the first half is.
src/main/runtime/orca-runtime.ts:16630returns false for any non-shell foreground process, so a plain unrecognized foreground already counts as busy.src/main/runtime/orca-runtime.ts:16647returnsrecognizeAgentProcess(confirmedProcess) === null, so an unrecognized-but-alive process is read as "no agent" and the terminal is reported not running. This PR narrows that toconfirmedProcess === null || isShellProcess(confirmedProcess): only a confirmed shell proves the agent exited.The branch carries brennanb2025's
fix(awake): reuse existing foreground inspections(11b6ed4), preserved through the latest rebase.Problem
Solution
observedAt/ TTL), reusing completed provider inspections rather than adding scansStack
Test plan
Focused suites re-run post-rebase at 5f08623 (2026-08-06): agent-awake-service, pane-foreground-agent, worktree-title-derived-agent-rows, ipc/pty, orca-runtime — 1586 passed / 1 skipped.
ELI5
Keep-awake and sidebar busy state now lean on real foreground-process evidence. Orca is less likely to sleep the machine or mislabel a tab while an agent it cannot name by title is still the process in front.