Skip to content

fix(sidebar): show agent activity before workspace activation - #20398

Merged
Jinwoo-H merged 3 commits into
mainfrom
sidebar-agent-status-regression
Sep 13, 2026
Merged

Jinwoo-H merged 3 commits into
mainfrom
sidebar-agent-status-regression

Conversation

@Jinwoo-H

@Jinwoo-H Jinwoo-H commented Sep 12, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​167 $\color{#cf222e}{\Huge{\mathbf{−}}}$​36 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​131
Prod 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​57 $\color{#cf222e}{\Huge{\mathbf{−}}}$​3 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​54

ELI5

An agent started with orca worktree create --agent could 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.

Before: never-activated agent workspace

After: freshly CLI-created status-fixed-fresh shows working activity while status-repro remains 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.

After: background agent activity before activation

Testing

  • I manually tested these changes locally
  • Automated tests added/updated

All app/test runs used ORCA_BACKGROUND_LAUNCH=1.

  • pnpm tc: passed, including final rerun.
  • Configured sidebar plus watcher/fact suites: 307 files, 2,633 tests passed with pnpm exec vitest run --config config/vitest.config.ts ....
  • Final focused regression suite: 10 passed, including git/folder workspace admission, delayed local/paired host capability, SSH parking changes, portal ownership, and empty-surface allocation.
  • Mutation: disabling never-mounted admission fails both git/folder cases; removing the capability dependency fails the delayed-admission case. Removing the paired-capability and SSH-setting dependencies also fails both new regression cases. Restored code passes.
  • 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/sidebar failed 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

  • Not applicable: no agent-skill source or fixtures changed.

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 and ORCA_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

September 6 source: missing agent row before activation

Same checkpoint: agent row appears after first click

Checklist

  • This PR is small and focused
  • I explained what changed and why
  • Before/after screenshots attached
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered
  • Full lint/build and remaining CI checks will be covered by CI; local focused tests, typecheck, and changed-code gates passed as detailed above

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
@coderabbitai

coderabbitai Bot commented Sep 12, 2026 •

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

📝 Walkthrough

Walkthrough

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

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)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 5 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 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 and concisely describes the main change: showing agent activity before workspace activation.
Description check ✅ Passed The description is detailed and mostly complete. It covers the problem, changes, rationale, linked issue, visual proof, testing, review findings, known validation limits, and checklist status.
  • 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 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.ts now seeds parkedTabIds / restoreTitleOnStartTabIds for coverable live tabs in workspaces absent from mountedWorktreeIdsRef, so a parked watcher consumes host title facts before the workspace is ever activated.
  • Late capability re-admission — terminalProviderSnapshotCapabilityRevision joins the effect deps, so a tab whose PTY was not coverable on the first pass is admitted once the host answers.
  • Test harness rework — renderWatcherEffects gains overrides + a rerender handle and canWatcherCoverParkedTerminalTab becomes 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?

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using 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'])(

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.

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.

@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

Incrementally reviewed the new commit at 5c10251 against the prior review at 90fff0c.

  • Remote coverage dependency wiring — use-terminal-watcher-effects.ts now depends on pairedRuntimeParkingEnvironmentIds and terminalSshParkingEnabled, 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 inputs canWatcherCoverParkedTerminalTab reads, 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.

Pullfrog  | Fix it ➔ | View workflow run | Using DeepSeek Flash (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.

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 win

Exclude eviction-exempt tabs from unmounted parking.

An eligible tab in a never-mounted workspace enters backgroundTabIds even when evictionExemptTerminalTabIds contains 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

📥 Commits

Reviewing files that changed from the base of the PR and between 5c10251 and 78072ca.

📒 Files selected for processing (2)
  • src/renderer/src/components/terminal-parked-watcher-sync-entries.test.tsx
  • src/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.

@Jinwoo-H
Jinwoo-H merged commit fdf16ff into main Sep 13, 2026
28 checks passed
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