Skip to content

fix(sidebar): keep project headers from overlapping the pinned host - #26775

Merged
AmethystLiang merged 1 commit into
mainfrom
AmethystLiang/fix-title-overlap
Oct 9, 2026
Merged

AmethystLiang merged 1 commit into
mainfrom
AmethystLiang/fix-title-overlap

Conversation

@AmethystLiang

@AmethystLiang AmethystLiang commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​78 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​78
Prod 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​14 $\color{#cf222e}{\Huge{\mathbf{−}}}$​5 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​9

ELI5

In the Projects sidebar with more than one host, the host card and the project headers below it stay pinned to the top while you scroll. The code that decides when the next project header takes over made two mistakes: it treated the host card as 32px tall when it really occupies 36px, and it chose which header to pin from a scroll position that trails the real one by a frame. Either mistake can pin a project header at the same moment its normal in-flow copy is still on screen, so two headers sit on top of each other. This makes the host row count as its true 36px and decides the handoff from where each row actually sits.

What Changed

Before: estimateRenderRowSize sized a host row at 32px, while the pinned host slot is 36px (the card is h-8 inside pt-1). The group tier's handoff test (scrollOffset + 36 >= candidate.start) therefore fired 4px early, and the pinned candidate was picked only from the virtualizer's rangeStartIndex, which lags the real scroll position. A project header could be pinned while its in-flow row was still laid out below.

After: the host row is measured at 36px, matching the pinned slot, and getActiveStickyIndexesForScroll picks the candidate whose row has actually reached the slot (virtualItems.get(index).start <= scrollOffset + pinnedOffset) in addition to the one the range start points at. A header is pinned exactly when it reaches the slot.

Why

The mismatch between the measured host row (32px) and the pinned slot (36px) is the direct cause of the overlap: the handoff math runs 4px ahead of the painted layout. Reading each candidate's real start from the mounted virtual items also removes the one-frame lag between rangeStartIndex and the scroll position, so the correct header is selected without waiting for the range extractor to catch up. The alternative — resyncing only on scroll events — misses the reported case, because the overlap appears without a scroll (e.g. expanding/collapsing a group) and a list too short to scroll may never emit one.

Linked Issue

Fixes #12532
Fixes #18820

#12532's report derives this exact fix from the shipped bundle: the group tier's pinnedOffset is a constant 36 while the host header it offsets past is estimated at 32px, so the group activates 4px early and two headers land on one coordinate. #18820 is the same double-render symptom (a header painted once pinned and once in flow).

Same defect family / related (not closed by this PR):

Visual Proof

Pending — this is a virtualizer layout change visible only with a multi-host sidebar and project groups collapsing/expanding. Before/after screenshots or a short video still need to be captured in a multi-host session.

Testing

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

virtual-rows.test.ts covers the handoff at the host slot, the first project pinning while the range still starts at the host, selection across several collapsed groups, lagging-range host transitions, and the host row height. Ran: focused Vitest (24 pass), pnpm tc:web, and pnpm run check:code-quality:changed.

Platforms: unit tests only so far. No app run; multi-host visual QA is outstanding.

Notes

  • Security: none.
  • Cross-platform: renderer-only layout/measurement; no platform-specific code, paths, or shortcuts.
  • SSH/remote: this is specifically the multi-host host-section path, which SSH/remote hosts use; the logic is keyed by row index/offset, not host kind.
  • Mobile: unaffected.
  • Backwards compatibility: no wire, persistence, or host-matching changes.
  • Performance: adds one Map build per sticky resolution over the already-iterated mounted virtual items; negligible.

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.

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)

The host header lays out as a 32px card in 4px top padding (36px), but
estimateRenderRowSize sized the row at 32px. The group tier's 36px pin
offset then fired 4px early, so a project header could pin while its
in-flow copy was still on screen — two headers at one coordinate.

Size the host row 36px so it matches the pinned slot, and resolve each
sticky handoff from the row's real start offset instead of only the
lagging range start, so a header pins exactly when it reaches the slot.
@coderabbitai

coderabbitai Bot commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 076ab613-c3e8-4887-b5a0-c2fad2dd89fe
📥 Commits

Reviewing files that changed from the base of the PR and between f01bd93 and 9f43a8c.

📒 Files selected for processing (2)
  • src/renderer/src/components/sidebar/worktree-list/viewport/virtual-rows.test.ts
  • src/renderer/src/components/sidebar/worktree-list/viewport/virtual-rows.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.


📝 Walkthrough

Walkthrough

The host header row height changes from 32 to 36 pixels, and the pinned host height uses that constant. Sticky-header selection now considers both the virtual range start and mounted row positions relative to the scroll offset and pinned slot. Tests cover group-header transitions, delayed virtual ranges, and host-row height estimates.

Priority: ➖ Normal

Severity of issue fixed: Medium

Merge Risk: ⚪ Minimal · up to 9f43a

This fixes sidebar project headers overlapping the pinned host by matching the host row height to the pinned slot and improving sticky-header selection. No merge-blocking risk was found; manual multi-host visual checks are still worth doing.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check Passed The title clearly and concisely describes the main fix: preventing project headers from overlapping the pinned host.
Description check Passed The description is detailed, on-topic, and covers the required explanation, changes, rationale, linked issues, testing, scope, and checklist items. It clearly states that visual proof and manual multi…
Linked Issues check Passed The changes address both direct issues [#12532, #18820]. HOST_HEADER_ROW_HEIGHT is 36px, and HOST_STICKY_PINNED_HEIGHT uses that value. Sticky selection now uses mounted row positions and the pinn…
Out of Scope Changes check Passed The pull request changes only virtual-row sizing, sticky-header resolution, and focused tests in the sidebar worktree-list viewport. The tests directly support the linked overlap fixes. No unrelated p…
Docstring Coverage Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 2 files.
✨ Finishing Touches
📝 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant