Skip to content

fix(sidebar): keep group headers visible when measured rows grow - #20883

Merged
nwparker merged 1 commit into
stablyai:mainfrom
kiendle:kiendle/sidebar-group-disappearing
Sep 19, 2026
Merged

nwparker merged 1 commit into
stablyai:mainfrom
kiendle:kiendle/sidebar-group-disappearing

Conversation

@kiendle

@kiendle kiendle commented Sep 15, 2026 •

Copy link
Copy Markdown
Contributor

ELI5

A card growing lower in the sidebar could make the sidebar act as though it had scrolled, even when the whole list still fit on screen. That could pin LaunchStack over the collapsed Research gang header and leave an empty slot underneath. This change keeps the existing scroll protections while preventing that incorrect movement.

What Changed

  • Restore TanStack's position-aware measurement policy underneath Orca's existing suppression gate: first measurements may adjust when their start is above the anchor; remeasurements may adjust only when their previous end is at or above the anchor and the direction is not backward.
  • Use the virtualizer's current offset plus pending adjustments and its existing measurement cache. No new state, reconciliation loop, listeners, timers, or fetches.
  • Add fold-boundary and direction regressions while retaining the existing suppression and pending-reveal tests.
  • Add a real hidden-Electron regression using three temporary Git repositories and one collapsed group. Grow an existing lower card through the DOM, let ResizeObserver run, and assert that the group remains hit-testable and the header gaps stay unchanged.

Why

The custom shouldAdjustScrollPositionOnItemSizeChange callback replaced TanStack's spatial rule with only a time/scrolling gate. A +50px measurement below the anchor could therefore request scroll offset 50 while the non-scrollable DOM remained at 0. Sticky-header selection then trusted the virtualizer's optimistic offset and covered the group with the next project header.

This fixes that producer rather than hiding the sticky header or changing catalog data. The existing 500ms user-scroll grace, 300ms agent-expansion suppression, asynchronous virtualizer updates, anchor/reveal behavior, and overscan remain unchanged. It does not add a generic repair for every possible offset mismatch.

Linked Issue

Fixes #18667.

Related: #18662 independently proposed the same position guard together with a broader offset-reconciliation layer. This PR keeps the primary guard narrow and supplies an actual rendered red/green reproduction. This is a different mechanism from the duplicate-group insertion race fixed in #19170; it does not claim to solve every disappearing-sidebar report.

Visual Proof

Same hidden Electron scenario, viewport, repositories, and +50px lower-card growth. Both images are captured after the growth: the left uses the original callback, the right uses the fixed callback. The diagnostic DOM growth exercises the real ResizeObserver/virtualizer path; it does not measure how frequently production content triggers the bug.

Before fix After fix
Before: Research gang is covered by LaunchStack, with an empty header slot below After: Research gang remains visible and project headers remain evenly spaced

Images uploaded with gh image; no screenshot binaries are committed.

Testing

  • I manually tested these changes locally through hidden Electron automation and inspected the captures.
  • Automated tests added/updated.

Observed on macOS arm64. All app/test launches used ORCA_BACKGROUND_LAUNCH=1; no test window was revealed or focused.

Passing

  • Policy red/green: four new policy assertions fail with the original callback; the completed scroll-adjustment.test.ts passes all 23 tests.
  • pnpm exec vitest run --config config/vitest.config.ts src/renderer/src/components/sidebar src/renderer/src/hooks/useVirtualizedScrollAnchor src/renderer/src/store/slices/repos-project-group-create-race.test.ts — 307 files / 2,608 tests passed.
  • Hidden Electron: the new regression fails before the fix at the obscured-group assertion and passes after the fix. Running it with the two existing project-group-creation-visibility.spec.ts scenarios gives 3 passed.
  • pnpm lint, pnpm typecheck, and full pnpm build passed. E2E builds passed for both original and fixed implementations.
  • After fetching the required v1.4.190 baseline tag, both previously blocked cross-version unit files passed: 20 tests.

Full-suite results and limitations — not an all-green claim

  • pnpm test --maxWorkers=4 completed: 8,748 files passed, 5 failed, 63 skipped. Two failed files were the missing-tag cross-version prerequisite and passed on the rerun above.
  • The other observed failures are outside the changed sidebar code: four live-Claude tests refused the selected account as unauthenticated; one existing shell-recipe test failed on macOS Bash 3.2 when expanding an empty array under set -u. These tests were not weakened or excluded to manufacture a green result.
  • The separate repository-wide pnpm typecheck:e2e reports diagnostics in untouched E2E specs; it reports none in the changed files.
  • Rendered Windows/Linux, live SSH, mobile, and a full E2E-suite run are not claimed as locally verified. CI results are recorded separately.

CI status for 102df83e688b489195cc38875ce258e2f4b604af: PR Checks and PR test LoC require maintainer approval (action_required; no jobs ran). This contributor has read-only upstream access and cannot approve those runs. The separate Pullfrog review is in progress. An explicit fork E2E dispatch was also unavailable (workflow API returned 404), so no full E2E result is claimed.

Reproduce the rendered check with:

ORCA_BACKGROUND_LAUNCH=1 pnpm run test:e2e tests/e2e/sidebar-measured-row-scroll.spec.ts tests/e2e/project-group-creation-visibility.spec.ts --workers=1

AI Disclosure

AI-assisted investigation, implementation, tests, and review with OpenAI Codex (GPT-6 Astra).

