Repository navigation
Stop the working shimmer from repainting on the main thread every frame - #3906
Merged
Merged
Conversation
While an agent works and the user does nothing, `.animate-shine` and `.animate-shine-icon` animated `background-position` / `mask-position`. The compositor cannot run either, so every frame at 60 fps was a full main-thread style, paint, layerize, and commit pass whose cost 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: roughly one core across the renderer, GPU, browser, and compositor for a status cue. The same sweep kept costing CPU inside collapsed containers. The sweep is now an animated image used as a mask. `shine-sweep.png` is a 128x2 APNG whose alpha band travels left to right once a second, stretched over the label or glyph. Chromium advances animated images on the compositor, so the page's main thread does nothing, and a hidden mask is not drawn at all. The look is unchanged: the mask carries alpha only, so one 2.6 KB file serves every theme, label, and icon, and it stays under Vite's inline limit so production CSS embeds it. - `apps/app/scripts/generate-shine-sweep.mjs` writes the APNG with no dependencies (`pnpm --filter @bb/app generate:shine-sweep`). - Reduced motion and `inert` / `aria-hidden` hosts drop the mask. - Icons now sweep once a second like labels instead of on a 2.6 s cycle. - The plugin status icon's `animation-duration` override had no effect any more and is removed. Co-Authored-By: Claude Code <[email protected]>
3 tasks done
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.
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-shineanimatesbackground-positionand.animate-shine-iconanimatesmask-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: transformfrom #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 withanimation-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.cssstretches it over the element withmask-size: 100% 100%. The mask carries alpha only, so one file serves every theme, label, and icon; the text stays real DOM text.apps/app/scripts/generate-shine-sweep.mjswrites 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-shineand.animate-shine-iconshare one rule; theshineandshine-maskkeyframes are gone. Reduced motion andinert/aria-hiddenhosts setmask-image: none.ThreadStatusGlyph: removed theanimation-duration: 1.5soverride on the plugin status icon, which no longer has any effect.Behavior differences from the CSS sweep:
animation-duration/animation-play-stateno 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
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.theme.css:pnpm exec turbo run test --filter=@bb/mobile(307 tests) andpnpm exec turbo run generate --filter=@bb/plugin-buildpass.pnpm exec turbo run build --filter=@bb/app: the PNG is inlined into the main CSS byte-for-byte, no separate asset is emitted, andcheck-bundle-budget.mjspasses./proc, frame and paint counts from a trace):🤖 Generated with Claude Code