Repository navigation
fix(sidebar): show agent activity before workspace activation - #20398
Conversation
Reuse parked terminal watchers for eligible live tabs in never-mounted workspaces, with initial title catch-up and capability-driven admission. Preserve existing watcher cleanup and avoid allocating watcher sets for empty workspaces. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
📝 WalkthroughWalkthroughThe watcher now parks eligible live terminals in unmounted workspaces when no activity terminal portal exists. It restores title state on start and re-runs when provider capability, paired runtime parking environments, or SSH parking settings change. Tests now control host coverage results, support watcher rerendering, and cover supported, unsupported, capability-transition, remote-setting, and activity-portal cases. Priority: ➖ Normal Merge Risk: 🔵 Low · up to Some force-parked terminals that must keep their mounted panes can be incorrectly admitted to background watching before workspace activation. Add the existing exemption check before merging. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
ℹ️ No critical issues — one coverage suggestion inline.
Reviewed changes
Reviewed the two-file change at 90fff0c (head) against main (403b62a).
- Never-mounted watcher admission —
use-terminal-watcher-effects.tsnow seedsparkedTabIds/restoreTitleOnStartTabIdsfor coverable live tabs in workspaces absent frommountedWorktreeIdsRef, so a parked watcher consumes host title facts before the workspace is ever activated. - Late capability re-admission —
terminalProviderSnapshotCapabilityRevisionjoins the effect deps, so a tab whose PTY was not coverable on the first pass is admitted once the host answers. - Test harness rework —
renderWatcherEffectsgains overrides + a rerender handle andcanWatcherCoverParkedTerminalTabbecomes mockable; new cases cover git/folder admission, refusal, delayed admission, and activity-portal ownership.
Verified that the new branch is mutually exclusive with the mounted-parking branch and that no double consumer is possible: every pane render site filters on mountedWorktreeIdsRef.current (TerminalLegacyTerminalPanes.tsx:41, TerminalSplitWorkspaceSurfaces.tsx:44), and the effect's early continue skips exactly the workspaces whose panes render. On activation the watcher is disposed by the pane-side useParkedTerminalWatcherSynchronization pass, which supplies the entry the host pass drops.
ℹ️ Legacy byte-parser mode still cannot recover a never-mounted idle agent's title
The fix's title recovery rides entirely on restoreTitleOnRegister, which is only honored when main owns side-effect parsing for the PTY. With the terminalMainSideEffectAuthority kill switch off, the watcher runs as a byte parser with no initial title and only derives one from future output — so an already-idle agent in a never-activated workspace still shows nothing until it emits bytes. Worth stating whether that path is in scope or intentionally left to the fact-mode default.
Technical details
# Title restore is fact-mode only
## Affected sites
- `src/renderer/src/components/terminal-pane/parked-terminal-byte-watcher.ts:236-251` — `restoreTitleOnRegister` is only passed when `factSideEffectAuthority` is true; the byte-parser branch builds `createPtyOutputProcessor` without `initialTitle` for a never-mounted tab (`:136` reads an empty title slot).
- `src/renderer/src/components/terminal-pane/terminal-side-effect-facts-handler.ts:46-64` — `isMainTerminalSideEffectAuthorityForPty` returns false only when the persisted `terminalMainSideEffectAuthority` flag is `false` (default on), so this is limited to kill-switch users.
## Required outcome
- A one-line confirmation that byte-parser-mode never-activated workspaces are accepted to show no activity until the agent emits output, or a note on the follow-up that covers them.
## Open questions for the human
- Is the `terminalMainSideEffectAuthority=false` path expected to get the same sidebar fix, or is fact mode the only supported target?
openrouter/deepseek/deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏
| expect(unmountedSets.size).toBe(1) | ||
| expect([...unmountedSets][0]?.size).toBe(0) | ||
| }) | ||
| it.each(['repo-1::/never-visited', 'folder:never-visited'])( |
There was a problem hiding this comment.
These new cases assert the host's syncEntriesByWorktreeId payload, but syncParkedTerminalTabWatchersForWorkspaces is mocked out, so nothing exercises the exit path this change depends on: when a never-mounted workspace later mounts/activates, the watcher it just started must be disposed. Could you add a case that rerenders with the workspace present in mountedWorktreeIdsRef.current (and no layout) and asserts its parkedTabIds/restoreTitleOnStartTabIds go empty? The watcher-to-mounted-pane handoff is currently covered only by the manual validation noted in the PR body.
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
Incrementally reviewed the new commit at 5c10251 against the prior review at 90fff0c.
- Remote coverage dependency wiring —
use-terminal-watcher-effects.tsnow depends onpairedRuntimeParkingEnvironmentIdsandterminalSshParkingEnabled, so a never-mounted workspace's watcher is admitted or dropped as paired-host snapshot capability or the SSH-parking setting changes. Both mirror exactly the store inputscanWatcherCoverParkedTerminalTabreads, and the paired set keeps a stable identity when the capable set is unchanged (paired-runtime-parking-capabilities.ts:41-46). - Regression coverage — a parameterized test toggles each new dependency in both directions and asserts watcher admission/removal, isolating each dependency so either can fail independently.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to GitHub limitations.
⚠️ Outside diff range comments (1)
src/renderer/src/components/use-terminal-watcher-effects.ts (1)
141-141: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick winExclude eviction-exempt tabs from unmounted parking.
An eligible tab in a never-mounted workspace enters
backgroundTabIdseven whenevictionExemptTerminalTabIdscontains its ID. The mounted-workspace path excludes these tabs. This branch then starts a watcher and requests title restoration for a tab that must remain exempt.Proposed fix
(tab) => canWatcherCoverParkedTerminalTab(workspaceId, tab) && + !evictionExemptTerminalTabIds.has(tab.id) && !findActivityTerminalPortal(activityTerminalPortals, {
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: 6800298d-6719-4e88-977b-fe9a39f6332a
📒 Files selected for processing (2)
src/renderer/src/components/terminal-parked-watcher-sync-entries.test.tsxsrc/renderer/src/components/use-terminal-watcher-effects.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 8 remain after this review.

ELI5
An agent started with
orca worktree create --agentcould be working while its sidebar card showed no agent activity until clicked. Its activity now appears while the workspace stays in the background.What Changed
Reuse parked-terminal watchers for eligible live tabs in never-mounted workspaces. Request the initial title snapshot to recover events emitted before registration, and retry admission when local snapshot capability, paired-host capability, or the SSH parking setting changes. Preserve activity-portal ownership and existing watcher cleanup.
Why
The reproduction already had hydrated tabs, PTY bindings, and stable-leaf layouts. The missing input was the live title: neither a mounted pane nor a parked watcher consumed host facts before the first activation. This fixes that missing consumer without introducing a new status store or precedence rule.
The existing pass still scans workspace surfaces; additional coverage costs one watcher and initial snapshot per eligible live PTY, not per saved workspace. Default fact-mode watchers share the existing channel and add no xterm mounts, raw-byte subscriptions, or polling. Legacy byte-parser mode retains its per-PTY output-processing cost. The 423-surface allocation test remains covered.
Linked Issue
Related to #18704 (similar click-to-reveal symptom). This PR proves the local CLI-created Codex/title-consumer case; it does not claim to close that issue's paired OMP attribution case.
Visual Proof
Captured through Playwright CDP in a separate hidden Electron instance. The existing user app was not restarted or stopped.
Before: a real Codex process was running in
status-repro, with no selected workspace. The card showed generic Active but no working glyph or agent row. Clicking made the row appear.After: freshly CLI-created
status-fixed-freshshows working activity whilestatus-reproremains selected. The new-card setting was enabled for this capture; the change does not alter card styling. Completion and watcher-to-mounted-pane handoff were also checked.Testing
All app/test runs used
ORCA_BACKGROUND_LAUNCH=1.pnpm tc: passed, including final rerun.pnpm exec vitest run --config config/vitest.config.ts ....pnpm run check:code-quality:changed: zero new findings.pnpm run check:react-doctor:changed: zero issues; score unavailable.git diff --check: passed.The brief's literal
pnpm exec vitest run src/renderer/src/components/sidebarfailed without the repository config (210 files failed, 91 passed; aliases/environment setup missing). The configured run above passed.Review
A second Astra medium review of the final diff found no concrete issues. The CI casting-rule failure is addressed with fully typed fixtures and a hook input type restricted to its consumed controller fields; no runtime behavior changed. Local typecheck, all 10 focused tests, changed-code quality, React Doctor, and the newer casting rule passed.
Astra medium review found one remote-admission dependency gap, repaired by adding two existing controller values to the effect dependencies. No additional abstractions were needed. Follow-up validation passed typechecking, 301 sidebar files / 2,537 tests, all 10 focused tests, and both changed-code gates. Self-reviewed consumer ownership, snapshot catch-up, cleanup, and allocation scope. Live validation covered macOS Codex working, normal completion, first activation, and terminal close. Folder coverage is automated. Live SSH/WSL/Linux/Windows, mixed-version paired clients, explicit blocked/waiting/interrupted hook states, and large-profile CPU/heap measurements remain unverified. Existing remote capability and exit-verdict gates are reused; no wire shape changes.
Agent skill upstream boundary
Notes
Regression attribution correction: the reporter says this began 1–5 days ago. #11445 is historical background-path context, not an established cause of that recent onset. No regressing PR is identified.
A historical check now reproduces the same missing-row/first-click repair on September 6 commit
bf4e2705046cf9ef9c915929a9646da85717af07, before the reported window and before the September 10–11 mounting/status-store changes. Built and launched that checkpoint in the same worktree with a fresh isolated profile andORCA_BACKGROUND_LAUNCH=1; created an inert real Codex agent via the CLI. Before activation, tabs/PTY bindings existed, runtime-title and hook-status maps were empty, and connected Codex PID 36123 had a working title. Clicking populated the title and rendered the agent row. Returned to the unchanged PR branch afterward.This proves the consumer gap existed in that older source under today's Codex v0.154.0 and installed dependencies. It does not reproduce the reporter's previous full environment or explain what changed for them recently. The fix addresses the demonstrated gap; attribution of the recent onset remains open.
September 6 checkpoint: before activation and after first click
Checklist