fix(web): CMS without dev server, subdir package path, and reliable preview refresh#4670
Merged
Merged
Conversation
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>
…ile edits Resolve the committed `.deco/*.gen.json` snapshots (and block writes/deletes) under the virtual MCP's package path (`metadata.runtime.path`) so the CMS works for projects that don't live at the repo root (e.g. `<pkg>/.deco/...`). The daemon resolves file ops against the repo root, so the fallback reads and the FS-backed writes now prefix the package path via `decoRepoPath`. Also refresh the preview reliably after a decofile edit: a `.deco/*` `file-changed` (block save, external/agent write) now reloads the iframe via the debounced rebuild-wait, replacing the immediate save reload that raced the dev server rebuild and left the preview stale. The loading overlay shows instantly via a new `reloadStart` signal, then clears on iframe load. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…LineNumbers tests - B1 (blocker): gate the `.deco/*` file-changed invalidation + iframe reload on the dev server being `running`. When it's down, `blocks.gen.json` is a stale build artifact the dev server can't regenerate, so refetching it overwrote the optimistic cache update from useSaveBlock/useDeleteBlock and the edit visibly reverted — defeating the committed-snapshot editing feature. Also stops the loading overlay flashing over a dead preview. - I1: isDecoOnlyDiff now recognizes `<pkg>/.deco/...` so pure-CMS edits in a subdir package-path project can still be published directly (were misclassified as code changes and forced into Submit-for-review). - I2: add stripLineNumbers unit tests, incl. the \r / U+2028 / U+2029 regression the replace()-over-capture change fixes. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Rebase onto main pulled in main's refactor of the blog mutation hooks (shared postToSandbox helper + a context-free unit test). Resolving `useVirtualMCP` inside useSaveBlogBlock/useDeleteBlogBlock made them require ProjectContext, which that unit test doesn't provide. Thread the package path in via params instead: a new `usePackagePath` hook resolves it at the call sites (content-browser + the post/category/record editors), keeping the mutation hooks free of ProjectContext. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
guitavano
force-pushed
the
guitavano/decofile-schema-fallback-v1
branch
from
July 20, 2026 15:18
ad77d8b to
0526053
Compare
decocms Bot
pushed a commit
that referenced
this pull request
Jul 22, 2026
PR: #4670 fix(web): CMS without dev server, subdir package path, and reliable preview refresh Bump type: patch - decocms (apps/mesh/package.json): 4.92.0 -> 4.92.1 Deploy-Scope: web
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.
Summary
Makes the Blocks/Content CMS usable when the sandbox dev server is down, extends it to projects whose code lives in a subdirectory, and fixes the preview so it reliably auto-refreshes after an edit.
1. CMS works without the dev server
Read the committed
.deco/*.gen.jsonsnapshots straight from the working tree (via the daemon file proxy) as a fallback for the live/.decofile+/live/_metaroutes. The Blocks editor opens, the preview URL-bar page dropdown populates, and edits (which persist to the FS) still work even when the dev server is crashed/paused. The live routes take over once it comes back up (lifecycle re-invalidates the queries).crashedis treated as recoverable instead of terminal.2. Subdir package path support
The daemon resolves file ops against the repo root, but a project may live under a package path (
metadata.runtime.path, e.g.eitri-shopping-monte-carlo-shared). NewdecoRepoPath()helper prefixes that package path onto every.deco/*daemon path — committed reads (blocks.gen.json/meta.gen.json) and block writes/deletes (generic + blog) — so<pkg>/.deco/...resolves correctly. The live routes already resolve relative to the dev-server cwd, so only the daemon-relative paths needed the prefix. Thefile-changedSSE handler now matches/.deco/too, so subdir projects aren't misrouted.3. Reliable preview auto-refresh after an edit
Previously the iframe reloaded immediately on save — racing the dev server rebuild and often showing stale content, with no second reload. Now a
.deco/*file-changed(Blocks save, external/agent write, decofile regen) reloads the iframe via the debounced rebuild-wait (500ms) using the existing scroll/focus-preserving reload. The deadnotifySaved/previewRevisionplumbing was removed. A newreloadStartsignal shows the loading overlay instantly on change (before the debounce); the iframe'sonLoadclears it.Testing
bun run fmt,bun run --cwd=apps/mesh check(tsc),bun run lint(0 errors) all passdeco-repo-path.test.tsand updated reducer/tab-state testsFollow-up (not in this PR)
.deco/blocks/filters still assume repo root (JSON viewer only) — minor, subdir projects would mis-filter that list.🤖 Generated with Claude Code
Summary by cubic
Make the CMS and preview navigation work without the dev server, add subdirectory package support, and make preview refresh on
.deco/*edits reliable. Blocks/Content and the preview URL bar read committed snapshots when the server is down and switch to live data when it’s running.New Features
.deco/blocks.gen.jsonand.deco/meta.gen.jsonvia the daemon; live/.decofileand/live/_metatake over once running (queries revalidated on the lifecycle transition).crashedas recoverable so Blocks/Content stay editable from committed data; the preview URL-bar page/global dropdowns also load from the snapshot.decoRepoPathprefixesmetadata.runtime.pathon all daemon.deco/*reads/writes (Blocks + blog), andfile-changednow matches/.deco/for subdir projects..deco/*change reloads by 500ms to wait for rebuilds;subscribeReloadStartshows the loading overlay immediately; reload preserves scroll/focus.Bug Fixes
.deco/*invalidation and iframe reloads unless the dev server isrunningto avoid clobbering optimistic saves and overlay flashes on a dead preview.stripLineNumbersto remove only the<n>\tprefix, preserving lines with\r, U+2028, or U+2029.isDecoOnlyDiffnow recognizes<pkg>/.deco/...so pure CMS edits in subdirectory projects can be published directly.Written for commit 0526053. Summary will update on new commits.