Skip to content

Fix reveal active workspace needing multiple clicks - #13926

Merged
nwparker merged 1 commit into
mainfrom
nwparker/reveal-active-workspace-button
Aug 12, 2026
Merged

nwparker merged 1 commit into
mainfrom
nwparker/reveal-active-workspace-button

Conversation

@nwparker

@nwparker nwparker commented Aug 12, 2026 •

Copy link
Copy Markdown
Contributor

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

  • revealElementInScrollContainer now reports the scroll target it issues (onScrollIssued).
  • WorktreeList arms a short "reveal scroll in flight" guard from that callback, and shouldSkipScrollAnchorRestore honours it — so the virtualized scroll-anchor restore stands down until the reveal lands (or 1s passes, or the target is reached).
  • New pure module worktree-sidebar-reveal-scroll-settle.ts holds 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 scrollTop after each click of the button, starting from the top of the list:

click 1 click 2 click 3 click 4 click 5
before 13 38 90 322 387 ✅
after 387 ✅ 387 387 387 387

Instrumenting writes to the container's scrollTop during one click showed the exact collision:

scrollTo {top: 387, behavior: "smooth"}   at revealElementInScrollContainer  (from 0)
set 4                                     at restoreFromDomElement <- runVirtualizedScrollAnchorRestore  (from 2)

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

  1. Open a workspace whose sidebar card sits a few hundred pixels below the fold (a long list makes this easy).
  2. Scroll the left sidebar to the very top.
  3. Click "Reveal active workspace" (crosshair, bottom-right of the sidebar) once.
  4. The active card scrolls into view and flashes on the first click. Repeat clicks are a no-op instead of creeping down a few pixels at a time.

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.

  • I manually tested these changes locally
  • Automated tests added/updated, or explained why not below

worktree-sidebar-reveal-scroll-settle.test.ts (settle predicate: in-flight, arrived, sub-pixel landing, timeout escape hatch) and worktree-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 vitest over components/sidebar + hooks: 303 files / 2771 tests pass. tsc -p config/tsconfig.tc.web.json and oxlint clean.

AI Disclosure

N/A (internal).

Review

Ensure no issues in: Security, Cross-platform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance

  • Security: none — no IPC, no data flow.
  • Cross-platform: renderer-only scroll math, no platform branches.
  • Remote SSH / folder workspaces: the reveal path is workspace-kind agnostic; unchanged.
  • Performance: one ref write per reveal scroll and a comparison inside an existing guard callback.
  • Backwards compatibility: onScrollIssued is optional; the third caller (WorktreeCardAgents, instant scroll) is untouched.

Checklist

  • This PR is small and focused
  • I explained what changed and why (including ELI5)
  • Before/after evidence attached for the behavior change
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered
  • Lint, typecheck, and the affected test suites pass locally

Made with Orca 🐋

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]>
@coderabbitai

coderabbitai Bot commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: df33d605-7e3a-4bdb-94a5-92ad664cae73

📥 Commits

Reviewing files that changed from the base of the PR and between 64aec94 and e63de5b.

📒 Files selected for processing (5)
  • src/renderer/src/components/sidebar/WorktreeList.tsx
  • src/renderer/src/components/sidebar/worktree-sidebar-reveal-scroll-settle.test.ts
  • src/renderer/src/components/sidebar/worktree-sidebar-reveal-scroll-settle.ts
  • src/renderer/src/components/sidebar/worktree-sidebar-reveal.test.ts
  • src/renderer/src/components/sidebar/worktree-sidebar-reveal.ts

📝 Walkthrough

Walkthrough

The 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)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description is detailed, but it omits the required linked issue and the required before-and-after visual attachment for this UI behavior change. Add a valid linked issue and attach explicit before-and-after screenshots or a video; the current table and narrative do not satisfy these required fields.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the main change: fixing the Reveal active workspace action so it no longer requires multiple clicks.
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.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch

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.

@nwparker
nwparker merged commit 0079623 into main Aug 12, 2026
45 checks passed
@nwparker
nwparker deleted the nwparker/reveal-active-workspace-button branch August 12, 2026 05:10
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 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