Skip to content

feat(sidebar): main produces per-workspace activity facts, checked against the window in dev and test - #29980

Merged
Jinwoo-H merged 7 commits into
mainfrom
jinwoo/sidebar-activity-facts
Oct 17, 2026
Merged

Jinwoo-H merged 7 commits into
mainfrom
jinwoo/sidebar-activity-facts

Conversation

@Jinwoo-H

@Jinwoo-H Jinwoo-H commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 10 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​507 $\color{#cf222e}{\Huge{\mathbf{−}}}$​1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​506
Prod 18 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​715 $\color{#cf222e}{\Huge{\mathbf{−}}}$​28 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​687

ELI5

The workspace list on the desktop and on the phone should come from one source: Orca's background process ("main"). Today the desktop window works out for itself which workspaces are busy: a terminal is running, a browser tab or chat is open, or an agent is working or waiting. This PR teaches main to work out the same answer. Nothing uses main's answer yet. In dev and test builds, the window checks main's answer against its own and counts the times they disagree, so we can prove the two match before switching anything over.

What Changed

No visible change. Production builds behave exactly as before. The new producer runs, but nothing reads it and the comparison does not run.

  • Main produces per-workspace activity facts (src/main/runtime/sidebar-inputs/). For each workspace main records:

    • whether its terminals are live or unverifiable
    • whether it has a browser tab
    • whether it has a structured chat
    • its strongest live agent state: working, monitoring, or waiting for permission

    Only workspaces with some activity are listed. A revision number increases whenever any fact changes. The same code runs in the desktop app, in orca serve, and in the Node-only orcad server, and it imports no Electron.

  • How main keeps the facts current. It never runs a full pass over every terminal and pane:

    • Terminal, browser and chat facts are re-read for one workspace each time the runtime publishes that workspace's tabs. That publication already exists, and it is already batched to at most one every 50 ms per workspace.
    • Agent state follows the hook server's existing per-row change and freshness notifications. A status ping re-derives only that one pane and does not re-read terminals or tabs.
    • A few runtime events never reach a tab publication, so main also listens to them directly: a terminal exiting, a change in whether a terminal is known to be alive, the terminal inventory sweep, and the window's terminal-graph sync (which is what agent rows are matched to workspaces through).
    • When an agent's status goes stale it drops out, using a single timer.
  • Agent status has one store. Main reads the hook server's store and keeps no copy of its own. The rule that matches an agent row to a workspace moved to src/shared, so the window and main use the same function.

  • Losing contact with an SSH host does not mean the terminal died. If the host only lost contact, the terminal reads unverifiable, even while its record still says connected.

  • Read path. A new RPC method, sidebarInputs.activityFacts, returns the current facts. An older host that does not have the method is simply skipped.

  • A shadow check that later PRs can reuse (src/renderer/src/lib/sidebar-shadow/):

    • defineSidebarShadowDomain({ name, readWindow, readMain, equals }) defines one comparison.
    • installSidebarShadowComparison([...]) runs every defined comparison every 1.5 s, in dev and test builds only.
    • A disagreement is counted only when both sides hold the same differing values across a whole check interval, so the normal delay between the window and main never counts.
    • Disagreements are logged with the workspace id, both values and main's revision, and exposed as window.__sidebarShadow.mismatches() and comparisons().
    • Workspaces on paired servers are left out of this comparison. A later PR covers them.
  • e2e: expectNoSidebarShadowMismatches(page) waits for two fresh comparisons that actually read main's data, then asserts there are no disagreements. Three sidebar specs now call it.

Why

This is the first of the main-side producers in the sidebar plan. Each one runs in shadow mode first, so any disagreement shows up before the window starts depending on main.

Alternatives considered:

  • Re-running the worktree ps activity pass on each change. Rejected: that pass scans every session, terminal and PTY each time.
  • Adding a new listener slot on the hook server. Not needed: the per-row change notifications already fan out to several subscribers, and only reading them leaves replay behavior unchanged.
  • A new IPC channel. Not needed: the window already calls runtime methods through runtime.call.

Linked Issue

Part of the sidebar refactor plan (step 5a). No issue.

Visual Proof

N/A. Nothing visible changes. The comparison is development tooling and does not run in production builds.

Testing

  • I manually tested these changes locally

  • Automated tests added/updated, or explained why not below

  • Producer unit tests:

    • only workspaces with activity are listed, and the revision moves only on a real change
    • folder workspaces
    • an SSH host that lost contact reads unverifiable
    • agent working, then waiting for permission, then monitoring, then done
    • a status ping does not re-read terminals or tabs
    • seeding from rows that existed before main started listening
    • a pane picks up its workspace once its tab becomes known
    • an SSH agent row is matched to the workspace its host reported
    • stale agent status drops out on one timer
  • Runtime test on plain Node, the same way orcad runs: the facts follow tab publications, a terminal exit, and an unverifiable or live liveness verdict, and agent status comes from the hook server. check:runtime-electron-ratchet passes (no Electron is reachable from the runtime).

  • Shadow tests: the counting rule, plus the window-side reader.

  • e2e on macOS, in a hidden window (ORCA_BACKGROUND_LAUNCH=1): sidebar-agent-row-identity, sidebar-folder-keyboard-navigation and sidebar-measured-row-scroll pass with zero disagreements.

    • Positive control, not committed: adding the check to worktree-smart-sort, which seeds agent status and terminals directly into the window's store, correctly reports both seeded workspaces as disagreements.
  • Cost on main, measured with 200 terminal views, 200 PTYs and 423 workspaces:

    • 20,000 agent status pings cost about 1.5 to 2 µs more per ping (7.4 µs without the producer, 8.6 to 9.8 µs with it).
    • Re-reading one workspace after a tab publication costs about 31 µs, at most once per 50 ms per workspace.
  • pnpm tc, check:code-quality:changed, verify:rpc-params-catalog, max-lines ratchet and oxlint all pass.

Review

An independent review found 3 must-fix and 6 should-fix issues. All of them are addressed in the third commit.

Agent skill upstream boundary

  • Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

  • SSH: a terminal on a host that only lost contact reads unverifiable, never gone.
  • Folder workspaces: covered by the tests.
  • Paired servers: left out of the comparison; a later PR handles their rows.
  • Wire compatibility: the only addition is a new read-only RPC method, which older hosts simply do not have.
  • Mobile: nothing changes.
  • Cross-platform: workspace ids are compared with the existing path rule, so differences in how a path is spelled still match.
  • Not in this PR, owned by later steps:
    • Smart-sort inputs that are only read when the sort settles (pane titles, last output time).
    • Moving the agent-freshness timer into the single scheduler.
    • Facts for paired-server rows.
    • Host-qualified ids for the phone feed.

@coderabbitai

coderabbitai Bot commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 8958b9e4-ef39-4a90-aaf0-3fa06cbe8c0c
📥 Commits

Reviewing files that changed from the base of the PR and between a665217 and 2fb6c39.

📒 Files selected for processing: 1
  • src/shared/host-operation-ownership.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 2 remain after this review.

📝 Walkthrough

The change adds shared workspace activity-fact schemas and a main-process producer that combines workspace surface activity with agent status. The runtime refreshes facts after session-tab, graph, and PTY changes and exposes snapshots through an RPC method. The renderer derives matching facts and periodically compares them with main-process snapshots. Development and configured test runs expose comparison results, and selected end-to-end tests assert that no mismatches remain.

Priority: ➖ Normal

Merge Risk: ⚪ Minimal · up to 2fb6c

The reviewed change establishes no actionable behavior or operational risk, so the supplied evidence identifies no specific blocker to merging.

Pre-merge checks: Passed 3 · Failed 2

Failed Failed checks: 2 warnings

Check name Status Explanation Resolution
Description check Warning The description is detailed and covers the change, rationale, testing, visual proof, scope, compatibility, and review notes. However, it states “No issue” instead of providing the required linked issu… Add the actual linked issue, unless the maintainer exception applies and is confirmed. Add the Checklist section and mark each applicable item as complete or explain any exception.
Docstring Coverage Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 21 functions across 27 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 3 passed
Check name Status Explanation
Title check Passed The title clearly describes the main change: main now produces per-workspace sidebar activity facts and compares them with the window in development and test builds.
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.
Full details: Description check

Explanation

The description is detailed and covers the change, rationale, testing, visual proof, scope, compatibility, and review notes. However, it states “No issue” instead of providing the required linked issue, and it omits the required Checklist section.

Resolution

Add the actual linked issue, unless the maintainer exception applies and is confirmed. Add the Checklist section and mark each applicable item as complete or explain any exception.

  • Fix all pre-merge checks with AI
✨ Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

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