Repository navigation
Fix reveal active workspace needing multiple clicks - #13926
Conversation
The sidebar's scroll-anchor restore writes scrollTop two frames into the reveal's smooth scroll, which silently cancels the animation. When the active workspace was mounted just below the fold the reveal moved ~13px and stopped, so the button took several clicks to bring the card in view. Arm a settle guard for the duration of a reveal scroll so anchor restore stands down until it lands, the same way direct wheel input already does. Co-authored-by: Orca <[email protected]>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (5)
📝 WalkthroughWalkthroughThe sidebar now records the target position of smooth reveal scrolls. Pending reveals expire after one second and remain active while the current position differs from the target by more than one pixel. Scroll-anchor restoration pauses during active settling. Worktree and sidebar-row reveal effects pass the tracking callback. Tests cover target reporting, visible elements, arrival tolerance, missing state, and timeout expiration. 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
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. Comment |
Co-authored-by: Orca <[email protected]>
ELI5
The "Reveal active workspace" button (the crosshair at the bottom of the sidebar) starts a smooth scroll toward your active workspace. Another piece of sidebar code writes the scroll position a couple of frames later, and in a browser that instantly cancels an in-flight smooth scroll. So the list nudged a few pixels and stopped — you had to click the button 3-5 times to actually get there.
What Changed
revealElementInScrollContainernow reports the scroll target it issues (onScrollIssued).WorktreeListarms a short "reveal scroll in flight" guard from that callback, andshouldSkipScrollAnchorRestorehonours it — so the virtualized scroll-anchor restore stands down until the reveal lands (or 1s passes, or the target is reached).worktree-sidebar-reveal-scroll-settle.tsholds the settle predicate, with unit tests.This is the same idiom the jump-to-top button already uses (
onUserScrollIntent→markDirectScrollInput): a programmatic sidebar scroll must announce itself so the scroll-position guards don't fight it. The reveal path never did.Why
Reproduced in a dev build against real data (312 workspaces), with the active workspace mounted just below the fold — the reported case (
nwparker/orca-lost-new-moon).Sidebar
scrollTopafter each click of the button, starting from the top of the list:Instrumenting writes to the container's
scrollTopduring one click showed the exact collision:The restore fires two frames in, at
scrollTop: 2, pins the anchored row back, and the animation dies at 13px. After the fix the same trace shows zero competing writes and the scroll completes.The far-offscreen path (target outside the virtual window →
scrollToIndex+ retry frames) was never affected because it retries; only the "already mounted, just scroll to it" path clears the pending reveal immediately after issuing the scroll, so it had no second chance.Linked Issue
No issue filed — reported directly by @nwparker against the prod release.
Visual Proof
After the fix, one click from the top of the sidebar reveals and highlights
nwparker/orca-lost-new-moon(screenshot captured from the running Electron app via CDP). Before the fix the identical action moved the list 13px and the card stayed offscreen — see the scroll-position table above, which is the same evidence in a form that survives a screenshot diff.How to test
Also worth exercising: reveal a workspace that is far offscreen (thousands of px away) and reveal a sidebar row via cmd-palette/"reveal in sidebar" — both still land in one action.
Tested on macOS (Electron dev build, real profile with 312 workspaces). The change is renderer-only DOM scroll bookkeeping — no platform, path, shortcut, SSH, or remote-wire surface is touched, so behavior is identical on Linux/Windows and for remote/folder workspaces.
worktree-sidebar-reveal-scroll-settle.test.ts(settle predicate: in-flight, arrived, sub-pixel landing, timeout escape hatch) andworktree-sidebar-reveal.test.ts(the reveal reports the target it scrolls to, and reports nothing when the element is already in view). The frame-level race itself can't be unit-tested — jsdom has no smooth scrolling — so the browser-level proof is the trace above.pnpm vitestovercomponents/sidebar+hooks: 303 files / 2771 tests pass.tsc -p config/tsconfig.tc.web.jsonandoxlintclean.AI Disclosure
N/A (internal).
Review
Ensure no issues in: Security, Cross-platform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance
onScrollIssuedis optional; the third caller (WorktreeCardAgents, instant scroll) is untouched.Checklist
Made with Orca 🐋