Repository navigation
feat(vue): one stylesheet tag for several apps, and experimental combine_assets() - #802
Merged
Merged
Conversation
A host that combines several Vue apps on one page, such as citry-django with one app per interactive region, can now keep one stylesheet link per file: data-citry-vue-style-app may list the app ids separated by single spaces. The runtime accepts only a list of distinct ids of 32 lowercase hex characters, keeps parsed lists as Sets in a size-capped Map, and removes a tag several apps adopted only when the last of them lets go. Citry still writes one id per tag, so the one-app output and behavior are unchanged. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01KUhrHaXagmW5ZxpRAMwyom
combine_assets() takes the same asset group from several renders serialized with deps_position="separate" and returns it with each shared tag written once. Stylesheet tags of several Vue apps that are byte-identical apart from the app id become one tag that names every app, which the browser runtime accepts. The app list is read only from the opening tag, and a tag it cannot read is kept as written. Tags keep their nonce, integrity and first-seen order. Groundwork for the citry-django integration. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01KUhrHaXagmW5ZxpRAMwyom
This was referenced Nov 19, 2026
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.
(Opus 5.5)
Change C5 of the citry-django redesign, in two commits:
combine_assets(), writes those tags. A host such as citry-django combines several renders' asset groups with it, without writing Citry's internal attribute itself.What changes
The runtime (
_vue/client.js,runtime.jsrebuilt)Citry writes each app's stylesheet tags with
data-citry-vue-style-app="<app id>", and the runtime adopts a served tag only when that attribute names the app that is starting. Before this change N apps that load the same file needed N tags.styleNamesAppnow also accepts several app ids, distinct and 32 lowercase hex characters each, separated by single spaces.Sets in aMap, which starts over past 64 lists.removeStyleElementtakes it off the page only when no other record still holds it. This covers retiring unused styles, a failed served link, and the probe that rechecks a served link.runtime.jsgrows by 751 bytes before compression.The helper (
citry.combine_assets, Experimental)<style>body.The one-app server output is unchanged, and a test locks it, mounted and standalone. Docs: "Combine several renders" in
asset-placement.md, theapp_assetsdocstring, the Experimental list inversioning.md,reference.yml, and a changelog line under Unreleased that names this as groundwork for the citry-django integration.Design (Mechanism 2)
Prior art.
_cut_separate_assets(serialize.py) builds the three groups; this helper does not change it.dict.fromkeysand kept every app tag.citry.assets.dedupededuplicates by equality but knows nothing of app ids.crates/or the other packages combines several renders' tags.API.
combine_assets(groups: Iterable[SerializedAssets]) -> SerializedAssets, called once per group. It is a function incitry_render.py, besideSerializedAssets, and is exported fromcitry.Alternatives considered.
combine_assets(renders) -> SerializedAssetsfor all groups at once: rejected. It would merge the three groups, and citry-django needs the component group apart for itson_page_assetshook.combine_assets(renders)returning a new type with three groups: rejected, because it adds a type for no gain over three calls.SerializedAssets: equivalent; a function matches the name the maintainer suggested.What would show it is wrong.
Versioning
combine_assetsis a new public name, marked Experimental and named in the Experimental list: a minor release.data-citry-vue-style-appstays internal ("not covered" indocs/design/public_api_1_0_0_audit.md). Now Citry writes the list itself, so no package outside Citry reads or writes it.citrypackage.Security (Mechanism 7)
Places touched: markers for Citry's browser code, and addresses and keys the browser code takes from the server.
combine_assets) from ids that match[0-9a-f]{32}, read only from each tag's opening tag; data cannot write the attribute name.Sets inside aMap, so__proto__matches only itself.result.securitystays correct: CSP hashes cover element content, which the helper never changes. The docs now say a combined page needs every result'ssecurity.docs/design/trust_boundaries.mdrow updated.Tests
JS (
pnpm --dir packages/js/citry-client run check, including the generated-files canaries): 382 passed, 6 new. They cover the one-app and list matches, 12 malformed values, lookup by URL, a shared tag staying until the last app lets go, and the cache limit.Python
tests/test_serialize_separate_assets.py: 36 passed. They cover:Browser (Chromium),
tests/e2e/test_serialize_separate_assets_e2e.py:combine_assetskeep one stylesheet link, and both are styled and interactive with no errors;On the old runtime the shared case fails with 3 links instead of 1.
Wider runs:
tests/e2ein Chromium: 658 passed. The one failure,test_preview_e2e, needs the full Chromium build, which is not installed here.main.scripts/validate.py: all passed.--platform linux) are clean on the changed files.Benchmark
Threshold: flag more than 3% on any existing Vue or serialize benchmark under
benchmarks/. Budget: about 10 minutes.The serialize path is unchanged, so the serialize benchmarks cannot move. No existing benchmark covers the runtime lookup or the new helper, so I timed them directly.
Runtime lookup, in Node: 200 apps each look up their stylesheet among the page's tags, median of 41 runs.
The one-app lookup costs about 0.5 ns more per comparison, too small to see in an app's startup. Some busy-machine runs, before and after alike, came out near 0.4 ms; that is JIT state in the timing loop, not this change.
combine_assetson 200 islands, all three groups: 0.97 ms, against about 0.64 ms to serialize each island.Review
Two independent reviews (technical, security, prose) found no security hole and no blocking bug.
Fixed during the review:
<style>, and describe the CSS order andsecurity.Left as is: there is no browser test of the standalone
<style>merge; the runtime's lookup there is covered by the JS unit tests.🤖 Generated with Claude Code
https://claude.ai/code/session_01KUhrHaXagmW5ZxpRAMwyom