Skip to content

Stop restyling the whole right panel on every resize frame - #6511

Merged
ymichael merged 1 commit into
mainfrom
bb/optimize-right-panel-resize-performance-thr_x8v94e5p39
Oct 29, 2026
Merged

ymichael merged 1 commit into
mainfrom
bb/optimize-right-panel-resize-performance-thr_x8v94e5p39

Conversation

@ymichael

Copy link
Copy Markdown
Collaborator

Human comments

What was wrong

On every drag frame, useSecondaryPanelResize set the inherited custom property --secondary-swipe-width on the right panel's <aside>. Because descendants inherit custom properties, each write made Chrome recompute styles for the whole panel subtree: about 535 elements, about 15ms per frame. The right-panel drag ran at 30fps, while the sidebar drag, which has no per-frame write like this, stayed at 60fps. While resizing, the aside never reads that variable; it is anchored with right-0.

What changed

  • apps/app/src/components/secondary-panel/useSecondaryPanelResize.ts: onResize no longer writes --secondary-swipe-width while a pointer drag is active. On release, onDragging(false) writes the final width once, before isSecondaryPanelResizing clears, so the aside switches back to the variable at the correct width. Opening, closing, double-click reset, and other non-drag layout changes still write the variable right away.

How you verified

  • New test in useSecondaryPanelResize.test.tsx: it drags a real PanelGroup handle and checks that the variable stays put mid-drag and holds the final width after release. It fails on the old code and passes now.
  • pnpm exec turbo run test typecheck lint --filter=@bb/app passes.
  • A/B profile on a real thread with the Info tab open: the main build against this branch's build, served through a dist proxy to the same server, three drag runs each.
Right-panel drag Before After
Style recalculation 1,566–1,631ms 64–76ms
p90 frame 33.3ms 16.7ms
Main-thread idle ~170ms ~1,250ms
  • Checked by hand: the panel contents track the panel edge during the drag and after release, and the width survives a reload.

AGENT GENERATED

🤖 Generated with Claude Code

Dragging the right-panel divider wrote the inherited --secondary-swipe-width
custom property onto the panel's aside every frame. Chrome restyled all ~535
descendants each time (~15ms per frame), so the drag ran at 30fps while the
sidebar drag stayed at 60fps. The aside ignores that variable while resizing,
so write it once on release instead.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@ymichael
ymichael merged commit 2f5abff into main Oct 29, 2026
30 checks passed
@ymichael
ymichael deleted the bb/optimize-right-panel-resize-performance-thr_x8v94e5p39 branch October 29, 2026 03:03
mistakeknot added a commit to mistakeknot/aleph that referenced this pull request Nov 3, 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