Repository navigation
Snap timeline height tweens and trim paint work on phones (C2, F1, D9, C10, F2, E2) - #1880
Merged
Merged
Conversation
SawyerHood
marked this pull request as ready for review
August 19, 2026 08:04
This was referenced Aug 19, 2026
Closed
On a phone the timeline's AutoHeightContainer eased its whole height 180ms
for every streaming delta. Deltas arrive every ~250ms, so the tween ran
continuously; each eased frame re-laid out the timeline and, without CSS
scroll anchoring (WebKit), the bottom-anchored scroller followed it with a
JS scrollTop restore per frame. AnimatedExpandablePanelContent restarted
its own 200ms height tween on every content-growth tick of an open body
without registering with layoutAnimationInFlightCountAtom, so the two
tweens stacked. Every collapsed ExpandablePanel body also pinned a
compositing layer with will-change-transform for the row's lifetime, and
the follow-up composer tweened its height 240ms in the sticky footer as
the soft keyboard and shell resize landed.
- AutoHeightContainer uses duration 0 on a coarse pointer, under reduced
motion, or where CSS.supports("overflow-anchor: none") is false
(new lib/scroll-anchoring-support.ts helper).
- AnimatedExpandablePanelContent eases only an expand/collapse toggle;
growth inside an already-open body snaps.
- Removed the unconditional will-change-transform from collapsed bodies.
- PromptBoxInternal skips the layout height tween on coarse pointer +
compact viewport, like the reduced-motion branch.
Co-Authored-By: Claude <[email protected]>
Three rules restyled or repainted far more of the document than needed:
- `.scroll-bottom-anchor-content *` toggled with isAtBottom (a 4px
threshold that rocks during streaming) and invalidated every timeline
node each time; on WebKit, which has no scroll anchoring, it had no
effect at all. The class now goes on the content wrapper alone (an
excluded element's whole subtree is skipped by anchor selection), the
sentinel moves outside the wrapper, and the class is never applied when
CSS.supports("overflow-anchor: none") is false.
- The shimmer sweep animates background-position / mask-position on the
main thread every frame and repainted the surrounding scroller tile.
`.animate-shine` / `.animate-shine-icon` now promote to their own layer
while present (only on active rows), and pause plus release the layer
under `[inert]` / `[aria-hidden="true"]` hosts (closed sidebar drawer,
collapsed banner bodies, retained overlays).
- `body[data-sidebar-dragging] *` set a cursor on every element in the
document at drag start and end. It is now scoped to the sidebar panel
and to `(pointer: fine)`; a touch drag has no cursor.
Co-Authored-By: Claude <[email protected]>
…ckdrops The page header is a non-overlapping flex sibling above the scroller, so nothing paints behind it; the scroll-to-bottom button stays mounted at opacity 0 over the streaming timeline; each realized drawer/dialog keeps a full-viewport backdrop at opacity 0 for the app's lifetime. A backdrop-filter on any of them adds a compositing pass per frame for no visible gain. Removed the blur classes (the button uses an opaque bg-background fill) and added class-string tests so they do not return. Co-Authored-By: Claude <[email protected]>
…sticky footer from anchoring Review fixes for the css-paint-ios package: - scroll-to-bottom-button: without the backdrop blur, `hover:bg-state-hover` (a translucent ink mix) let timeline text show through the button on hover; use the opaque `hover:bg-accent` step. The hidden button is now `invisible` and stops its shimmer, so an active thread at the bottom no longer repaints an opacity-0 sweep every frame (F2/D9 as written in the audit). - bottom-anchored-scroll-body: the sticky footer lost its `overflow-anchor: none` when the `*` rule went away; give it a static exclusion so anchoring can never pick a footer control once the wrapper is excluded. - Tests for both, prettier on lines this branch introduced. Co-Authored-By: Claude <[email protected]>
Snapping the compact -> expanded height change on coarse-pointer phones (audit D7) left the iOS caret one line above the editor after the first tap: WebKit computed the native caret rect at focus time and, without the per-frame layouts of the tween, never refreshed it. Measured on an iPhone against a build with only this layer; restoring the 240 ms tween fixes it. The timeline-side snaps (AutoHeightContainer, scroll-anchor scoping) are unaffected. Co-Authored-By: Claude <[email protected]>
SawyerHood
force-pushed
the
bb/mobile-perf/css-paint-ios
branch
from
August 19, 2026 16:13
a6b3a24 to
5db7529
Compare
SawyerHood
added a commit
that referenced
this pull request
Aug 19, 2026
…l mounted (G1, G4) (#1881) ## What was wrong The secondary panel keeps its content mounted while closed so the next open is instant (compact drawers retain the panel off-screen; desktop keeps the subtree). But its data stayed live: the diff tab TOC query, the toolbar's shared TOC observer, visible-row patch requests, and every file-preview query kept running behind a closed panel. Each workspace write emits `work-status-changed`, which invalidates the diff TOC and previews and evicts the patch cache, so a hidden panel refetched the TOC, re-requested patches, and remounted the highlighted preview on every fs event (audit G1). Terminals were gated on `isPanelOpen`, but on compact that meant every drawer close disposed xterm and its socket, and every reopen re-created xterm/WebGL and replayed up to the full scrollback (audit G4). ## What changed - `ThreadSecondaryPanel` derives `isDiffPanelLive = isDiffPanelActive && isLayoutOpen` and uses it for the toolbar TOC observer and the diff-target work-status query. - `GitDiffTabContent` and `DiffFilesPanel` take `isPanelOpen`. The TOC query is enabled only while the panel is open. `requestPaths` is skipped while closed and re-fires for the current visible set on reopen (dedupes against the cache). - Workspace / project / host / thread-storage preview tab bodies take `isPanelOpen` and pass `enabled` to their preview queries. `ThreadDetailView` and `RootComposeView` pass `isSecondaryPanelOpen`. The DOM stays mounted; an invalidated query refetches once on reopen. - Terminal controller exposes `shouldMountTerminalView = isPanelOpen || (isPanelPersistedOpen && hasPanelOpened)`. `ThreadTerminalContent` mounts on it. A compact drawer close keeps an already-mounted terminal alive; a persisted-open tab synced from another device does not start xterm on a phone that never opened the drawer; closing the persisted panel releases the view. Desktop is unchanged (`isPanelOpen === isPanelPersistedOpen`). ## How you verified - New `ThreadSecondaryPanelTabContent.panelGate.test.tsx`: with the real query hooks and a mocked sdk, the diff TOC and workspace preview do not fetch while `isPanelOpen` is false, do not refetch after `invalidateQueries` while closed, and refetch exactly once on reopen. Fails before, passes after. - New `useThreadTerminalController.mount.test.tsx` and extended `ThreadTerminalContent.test.tsx`: view is retained (same DOM node) across a hidden-but-persisted panel, unmounts when persisted state closes, and never mounts for a persisted-open panel this client has not shown. Fail before, pass after. - `pnpm exec turbo run typecheck --filter=@bb/app`, `pnpm exec turbo run lint --filter=@bb/app` (147 warnings, same as baseline, 0 errors), targeted vitest for `src/components/secondary-panel`, `src/components/thread/terminal`, `src/views/thread-detail`, `src/views/RootComposeView` (50 files, 408 tests pass). Fixes: part of the mobile / iOS Safari performance program (verified sweep report in the bb thread; no single issue). ## Stack context Layer 2 of 22 in the `bb/mobile-perf/*` stack (bottom → top: quick wins first, big rocks last). - Prerequisite (layer below): `bb/mobile-perf/css-paint-ios` (#1880). - Next layer: `bb/mobile-perf/invalidation-tuning` (#1882). - Audit findings addressed: see title IDs. Review: approved. - Deliberately not done here: G4 optional 'smaller replay tail for compact clients': not done. It requires a client hint on the terminal WebSocket URL plus server/daemon handling (wire chang - Reviewer notes / follow-ups: Minor test gap (not blocking): DiffFilesPanel's `requestPaths` early-return while `isPanelOpen === false` and its re-fire on reopen is untested; no existing jsdom harness renders D | Trade-off to be aware of (by design, per G4): on compact a hidden-but-persisted terminal keeps its WebSocket and xterm/WebGL context alive off-screen while the drawer is closed; xt - Wire/contract: None. No server, daemon, protocol, CLI, config, or plugin API changes. HOST_DAEMON_PROTOCOL_VERSION untouched. > AGENT GENERATED: by Claude Code (claude-mangosteen-eap) --------- Co-authored-by: Claude <[email protected]>
This was referenced Aug 20, 2026
SawyerHood
added a commit
that referenced
this pull request
Aug 21, 2026
## What was wrong `InlineVisDirective` in `plugins/inline-vis/app.tsx` starts in `loading` and stays there until the `prepareHtmlPreview` RPC resolves. The loading branch rendered a bare one-line "Loading visualization…" box with no height (37px in the app). The ready branch renders a header plus an iframe whose inline height comes from the directive's `height` attribute (default 224px, min 120px). The card therefore grew by hundreds of pixels in one React commit (measured 37px -> 515px for `height="480"`). The thread timeline is bottom-anchored, so that growth scrolled every earlier message upward on every mount of the directive, not only on cold loads. The preview height is known synchronously from the attributes, so the final geometry was knowable in the loading state; it just was not used. Issue: #1837. Report: https://get-bb.github.io/reports/issues/1837.html ## What changed - `plugins/inline-vis/app.tsx`: extracted the card chrome (outer card + header row) into a small `PreviewCard` so the loading and ready states cannot drift. The loading branch now renders that card with a `size-5` spacer where the open-in-sidebar button goes, and a `role="status"` / `aria-busy` / `aria-label="Loading visualization <file>"` container with `style.height = previewHeight` holding a plain `<Skeleton className="size-full" />` from `@bb/shared-ui/skeleton`. The ready branch is unchanged except for using `PreviewCard`. - `plugins/inline-vis/app.test.tsx`: new test pins the behaviour (loader height equals the iframe height, same card/header classes, status role and label); the existing sandbox test now finds the loader by role instead of the removed text. - Error, missing-file, and invalid-height branches still render compact alerts; loading -> error shrinks the card, which is acceptable for an error path and out of scope here. - No server, wire, CLI, or doc changes. App-side plugin UI only. Relation to #1555: that PR also reserves the height, but it duplicates the header markup, uses `.animate-shine-icon` inside an `aria-hidden` grid, which `theme.css` pauses since #1880 (so its advertised shimmer is frozen in the app), and its ~100-line test pins data attributes and class names rather than behaviour. It also predates #2140, which removed the `PrepareHtmlPreviewRpcResult` type it touches. This PR is the ~20-line version the report recommends: shared header, fixed-height `Skeleton` with its built-in pulse (verified running in the app), and a behaviour-only test. ## How you verified - New test fails on `origin/main` `app.tsx` (`git checkout origin/main -- plugins/inline-vis/app.tsx`, then `pnpm exec vitest run app.test.tsx` in `plugins/inline-vis`): ``` × reserves the preview height while loading so the timeline does not jump AssertionError: expected '' to be '480px' // Object.is equality ``` - On this branch, from the committed tree (`git status --porcelain` empty): `pnpm exec turbo run typecheck test --filter=bb-plugin-inline-vis --force` -> `Tasks: 6 successful, 6 total`, `Tests 17 passed (17)`. - Manual repro in a dev instance (`scripts/bb-dev-app current`, claude-code turn that replied with `::inline-vis{file="demo.html" height="480"}`), holding the `prepareHtmlPreview` request in headless Chrome and measuring the card before and after release: - main `app.tsx`: loading `boxHeight: 37` -> ready `boxHeight: 515`, `deltaHeight: 478`; the user message above moved from `top: 75` to `top: 17`. - this branch: loading `boxHeight: 515` -> ready `boxHeight: 515`, `deltaHeight: 0`; user message stays at `top: 17`; skeleton `animationName: pulse`, `playState: running`. Fixes #1837 > AGENT GENERATED: by Claude Opus 5 ## Independent verification Checked out `140e23e7f` (`git fetch origin bb/fix-1837-inline-vis-layout-jump && git checkout -b verify-1837-r1 FETCH_HEAD`); `origin/main` is an ancestor, GitHub reports `MERGEABLE`. Diff: `plugins/inline-vis/app.tsx` + `plugins/inline-vis/app.test.tsx` only, +117/-17. Fail-before: `git checkout origin/main -- plugins/inline-vis/app.tsx`, then `pnpm exec vitest run app.test.tsx` in `plugins/inline-vis`: ``` FAIL app.test.tsx > InlineVisDirective > reserves the preview height while loading so the timeline does not jump AssertionError: expected '' to be '480px' // Object.is equality Tests 2 failed | 5 passed (7) ``` (The second failure is the existing sandbox test, which now looks the loader up by `role="status"` name.) Pass-after: restored `app.tsx` from the PR head (`git status --porcelain` empty), `pnpm exec vitest run app.test.tsx` -> `Tests 7 passed (7)`. `pnpm exec turbo run typecheck test --filter=bb-plugin-inline-vis --force` -> `Tasks: 6 successful, 6 total`, `Tests 17 passed (17)`. Repro on the fixed branch: own dev instance (`scripts/bb-dev-app current`, app :13647 / server :21647), scratch project with `demo.html`, real claude-code turn replying `::inline-vis{file="demo.html" height="480"}`. Headless Chrome via doobie held the `prepareHtmlPreview` RPC, measured the card, released it, measured again: ``` before: state=loading cardHeight=515 innerHeight=480 userMsgTop=17 role=status label="Loading visualization demo.html" skeleton animation=pulse playState=running after: state=ready cardHeight=515 innerHeight=480 userMsgTop=17 deltaHeight: 0, userMsgShift: 0 ``` The report measured 37px -> 515px (delta 478) for the same scenario on main. The issue no longer reproduces. CI: all required checks green on `140e23e7f` (Checks, Tests app-1/2/3, integration, server, packages, Package Smoke ubuntu/macos, version check). Residual risks: error / missing-file / invalid-height branches still render compact alerts, so loading -> error shrinks the card (error path, out of scope). The loader no longer shows visible "Loading visualization" text; it is conveyed through `role="status"` + `aria-label`. No wire, CLI, or plugin-API surface changed, so no protocol bump or doc update is required. > AGENT GENERATED: by Claude Opus 5 Co-authored-by: Claude <[email protected]>
SawyerHood
added a commit
that referenced
this pull request
Sep 18, 2026
…me (#3906) ## Human comments ## What was wrong With an agent working and the user doing nothing, the app kept roughly one CPU core busy. The cause is the working shimmer: `.animate-shine` animates `background-position` and `.animate-shine-icon` animates `mask-position`. The compositor cannot run either, so every frame at 60 fps is a full main-thread style, paint, layerize, and commit pass, and the cost of that pass grows with the weight of the page around the label. A DevTools trace of an idle app with one working thread showed 804 main-thread frames in 13.6 s with about 1% of the time in JavaScript. Every frame repainted the same four nodes (two title spans, two status icons). By OS thread: renderer main 47% of a core, GPU 28%, browser 13%, compositor 8.5%, Viz 7%. There is no single regressing commit. The text sweep dates from the initial commit, the icon mask from #86, and `will-change: transform` from #1880 measured neutral (52.6% vs 50.7%). What grew is the page: on a synthetic timeline the same animation costs 41%, 52%, and 76% of a core at 300, 2,500, and 8,000 rows. The sweep also kept costing CPU while hidden, which is what #768 worked around with `animation-play-state`. ## What changed The sweep is now an animated image used as a mask, with the same look. - `apps/app/src/components/ui/shine-sweep.png`: a 2.6 KB, 128x2 APNG whose alpha band (50% to 100% to 50%) travels left to right once a second. `theme.css` stretches it over the element with `mask-size: 100% 100%`. The mask carries alpha only, so one file serves every theme, label, and icon; the text stays real DOM text. - Chromium advances animated images on the compositor, so the page's main thread does no work for the shimmer, and a hidden mask is not drawn at all. - `apps/app/scripts/generate-shine-sweep.mjs` writes the APNG with no dependencies (`pnpm --filter @bb/app generate:shine-sweep`). The file stays under Vite's 4 KB inline limit, so production CSS embeds it as a data URI and no separate request is made. - `.animate-shine` and `.animate-shine-icon` share one rule; the `shine` and `shine-mask` keyframes are gone. Reduced motion and `inert` / `aria-hidden` hosts set `mask-image: none`. - `ThreadStatusGlyph`: removed the `animation-duration: 1.5s` override on the plugin status icon, which no longer has any effect. Behavior differences from the CSS sweep: - Icons sweep once a second like labels, instead of on their own 2.6 s cycle, and their edge alpha is 0.5 instead of 0.45. - The sweep redraws 20 to 30 times a second instead of 60. - All shimmering elements share the image's clock, so they sweep in phase. - The cadence lives in the file, so `animation-duration` / `animation-play-state` no longer affect it. No wire, CLI, config, or plugin API change. Plugins that use the classes get the new behavior from the host CSS. ## How you verified - New tests in `theme.test.ts` (fail before, pass after): the shared mask rule and absence of a CSS animation, the reduced-motion and hidden-host rules, and the APNG itself (frame count matches its control chunk, loops forever, runs 1 s, under 4 KB). - `pnpm exec turbo run test --filter=@bb/app -- src/components/ui/theme.test.ts src/components/sidebar/ThreadRow.test.tsx src/components/ui/height-transition.test.tsx src/components/ui/scroll-to-bottom-button.test.tsx`: 127 tests pass. - `pnpm exec turbo run typecheck lint --filter=@bb/app`: pass, 0 lint errors. - Other readers of `theme.css`: `pnpm exec turbo run test --filter=@bb/mobile` (307 tests) and `pnpm exec turbo run generate --filter=@bb/plugin-build` pass. - `pnpm exec turbo run build --filter=@bb/app`: the PNG is inlined into the main CSS byte-for-byte, no separate asset is emitted, and `check-bundle-budget.mjs` passes. - Measured in headless Chromium (per-process CPU from `/proc`, frame and paint counts from a trace): | | main-thread frames/s | paints/s | draws/s | CPU (% of a core) | |---|---|---|---|---| | Ladle streaming story, before | 60 | 240 | 60 | 13.3 | | Ladle streaming story, after | 0 | 0 | 20 | 4.6 | | Synthetic 2,500-row page, before | 60 | 300 | 60 | 53 | | Synthetic 2,500-row page, after | 0 | 0 | 20 | 8 to 9 | | Same page, shimmer inside a collapsed container, before | 60 | 60 | 0 | 32 | | Same page, shimmer inside a collapsed container, after | 0 | 0 | 0 | 0.8 (idle) | - Look: the mask frames use the same triangle profile as the CSS gradient, a side-by-side real-time capture of the Ladle stories shows the same sweep in Chromium, and the owner compared it with the old sweep on an iPhone. - Not verified: Firefox, and the CPU cost in WebKit (only the look was checked there). 🤖 Generated with [Claude Code](https://claude.com/claude-code) > AGENT GENERATED Co-authored-by: Claude Code <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What was wrong
Seven paint/layout costs hit iOS Safari during a streaming turn (audit findings C2, C10, D7, D9, E2, F1, F2):
AutoHeightContainereased its whole height 180 ms for every streaming delta. Deltas arrive every ~250 ms, so the tween ran continuously. Each eased frame re-laid out the timeline; on WebKit (no CSS scroll anchoring) the JS scrollTop restore followed every frame.AnimatedExpandablePanelContentrestarted its own 200 ms height tween on content growth of open bodies without registering withlayoutAnimationInFlightCountAtom.ExpandablePanelbody pinned a compositing layer withwill-change-transform..scroll-bottom-anchor-content *toggled withisAtBottomand restyled every timeline node; WebKit ignoresoverflow-anchorso the toggle was pure cost there.body[data-sidebar-dragging] *set a cursor on every element at drag start/end, including on touch drags.backdrop-blursat on the page header, the scroll-to-bottom button, and the retained overlay backdrops, where nothing needs blurring.What changed
AutoHeightContaineruses duration 0 on a coarse pointer, under reduced motion, or whenCSS.supports("overflow-anchor: none")is false (lib/scroll-anchoring-support.ts).AnimatedExpandablePanelContenteases only expand/collapse toggles; growth inside an open body snaps.will-change-transformfrom collapsed panel bodies.PromptBoxInternalskips the layout height tween on coarse pointer + compact viewport..animate-shine/.animate-shine-iconpromote to their own layer while present and pause under[inert]/[aria-hidden="true"].[data-sidebar="panel"]inside@media (pointer: fine).backdrop-blurfrom the header surface, the scroll-to-bottom button (opaquebg-background), and the shared dialog/drawer/persistent-drawer backdrops.How you verified
height-transition.test.tsx(coarse/reduced-motion/no-anchoring =>height 0ms, fine pointer =>180ms),disclosure.test.tsx(mount and content growth snap; toggle eases),bottom-anchored-scroll-body.anchor-class.test.tsx(class on wrapper only, sentinel outside, no class when unsupported),theme.test.ts(shimmer will-change and pause rule; no.scroll-bottom-anchor-content *),app.css.test.ts(cursor rule scope),scroll-to-bottom-button.test.tsx+responsive-overlay.test.tsx(nobackdrop-blur),PromptBoxInternal.test.tsx(coarse+compact snaps the tween).pnpm exec turbo run typecheck --filter=@bb/app --filter=@bb/shared-ui: pass.pnpm exec turbo run lint --filter=@bb/app: 0 errors (147 pre-existing warnings, none new).Update (2026-08-19)
D7 (skip the follow-up composer height tween on phones) was removed after an iPhone test of this layer alone showed the caret rendered one line above the editor after the first tap: WebKit computes the native caret rect at focus time and, without the per-frame layouts of the tween, never refreshed it. The 240 ms tween is back on phones; the timeline-side snaps (C2) and the rest of this PR are unchanged.
Fixes: part of the mobile / iOS Safari performance program (verified sweep report in the bb thread; no single issue).
Stack context
Layer 1 of 22 in the
bb/mobile-perf/*stack (bottom → top: quick wins first, big rocks last).main).bb/mobile-perf/secondary-panel-gating(Gate closed secondary-panel diff queries and keep the compact terminal mounted (G1, G4) #1881).will-change: transformon.animate-shine(background-clip: text) and.animate-shine-icon(mask-image) renders correctly in Chromium (verified via a | E2 (cosmetic, desktop only): with the cursor rule scoped to[data-sidebar="panel"], dragging a sidebar row while the mouse strays over the main content now shows the underlying e | C2 optional burst gate (snap when the previous growth was <250 ms ago) was intentionally not implemented; desktop Chromium/Firefox with a fine pointer still eases every streaming d