Skip to content

feat(sidebar): sort Recent and Smart by the owning host's stamps, hold order under the pointer (dark) - #30284

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

Jinwoo-H merged 12 commits into
mainfrom
jinwoo/sidebar-sort-stamps-order

Conversation

@Jinwoo-H

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

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 14 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​918 $\color{#cf222e}{\Huge{\mathbf{−}}}$​355 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​563
Prod 32 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​7877 $\color{#cf222e}{\Huge{\mathbf{−}}}$​23 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​7854

ELI5

Earlier PRs (#30235, #30259) made the computer that owns a workspace write two notes on its record: "last time something real happened here" and "its agent needs you / is done / is working, since when". This PR makes the sidebar sort by those notes, on the desktop window, in main, and on the phone, instead of each one guessing from timers. It also stops rows from moving while your mouse is over the list. Everything is still switched off in every build people use.

What Changed

Behind the build switch ORCA_SIDEBAR_INPUTS=main only:

  • One order everywhere. stamp-order.ts compares two rows by their stamps: Recent by lastActivityAt; Smart by tier (Needs you, Done, Working, then everything else), newest smartAt first inside a tier, then Recent. An unknown tier counts as the rest. buildWorktreeComparator / rankWorktreesForSort (window, palette, main) and the phone's sortWorktrees use it through the existing buildWorkspaceRowComparator. No clock, settle window, cold phase, latch or create grace is read.
  • Stamps reach every client. When the host writes a stamp it announces a metadata-only catalog change (git scans stay cached), so the window and phone re-list the row. The window re-sorts when its rows change; main re-samples on every re-list and on saved metadata writes the window does not announce (a rename, a manual order).
  • The window stops writing its own Recent stamps: terminal start and exit, unread marks and comment edits no longer set lastActivityAt (the note's table: these are not events). The unread flag itself is unchanged.
  • Phone. worktree.ps summaries carry smartTier, smartAt and sortedByStamps: true. A phone sorts by stamps when the host says so (decided from the unfiltered list); rows from an older paired server that writes no tier sort in the rest by Recent (owner decision Q4).
  • Hover and drag hold (desktop, display only). In Recent and Smart the shown order holds while the pointer is over the list, a press started in it, or a drag runs; it applies on leave or drag end. New and removed rows show at once. Manual and Name never hold, so your own drop or rename shows at once. held-order.ts + use-order-hold.ts, wired in WorktreeList.tsx.

With the switch off every branch above is skipped: the existing sidebar goldens are byte-identical (no golden file changed), and the stamp producer never attaches.

The old timer machinery (settle, latch, saved Smart order, create grace, main's temporal-owner sort parts) is not deleted; that is PRs 3 and 4 of the plan.

Why

Timers made each client guess from its own view, so the window, main and the phone could disagree and rows could re-shuffle after a restart. Reading the owning host's stamps gives one answer for every client and keeps the order across restarts.

Alternatives considered: keep the window's own lastActivityAt writes until PR 3. Rejected, because with the switch on they moved rows on comment edits and terminal exits, which the plan says must not move, and main could not see them. Holding in every mode was rejected because it froze your own Manual drop until the pointer left.

Linked Issue

Follow-up to #30235 and #30259 (sidebar sort stamps plan, PR 2).

Visual Proof

N/A: dark behind a build switch; no build people use changes. Order on a switch-on build is covered by the e2e below.

Testing

  • I manually tested these changes locally

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

  • Goldens: the existing sidebar golden suite now also runs with the switch on into __goldens__/sidebar-list-stamp-order, plus a stamp-tiers scenario across Smart/Recent, every group-by and pinned. Switch-off goldens unchanged.

  • Note section 4 before/after table, one test per row (stamp-order-scenarios.test.ts): streaming agent stays put; a finish tops Recent and Done and holds with no fade; a finish in the open workspace; approval tops Needs you; shell typing, rename and comment edits are not events (plus worktrees-recent-stamp-switch-on.test.ts: the window writes no stamp for them); a prompt tops Recent and moves to Working; a created workspace stays on top until something newer; two finishes a second apart; an SSH disconnect holds; a restart keeps the identical order; a resumed approval returns to Working without topping Recent. Pin is grouping, unchanged.

  • Unit: comparator, held order, hover/drag hold (Recent hold, press, drag end, Manual/Name never hold), main owner with the switch on, runtime announces a stamp write, worktree.ps fields, phone ordering and older-server rows. Positive controls: each new switch-on test fails with its fix reverted.

  • e2e on a switch-on build, hidden window: new sidebar-sort-stamps-order.spec.ts (DOM order follows a prompt and a finish in Smart and Recent; shadow check clean), plus the existing stamp, startup, workspace-rows, creation-registry, review-facts, recent-sort and manual-sort specs: pass. worktree-smart-sort.spec.ts is skipped on that build only, because its statuses are seeded in the window and never reach the host. Switch-off build: recent/smart sort specs pass.

  • Cost of the host's bell/title scanning, main process, 10 s windows, terminal flooding seq output with a title change and a bell per batch (about 2 runs each, macOS): switch off 26.3% / 25.6% CPU, switch on 26.7% / 29.8% CPU; idle 1.6 to 1.8% both; event-loop delay max 11.4 to 12.1 ms both (10 ms histogram resolution). No measurable event-loop cost; CPU within run-to-run noise.

  • pnpm tc, mobile tsc + tests + format check, check:code-quality:changed, focus-read ratchet, oxlint: pass. macOS only.

Review

Opus review of the diff and of the fix delta. Findings fixed: Manual/Name hold, re-sort on unrelated full saves, window-side stamps moving rows, phone algorithm depending on the filter, missing wiring tests.

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

To decide before the switch flips (not reachable in any shipped build):

  • A switch-on desktop paired to an older server no longer writes Recent for that server's rows on an unread mark, and the older server writes none, so those rows move only when created.
  • lastActivityAt also feeds workspace cleanup's "last active" (SSH and remote rows trust it alone), the jump palette and kanban. With terminal start/exit no longer stamping, a shell-only remote workspace can look inactive to cleanup.
  • Folder workspaces in the desktop window are still placed by their manual order in their own lanes, as today; the phone sorts them with the rest. Each folder stamp re-lists the catalog through the existing folder-change path.
  • Clients that read Smart from saved sortOrder (very old phones) keep the last saved order, since a stamp-sorted window never saves one.

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 11 commits October 18, 2026 03:21
…r-inputs switch

With ORCA_SIDEBAR_INPUTS=main, the window, main and the phone order Recent by
lastActivityAt and Smart by smartTier then smartAt (Needs you, Done, Working,
then the rest by Recent). The window holds its displayed order while the
pointer is over the list or a drag runs. Switch off: today's sort path.

Co-Authored-By: Claude <[email protected]>
…tamps-order

# Conflicts:
#	src/main/runtime/sidebar-inputs/orca-runtime-sidebar-temporal.ts
#	src/main/runtime/sidebar-inputs/sort-stamps-producer.ts
The window writes no Recent stamps with the switch on (terminal start and
exit, unread marks, comment edits), the hover hold covers only Recent and
Smart and ends with a drag, main follows only explicit metadata saves, and
the phone picks its sort from the unfiltered rows.

Co-Authored-By: Claude <[email protected]>
@coderabbitai

coderabbitai Bot commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

📝 Walkthrough

The main runtime now includes Smart-tier and timestamp fields in worktree summaries and notifies clients when sort stamps change. Main-runtime sorting uses those stamps, while other runtimes retain their existing sorting paths. The renderer holds Recent and Smart row order during specified pointer and drag interactions. The mobile client also supports stamp-based ordering. Tests cover stamp comparisons, runtime updates, mobile ordering, and sidebar output.

Priority: ➖ Normal

Merge Risk: 🔵 Low · up to e93f7

The new end-to-end check could miss a renderer regression that ignores Smart stamps. The ordering behavior otherwise appears consistent with the inspected contracts, so this is a bounded test-confidence risk.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 31.11% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 45 functions across 33 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 clearly identifies the main changes: host-stamp sorting for Recent and Smart and pointer-based order holding. The trailing “(dark)” is unnecessary but does not make the title misleading.
Description check Passed The description is complete and closely follows the required template. It explains the user impact, implementation, rationale, linked issues, visual-proof exception, testing, compatibility notes, and …
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 closely follows the required template. It explains the user impact, implementation, rationale, linked issues, visual-proof exception, testing, compatibility notes, and checklist status.

  • 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
tests/e2e/sidebar-sort-stamps-order.spec.ts: 1

52-65: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Use different Smart and Recent orders in this e2e.

After the prompt, both assertions expect [pane.worktreeId, otherId]. If the hook updates only recentAt, the Smart view can fall back to Recent and produce the same order, so this test can pass while the renderer ignores smartTier or smartAt. tests/e2e/sidebar-sort-stamps.spec.ts checks the host row fields, but it does not check rendered ordering.

Stamp the secondary row as done before prompting the active row. Then assert that Smart places the secondary row first while Recent places the active row first.

Suggested fix
-    // A newer Recent stamp on the other row, with no tier on either.
-    store.getState().updateWorktreeMeta(other.id, { lastActivityAt: Date.now() })
     return other.id
   }, pane.worktreeId)
   const ids = [pane.worktreeId, otherId]
+  const otherPane = {
+    paneKey: 'tab-stamps-order:22222222-2222-4222-8222-222222222222',
+    worktreeId: otherId
+  }
+  await postClaudeHook(endpoint, otherPane, {
+    hook_event_name: 'UserPromptSubmit',
+    prompt: 'other'
+  })
+  await postClaudeHook(endpoint, otherPane, {
+    hook_event_name: 'Stop',
+    last_assistant_message: 'ok'
+  })
   await expect.poll(() => rowOrder(orcaPage, ids)).toEqual([otherId, pane.worktreeId])
 
   await orcaPage.waitForTimeout(RECENT_STAMP_THROTTLE_MS + 500)
   await postClaudeHook(endpoint, pane, { hook_event_name: 'UserPromptSubmit', prompt: 'go' })
-  // Working outranks a row with no tier; the prompt's Recent stamp also tops Recent.
-  await expect.poll(() => rowOrder(orcaPage, ids)).toEqual([pane.worktreeId, otherId])
+  // Done outranks Working in Smart, while the active row has the newer Recent stamp.
+  await expect.poll(() => rowOrder(orcaPage, ids)).toEqual([otherId, pane.worktreeId])
   await orcaPage.evaluate(() => window.__store!.getState().setSortBy('recent'))
   await expect.poll(() => rowOrder(orcaPage, ids)).toEqual([pane.worktreeId, otherId])

ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: e03b6ee6-138a-43a0-a677-60527153c5e8
📥 Commits

Reviewing files that changed from the base of the PR and between feda5bc and e93f70a.

📒 Files selected for processing: 1
  • src/main/runtime/runtime-worktree-ps-summaries-sort-stamps.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 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