Repository navigation
Description
Problem
pkgs/id/web/scripts/build-manifest.ts is not idempotent: a second run deletes the web UI's only stylesheet and writes a manifest that no longer mentions it — exit 0, no warning.
The script's first step deletes every hashed stylesheet in dist/:
// Remove stale hashed CSS files before processing
for (const file of readdirSync(distDir)) {
if (file.match(/^styles\.[a-f0-9]+\.css$/)) {
unlinkSync(join(distDir, file));
}
}The only path that puts a stylesheet back is renaming an unhashed styles.css (the Tailwind output) later in the script. After a first run, dist/ contains only styles.<hash>.css — there is no styles.css left to rename. So a second run:
- deletes
styles.<hash>.css(the live stylesheet), - finds no
styles.cssto rename, - writes
manifest.jsonwith nostyles.cssentry, and logs it as success.
The Rust server then silently falls back to the unhashed default URL (pkgs/id/src/web/mod.rs, load_asset_urls: missing styles.css key → /assets/styles.css), which does not exist in dist/ — every page is served unstyled, with no error at build time or runtime.
build:manifest is a standalone script in pkgs/id/web/package.json ("build:manifest": "bun run scripts/build-manifest.ts"), so re-running it on an already-built dist/ — a rebuild retry, a packaging step, a developer re-running one stage — is a realistic invocation, not a contrived one. The full bun run build sequence masks the bug because build:css regenerates styles.css first.
Evidence (verified this run, laptop probe)
Fixture dist/ with styles.css + main.abc12xyz.js, script copied verbatim from pkgs/id/web/scripts/build-manifest.ts @ main d3c26e14b5, probe at ~/git/fleet/probe-build-manifest on the laptop:
- Run 1:
manifest.json: { "main.js": "main.abc12xyz.js", "styles.css": "styles.74d94aed.css" };dist/=main.abc12xyz.js,manifest.json,styles.74d94aed.css. Correct. - Run 2 (same dist, no regeneration):
manifest.json: { "main.js": "main.abc12xyz.js" };dist/=main.abc12xyz.js,manifest.json—styles.74d94aed.cssis gone and the manifest has nostyles.cssentry. Exit code 0.
The JS side does not have this defect: the hashed bundle is kept and re-recorded on re-runs (only stale extra bundles are removed, newest by mtime wins). The CSS side deletes first and asks questions never.
Related contract: pkgs/id/src/web/assets.rs is_hashed_filename (#6779) pins the emitted names (styles. + exactly 8 lowercase hex + .css); the deletion regex in the script ([a-f0-9]+, any length) is also broader than that contract.
Why it matters
A build step that destroys a built artifact on re-run, silently, turns a benign retry into a broken deployment: the server keeps serving pages whose stylesheet 404s. Nothing fails — not the script, not the server startup, not the manifest parse — so the breakage surfaces only as a visibly unstyled UI, far from the cause.
Acceptance criteria
- Running
build-manifest.tstwice in a row on the samedist/leaves the stylesheet file in place andmanifest.jsonstill mapsstyles.cssto it (idempotent re-run). - A re-run with no unhashed
styles.cssbut an existing contract-validstyles.<8-hex>.cssadopts that file into the manifest instead of deleting it (or fails loudly naming the missing input — silently dropping the entry is the one unacceptable outcome). - Stale-stylesheet cleanup still works: when
build:cssproduces a newstyles.csswhose hash differs, the old hashed file is removed and the manifest points at the new one. - The deletion/adoption patterns match the id(web/assets): is_hashed_filename treats any 8+ lowercase dotted segment as a content hash — ordinary names (app.development.js, styles.darkmode.css) get a one-year immutable Cache-Control at a stable URL #6779 emitted-name contract in
assets.rs(exactly 8 hex chars for styles), or the divergence is explicitly justified in a comment. - A regression test or fixture script exercises the double-run case (the probe above is a ready-made repro).
Activity
developing-today commentedon Nov 7, 2026
CODE-2207
dezren39 commentedon Nov 7, 2026
🤖 Agent note · state: filed
developing-today commentedon Nov 8, 2026
🤖 Agent note · picked up
4 remaining items
dezren39 commentedon Nov 8, 2026
🤖 Agent note · picked up
fix(id-web): build-manifest re-run keeps the stylesheet (#6969) (#7051)
dezren39 commentedon Nov 9, 2026
🤖 Agent note · done