Skip to content

fix(sidebar): a sort stamp no longer makes the window re-list its repo - #31369

Closed
Jinwoo-H wants to merge 2 commits into
sidebar-flip-afrom
sidebar-stamp-no-relist
Closed

Jinwoo-H wants to merge 2 commits into
sidebar-flip-afrom
sidebar-stamp-no-relist

Conversation

@Jinwoo-H

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

Copy link
Copy Markdown
Contributor

ELI5

When an agent starts or finishes, the app updates that workspace's "last active" time and unread dot. With the new sidebar switch on, each of those small updates made the window reload the whole list of workspaces for that project. While you scroll the sidebar with agents running, those reloads pile up and the list freezes for a tenth of a second at a time. Now the window picks up those updates from the sidebar feed it already reads, so nothing gets reloaded.

What Changed

  • Before (switch on): main writes the Recent/Smart stamps and the unread flag on every agent transition. It announced each one to its own window as worktrees:changed. The window then re-listed that project's workspaces over IPC, merged the result and replaced worktreesByRepo. That re-rendered the list, every mounted card and its context menu, and the file explorer rows, on top of the sidebar-feed re-plan the same write already triggers.
  • After: notifySortStampsChanged (with the switch on) announces stamp writes to paired clients only, through the existing notifyWorktreesChangedForRemoteClients / notifyReposChangedForRemoteClients. A folder stamp still wakes the folder git-upgrade watch. The new src/renderer/src/lib/sidebar-feed-sort-stamps.ts keeps main's last installed workspace rows. It writes their isUnread / recentAt / smartTier / smartAt onto the window's own records: worktrees, the detected listing and folder workspaces. It re-applies them, idempotently, after every feed install and whenever a listing replaces those records, so a listing that read main before a stamp is corrected as it lands. A row with the window's own unanswered unread write keeps the window's value until main shows it. It is installed once at renderer start and starts the feed itself, because the dock badge, palettes and cleanup views read these records even when no list is mounted.
  • The switch-off path is unchanged. Paired clients and the phone get the same event as before (no wire change).

Why

The feed already carries the stamps, and main bumps it on every metadata write. Taking the stamps from the feed follows the switch's direction (main owns the sidebar inputs) and needs no new IPC.

Making only the cards read stamps from feed rows was considered. It leaves stale every other reader of the window's records: the unread badge count, the activity unread count, the jump palette's Recent order and workspace cleanup. Patching the record covers all of them.

invalidateResolvedWorktreeCache() on stamp writes is kept. It only drops the 1 s merged snapshot; git results come from the 30 s scan cache, so it starts no git worktree list (measured below). Paired clients re-list through that snapshot right after the event, so dropping the invalidation would hand them a snapshot without the stamp.

Linked Issue

N/A (internal, sidebar switch follow-up)

Visual Proof

N/A: no visual change. The fix removes scroll stutter, measured as frame times below.

Testing

Hidden window (ORCA_BACKGROUND_LAUNCH=1), driven over CDP. Fixture: 134 workspaces, 67 fake agents, a hook driver flipping working/done every 2 s. The sidebar scrolls 24 px per frame for 20 s. Runs were interleaved, 4 per build on the same profile. The display runs at 120 Hz, so a normal frame is 8.3 ms.

per 20 s base (6dbe87e) this PR
frames over 50 ms 21–24 1–5
frames over 25 ms 33–42 18–24
worst frame 126–142 ms 50–58 ms
  • git worktree list spawns during the 20 s window were 0 on both builds, and 0 in a 60 s window on both. About 20 spawns at each launch, the same on both.

  • A third build that also dropped the cache invalidation matched this PR (0–2 frames over 50 ms), so the invalidation does not cost frames either.

  • New tests: orca-runtime-sort-stamps.test.ts (fails on the base: the window notifier was called) and sidebar-feed-sort-stamps.test.ts. 569 related node-project tests pass; pnpm tc passes.

  • I manually tested these changes locally

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

Notes

Separate follow-up, not in this PR: the revealOwner selector in right-sidebar/file-explorer-row-context-menu.tsx builds a new object on every store change, so every file explorer row re-renders on any write, with the switch on or off.

With the sidebar switch on, main writes the Recent/Smart stamps and the unread
flag on every agent transition and announced each one as worktrees:changed.
The window answered with a full repo listing and merge, re-rendering every
mounted card and menu; under agent churn those stacked into 50-140 ms frames
while scrolling. The window now takes the stamps off main's sidebar feed, which
already carries them; paired clients still get the re-list event.
…e listings

Re-applies main's last installed stamps whenever a listing replaces the
window's records (worktrees, detected listing, folder workspaces), holds the
window's own unanswered unread write, and keeps waking the folder git-upgrade
watch on a folder stamp.
@Jinwoo-H

Copy link
Copy Markdown
Contributor Author

Replaced by the planned workspace-records change, where the window reads these fields from main's feed instead of copying them.

@Jinwoo-H Jinwoo-H closed this Oct 21, 2026
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