Skip to content

fix(bots): attach the bot sidebar virtualizer when the list and rows mount together - #51470

Merged
nwparker merged 1 commit into
stablyai:mainfrom
nkmryu:fix/bots-sidebar-rows-after-reopen
Nov 28, 2026
Merged

nwparker merged 1 commit into
stablyai:mainfrom
nkmryu:fix/bots-sidebar-rows-after-reopen

Conversation

@nkmryu

@nkmryu nkmryu commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

ELI5

After you closed and reopened the sidebar, the Bots list sometimes drew only the first few bots and left the rest of the space blank until you clicked something. The list tried to measure its container before the container was hooked up, decided it was one row tall, and never checked again. Now the list finds its container by itself, so every bot that fits is drawn right away.

What Changed

Before: Reopening the sidebar drew only Bot 0 to Bot 6 in the Bots section and left the rest blank. Clicking a bot made the missing rows appear. Revealing a row (rename or a search pick) right after reopening did not scroll to it.

After: Every row that fits is drawn as soon as the sidebar opens, and reveals work on the first commit.

Mechanism: rowsMounted follows sidebarOpen, so reopening (and the first lazy mount when bots are already loaded) mounts the list <div> and BotSidebarVirtualRows in one commit. React attaches a parent host's ref only after its children's layout effects run, so when TanStack's _willUpdate layout effect read getScrollElement() (listRef.current), it got null. The virtualizer had no scroll element and no ResizeObserver, kept its 48px initialRect, and drew 1 row plus overscan: 6. Rows measured exactly the 48px estimate, so resizeItem saw no change and nothing re-rendered. The botSidebarVirtualScrollers registration effect also saw null and never re-ran, so reveal had no scroller.

  • BotSidebarVirtualRows puts a ref on its own rows wrapper and finds the list with closest('[data-bot-sidebar-list]'). A component's own host refs are attached before its layout effects, and the wrapper is already inside the list, so the scroller is found on the first commit. This lookup feeds both getScrollElement and the scroller registration.
  • The listRef prop is removed. SidebarBotsSection stops passing it (it still uses listRef for its own layout effects, which run after its ref attaches).
  • The fixture gains a mountedWithList case that mounts the list and rows in one commit. The existing fixture mounts rows one commit after the list, which is why it never caught this.

Why

Keeping the ref and forcing a second render once it attaches (or moving the list element into state) would add a render on every mount and track the same element in two places. Looking the list up from the rows' own DOM adds no render, and [data-bot-sidebar-list] is already how reveal-bot-sidebar-row.ts and use-bot-search-viewport.ts find this list.

Linked Issue

Fixes #51464

Visual Proof

Component fixture rendered in headless Chromium, list and rows mounted in one commit (400px list, 48px rows).

Before (main) After (this PR)
before: only Bot 0 to Bot 6 drawn, blank below after: reveal of Bot 150 scrolls and focuses it, list full

Before: 7 rows, blank below, reveal does nothing. After: list full, reveal of Bot 150 scrolls there and focuses it.

New mountedWithList fixture on this PR (all 9 visible rows drawn):

after: mountedWithList fixture shows Bot 0 to Bot 8

Testing

  • Reproduced with the mountedWithList fixture (pnpm fixtures:shot bots/BotSidebarVirtualRows): main draws Bot 0 to Bot 6 and "Show list and reveal Bot 9" leaves scrollTop at 0; this PR fills the list and reveal scrolls to Bot 9 (scrollTop 80) and focuses it.

  • N=200 one-commit mount: main 7 rows and reveal of Bot 150 does nothing; this PR 15 rows, reveal sets scrollTop 7200 and focuses "Bot 150", and scrolling renders new rows.

  • Instrumenting the real SidebarBotsSection on main confirmed the first commit on reopen sees a null listRef.

  • growingRow, revealAfterHiddenShrink and the other regression fixture shots are byte-identical between main and this PR.

  • vitest on components/bots/, lib/list-interaction/ and sidebar/worktree-list/viewport/: 66 files, 345 tests pass.

  • oxlint, oxfmt, anti-slop oxlint, native code-quality oxlint, ast-grep and the changed-code quality gate: 0 findings.

  • Platform: macOS, headless Chromium via the component fixture. Pure DOM change, nothing platform-specific.

  • I manually tested these changes locally (component fixture in headless Chromium)

  • Automated tests added/updated, or explained why not below

  • Every added test fails without this change and avoids the test anti-patterns

No unit test added: this is UI rendering behavior, which AGENTS.md asks to verify by running it. The mountedWithList fixture keeps the repro.

Performance

None measurable. Renderer only, on the Bots section mount/reopen path:

  • getScrollElement does one closest() walk (about 40 ns, vs about 3 ns for a ref read) per virtualizer update, not per row.
  • N=200 one-commit mount: 2 renders and 22 renderEntry calls, the same as main's healthy path (rows mounting after the list). N=2000 gives the same counts, so the work does not grow with the number of bots.
  • No store selectors, subscriptions, caches, polling, I/O or IPC changed, so one bot's update cannot fan out to the others.

Risk

The riskiest part is the scroller lookup: if the rows were ever rendered outside a [data-bot-sidebar-list] element, the virtualizer would have no scroller and fall back to a one-row window. The only callers (SidebarBotsSection and its fixture) render it directly inside that element, which reveal and search already rely on. Renderer only, no saved data, no SSH or paired-phone surface. Back out with a plain revert.

Level: Low

Review

  • Cross-platform: renderer DOM only.
  • SSH/remote and mobile: no change.
  • Performance: no extra renders, one closest() per virtualizer update.
  • Security: no change.

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.

Notes

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

