Skip to content

feat(sidebar): after a restart, the host clears sort tiers nothing backs any more (dark) - #30259

Merged
Jinwoo-H merged 6 commits into
mainfrom
jinwoo/sidebar-sort-stamps-reconcile
Oct 18, 2026
Merged

Jinwoo-H merged 6 commits into
mainfrom
jinwoo/sidebar-sort-stamps-reconcile

Conversation

@Jinwoo-H

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

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 5 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​316 $\color{#cf222e}{\Huge{\mathbf{−}}}$​28 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​288
Prod 5 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​227 $\color{#cf222e}{\Huge{\mathbf{−}}}$​75 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​152

ELI5

The previous PR (#30235) made the computer that owns a workspace write down "this workspace's agent needs you / is done / is working" on the workspace's record. If Orca quits and the agent dies while it is closed, nothing would ever erase that note. This PR checks the notes once after Orca restarts and erases the ones nothing backs any more. It is still switched off in every build people use.

What Changed

Behind the build switch ORCA_SIDEBAR_INPUTS=main only:

  • SortStampsProducer.reconcileStoredTiers runs once per start, at the point where the host's own evidence has settled:
    • desktop and orca serve: at the end of the existing restored-status dead-terminal sweep (main-process-pty-startup.ts), which runs after the hook server has loaded its saved rows and the local PTY provider is ready;
    • orcad: after the PTY runtime is registered and legacy worker terminals are reconciled.
  • It first seeds every hook row the producer has not seen (a row seeded at rest adds nothing and clears nothing). Loading saved rows does not fire a row mutation, so before this a restored row could be taken for a new event later.
  • It then clears a stored tier only when all of these hold:
    • the workspace belongs to this machine (resolveAgentWorkspaceExecutionHostId + isLocalExecutionHost, the same rule the dead-terminal sweep uses; unknown ownership is not treated as local);
    • no hook row backs it;
    • the workspace held at least one terminal (open now, or saved in its session and layout), and the provider proves every one of them gone. A probe that cannot answer keeps the tier, and so does a workspace with no terminal on record: a native chat's row is republished after startup, and on orcad the clients own the layout, so absence of evidence proves nothing.
  • Clearing writes only the tier; Recent is never stamped by a restart. A clean start writes nothing.
  • Record reads and writes moved into sort-stamp-records.ts to keep the producer under the line limit.

With the switch off nothing here runs: the reconcile lives on the switch-only runtime layer, and the two call sites go through sidebarFacts, which is null.

Why

A tier is only true while something backs it. Hook-backed agents are covered by the hook server's own restored-row sweep, which removes rows whose terminal died; hookless agents (title heuristic) have no row, so their tier needed this check. The check never treats an SSH host or a paired server as dead: a host that is not connected yet proves nothing (docs/reference/ssh-execution-boundary.md).

Alternative rejected: reconciling when the producer attaches. On the desktop that runs before the hook server loads its saved rows and before any terminal is known, so it wiped every tier on every start (found in review).

Linked Issue

Follow-up to #30235 (sidebar sort stamps plan, deferred item).

Visual Proof

N/A: dark behind a build switch; nothing reads the stamps for ordering yet.

Testing

  • I manually tested these changes locally

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

  • Unit: sort-stamps-producer.test.ts (clears an unbacked local tier on a worktree and a folder; keeps tiers backed by a hook row, a live terminal, a terminal the probe cannot answer for, or no terminal on record; seeds rows hydrated without a mutation; never touches another host's tiers), orca-runtime-sort-stamps.test.ts (real runtime, live vs gone terminal).

  • e2e on a switch-on build, hidden window: tests/e2e/sidebar-sort-stamps-startup.spec.ts restarts the app with a saved hook done row (kept), a folder workspace tier whose terminal died while Orca was closed (cleared) and an SSH host's tier (kept); passes 3 of 3. Positive controls: with the desktop call removed the spec fails (Received: "working"), and with no dead terminal on record the folder tier is kept, so the spec fails too. sidebar-sort-stamps.spec.ts and sidebar-workspace-rows.spec.ts still pass.

  • pnpm tc, relevant suites, check:code-quality:changed, focus-read ratchet, oxlint: pass. macOS only.

Review

Opus review of the diff and of the redesign delta.

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

  • A clear skipped because a WSL move froze the project is not retried until the next start.
  • A desktop running without the terminal daemon skips the existing dead-terminal sweep, and this reconcile with it, so stale tiers stay there (the safe direction).
  • On orcad the evidence is the runtime's own PTY records; a workspace whose surviving terminal is not yet known keeps its tier.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

@coderabbitai

coderabbitai Bot commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

📝 Walkthrough

Startup now reconciles stored sidebar tiers against hook status and local PTY evidence. The reconciliation preserves tiers backed by hook rows, live or unverifiable PTYs, and workspaces on other hosts. It clears a local tier when recorded PTYs are confirmed absent and no pane backs the tier. Shared record helpers handle tier access across worktree and folder-workspace records. Unit and end-to-end tests cover reconciliation and restart behavior.

Priority: ⬇️ Low

Merge Risk: 🔵 Low · up to 40856

Startup tier reconciliation looks correct. One unit test does not actually cover the live-terminal case, so a future regression there could go unnoticed. Fix the fake probe soon, but it does not block merge.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 28.57% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 14 functions across 10 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title accurately describes the main change: clearing unsupported sidebar sort tiers after restart. The wording is awkward, especially "nothing backs any more," but the title remains specific and u…
Description check Passed The description is complete and closely follows the repository template. It explains the user impact, implementation, rationale, linked issue, testing, platform coverage, and checklist status. It also…
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: Title check

Explanation

The title accurately describes the main change: clearing unsupported sidebar sort tiers after restart. The wording is awkward, especially "nothing backs any more," but the title remains specific and understandable.

Full details: Description check

Explanation

The description is complete and closely follows the repository template. It explains the user impact, implementation, rationale, linked issue, testing, platform coverage, and checklist status. It also documents the build switch, limitations, and safety conditions for reconciliation.

  • 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.

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

🧹 Nitpick comments: 1
src/main/runtime/sidebar-inputs/sort-stamps-producer.test.ts: 1

405-405: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Make the fake probe answer true for 'pty-live'.

The test name says a live terminal keeps the tier. The fake probe instead returns false for 'pty-live', and false means "proven absent." The live case therefore never runs in this test. The WT tier survives only because 'pty-unknown' returns null. If the producer ever treated a true result as absent, this test would still pass. Return true for 'pty-live' so this test covers all three ways a tier is kept.

🧪 Proposed fix
-        probePtyLiveness: async (ptyId) => (ptyId === 'pty-live' ? false : null)
+        probePtyLiveness: async (ptyId) => (ptyId === 'pty-live' ? true : null)

ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 4a781427-ad03-4add-ad6f-094dd43a2aeb
📥 Commits

Reviewing files that changed from the base of the PR and between 06618fd and 408561f.

📒 Files selected for processing: 10
  • src/main/orcad/orcad-entry.ts
  • src/main/runtime/sidebar-inputs/orca-runtime-sidebar-temporal.ts
  • src/main/runtime/sidebar-inputs/orca-runtime-sort-stamps.test.ts
  • src/main/runtime/sidebar-inputs/sort-stamp-records.ts
  • src/main/runtime/sidebar-inputs/sort-stamps-producer.test.ts
  • src/main/runtime/sidebar-inputs/sort-stamps-producer.ts
  • src/main/startup/main-process-pty-startup.ts
  • tests/e2e/helpers/agent-hook-endpoint.ts
  • tests/e2e/sidebar-sort-stamps-startup.spec.ts
  • tests/e2e/sidebar-sort-stamps.spec.ts

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

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