Repository navigation
feat(sidebar): sort Recent and Smart by the owning host's stamps, hold order under the pointer (dark) - #30284
Conversation
…live hook rows and terminals (dark)
…tle, seeding hydrated rows
… rest seed adds no clear
…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
Co-Authored-By: Claude <[email protected]>
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]>
Co-Authored-By: Claude <[email protected]>
📝 Walkthrough
Priority: ➖ Normal Merge Risk: 🔵 Low · up to
|
Co-Authored-By: Claude <[email protected]>
There was a problem hiding this comment.
🧹 Nitpick comments: 1
tests/e2e/sidebar-sort-stamps-order.spec.ts: 1
52-65: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winUse different Smart and Recent orders in this e2e.
After the prompt, both assertions expect
[pane.worktreeId, otherId]. If the hook updates onlyrecentAt, the Smart view can fall back to Recent and produce the same order, so this test can pass while the renderer ignoressmartTierorsmartAt.tests/e2e/sidebar-sort-stamps.spec.tschecks the host row fields, but it does not check rendered ordering.Stamp the secondary row as
donebefore 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
📒 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.
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=mainonly:stamp-order.tscompares two rows by their stamps: Recent bylastActivityAt; Smart by tier (Needs you, Done, Working, then everything else), newestsmartAtfirst inside a tier, then Recent. An unknown tier counts as the rest.buildWorktreeComparator/rankWorktreesForSort(window, palette, main) and the phone'ssortWorktreesuse it through the existingbuildWorkspaceRowComparator. No clock, settle window, cold phase, latch or create grace is read.lastActivityAt(the note's table: these are not events). The unread flag itself is unchanged.worktree.pssummaries carrysmartTier,smartAtandsortedByStamps: 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).held-order.ts+use-order-hold.ts, wired inWorktreeList.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
lastActivityAtwrites 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 (plusworktrees-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.psfields, 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.tsis 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
seqoutput 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, mobiletsc+ 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
Notes
To decide before the switch flips (not reachable in any shipped build):
lastActivityAtalso 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.sortOrder(very old phones) keep the last saved order, since a stamp-sorted window never saves one.Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)