Repository navigation
Avoid full-page restyles when plugin stylesheets load or unload - #6148
Merged
ymichael merged 6 commits intoOct 27, 2026
Merged
Conversation
ymichael
force-pushed
the
bb/plugin-css-animation-properties-thr_yvsvx8anai
branch
from
October 23, 2026 20:00
de38101 to
3c0c256
Compare
…bles to plugin sheets Inserting a plugin stylesheet restyled the whole document in Chrome for two reasons: every sheet carried @Property registrations (any @Property in an inserted sheet invalidates every element), and every sheet redeclared Tailwind theme variables on :root (inherited, so every element recomputes). All of them duplicated what the host already declares. plugin-build now generates every registration and theme variable its Tailwind input can emit, the app loads that sheet once with its own CSS, and plugin builds drop the identical registrations, their fallback declarations and the identical theme variables. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Its only utility, line-clamp-2, passed 1 KiB because tw-animate's registrations rode along in every plugin sheet. They now come from the host. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
… at build time Stripping at build time made a dist built with this bb rely on host registrations an older bb does not make, and an older bb checks only the SDK major and the author's engines ranges, so it would load such a bundle unstyled. plugin-build now emits the full sheet again, byte-identical to before, and the server removes the rules its own app already provides when it loads the bundle. Older bundles get the same treatment. Co-Authored-By: Claude Opus 5.5 <[email protected]>
In Chrome, removing a stylesheet that contains @layer re-resolves every @Property rule in the document and restyles every element. Plugin sheets come and go with their views, so each close restyled the whole page about 1.5 s later. The app now registers its stylesheets' @Property rules with CSS.registerProperty before the first render and removes them from the CSS, which leaves nothing for a removal to re-resolve. Co-Authored-By: Claude Opus 5.5 <[email protected]>
ymichael
force-pushed
the
bb/plugin-css-animation-properties-thr_yvsvx8anai
branch
from
October 27, 2026 16:54
3c0c256 to
f501ca1
Compare
ymichael
deleted the
bb/plugin-css-animation-properties-thr_yvsvx8anai
branch
October 27, 2026 22:05
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
Plugin stylesheets repeated Tailwind
@propertyregistrations and inherited theme variables on:root, so inserting a sheet restyled the entire document. Removing a layered plugin stylesheet also made Chrome re-resolve the host's CSS@propertyrules and restyle the whole page. Fixing only insertion or only the host registrations left the other trigger intact.Unconditionally stripping plugin CSS on the server also created version skew: a tab loaded before an update retains its old host CSS while fetching new plugin CSS. The old host lacks about 50 registrations and 330 theme variables supplied by the expanded host sheet.
What changed
This combines #6148 and #6149, rebased onto
origin/mainat2f61afc227(#6157). Conflict resolution preserved main's runtime-slot metadata, retired Git API migration-warning coverage, and this PR's CSS regression coverage; no CSS behavior changes were needed.CSS.registerProperty()and delete the equivalent CSS rules. Keep conflicting rules, rejected registrations and unreadable sheets. Keep the loader's existing attach/release lifecycle and 1.5-second removal grace period.host-tailwind=<hash of generated host CSS>. Both asset routes serve the complete original CSS for absent or mismatched markers. A future host CSS change gets a different marker automatically. Bundle hashes cover both CSS variants, and compressed response caches distinguish them.docs/debugging-and-qa.md. No daemon wire changes or new CLI/SDK controls; browser, desktop and mobile use the same app loader.Script registrations take precedence over CSS
@property; a plugin's conflicting registration can no longer override a host registration. No bundled plugin depends on that behavior. Browsers withoutCSS.registerPropertyretain the CSS rules and fallback layer.How you verified
Combined performance results
The existing PR measurements below used the same 70-thread fixture (about 1,420 elements), Chrome at 1280×800, Performance-domain style duration and trace element counts, median of seven. The after column includes both changes.
The prior insertion-only measurements were Automations 38.2 → 17.3 ms (1,234 → 86 elements), Plugin Guide 39.4 → 16.4 ms (1,234 → 86), and GitHub PR Status 35.7 → 3.5 ms (1,346 → 26). WebKit broadly restyles on sheet changes and showed no material improvement. Prior combined verification covered open/close/reopen, popover and dialog animations, spinners, the Automations toast, and compact drawer transitions in Chrome and WebKit.
Stale tab across a server update
Reproduced in real headless Chrome 155 at 1280×800 using main
efe987702b87ca4bfe9df905b4b63ede478e12c7, then switching the same isolated server to the combined branch and opening Automations and Plugin Guide through their navigation buttons.Test condition: normal
AppUpdateHostrevision detection automatically reloads the tab. To exercise the requested client that has not received that update status yet, a local proxy held/api/v1/system/app-updateat main's actual response and retained main's immutable app assets. All plugin metadata, JS and CSS came from the real switched server. No app CSS or plugin styles were injected into the tab. The stale tabs'performance.timeOriginandindex-BR1pQoni.csshost URL stayed unchanged across the server switch.--font-weight-bold; fresh load is 700@propertyrules and theme layer@propertyrules and no:rootBefore the fix, the Guide heading differed by 440 screenshot pixels. After the fix its heading matches, and the Guide's computed styles and element geometry match across the old and fresh tabs; tiny rasterization differences remain in scaled fixture strokes. Screenshots and observations are retained in the task evidence directory (
/tmp/bb-6148-evidence/).Old-tab timestamps: before case
1792785386806, after case1792785387394.9; both retained main's CSS. The fresh app addshost-tailwind=90105b453d213b90e1c3f988b900bdc9fbb0a5f2677466f83df3227db69320f9; the old app sends no marker.Regression coverage and checks
pnpm exec turbo run lint typecheck --filter=@bb/app --filter=@bb/server --filter=@bb/plugin-build: passed.pnpm start:worktreebuild: passed, including app, server, host daemon, SDK and bundled plugins.pnpm exec turbo run test --filter=@bb/plugin-build: 235 passed, 1 skipped.f501ca183c4c7fd0e6960c13169e2f817f5a47ba: 47 successful checks, 4 conditional skips, zero failures or pending checks. Skips: iOS, Android, Node Compatibility smoke, and Windows dependency warming. All executed checks passed on their first attempt. Local affected lint/typechecks, 46 app tests, 13 server asset tests, and 235 plugin-build tests also passed (1 plugin-build test skipped).