Skip to content

refactor(sidebar): main keeps sleeping retention only, no order of its own (dark) - #30404

Merged
Jinwoo-H merged 13 commits into
mainfrom
jinwoo/sidebar-stamps-main-cleanup
Oct 18, 2026
Merged

Jinwoo-H merged 13 commits into
mainfrom
jinwoo/sidebar-stamps-main-cleanup

Conversation

@Jinwoo-H

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

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 9 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​233 $\color{#cf222e}{\Huge{\mathbf{−}}}$​773 $\color{#cf222e}{\Huge{\mathbf{−}}}$​540
Prod 13 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​197 $\color{#cf222e}{\Huge{\mathbf{−}}}$​748 $\color{#cf222e}{\Huge{\mathbf{−}}}$​551

ELI5

In the new sidebar build (still switched off for everyone), every client sorts the workspace list by notes the owning computer writes on each workspace. Main used to keep its own copy of the old timer-based order so a test-only "shadow" check could compare it with the window's. That copy is no longer needed, so this PR deletes it. Main keeps the one piece still in use: which sleeping workspaces "Hide sleeping" keeps for a moment while a terminal reconnects.

What Changed

Behind the build switch ORCA_SIDEBAR_INPUTS=main only (main's sidebar layer does not exist in a switch-off build):

  • SidebarTemporalOwner becomes SidebarRetentionOwner (sidebar-retention-owner.ts): sleeping retention only. Gone: the settle window, the Smart latch, create grace, the sort sample and its deadline.
  • Retention needs to know each row's host. The owner lists rows at session start and on every worktree/repo change, through one sequence so an older slow listing never overwrites a newer one, and publishes retention only once a listing has landed.
  • Deleted modules that only fed main's order: catalog-listing-change.ts, runtime-smart-sort-sources.ts, smart-sort-agent-entries.ts, and the runtime layer's graph-sync sort causes and saved-metadata re-sort listener.
  • SidebarTemporalSnapshot drops sortSnapshot (the sidebarInputs.temporal result and the feed's temporal domain).
  • Renderer: the shadow check compares retention only; useSidebarListSession() no longer records the window's order; the shadow readout keeps the window's retention even when the sweep commits before the list's session begins (it was dropped before). The window/main parity test is now retention-only.

Unchanged: the sidebar clock (activity facts still use it), the host's sort stamps and the startup reconcile.

Why

Plan step 4 of the sort-stamps note. After #30284 and #30401 the order is a pure read of the stamps on every client, so main's copy of the old time rules only cost work on every catalog change, agent row change and graph sync, and a comparison that was meant to differ.

Wire: the only parser of sortSnapshot was the renderer's dev/test shadow check, behind the same switch. A newer client reading an older dark host strips the extra key; an older dark client reading this host stops comparing that domain. Nothing user-facing reads it, so no null placeholder was kept.

Linked Issue

Follow-up to #30284 and #30401 (sidebar sort stamps plan, PR 4).

Visual Proof

N/A: dark behind a build switch; no shipped build changes.

Testing

  • I manually tested these changes locally

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

  • sidebar-retention-owner.test.ts: idle until a session and after dispose; a live row held through a rebind gap then released; the show-sleeping reset; nothing published until a listing lands (with a revision bump when it does); a slow session listing never overwrites a newer catalog listing. Positive control: with the sequence check removed, the last test fails.

  • use-sleeping-sweep-retention.main-parity.test.tsx: main and window keep and release the same sleeping rows on one fake clock.

  • Sidebar, sidebar-inputs and shadow suites; pnpm tc.

  • e2e on a switch-on build, hidden window, all shadow-checked specs (workspace rows, sort-stamps order/stamps/startup, inputs feed, creation registry, review facts, repo icons, agent row identity, folder keyboard navigation, collapse, measured scroll, paired mobile mirror visibility, paired-server rows): pass. paired-server-rows-shadow timed out once and passed on rerun.

  • All check:*ratchet* scripts (launcher protocol with --base origin/main), check:code-quality:changed, anti-slop lint (config/oxlint-anti-slop.json --deny-warnings), oxlint: pass. macOS only.

Review

Opus review of the diff and the fix delta. Fixed from review: every listing goes through one sequence (catalog listings could land out of order), retention is not published before the first listing, a revision assertion.

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

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)

Jinwoo-H and others added 13 commits October 18, 2026 14:58
… or saved order (dark)

With ORCA_SIDEBAR_INPUTS=main the window's sort hook is a pure read of the
rows' stamps: no settled-epoch store listener, no Smart latch, no saved Smart
order writes, no class telemetry over the old attention map. Switch off: the
existing hook, unchanged.

Co-Authored-By: Claude <[email protected]>
…anup' into jinwoo/sidebar-stamps-main-cleanup
… renderer layout literal

The layout-writer ratchet counts layout field keys written in the renderer;
the empty sources object now lives beside SmartSortSources in shared code.

Co-Authored-By: Claude <[email protected]>
…s own (dark)

Clients sort by the owning host's stamps, so main's temporal owner loses its
settle window, Smart latch, create grace and catalog-listing classifier, and
the shadow check stops comparing order. Retention, its clock and its shadow
comparison stay.

Co-Authored-By: Claude <[email protected]>
…anup' into jinwoo/sidebar-stamps-main-cleanup
…anup' into jinwoo/sidebar-stamps-main-cleanup
…-main-cleanup

# Conflicts:
#	src/renderer/src/components/sidebar/worktree-list/listing/use-sort-order.ts
@coderabbitai

coderabbitai Bot commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

📝 Walkthrough

The temporal snapshot and window readout no longer include sort state. Main runtime replaces its temporal sort owner with SidebarRetentionOwner, which tracks sleeping-workspace retention using worktree listings and retention candidates. The change removes Main-side sort sampling utilities and adds retention-owner tests, including a parity test with the window hook.

Priority: ⬇️ Low

Merge Risk: 🔵 Low · up to d64b7

With main sidebar inputs enabled, some metadata updates can leave workspace details and sleeping-workspace retention stale. Restore the write notification before enabling that build broadly.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 53.85% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 13 functions across 11 files. (1 skipped:… 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 clearly summarizes the main change: Main retains sleeping-workspace retention and removes its own sidebar ordering logic. The '(dark)' qualifier is relevant to the build scope.
Description check Passed The description is complete and directly addresses the template. It explains the change, rationale, testing, scope, compatibility considerations, and checklist status. The linked issue section referen…
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 complete and directly addresses the template. It explains the change, rationale, testing, scope, compatibility considerations, and checklist status. The linked issue section references follow-up PRs rather than an issue, but the overall description remains sufficiently complete.

Full details: Docstring Coverage

Explanation

Docstring coverage is 53.85% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 13 functions across 11 files. (1 skipped: 1 unsupported.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

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

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 3a4bdffe-f802-4504-86c8-26770fe25697
📥 Commits

Reviewing files that changed from the base of the PR and between 63f0cb9 and d64b779.

📒 Files selected for processing: 22
  • config/tsconfig.tc.web.json
  • src/main/runtime/sidebar-inputs/catalog-listing-change.ts
  • src/main/runtime/sidebar-inputs/orca-runtime-sidebar-inputs-feed.test.ts
  • src/main/runtime/sidebar-inputs/orca-runtime-sidebar-temporal.ts
  • src/main/runtime/sidebar-inputs/runtime-smart-sort-sources.test.ts
  • src/main/runtime/sidebar-inputs/runtime-smart-sort-sources.ts
  • src/main/runtime/sidebar-inputs/sidebar-inputs-feed-domains.ts
  • src/main/runtime/sidebar-inputs/sidebar-retention-owner.test.ts
  • src/main/runtime/sidebar-inputs/sidebar-retention-owner.ts
  • src/main/runtime/sidebar-inputs/sidebar-temporal-owner-stamps.test.ts
  • src/main/runtime/sidebar-inputs/sidebar-temporal-owner.test.ts
  • src/main/runtime/sidebar-inputs/sidebar-temporal-owner.ts
  • src/main/runtime/sidebar-inputs/smart-sort-agent-entries.test.ts
  • src/main/runtime/sidebar-inputs/smart-sort-agent-entries.ts
  • src/renderer/src/components/sidebar/worktree-list/listing/use-sleeping-sweep-retention.main-parity.test.tsx
  • src/renderer/src/components/sidebar/worktree-list/listing/use-sort-order.main-parity.test.tsx
  • src/renderer/src/components/sidebar/worktree-list/listing/use-sort-order.ts
  • src/renderer/src/lib/sidebar-list-session.ts
  • src/renderer/src/lib/sidebar-shadow/sidebar-temporal-shadow.ts
  • src/renderer/src/lib/sidebar-shadow/window-sidebar-temporal-readout.ts
  • src/shared/sidebar-list/sidebar-temporal-snapshot.ts
  • tests/e2e/sidebar-inputs-feed.spec.ts
💤 Files with no reviewable changes: 10
  • src/main/runtime/sidebar-inputs/smart-sort-agent-entries.test.ts
  • src/main/runtime/sidebar-inputs/sidebar-temporal-owner-stamps.test.ts
  • src/main/runtime/sidebar-inputs/runtime-smart-sort-sources.test.ts
  • src/renderer/src/components/sidebar/worktree-list/listing/use-sort-order.main-parity.test.tsx
  • src/main/runtime/sidebar-inputs/sidebar-temporal-owner.test.ts
  • src/shared/sidebar-list/sidebar-temporal-snapshot.ts
  • src/main/runtime/sidebar-inputs/smart-sort-agent-entries.ts
  • src/main/runtime/sidebar-inputs/catalog-listing-change.ts
  • src/main/runtime/sidebar-inputs/sidebar-temporal-owner.ts
  • src/main/runtime/sidebar-inputs/runtime-smart-sort-sources.ts

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

(event) => {
if (event.type === 'worktreesChanged' || event.type === 'reposChanged') {
this.noteSidebarCatalogChange(event.type)
this.sidebarTemporal.noteCatalogChange()

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.

🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win

🔎 Supported by static analysis

🏁 Script executed:

set -eu
printf '%s\n' '--- runtime sidebar temporal ---'
nl -ba src/main/runtime/sidebar-inputs/orca-runtime-sidebar-temporal.ts | sed -n '1,190p'
printf '%s\n' '--- retention owner ---'
nl -ba src/main/runtime/sidebar-inputs/sidebar-retention-owner.ts | sed -n '1,210p'
printf '%s\n' '--- metadata handler ---'
nl -ba src/main/ipc/worktrees/metadata/register-worktree-metadata-handlers.ts | sed -n '1,125p'
printf '%s\n' '--- metadata domain definitions and relevant references ---'
rg -n -F --glob '*.ts' -e 'WORKTREE_METADATA_DOMAINS' -e 'noteRowsWritten' -e 'invalidateResolvedWorktreeCache' -e 'notifyWorktreesChangedForRemoteClients' src/main src/shared

Repository: stablyai/orca

Length of output: 27765


🏁 Script executed:

set -eu
printf '%s\n' '--- reviewed diff for temporal owner ---'
git diff --no-ext-diff --unified=30 63f0cb9570f581b7589534d9c630e54bd41debf7 d64b779e00ebf5d25a1c0c4643825f38f4048373 -- src/main/runtime/sidebar-inputs/orca-runtime-sidebar-temporal.ts
printf '%s\n' '--- surviving state-write listener ---'
nl -ba src/main/runtime/sidebar-inputs/workspace-rows-producer.ts | sed -n '1,75p'
printf '%s\n' '--- onStateWritten declaration and store metadata write path ---'
rg -n -F --glob '*.ts' -e 'onStateWritten' -e 'setWorktreeMetaForHost' -e 'setWorktreeMeta(' src/main/persistence src/main/runtime src/main/ipc | head -80

Repository: stablyai/orca

Length of output: 25665


Restore metadata-write invalidation and retention relisting.

A non-display-name worktrees:updateMeta write can change WorktreeMeta.hostId. The current path updates the store and bumps WorkspaceRowsProducer.revision, but it does not invalidate resolvedWorktrees or relist SidebarRetentionOwner.

Workspace and review readers can therefore receive stale resolved rows. The retention owner can also publish the old host-qualified identity until another catalog event triggers a relist.

Restore the metadata-write handler. Invalidate the cache before notifying the owner to relist.

Suggested fix
 import { SortStampsProducer } from './sort-stamps-producer'
+import { WORKTREE_METADATA_DOMAINS } from '../../persistence/loading-store/worktree-identity-metadata'
 ...
     this.workspaceActivityFacts.revision.onChange(() => this.sidebarTemporal.noteActivityChange())
     this.store?.onUIChanged?.(() => this.sidebarTemporal.noteViewChange())
+    this.store?.onStateWritten?.((domains) => {
+      if (
+        ORCA_SIDEBAR_INPUTS_IS_MAIN &&
+        (domains === undefined ||
+          WORKTREE_METADATA_DOMAINS.some((domain) => domains.includes(domain)))
+      ) {
+        this.invalidateResolvedWorktreeCache()
+        this.sidebarTemporal.noteCatalogChange()
+      }
+    })
     // Every catalog change, from IPC or the runtime, reaches clients through this one bus.

@Jinwoo-H
Jinwoo-H merged commit 91b696b into main Oct 18, 2026
40 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