Original fix by @nkmryu in #51470

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)
  • I stated the risk: what could break, for whom, and how to back it out
  • 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)

@coderabbitai

coderabbitai Bot commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

BotSidebarVirtualRows finds the enclosing sidebar list from its rendered rows container. It uses that element for virtualizer scrolling and scroll registration. SidebarBotsSection and the fixture no longer pass a listRef. The fixture adds a mountedWithList case with ten rows.

Severity of issue fixed: Medium

Merge Risk: Minimal · up to e7101

This change makes the Bots sidebar draw all rows that fit when it reopens, and lets row reveals work on the first render. I found no concrete regression. It was checked only through the fixture, not in the Electron app.

Pre-merge checks: Passed 4

Check name Status Explanation
Linked Issues check Passed Issue #51464 requires that all bot rows that fit render when the Bots sidebar opens, without a bot click. At the reviewed head, BotSidebarVirtualRows.tsx resolves its scroll element with getList(), wh…
Out of Scope Changes check Passed The whole-PR changes stay in the bots sidebar rendering path. BotSidebarVirtualRows.tsx replaces the listRef prop with an internal rowsRef and a closest() lookup, and updates the effect dependency lis…
Title check Passed The title names the actual fix: the bot sidebar virtualizer now attaches when the list and its rows mount in the same commit. It matches the changeset, which removes the listRef prop and finds the scr…
Description check Passed The description follows the repository template and covers every required section. It gives a plain-language ELI5 and a before/after account of the user-visible behavior. It explains the mechanism (re…
Full details: Linked Issues check

Explanation

Issue #51464 requires that all bot rows that fit render when the Bots sidebar opens, without a bot click. At the reviewed head, BotSidebarVirtualRows.tsx resolves its scroll element with getList(), which calls rowsRef.current?.closest('[data-bot-sidebar-list]'). The rows wrapper div (ref={rowsRef}) sits inside the list element that carries data-bot-sidebar-list, so the lookup does not depend on the list's ref attaching first. getList feeds the virtualizer getScrollElement, the layout effect that registers botSidebarVirtualScrollers, and the reveal path. The listRef prop is removed from the component. The mountedWithList fixture case mounts the list and rows in one commit, which matches the reopen order in the issue. The incremental diff from the previous reviewed head could not be read, so this verdict rests on the whole-PR code at head. I did not run the fixture or the Electron app. The PASS relies on static code evidence and the author's reported fixture results. The issue's suspected cause is a hypothesis, and the PR mechanism (layout effects run before the parent ref attaches) is consistent with the reported one-row initialRect behavior.

Full details: Out of Scope Changes check

Explanation

The whole-PR changes stay in the bots sidebar rendering path. BotSidebarVirtualRows.tsx replaces the listRef prop with an internal rowsRef and a closest() lookup, and updates the effect dependency list. It also updates the RefObject import to match. SidebarBotsSection.tsx drops the single listRef prop pass-through. BotSidebarVirtualRows.fixture.tsx adds a mountWithList flag and a mountedWithList case, which supports the reproduction and is test-only. No unrelated files or behavior changes appear in the reviewed summaries or the inspected diff. The incremental diff from the previous reviewed head was unavailable, so changes between the previous head and the current head were checked only through the whole-PR code and summaries.

Full details: Title check

Explanation

The title names the actual fix: the bot sidebar virtualizer now attaches when the list and its rows mount in the same commit. It matches the changeset, which removes the listRef prop and finds the scroll container from the rows wrapper, and adds a mountedWithList fixture. The conventional-commit prefix and scope are accurate, and the title is 83 characters, slightly long but readable.

Full details: Description check

Explanation

The description follows the repository template and covers every required section. It gives a plain-language ELI5 and a before/after account of the user-visible behavior. It explains the mechanism (ref attachment order versus layout effects) and why the chosen approach beats the alternatives. It links the issue (Fixes #51464), includes before/after visual proof, lists testing steps and results, states a performance rationale, and gives a risk level with a revert path. The AI Disclosure section is left blank, which is acceptable for an internal contributor. The Visual Proof images are hosted links, and the Review section is brief but complete.

  • 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

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 9e26ce84-22c0-485c-85eb-bb381dc17b61
Commits

Reviewing files that changed from the base of the PR and between 9f0576f and e710147.

Files selected for processing: 1

  • src/renderer/src/components/bots/BotSidebarVirtualRows.tsx

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

…mount together

Closing the sidebar unmounts the Bots section, so reopening it mounts the
list and its virtual rows in one commit. React attaches the list's ref
after the rows' layout effects, so the virtualizer found no scroll element,
kept its one-row initialRect and drew that row plus the overscan of 6. With
every row at the 48px estimate nothing re-rendered it until another update,
such as a bot click. A reveal on that first commit also did nothing, since
the rows' scroller was never registered.

Find the list from the rows' own element, which is in the DOM by then,
instead of from the list's ref. The fixture adds the reopen case.

Fixes stablyai#51464

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@nwparker
nwparker force-pushed the fix/bots-sidebar-rows-after-reopen branch from 9f0576f to e710147 Compare November 28, 2026 05:52
@nwparker nwparker changed the title fix(bots): draw every bot row when the sidebar reopens fix(bots): attach the bot sidebar virtualizer when the list and rows mount together Nov 28, 2026
@nwparker
nwparker merged commit 6d56bbe into stablyai:main Nov 28, 2026
55 of 56 checks passed
@nkmryu
nkmryu deleted the fix/bots-sidebar-rows-after-reopen branch November 28, 2026 06:18
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.

[Bug]: Bots sidebar draws only the first 6 bots until a bot is clicked

2 participants