Skip to content

fix(web): read committed .deco snapshots so CMS works without dev server#4630

Open
guitavano wants to merge 3 commits into
mainfrom
guitavano/decofile-schema-fallback
Open

fix(web): read committed .deco snapshots so CMS works without dev server#4630
guitavano wants to merge 3 commits into
mainfrom
guitavano/decofile-schema-fallback

Conversation

@guitavano

@guitavano guitavano commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Summary

Makes the Content tab (CMS) available and editable without a running dev server, by reading the committed .deco/ snapshots straight from the sandbox working tree, and fixes a latent stripLineNumbers bug that was silently truncating large file reads.

CMS without the dev server

  • useDecofile / useLiveMeta now read the committed .deco/blocks.gen.json (decofile) and .deco/meta.gen.json (live meta) via the daemon file-read proxy (/read) when the dev server is down, falling back to it even when the route errors (crashed dev script). The live /.decofile + /live/_meta routes still win once the dev server is up.
  • Single cache per key (KEYS.decofile / KEYS.liveMeta): the committed snapshot seeds it, so the existing optimistic block writes (which already persist to the FS via /write + /unlink) operate on a full base.
  • On the sandbox lifecycle running transition, the CMS queries are re-invalidated so they swap from the committed snapshot to the live routes.
  • content-browser passes fetchEnabled: devServerReady so it prefers committed while the dev server is down.

stripLineNumbers truncation fix

The daemon's /read returns line-number-prefixed content. stripLineNumbers used a (.*) capture whose . does not match \r, U+2028, or U+2029. A single-line minified JSON payload with an embedded line separator (common in pasted rich-text content) was truncated at the first such char — an ~11MB decofile was cut in half, breaking JSON.parse. Switched to a prefix-only replace that preserves the rest of each line verbatim. This also fixes the same latent corruption in the file explorer.

Testing

  • tsc, lint, fmt clean.
  • Verified end-to-end in the app: with the dev server paused, the 11MB .deco/blocks.gen.json now parses fully and the Content tab appears (diagnosed via temporary logging, since removed).

Notes / known limits

  • Requires the sandbox daemon to be reachable. A fully paused/suspended sandbox (pod frozen) still can't serve /read, so the tab won't show until resume — separate follow-up (read committed files from git directly).
  • Read source is the aggregate blocks.gen.json, which the dev server regenerates; while the dev server is down, a reload won't reflect just-written blocks until it regenerates.

🤖 Generated with Claude Code


Summary by cubic

Make the CMS Content and Blocks editors, plus the preview URL-bar pages/global list, work without the dev server by reading committed .deco snapshots. Also fixes a file-read bug that could corrupt large JSON files.

  • New Features

    • Read committed .deco/blocks.gen.json and .deco/meta.gen.json when the preview is down or live routes fail; used for the Content tab, Blocks editor, and Preview URL-bar lists before the dev server is up.
    • Added readCommittedJson; useDecofile/useLiveMeta prefer committed data until devServerReady, and the lifecycle running transition now invalidates queries to swap to live routes.
    • Treat crashed as recoverable so the Blocks editor stays available; ungated fetch params in Blocks panel and Preview while keeping fetchEnabled: devServerReady for live routes.
  • Bug Fixes

    • stripLineNumbers now uses a prefix-only replace to avoid truncating lines with \r, U+2028, or U+2029`, fixing corruption in large files.

Written for commit caf2f49. Summary will update on new commits.

Review in cubic

@guitavano
guitavano force-pushed the guitavano/decofile-schema-fallback branch from abedce1 to 65b677a Compare July 15, 2026 22:24
guitavano and others added 3 commits July 16, 2026 09:07
Read the committed `.deco/blocks.gen.json` (decofile) and `.deco/meta.gen.json`
(live meta) straight from the working tree via the daemon file-read proxy, so
the Content tab shows and is editable even before the dev server boots or when
the dev script has crashed (block writes already persist to the FS). The live
`/.decofile` + `/live/_meta` routes still take over once the dev server is up
(re-invalidated on the lifecycle `running` transition).

Also fixes `stripLineNumbers`, which used a `(.*)` capture whose `.` does not
match `\r`, U+2028, or U+2029 — a single-line JSON payload with an embedded
line separator was silently truncated at the first such char, corrupting large
files (e.g. an 11MB decofile cut in half). Switched to a prefix-only `replace`
that preserves the rest of each line verbatim.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Stop gating the preview's decofile/meta fetch on `devServerReady` so the URL-bar
page list and global-sections dropdown read the committed `.deco/*.gen.json`
snapshot when the dev server is down (page create + SEO edits persist to the FS).
The inline visual editor still requires the dev server — it overlays the page
rendered inside the iframe — but its activate postMessage is a no-op without a
rendered page, so nothing breaks.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…is down

When the dev server is paused/crashed the lifecycle phase is `crashed` ("was
running, stopped responding"), which `resolveBlocksTabState` treated as a hard
sandbox error — so the Blocks form editor was unavailable even though the
committed `.deco/*.gen.json` is still readable and block edits persist to the
FS (same as the Content tab). Treat `crashed` like `running` and let the data
drive the state, and stop gating BlocksPanel's decofile/meta fetch on
devServerReady so it reads the committed snapshot. The live preview canvas
stays broken until the dev server is back; genuine setup failures
(clone/install/start-failed) remain terminal errors.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@guitavano
guitavano force-pushed the guitavano/decofile-schema-fallback branch from 65b677a to caf2f49 Compare July 16, 2026 12:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants