Skip to content

fix(sidebar): do not sticky-pin Project header without mounted geometry - #10090

Merged
nwparker merged 1 commit into
stablyai:mainfrom
innocarpe:fix/sidebar-sticky-project-host-overlap
Jul 24, 2026
Merged

nwparker merged 1 commit into
stablyai:mainfrom
innocarpe:fix/sidebar-sticky-project-host-overlap

Conversation

@innocarpe

@innocarpe innocarpe commented Jul 23, 2026 •

Copy link
Copy Markdown
Contributor

fix(sidebar): do not sticky-pin Project header without mounted geometry

Summary

Fixes the multi-host Projects sidebar painting a project-group sticky header over the host card when revealing or scrolling to a workspace (#10088).

ELI5

In the sidebar, jumping to a project under a host could make the project's name label overlap and cover the host's card. This makes the sticky labels stay in the right place while you scroll.

Root cause & fix

getActiveStickyIndexesForScroll → resolveWithHandoff returned the candidate sticky header index even when that virtual row wasn't mounted yet — which happens when scrollToIndex/reveal advances rangeStartIndex before TanStack mounts the row. A Project sticky then activated without any geometry while the Host sticky was still active. The fix now prefers a previously-mounted sticky header when the candidate is unmounted, and only falls back to the raw candidate when fallbackToCandidate is true (host tier). The group tier (fallbackToCandidate=false) returns null instead of pinning without geometry.

Evidence

Validated & rebased onto latest main during a bug-bash triage on 2026-07-23.

  • Test file: src/renderer/src/components/sidebar/worktree-list-virtual-rows.test.ts
  • On branch: 9/9 passed (1 file). With the fix reverted (test kept): 2 failed | 7 passed, proving the tests catch the regression.
  • Failing assertions when fix reverted:
✗ does not pin a Project header whose virtual item is not mounted yet (#10088)
    AssertionError: expected 5 to be null (groupIndex was 5)
✗ keeps the previous mounted Project sticky when the next group is unmounted
    AssertionError: expected 3 to be 1 (groupIndex was 3, should hold previous)
  • Lint: oxlint clean (no warnings/errors) on the fix file.
  • Rebase: clean onto origin/main.

Trade-offs

None — pure fix. Host tier retains its legacy fallback so a re-mounting host section keeps sticky identity.

Regression risk

Effectively zero. Only the branch that handled an unmounted candidate changes; every path with a mounted candidate or a truthy fallbackToCandidate behaves identically. The host tier is byte-for-byte preserved, and the passing test proves both the new group-tier and previous-sticky-hold behaviors.


Original fix by @innocarpe. Validated, rebased, and (where applicable) hardened via automated bug-bash review; original fix design preserved.

@coderabbitai

coderabbitai Bot commented Jul 23, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@nwparker, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 13 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: e4d2c59d-72b6-41b1-a5bf-5709fb9112f1

📥 Commits

Reviewing files that changed from the base of the PR and between 5b7f6499bb2c07077c48428bfeda7bcf823bc494 and 7dfdab9.

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

Walkthrough

Updated sticky-header resolution to prefer a previously mounted header when the computed candidate is not present in the virtual items. Added tests covering unmounted group headers and partially mounted multi-group scenarios, including expected host and group sticky indexes.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description covers summary and evidence, but it omits required template sections like Screenshots, Testing, AI Review Report, Security Audit, and Notes. Add the missing template sections, including screenshots or no-visual-change confirmation, testing checklist status, AI review report, security audit, and notes.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The code and tests address #10088 by preventing project sticky promotion before mounted geometry is available.
Out of Scope Changes check ✅ Passed The changes stay scoped to sticky-header logic and regression tests, with no unrelated subsystems touched.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Title check ✅ Passed The title is specific and matches the main fix to Project sticky-pin behavior in the sidebar.

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 4b105c72-46da-43df-9d85-c389e6979da6

📥 Commits

Reviewing files that changed from the base of the PR and between 1d8ce38 and 5b7f6499bb2c07077c48428bfeda7bcf823bc494.

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

Comment on lines +162 to +168
const previous = getPreviousStickyHeaderIndex(candidates, candidateIndex)
if (previous !== null) {
const previousItem = args.virtualItems.find((item) => item.index === previous)
if (previousItem) {
return previous
}
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Keep mounted-previous fallback scoped to Project groups.

Because host resolution passes fallbackToCandidate: true, this new branch can retain Host A when rangeStartIndex has already advanced to an unmounted Host B. Previously it returned Host B’s candidate ID; this changes the host-tier behavior the PR explicitly intends to preserve.

Proposed fix
   const resolveWithHandoff = (
     candidates: readonly number[],
     pinnedOffset: number,
-    fallbackToCandidate: boolean
+    fallbackToCandidate: boolean,
+    preferMountedPrevious: boolean
   ): number | null => {
...
-    if (!candidate) {
+    if (!candidate && preferMountedPrevious) {
       const previous = getPreviousStickyHeaderIndex(candidates, candidateIndex)
       if (previous !== null) {
         const previousItem = args.virtualItems.find((item) => item.index === previous)
         if (previousItem) {
           return previous
         }
       }
-      return fallbackToCandidate ? candidateIndex : null
     }
+    if (!candidate) return fallbackToCandidate ? candidateIndex : null
...
-  const hostIndex = resolveWithHandoff(hostIndexes, 0, true)
+  const hostIndex = resolveWithHandoff(hostIndexes, 0, true, false)
...
   const groupIndex = resolveWithHandoff(
     groupIndexes,
     hostIndex !== null ? HOST_STICKY_PINNED_HEIGHT : 0,
-    hostIndex === null
+    hostIndex === null,
+    true
   )

Based on PR objectives, “Host-tier fallback behavior remains unchanged.”

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const previous = getPreviousStickyHeaderIndex(candidates, candidateIndex)
if (previous !== null) {
const previousItem = args.virtualItems.find((item) => item.index === previous)
if (previousItem) {
return previous
}
}
const resolveWithHandoff = (
candidates: readonly number[],
pinnedOffset: number,
fallbackToCandidate: boolean,
preferMountedPrevious: boolean
): number | null => {
if (!candidate && preferMountedPrevious) {
const previous = getPreviousStickyHeaderIndex(candidates, candidateIndex)
if (previous !== null) {
const previousItem = args.virtualItems.find((item) => item.index === previous)
if (previousItem) {
return previous
}
}
}
if (!candidate) return fallbackToCandidate ? candidateIndex : null
}
const hostIndex = resolveWithHandoff(hostIndexes, 0, true, false)
const groupIndex = resolveWithHandoff(
groupIndexes,
hostIndex !== null ? HOST_STICKY_PINNED_HEIGHT : 0,
hostIndex === null,
true
)

During scrollToIndex/reveal, rangeStartIndex can advance before TanStack
mounts the candidate Project row. Returning that unmounted index made a
Project sticky paint over the Host card in multi-host views. Prefer a
previous mounted sticky (or none for the group tier) until geometry exists.

Closes stablyai#10088
@nwparker
nwparker force-pushed the fix/sidebar-sticky-project-host-overlap branch from 5b7f649 to 7dfdab9 Compare July 23, 2026 11:49
@nwparker
nwparker merged commit 1f29a33 into stablyai:main Jul 24, 2026
@nwparker

Copy link
Copy Markdown
Contributor

Thanks so much for this, @innocarpe — do not sticky-pin Project header without mounted geometry. Verified (fail-on-main/pass-on-branch), reviewed, and merged. Really appreciate it! 🙏

@AmethystLiang

Copy link
Copy Markdown
Contributor

thanks for reporting. looking into it

enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
…ry (stablyai#10090)

During scrollToIndex/reveal, rangeStartIndex can advance before TanStack
mounts the candidate Project row. Returning that unmounted index made a
Project sticky paint over the Host card in multi-host views. Prefer a
previous mounted sticky (or none for the group tier) until geometry exists.

Closes stablyai#10088
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.

4 participants