Repository navigation
live: keep the Astro carbonize style block is:inline - #993
Conversation
On accept, the carbonize block was written with a bare <style> on every non-JSX file. In an .astro file that is not the same thing as the is:inline tag the variants block used: Astro compiles it into a ?astro&type=style&index=N module ahead of the page's own, and the carbonize cleanup then deletes it again together with a markup change. Astro 7.3.6 (withastro/astro#18076) drops its compile metadata on such a save, so the reload of the index that vanished fails with "No Astro CSS at index 1": a 500 in the dev server and two errors in the browser console after every accept that carries CSS. On 7.3.5 and earlier the same sequence logged nothing but served stale CSS under the surviving index. The carbonize block now takes the file type's own styleTag, so on Astro it stays is:inline and the set of compiled style modules never changes during a session. Output for every other file type is byte-identical. The astro-vite7 live-e2e fixture goes back to a floating ^7.1.0 (it was pinned to 7.3.5 to unblock a release). New oracle cases live-accept-astro-variant-2-steps and live-accept-astro-discard were recorded from the binary; no existing golden changed. Fixes #992 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
🟢 Approval recommended
The targeted fix is consistent with source traits and is covered across unit, oracle, and runtime tests.
0 open findings
What changed in this PR
Fixes Astro live-accept styling by preserving is:inline during carbonization, preventing style-module churn and dev-server errors.
Changes:
- Uses source-specific style tags during carbonization.
- Adds Rust, oracle, and Astro runtime regression coverage.
- Restores floating Astro 7 fixture updates and documents the behavior.
| File | Description |
|---|---|
crates/live/src/live_accept.rs |
Preserves Astro’s inline style tag and adds unit tests. |
docs/CLI-CONTRACT.md |
Documents Astro carbonization behavior. |
tests/framework-fixtures/astro-vite7/files/package.json |
Restores the Astro 7 version range. |
tests/oracle/cases/live-accept.mjs |
Adds Astro accept and discard cases. |
tests/oracle/live-helpers.mjs |
Adds Astro wrapper staging. |
tests/oracle/golden/live-accept-astro-variant-2-steps.json |
Records Astro accept output. |
tests/oracle/golden/live-accept-astro-discard.json |
Records Astro discard output. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
Fixes #992.
The problem
On Astro 7.3.6 and later, every live accept that carries CSS ends with a 500 from the dev server and two errors in the browser console (
No Astro CSS at index 1,[vite] Failed to reload ...?astro&type=style&index=1&lang.css). The page reloads and ends up correct, but the live-e2eastro-vite7fixture fails its clean-console check, so the fixture was pinned toastro@7.3.5to unblock a release.Root cause
During a session the variants CSS sits in
<style is:inline data-impeccable-css="ID">, which Astro's compiler leaves alone. On accept,build_carbonize_replacementwrote a bare<style data-impeccable-css="ID">for every non-JSX file. In an.astrofile Astro compiles that into a?astro&type=style&index=Nmodule, numbered in source order, ahead of the page's own<style>. The carbonize cleanup then deletes it again in a save that also changes markup.Astro 7.3.6 (withastro/astro#18076) clears its compile metadata on such a save. The reload of the index that no longer exists then throws in the load hook. Before 7.3.6 the same sequence logged nothing and served stale CSS under the surviving index, so the page's own styles were wrong after an accept until the next edit. Details, the Astro diff, and a reproduction with no impeccable involved are in #992.
So this is both: a rough edge upstream (removing a
<style>block together with markup is a 500 in dev) and an inconsistency of ours that walks into it on every accept.The fix
The carbonize block takes the file type's own
styleTagfromresolve_source_traits, the same source inject and wrap already use. On.astrothat is<style is:inline data-impeccable-css="ID">; everywhere else it is the tag that was hardcoded before, so output for other file types is byte-identical. The set of compiled Astro style modules no longer changes at any point of a live session.Tests
live_accept.rs: the Astro carbonize block isis:inline(also when the agent wrote the variants tag without it), the HTML block is unchanged.live-accept-astro-variant-2-stepsandlive-accept-astro-discard. No existing golden changed.tests/framework-fixtures/astro-vite7goes back to the floating^7.1.0it had before the pin, so CI keeps catching drift. It resolves to 7.3.8 today.docs/CLI-CONTRACT.mdgains the Astro line under the carbonize block shape.Verification
IMPECCABLE_E2E_ONLY=astro-vite7 IMPECCABLE_E2E_SCENARIOS=core,agent-target bun run test:live-e2eon Astro 7.3.8: fails with the pinned 0.1.12 release binary, passes with a binary built from this branch.is:inline, no failed request and correct computed styles on all three.cargo test --workspace,bun run build,bun run test(withIMPECCABLE_BINpointing at this branch's build): green.bun run test:live-e2elocally: 44 of 47 passed,astro-vite7among them.vite8-react-plainfailed once in the full run and passed when rerun.nextjs-app-routerfailed on a DOM wait and fails the same way with the pinned release binary on this machine (load average around 12 during the run), at a different step each time, so it does not come from this change. The CI smoke job runs that fixture and is the cleaner signal.No version bump and no changelog entry. Users get the fix with the next engine release.
This PR was prepared by an AI agent (Claude Code) working under pbakaus's instructions.
🤖 Generated with Claude Code
Note
Medium Risk
Changes live-accept source rewriting for Astro (and any future file types using custom style tags); behavior is covered by new tests and should be byte-identical for non-Astro templates.
Overview
Live accept now emits carbonize
<style>openings from each file type’sstyleTag(resolve_source_traits) instead of a hardcoded bare<style data-impeccable-css="ID">. On.astrothat meansis:inline, matching the variants preview block so accept/cleanup no longer add and remove a compiled Astro style module (which triggered dev-server 500s on Astro 7.3.6+ and wrong CSS on earlier versions).Non-Astro HTML output stays the same.
build_carbonize_replacementtakes astyle_openargument;carbonize_style_opencentralizes the tag choice.Tests & docs: Rust carbonize unit tests (Astro inline vs HTML plain), oracle
live-accept-astro-*goldens andstageWrappedAstro,CLI-CONTRACT.mdAstro carbonize note, andastro-vite7fixture dependency restored to^7.1.0(drops the 7.3.5 pin).Reviewed by Cursor Bugbot for commit 2ec8c64. Bugbot is set up for automated code reviews on this repo. Configure here.