Review

  • Cross-platform: production changes are platform-neutral geometry/cache reads. No shortcuts, paths, native APIs, or platform branches changed. Fixture Git commands use the existing bounded cross-platform process runner and temporary paths.
  • Local / SSH / remote: no execution, status, catalog, RPC, or host-ownership behavior changed; the same renderer measurement policy applies to rows regardless of their execution host. Live SSH latency/disconnect behavior was not exercised.
  • Agents / integrations / providers / folder workspaces: no agent-specific or Git-provider-specific behavior added. The policy does not assume that a row represents a Git worktree rather than a folder workspace.
  • Performance: one existing-cache lookup and constant-time numeric comparisons per resize decision; no polling, extra rendering state, or unbounded work.
  • UI quality: actual before/after hit-testing and gap assertions defend against an obscured header, not merely its presence in the DOM. No colors, typography, controls, or layout styling changed.
  • Security / compatibility: no credentials, dependencies, persistence formats, IPC/wire contracts, or mobile-facing APIs changed. No new security boundary or migration.

Agent skill upstream boundary

  • Not applicable: no agent skill or installer changes.

Notes

No version bump, release changes, screenshot files, or diagnostic production hooks. No documentation/configuration migration is needed for this restored behavior.

Author

GitHub: @kiendle. X/Twitter handle: not provided; none listed on the GitHub profile.

Checklist

  • This PR is small and focused
  • I explained what changed and why (including ELI5)
  • 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 (full-suite exceptions disclosed above; upstream CI awaits maintainer approval)

@coderabbitai

coderabbitai Bot commented Sep 15, 2026 •

Copy link
Copy Markdown
Contributor

Review Change StackReview 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: 39777510-1aa4-4237-9b27-f5715a286166

📥 Commits

Reviewing files that changed from the base of the PR and between 60d7939 and 102df83.

📒 Files selected for processing (4)
  • src/renderer/src/components/sidebar/worktree-list/viewport/scroll-adjustment.test.ts
  • src/renderer/src/components/sidebar/worktree-list/viewport/use-scroll-suppression.ts
  • src/renderer/src/components/sidebar/worktree-list/viewport/use-virtualizer.ts
  • tests/e2e/sidebar-measured-row-scroll.spec.ts

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


📝 Walkthrough

Walkthrough

The scroll-adjustment predicate now considers item bounds, scroll offset, first-measurement state, and scroll direction. The virtualizer passes these values for resized items. Unit tests cover anchor and scrolling cases. A new end-to-end test grows an idle worktree card and verifies that collapsed project-group geometry and scroll position remain unchanged.

Priority: ➖ Normal

Severity of issue fixed: Medium

Merge Risk: ⚪ Minimal · up to 102df

The sidebar measurement change includes coverage for the reported non-scrollable layout regression and its geometry remains stable after card growth. No current merge-blocking risk was identified.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 4 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Issue #18667 requires correct header order, no gap, a visible first project, and no obscuring after a lower card grows in a non-scrollable list. The virtualizer now passes item bounds, the effective s…
Out of Scope Changes check ✅ Passed The changes are limited to measured-row scroll-adjustment policy, its virtualizer integration, focused unit tests, and a regression test for the sidebar scenario in issue #18667. The new end-to-end fi…
Title check ✅ Passed The title clearly and concisely describes the primary change: keeping sidebar group headers visible when measured rows grow.
Description check ✅ Passed The description includes all required sections, explains the problem and implementation, links issue #18667, provides visual proof, documents testing and limitations, and addresses compatibility and p…
  • Fix all pre-merge checks with AI

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.

@pullfrog pullfrog 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.

✅ No new issues found.

Reviewed changes

  • Restored TanStack's fold rule in the measurement predicate — shouldAdjustWorktreeSidebarMeasuredRowScroll now adjusts a first measurement only when its start is above the anchor, and a remeasurement only when its end is at or above the anchor and the direction is not backward. This matches @tanstack/[email protected]'s resizeItem default, verified against the installed package source; the wall-clock/is-scrolling suppression gate is preserved in front of it.
  • Passed geometry into the predicate from the virtualizer — use-virtualizer.ts supplies item.start/item.end, scrollOffset (instance.scrollOffset ?? scrollOffsetRef.current plus scrollAdjustments), isFirstMeasurement from itemSizeCache, and scrollDirection. All of these are public on the Virtualizer type and align with the library's internal scrollOffsetWithAdj/isFirstMeasure computation.
  • Added pure policy tests — scroll-adjustment.test.ts pins the below-anchor, spanning, boundary, first-measurement, and backward-direction branches beside the existing suppression cases.
  • Added a rendered Electron regression — sidebar-measured-row-scroll.spec.ts grows a lower card through the DOM in an unscrollable three-repo sidebar and asserts the collapsed group stays hit-testable with unchanged header gaps, so it fails on the obscured-group assertion rather than merely checking DOM presence.

I traced the changed predicate against the TanStack default and confirmed the new logic is a strict narrowing of the previous behavior — below-anchor growth is now rejected while suppression, anchor/reveal, and expanding-card paths are unchanged. The new signature has only one production caller (updated) and one test caller (updated), so no stale call sites remain.

Pullfrog  | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

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.

Sidebar: collapsed project leaves a gap and headers jump/pin over the first row (Recent order, unscrollable list)

2 participants