Skip to content

feat(api): Blocks v8 server side — content protocol (GitHub + sandbox over the daemon's fs routes), hosted releases and site tokens - #7887

Closed
tlgimenes wants to merge 20 commits into
mainfrom
fold/v8-api
Closed

tlgimenes wants to merge 20 commits into
mainfrom
fold/v8-api

Conversation

@tlgimenes

@tlgimenes tlgimenes commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Server side of Blocks v8 (part 1 of 2). The editor that uses it is the stacked web PR, which needs this one merged first.

This PR and #7888 replace the v8 stack (#7877, #7800–#7825, #7803–#7840, #7841–#7843, #7871–#7878), whose PRs are closed with a link here; their branches are kept. The order is this API PR, then the web PR #7888.

PO decisions this implements

  • The sandbox daemon only does fs and git; the rest of the APIs live in Studio's backend. The daemon is unchanged (git diff origin/main -- packages/sandbox is empty). feat(daemon): content protocol in the sandbox daemon #7877, the Go content protocol, was closed as superseded.
  • v8 is decided per site, from main's schema. isV8Schema in @decocms/shared/blocks-major returns true when .deco/schema.gen.json has a top-level "blocksMajor": 8. There is no org flag.
  • Staging and prod share the site-token signing key and the R2 delivery bucket. There is no kill switch: a site leaves v8 when its main schema goes back to v7.

What's in it

packages/shared

  • blocks-major.ts is the one v8 detector. Its guard test fails if any other file decides v8 or reads meta.gen.json for that.
  • session-runtime: a v8 project that has a preview server always gets Fast Preview. v7 keeps its switch.
  • secret-ciphertext.ts: the sealed-box format shared by the server and the editor.
  • site-editor is now a reserved org slug.

Content protocol over GitHub (decofile.ts, decofile/repo-content-storage.ts)

  • POST /api/:org/decofile/:id/:branch/rpc serves the Blocks content protocol (createContentHandler from @decocms/[email protected]) over the repository. It also serves hosted draft publish and its status.
  • A v7 main gets a read-only answer with schema: null.
  • v8 gates are computed from main and never trust the marker. A site owned by another project gets 409 site_not_owned. An unconfigured bucket gets 503 hosted_delivery_unconfigured.

Content protocol in a sandbox (sandbox/content-storage.ts, sandbox-proxy.ts)

  • /api/:org/sandbox/:id/:branch/rpc runs the same protocol core over the daemon's existing authed routes: read, write, unlink and bash. There is no proxy to /_sandbox/rpc. A session without a sandbox gets 404.
  • Listing: one bash call per listing. Files that git diff-files sees as unchanged take their hash from git's index, which is git's own path + mtime + size check (racy entries are re-checked by content). Only changed, untracked or filtered files (autocrlf, filter, eol, working-tree-encoding) are hashed with git hash-object. On a 3,000-block repo with 2 dirty files, a listing takes about 0.1 s.
  • The listing goes through a file, not stdout. The command writes it to a folder in the sandbox's tmp and prints one line; Studio reads the file through /_sandbox/read. The file ends with an @end line. A missing @end, a malformed line or a truncated bash answer is refused as Unavailable, so a cut listing never pairs a hash with the wrong file or reads as an empty site. Each listing removes the previous one's folder; folders left by a pod that went away are swept after 5 minutes.
  • Reads: parallel, 8 at a time, and only for versions not already cached. Each sandbox keeps a warm handler (LRU of 16 sandboxes) with an 8 MiB body cache.
  • Apply: serialized per sandbox. Each apply takes a fresh listing and checks every expected version and the schema's. A mismatch gives the protocol's 409 Conflict and retry. Then the writes and deletes run in order and the listing cache is cleared. On failure every touched file is put back, including a write that landed but then timed out.
  • Edits right after a poll: the listing is reused for 250 ms. A block body that disagrees with that listing drops it, so a poll right after an agent edit reads the edit and does not fail with "kept changing".
  • Remaining race: another writer can still slip in between the check and the write. That means the agent, or another API pod, since the lock is per process. The daemon's own file routes have the same exposure.
  • Remaining cost, for the PO: each listing is one daemon task, so about one "task exit" log line and two "tasks" SSE broadcasts every 2 s per open editor. Its output is about 120 bytes. Only a daemon stat or listing route would remove this, and decision (1) rules that out.
  • Tests: the published conformance suite, the byte-for-byte parity run against the reference fs server, and the sandbox cases: outside edits, conflicts, a sub-folder app root, no .deco folder, rollback, cut listings, and index versus hashed versions (committed, staged, same-size edits, new, deleted, CRLF). They run against an in-process stand-in for the daemon in the unit tests, and against the real main daemon in content-storage.daemon.e2e.test.ts, a new step in the Sandbox workflow.

Hosted Deco CMS (hosted/, /api/:org/hosted/:id/{releases,site-tokens})

  • The delivery bucket (R2 through its S3 API) and its CDN purge, drafts, releases (list, and reapply an earlier version: see below), publish, and Ed25519 site tokens.
  • Config: DELIVERY_R2_*, DECO_SITE_TOKEN_SIGNING_KEY and CF_DELIVERY_ZONE_ID/CF_PURGE_API_TOKEN. When these are unset, the routes answer "not configured" and the purge is skipped with a warning.
  • The blocksMajor marker: it caches main's isV8Schema answer on the project. It is written only by code that has just run the predicate: create/import, thread create and the hosted gates.
  • Admin backfill: POST /api/_admin/hosted/site-claims/backfill is a dry run by default. It links existing v8 projects to their org_sites row and syncs the marker.
  • Project create: a free site slug is claimed for the new project's org. It never takes another org's slug, a deleted org's, or one deco.cx has. A linked site gets its managed asset config (S3); the deco.cx import shares that code (file-storage/managed-site-config.ts).
  • Thread create: a new thread on an unmarked repo-backed project checks for v8 first, bounded in time, so a v8 site gets the cms runtime.

Releases: Reapply version rolls forward (PO decisions 2026-10-14)

Releases never move latest.json back to an older commit. The pointer flip (makeCurrent) is deleted, and there is no kill switch.

  • POST /api/:org/hosted/:id/releases/:sha/reapply (hosted/reapply.ts) makes a NEW version whose content equals that version's.
    • It commits to main, restoring .deco/blocks/*.json from that version's commit:
      • A block changed since is copied back (copyFromRef: exact bytes, nothing uploaded).
      • A block added since is deleted.
      • An equal block is not touched.
      • schema.gen.json, index.ts and the rest of the code stay as they are. A tracked blocks.gen.json is regenerated, as Publish does.
    • Then it runs Publish's release path, now shared as releaseCommit(): companion release, latest.json, purge. It has the same main-moved check as Publish (409 main-moved).
    • If main already has that content, the answer is {result: "up-to-date"} and nothing is committed. A commit with no release gives 404.
  • Schema change (round 3): a version made for another schema is reapplied anyway. There is no 409 and no second confirmation.
    • The answer adds schemaChanged: boolean, which is logged as info.
    • GET …/releases/:sha/reapply → {schemaChanged} lets the dialog know before the user confirms. It compares the blob ids of schema.gen.json at both commits and reads the schemas only when the ids differ. Canonical JSON means a formatting-only change doesn't count.
    • The new commit keeps main's schema, so it is served with the current code. Going back is another reapply.
  • Message: follows git's revert convention: Reapply: <original note>.
    • It never chains: reapplying a reapplied version keeps a single prefix.
    • A version without a note gets Reapply: version from <YYYY-MM-DD HH:MM> UTC.
    • A Reapplied-From: <sha> trailer goes in the same block as the co-author, so GET releases returns reapplyOf: {sha}.
  • No served-revision reads: GET releases returns current (the latest.json pointer), the commits and the cursor. There is no telemetry or stats-lake query; decocms/stats-lake#64 was closed unmerged.
  • POST …/releases/retry (releaseMainHead) is Publish's "Try again" (it was releases/current, which is gone).
  • Git providers: content clients gain readCommit(sha) (GitHub, GitLab, Bitbucket). Insights commits carry body (GitHub messageBody).
  • Tests:
    • reapply.test.ts: changed/added/deleted blocks, only differing files touched, code untouched, gen artifact, empty diff, main moved, no release, schema changed (reapplied with schemaChanged: true), formatting-only schema change, message including chained and no-note cases, a later edit on top.
    • releases.test.ts: reapplyOf, releaseMainHead.
    • hosted-releases.test.ts route tests: reapply, the GET check, no 409 on a schema change, retry, and releases/current is 404.
    • v8-gates.test.ts: the gates.

With this PR alone

  • Nothing in apps/web calls the new routes yet, and web is unchanged: it typechecks against the new packages/shared.
  • v7 projects behave as on main, with two exceptions:
    • The managed assets' public base now defaults to https://assets.decocms.com (it was https://decoims.com).
    • The new-thread check above can add one main head read, ETag-cached, when a repo-backed project with a preview server has no marker and Fast Preview off.
  • The releases sidebar view and the web halves of the detector guard ship with the web PR. They need web code to exist.

Rebased on main 1a6b3da (2026-10-17)

The branch is rebased on origin/main at 1a6b3da99 (28 commits past f3dffbf3e), so the PR is mergeable again. The 20 commits are replayed one by one with the same subjects; the previous history is on backup/fold-v8-api-2026-10-17. One conflict, in the first API commit: apps/api/src/storage/virtual.ts, where main's #7966 already clears the request-cached project list on patchMetadata (the same line this branch added), so main's version is kept. Apart from that line, the branch's diff against main is the same as before the rebase. #8027 is still open, so nothing of it is in main yet; this branch never carried its commits.

Earlier rebase on main f3dffbf (2026-10-16)

The branch is rebased on origin/main at f3dffbf3e (106 commits past the last merge, 5015180cd). The three old merges of main are gone; the 15 commits of this branch are replayed on top of main, one by one, with the same subjects. The pre-rebase history is on backup/fold-v8-api-2026-10-16. The final tree equals a plain merge of the old head with main: the only conflicts were apps/api/Dockerfile (main's #8006 starts the server by path, so this branch's CLI-by-path change is dropped and deco-bin.test.ts now checks that the image starts Studio by path, never through the deco bin) and bun.lock (regenerated). In the first commit, commit-coalescer.ts takes the resolution of the old merge: the shared gen-artifact.ts helpers with #7909's accepted set/del. Main has not touched apps/api/src/decofile since 5015180cd, so #7909's server behaviour (the PATCH route's expect and 409 block-conflict, the per-block fingerprint check, the value-by-value merge on sync) is main's, unchanged. The v8 counterpart of #7909 (stale section saves refused through the content protocol's ifMatch) is in #7888.

Who made the other change, and when: hosted v8 only (PO 2026-10-16)

PO (final): "only have metadata and changed by on v8 hosted".

  • Where it lives: in the hosted draft object's storage metadata, never in its JSON. The draft stays exactly { set, delete }, no block carries anything, and the site's SDK never sees it.
  • Format: x-amz-meta-deco-edited on the draft object: entries joined by ;, oldest first. Each entry is <name>,<userId>,<seconds>. The name and user id are encodeURIComponent-escaped so the value stays ASCII, as a header must, and the time is in base-36 Unix seconds. The value is capped at 1900 bytes, under the 2 KB of user metadata S3 and R2 allow per object; past that the oldest entries are dropped first.
  • Writes: DraftStore.update stamps the names a save changed with the session user (the ref's editor). It keeps the others, drops names no longer in the draft, and writes the map with the draft. It carries the map forward from the GET the save already makes, so there's no extra HEAD per save.
  • Reads: load decodes the map from the same GET. The session GET answers changedBy: { [name]: { userId, at } } next to { draft, version }. The editor resolves names and avatars from the org's members.
  • Store support: DeliveryStore.putJson takes metadata and get returns it.
  • Fast Preview (v7) and Localhost: no who/when. The git-history route (changed-by), the trailer and author parsing, insights' path filter and the block __meta experiments are reverted in a06d99e1a.
  • Tests:
    • draft-editors.test.ts: encode and decode with any characters, malformed values, the cap dropping the oldest, and stamping.
    • draft-store.test.ts: the map carried forward across saves, one object, JSON free of ids, one put per save, discard and publish.

Checks

  • Rebase on 1a6b3da99 (2026-10-17, head 9661c28a7; the web half feat(web): Blocks v8 site editor — content backends, deco serve, hosted Publish, Versions and site tokens #7888 at 695fca387 on top): packages/shared, apps/api, apps/web and packages/e2e typecheck (tsc, single-threaded); oxlint, biome and knip are clean. Unit tier as CI runs it (per-file isolation, --parallel=2, 2 GB cap): the api, migrations, packages, plugins and scripts suites 6856 pass, 0 fail; the web suite 4819 pass, 0 fail. e2e on a production web build of the stack's top (shared Postgres/NATS, clean database and streams per run, 4 workers): site-editor-stale-form + content-protocol-deco-serve 23/23 twice; content-protocol-github + decofile-api + fast-preview-git-sync 44/44 (after two e2e test fixes in feat(web): Blocks v8 site editor — content backends, deco serve, hosted Publish, Versions and site tokens #7888), and content-protocol-github 22/22 twice more, including the hosted v8 "changed by" case. PR CI at 9661c28a7: every check passes (19 pass, the rest skipped by path).
  • Who and when on hosted v8 (a06d99e1a reverts e3544e9b7, 92038d914, d3df85b4c; 0d8ce2bdf the draft object's metadata, 2026-10-16): apps/api typechecks (tsc, single-threaded); oxlint and biome are clean. The hosted, decofile, v8-gates and decofile route tests pass (318). The tree outside apps/api/src/hosted and the session GET equals 3914dd50e.
  • 2026-10-16: this branch is unchanged at 3914dd50e. The web half feat(web): Blocks v8 site editor — content backends, deco serve, hosted Publish, Versions and site tokens #7888 is at 10684efe8 with the concurrent-edit fixes from the spike; e2e on its production build (this API included): decofile-api, fast-preview-git-sync, content-protocol-deco-serve and site-editor-stale-form pass.
  • After the rebase on f3dffbf3e: apps/api, packages/shared and apps/web typecheck (tsc, single-threaded), oxlint and biome are clean. Unit tests: the api, migrations and shared suites 5946 pass, 1 fail (heartbeatWhileQueued in hosted-harness-workflow.test.ts, a timing test this branch does not touch; it passes 2 of 3 runs alone); the web suite 4771 pass, 0 fail.
  • Before the rebase: the branch includes origin/main at 5015180cd (merge af8b74dde). After that merge: the decofile, hosted and route tests 335 pass, packages/shared decofile tests 49 pass (including block-merge.test.ts), the api and shared unit suites 5882 pass (7 fail only when run in one process, from mocks leaking across files; each passes alone), apps/api, packages/shared and packages/e2e typecheck, oxlint, biome and knip are clean. Locally, e2e decofile-api.spec.ts (19) and fast-preview-git-sync.spec.ts (3) pass.
  • CI on this PR at 08eb358bf is green: Checks & Unit Tests, E2E, Sandbox (including the daemon content step), Storage Integration, SAST and CodeQL. Multi-Pod failed twice on the PR run in the rollout churn scenario, at two different steps; the same SHA then passed when dispatched (38444820216), and so did the stack's top (38444814521).
  • The e2e spec decofile-api.spec.ts now expects the coded no_repository 404. It moved here from the web half so this PR is green on its own.
  • apps/api, packages/shared and apps/web typecheck. oxlint, biome and knip are clean.
  • Locally: storage unit tests 90 pass, the real-daemon e2e 85 pass, the route test 3 pass. Tests that need Postgres/NATS run in CI.
  • git diff origin/main -- packages/sandbox is empty.
  • Reapply version (453ebb6b2): PR CI is green, including Checks & Unit Tests 38505127392, E2E 38505127290, Sandbox, Storage Integration, Multi-Pod, Native, SAST and CodeQL. Locally, the hosted and route tests pass (566), and apps/api typechecks.

🤖 Generated with Claude Code

https://claude.ai/code/session_016ZsmzpZ2zahRBoATBb2tBu

try {
return await daemon(claim, path, init);
} catch (error) {
return new Response(JSON.stringify({ error: String(error) }), {
This was referenced Oct 13, 2026
tlgimenes added a commit that referenced this pull request Oct 16, 2026
…, and when

GET /api/:org/decofile/:project/:branch/changed-by?block=<key> (1 to 5 keys,
signed-in members only) answers { changedBy: { [key]: { name?, email?,
avatarUrl?, at, you? } } } for the "someone else changed this" dialog. The
editor asks once per version the dialog shows, never per poll.

Nothing new is stored: the block file's latest commit on the draft branch
(insights listCommits with a new `path` filter, limit 1: one GitHub call per
block) gives the Co-authored-by trailer the commit coalescer appends, else
the commit author when it is a person, and the commit time. The identity is
mapped to the org member (name, avatar) by email, else the git name; `you`
when it is the viewer. Unknown parts are left out.

Insights commits now carry the message body (where the trailers are), and
insightsClientForProjectRepo opens a project's history client, as on the
Blocks v8 line (#7887).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016ZsmzpZ2zahRBoATBb2tBu
tlgimenes added a commit that referenced this pull request Oct 18, 2026
…, and when

GET /api/:org/decofile/:project/:branch/changed-by?block=<key> (1 to 5 keys,
signed-in members only) answers { changedBy: { [key]: { name?, email?,
avatarUrl?, at, you? } } } for the "someone else changed this" dialog. The
editor asks once per version the dialog shows, never per poll.

Nothing new is stored: the block file's latest commit on the draft branch
(insights listCommits with a new `path` filter, limit 1: one GitHub call per
block) gives the Co-authored-by trailer the commit coalescer appends, else
the commit author when it is a person, and the commit time. The identity is
mapped to the org member (name, avatar) by email, else the git name; `you`
when it is the viewer. Unknown parts are left out.

Insights commits now carry the message body (where the trailers are), and
insightsClientForProjectRepo opens a project's history client, as on the
Blocks v8 line (#7887).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016ZsmzpZ2zahRBoATBb2tBu
tlgimenes added a commit that referenced this pull request Oct 19, 2026
…e into someone else's text (#8027)

* fix(web): a skipped preview transition no longer logs an uncaught AbortError

Quick successive saves skip the running view transition; its ready and
updateCallbackDone promises then reject with "Transition was skipped" and
only finished was handled. The swap now settles all three.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016ZsmzpZ2zahRBoATBb2tBu

* fix(web): a section form saves one change at a time, so a refused save can't drop the next edit

Under load the form's autosave could send a second save while a first one
was still on its way. When the first was refused as stale, the second was
built on a copy that never landed: mutate() reported only its outcome, its
starting point was put back to the unsaved first edit, and the replay on
the stored block then counted the user's own edit as a conflict and kept
the stored value. The user's edit was lost and the toast named the wrong
field (seen on a v7 site with two people on one block).

- A section form now has one save on the wire at a time; the next is built
  once that one lands or is refused (mutateAsync, so every outcome is
  heard). A retry after a refusal reads the form's value when it runs.
- The conflict toast names fields by their label in the form ("Headline",
  not "title"), says "The latest version was kept." when nothing else of
  the form's was left to save, and every outcome of one change shares one
  toast.
- With main's #8000, a refused save is retried with backoff (up to 3
  times) before the form reloads; while a retry waits out its backoff the
  form's next saves wait behind it, as behind a save on the wire, and the
  retry carries the form's latest value.

Tests: e2e "a form that saves again while its refused save is on the wire
keeps both edits" (fails before: the headline goes back to the stored one
with a "Changed while you were editing: headline" toast); the same-field
e2e now expects the label and the shorter copy; unit tests for the labels.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016ZsmzpZ2zahRBoATBb2tBu

* fix(web): a merge never swaps a field under the user's cursor

Under load the form's autosave fires while the user is still typing. When
the save comes back merged and the merge kept another editor's value of
the field being typed in, the form showed that value at once, so the next
keystrokes landed after it ("Picks A again" + "holk" ...) and the mix was
saved as the user's edit, over the other editor's value. The reload after
the last retry re-seeded the form under the cursor the same way.

While focus is in the open form, those now wait: the form keeps showing
what the user types (its saves keep merging onto the stored section, so
the field keeps the stored value) and re-reads the stored section once
the user leaves the form and its own saves have settled. Merges that kept
every edit of the form still show at once.

Tests: e2e "typing on after a save kept the other editor's value does not
add the keystrokes to that value" (fails before: the field reads
"Published headline more"); the same-field e2e checks the stored value
after the user leaves the field; unit tests for mergedFormDisplay.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016ZsmzpZ2zahRBoATBb2tBu

* fix(web): what a user types after "The latest version was kept" is saved

When a save kept another editor's value of the field the user is typing in,
the form keeps showing their text until they leave it (05d4ae5), but its
baseline stayed the refused copy. Their next keystrokes were merged against
that copy again, lost to the stored value with a second toast, and the field
went back to the stored value when they left it: the edit was gone.

The form's baseline is now the merge it saved, and FormBase.displayed holds
what the form shows instead. A field the user changes after the notice is
saved over the stored value they were told about; a field they leave alone
keeps the stored value; a change from elsewhere after that is still caught
by #7909's check. Nothing is ever a mix of both texts.

Tests: e2e "typing on after a save kept the other editor's value saves what
the user typed, never mixed with that value" (fails before: the stored
headline stays "Published headline"); unit tests for formValueOnBase and
displayedOverBase. The spec's toast and poll waits allow for main's backoff
retry (#8000) under load, and toasts are counted as they appear.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016ZsmzpZ2zahRBoATBb2tBu

* fix(web): typing the same text again after "The latest version was kept" saves it

After a save kept another editor's value of the field the user is in, the
field still shows the user's text (until they leave the form). A user who
insists, selecting it and typing the same text again, ended with the value
the form already showed, so nothing counted as changed: the save kept the
stored value and the field flipped to it when they left.

Every value the user changes after the merge is now marked in
FormBase.displayed, so it is theirs even when it ends as it was shown.
Values they don't touch still keep the stored value.

Tests: e2e "typing the same text again after the latest version was kept
saves it" (fails before: the stored headline stays "Published headline");
unit tests for markEditedSinceDisplayed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016ZsmzpZ2zahRBoATBb2tBu

* test(e2e): stale-form toasts are counted as they appear

"a form that saves again while its refused save is on the wire keeps both
edits" counted the toasts on screen after a poll of up to 30 s; on a busy
machine the toast had already expired (count 0). Toasts are now counted by
text as they appear, as in the typing-on test.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016ZsmzpZ2zahRBoATBb2tBu

* feat(web): a same-field edit conflict asks the user whose version to keep

When the user and someone else changed the same values of a section, the
form no longer keeps the stored value with a toast and the "on-leave"
heuristics. Nothing of the form's is written: its saves wait, and one dialog
("Someone else changed this while you were editing") lists each value by
its form label, "Your version" next to "Their version" (a word diff for
text, a thumbnail for images, a summary for lists and objects), with "Keep
mine" / "Use theirs" per field and "Keep all mine" / "Use all theirs".
Apply saves the choice against the stored version the dialog showed (the
save's `expect`); a newer one refuses it and the same choice is asked again
with that version. "Decide later" keeps their version stored and the
user's edits in the form, unsaved, with a "Choose versions" notice. Values
only one side changed still merge silently, now item by item within lists.

Removed: the "Changed while you were editing" toasts, mergedFormDisplay
"on-leave", FormBase.displayed (typing on after the toast saving over
theirs). A save's page, page variant and section variant are fixed when it
is scheduled, so a choice made after the user moved on still writes there.

(Port of 731befa from the v8 stack, without the v8 parts.)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016ZsmzpZ2zahRBoATBb2tBu

* test(e2e): same-field conflicts go through the choose-versions dialog

site-editor-stale-form: keep mine, decide later then use theirs, mixed
per-field choices, different fields merge with no dialog, a third change
while the dialog is open asks again with the newer version. The hero
fixture gains a Subtitle field.

(Port of c63ee03 from the v8 stack, without the deco-serve case.)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016ZsmzpZ2zahRBoATBb2tBu

* test(e2e): find the form behind the conflict dialog with includeHidden

The Keep mine case checked the headline after typing into the open dialog
with the form's role locator. The dialog is modal, so everything outside it
is aria-hidden and the locator found nothing ("element(s) not found", the
form showing "Draft headline" behind the dialog in the screenshot). The
check now includes hidden elements.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016ZsmzpZ2zahRBoATBb2tBu

* feat(api): changed-by tells the site editor who made the other change, and when

GET /api/:org/decofile/:project/:branch/changed-by?block=<key> (1 to 5 keys,
signed-in members only) answers { changedBy: { [key]: { name?, email?,
avatarUrl?, at, you? } } } for the "someone else changed this" dialog. The
editor asks once per version the dialog shows, never per poll.

Nothing new is stored: the block file's latest commit on the draft branch
(insights listCommits with a new `path` filter, limit 1: one GitHub call per
block) gives the Co-authored-by trailer the commit coalescer appends, else
the commit author when it is a person, and the commit time. The identity is
mapped to the org member (name, avatar) by email, else the git name; `you`
when it is the viewer. Unknown parts are left out.

Insights commits now carry the message body (where the trailers are), and
insightsClientForProjectRepo opens a project's history client, as on the
Blocks v8 line (#7887).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016ZsmzpZ2zahRBoATBb2tBu

* feat(web): the same-field conflict dialog says who made the other change, and when

Under the dialog's title: "Changed by Ana Souza · 3 minutes ago" with the
member's avatar and the exact time on hover; "You, in another tab or window
· …" for the viewer's own change; "Changed … ago" when only the time is
known. No line while it isn't known (never "unknown"). en and pt-BR.

A Fast Preview session asks Studio's history (GET …/changed-by) once per
version of theirs the dialog shows, never per poll: "Their version changed
again" reads who and when again. A sandbox session shows nothing. The
conflict remembers the block its save writes (a saved block, else the page).
formatRelativeTime comes from the Blocks v8 line (#7888).

e2e (written, not run here): stale-form asserts "You, in another tab or
window" for the same user's other save and "Changed by Dev Person" after a
developer's push while the dialog is open. The GitHub stub gains the
GraphQL commit history (as on #7888) with a path filter, commit dates and
authors, and an admin push; the API's GraphQL URL points at the stub.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016ZsmzpZ2zahRBoATBb2tBu

* Revert who/when in the same-field dialog on main

This reverts commits 9dcf8fb and 46fe475. PO (final): "only have
metadata and changed by on v8 hosted": a v7 (Fast Preview) dialog shows no
"changed by" line. The dialog itself stays. Gone with it: the changed-by
route, commit trailer/author parsing, insights' path filter and message
body, insightsClientForProjectRepo and formatRelativeTime copied for it, the
GitHub stub's history and push, and the GraphQL URL in the e2e config.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016ZsmzpZ2zahRBoATBb2tBu

* fix(web): the conflict dialog reads rich text with the DOM parser, never regex sanitizing

CodeQL flagged the tag stripping and entity decoding (incomplete multi-character
sanitization, double unescaping). Text now comes from DOMParser's textContent;
without a DOM, tags are dropped until none is left and each entity is decoded once.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016ZsmzpZ2zahRBoATBb2tBu

* feat(web): the same-field dialog must be answered, with yours preselected

PO 2026-10-18: "Keep yours" / "Use theirs" wording, and "If the user needs
to decide, we need to raise an alert dialog with no close option" (Decide
later left the form in a frozen state). Picked: must-decide, yours
preselected.

- FormConflictDialog is an AlertDialog with no close button; Escape and a
  click outside don't close it. Only "Save selected versions" does.
- Every conflicting field starts on "Keep yours" (defaultConflictChoices);
  a re-plan (their version changed again) keeps the choices that still
  hold and puts the rest back on yours. "Use theirs" switches every field.
- Removed: Decide later, the "not saved yet / Choose versions" notice,
  conflictDialogOpen, reviewFormConflict, everyConflictChosen and their
  strings. One save at a time and the expected-version guard are unchanged.
- pt-br: "Manter a sua" / "Usar a deles" / "Salvar versões escolhidas".
- Tests: unit (default yours, one click, mixed, switch all, no close
  affordance); e2e stale-form drops the decide-later case, adds Escape /
  click outside, default saves yours, Use theirs for every field.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016ZsmzpZ2zahRBoATBb2tBu

* fix(web): the conflict dialog takes focus when it opens

Radix's alert dialog focuses its Cancel button on open; this one has none,
so focus stayed in the form behind it and keys typed after the dialog
appeared still reached the field (the stale-form e2e caught "Draft
headlinexyz"). Focus the dialog itself: typing stops there, and a space
typed mid-word can't press a button.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016ZsmzpZ2zahRBoATBb2tBu

* fix(web): a skipped page-to-page preview transition no longer logs an uncaught AbortError

A site that opts into cross-document view transitions
(`@view-transition { navigation: auto }`, as the Storefront v7 store does)
gets one on every reload a Fast Preview save makes. When the next save
navigates the frame before that transition starts, Chrome skips it and
rejects the outgoing page's `pageswap` transition `ready` promise with
"AbortError: Transition was skipped". Nothing handled it, so the editor's
page logged an uncaught error (QA-8027, step 8).

The editor script, injected into every preview page on load, now settles
the promises of the outgoing page's transition from a `pageswap` listener
(registered once per page and kept after deactivate), with the same helper
the in-place swap already used.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016ZsmzpZ2zahRBoATBb2tBu

* fix(web): the open conflict dialog follows their version in place

While a same-field dialog was open nothing read the stored blocks again,
so "their version" stayed the copy the dialog opened with; a newer save
only showed after "Save selected versions" was refused (QA-8027, step 5).

While a dialog is open, the editor's own decofile read runs again every
3 s (15 s after two minutes open), one poll however many fields or waiting
saves, stopped when the dialog closes. A tick is skipped while a write is
on the wire, a read is running or just landed, or the tab is hidden. On
Fast Preview the read first asks the branch head conditionally
(`If-None-Match`, the same GET): an unchanged branch answers 304, with no
body and no new draft grant, so the preview pointer (and frame) stays put.
The newer copy goes through the existing render-time re-plan, now
`refreshWaitingChoice`: their version in place, "Their version changed
again while this was open.", picks kept where both versions are unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016ZsmzpZ2zahRBoATBb2tBu

* test(e2e): the open conflict dialog shows a newer version of theirs with no click

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016ZsmzpZ2zahRBoATBb2tBu

* fix(web): a Fast Preview frame loads one draft at a time

Every save gives the preview a new `?__draft=` pointer, and React set it on
the frame at once, even while the frame was still loading the last one.
That cancels the load (its render is wasted, so quick saves showed nothing
new until they stopped), and on a site with page-to-page view transitions
(`@view-transition { navigation: auto }`) the page being left rejects its
`pageswap` transition with "AbortError: Transition was skipped". Measured
on the kit: the store answered about 0.9 s after a save's navigation, the
next save's pointer came 0.5 s later, before the page committed (QA-8027,
step 8). The editor script settles that promise where it runs, but a v7
site only runs it for the origins its LiveControls trusts.

A Fast Preview pointer that arrives while the frame loads now waits for
the frame's load; then the latest goes in, the ones in between skipped.
A held navigation whose load never fires is released after 15 s. Other
frames (sandbox, Local) follow their src at once, as before.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016ZsmzpZ2zahRBoATBb2tBu

* fix(web): the merge toast says both changes were kept

"Your changes were applied on top of the latest version" read like an
override. When different fields were changed, both edits are kept, so it now
says so: "Someone else also edited this block. Both changes were kept."

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016ZsmzpZ2zahRBoATBb2tBu

* feat(web): the same-field dialog shows two people, two cards

The product owner picked "Option B: two people, two cards" ("i like the
friendliest option b") for the dialog that asks whose version to keep.

One field in conflict, the common case: "Someone else changed the title
while you were editing", "Pick the one to keep. The other is discarded."
Two whole-card choices, stacked: "You" (your avatar or initials, "Your
version · not saved yet") and "Someone else" ("Their version · already
saved"), each with its text and the changed words marked. Each card is a
radio (arrow keys move the choice). Yours is chosen; the one button names
what saving does: "Keep yours" or "Use theirs".

Two or more fields: a row per field with its label, a Yours / Theirs switch
and that side's value. "Use theirs for all", and a button that names the
outcome: "Keep yours", "Keep a mix" or "Use theirs".

Unchanged: it must be answered (no close button, Escape or click outside),
it follows their newer version in place while open, images, lists and
objects keep their previews. Strings the old layout used are removed;
pt-br says "o campo “Título”", which reads naturally whatever the label's
gender.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016ZsmzpZ2zahRBoATBb2tBu

* chore(web): applyLabel is not exported

Only the dialog uses it (knip).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016ZsmzpZ2zahRBoATBb2tBu

* feat(web): several conflicting fields are asked one at a time

The product owner approved "one field at a time" for a conflict on several
fields ("good"), replacing the Yours / Theirs switch per field.

Each field gets a step with the same two cards as the single-field dialog,
yours chosen: "Someone else also changed the title", "Pick the one to keep.
You can go back before saving." A dot per field (a button named by it; the
current one wider, the ones moved on from filled) and "1 of 3" above. Next
keeps the pick and moves on; Back, a dot or the ←/→ keys revisit a step
(not while typing in a text field; on a card, ↑/↓ change the pick). The
last step sums up the picks ("Title: yours · Button text: theirs") and its
button names the outcome: "Keep yours", "Keep a mix" or "Use theirs".
Nothing is saved before that click, and the second click of a double click
on Next doesn't count as one.

"Use theirs for all" stays on every step: it picks theirs everywhere and
goes to the last step, so saving is still one click on "Use theirs".

When their version changes again while the dialog is open, the steps show
the newer values, the picks that still apply are kept, and the dot of each
field whose value changed gets a ring until it is visited
(markTheirsChanged counts the changes per field).

One field is unchanged: no dots, no Back or Next. The switch layout's code
and strings are removed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016ZsmzpZ2zahRBoATBb2tBu

* feat(web): the conflict dialog's buttons read Next and OK

The product owner asked for plain step buttons: "Remove the 'use theirs
for all' button", the primary as "next/next/done", then "instead of done,
ok".

With several fields, every step but the last shows Next and the last one
OK, which saves the picks as "Keep yours" / "Keep a mix" / "Use theirs"
did. The single-field dialog's button is OK as well. pt-br: "Próximo" and
"OK".

"Use theirs for all" is gone from every step, with its strings, unit test
and e2e case; so is the label that named the outcome and its strings.
Cards, dots, Back, the last step's summary, the arrow keys, the must-decide
dialog, the refresh ring, yours preselected and the double-click guard on
the last Next are unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016ZsmzpZ2zahRBoATBb2tBu

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
tlgimenes and others added 20 commits October 19, 2026 14:49
…ciphertext

- blocks-major: the one place that decides whether a project is a Blocks v8
  site (isV8Schema / isBlocksV8Project), with a guard test that no other file
  decides v8 or reads meta.gen.json for it.
- session-runtime: a v8 project (server-managed blocksMajor: 8) with a preview
  server always has Fast Preview; v7 keeps its switch, unchanged.
- secret-ciphertext: the sealed-box format shared by the server and editor.
- site-editor is a reserved organization slug (it is a top-level route).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01WNwbSEePYNcY5YCgqZURig
…ite tokens

Server side of Blocks v8 (no UI calls any of it yet; v7 projects are
unchanged):

- decofile routes: POST /api/:org/decofile/:id/:branch/rpc serves the
  Blocks content protocol (createContentHandler from @decocms/blocks) over
  the repository (decofile/repo-content-storage.ts), plus hosted draft
  publish and its status. gen-artifact.ts is the shared blocks.gen.json
  regeneration and commit message the commit coalescer now uses.
- hosted/: the delivery bucket (R2 through its S3 API) and its CDN purge,
  drafts, releases (list + roll back the current one), publish, site
  tokens (Ed25519), the v8 scope checks and the blocksMajor marker that
  caches main's isV8Schema answer on the project. Unconfigured (no
  DELIVERY_R2_* / DECO_SITE_TOKEN_SIGNING_KEY) they answer 'not configured'.
- /api/:org/hosted/:id/{releases,site-tokens}; admin backfill route that
  links existing v8 projects to their org_sites row and syncs the marker.
- project create claims a free site slug for its org (never another org's,
  a deleted org's, or a deco.cx one) and gives a linked site its managed
  asset config; the deco.cx import shares that config code
  (file-storage/managed-site-config.ts). A new thread on an unmarked
  repo-backed project checks for v8 first (bounded) so it gets the cms
  runtime for life.
- the managed assets' public base defaults to https://assets.decocms.com.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01WNwbSEePYNcY5YCgqZURig
…utes

The sandbox daemon stays files and git only (packages/sandbox untouched).

POST /api/:org/sandbox/:id/:branch/rpc now runs the same protocol core
GitHub mode uses (createContentHandler) over a new storage,
apps/api/src/sandbox/content-storage.ts, backed by the daemon's existing
authed routes:

- listing: one /_sandbox/bash call hashes `.deco/blocks/*.json` and the
  schema/secrets files with `git hash-object` (exact git-blob versions of the
  uncommitted working tree; the daemon has no stat route);
- reads: /_sandbox/read in parallel, only for versions the core's per-sandbox
  body cache lacks (handlers stay warm per claim, LRU of 16);
- apply: under a per-sandbox lock, a fresh listing checks every expected
  version and the schema's (stale -> the protocol's Conflict/retry), then
  ordered /_sandbox/write and /_sandbox/unlink calls, rolled back on failure;
  the listing cache is invalidated after every write.

The daemon e2e conformance suite moves with it: the published conformance
suite, the byte-for-byte parity run against the reference fs server and the
sandbox-specific cases now run against the Studio route, over an in-process
stand-in for the daemon's fs routes (unit) and over the real main daemon
(content-storage.daemon.e2e.test.ts, run by the Sandbox workflow).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01WNwbSEePYNcY5YCgqZURig
…f failing

The sandbox listing is reused for 250 ms. When the agent wrote a block in
that window and the core had to read its body, the bytes never matched the
reused listing, so all three of the core's snapshots saw the same stale
versions and the poll failed with "saved blocks kept changing while being
read". A body that disagrees with the listing now drops it, so the core's
next snapshot is fresh. Found by driving the real main daemon with an agent
writing through /_sandbox/write while the editor polled and saved.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01WNwbSEePYNcY5YCgqZURig
… coded

The decofile routes now answer {error, code: "no_repository"} (the editor
reads that code as a v7 answer), so the spec expects the code.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01WNwbSEePYNcY5YCgqZURig
… back the file in flight

- The listing no longer travels through /_sandbox/bash stdout, where the
  daemon keeps only the last 256 KiB: big sites lost the head of it, and past
  ~6.4k blocks it parsed as an empty site that an apply could overwrite. The
  command writes it to a file in the sandbox's tmp and prints its path; Studio
  reads it back through /_sandbox/read. A `truncated` answer is refused, and the
  listing (one `<hash> <path>` line per file, then `@end`) is refused unless
  complete, so a cut can never read as a short or empty site.
- Hashes come from git's index for the files git's own path + mtime + size
  check says are unchanged, and `git hash-object` runs only on changed,
  untracked or filtered files. The task's output is one line, so a retained
  daemon task costs almost nothing.
- commit() marks each file as touched before its daemon call, so a write or
  unlink that landed but then timed out or lost its connection is rolled back
  with the rest.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01WNwbSEePYNcY5YCgqZURig
A discard in the v8 editor writes main's version of a block back through
blocks.apply. applyAttemptToDraft now drops the draft entry when the put
equals main's one file for that name (by blob sha, else as JSON values)
instead of keeping a copy, which would shadow a later change on main and
never let the draft be empty. The write reports main's version for it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01WNwbSEePYNcY5YCgqZURig
…flip

Releases no longer move latest.json back to an older commit. Republishing a
release (POST hosted/:vmcp/releases/:sha/republish) commits that release's
.deco/blocks/*.json on main (only the files that differ: copied from the
release's commit, blocks added since deleted; schema, index.ts and the rest
of the code untouched), then runs Publish's release path (companion release,
latest.json, purge), with the same main-moved conflict check. A release made
for another schema asks again (409 schema-mismatch) and goes live once
confirmed.

The message follows git's revert convention: "Republish: <note>", never
chained, "Republish: release from <date UTC>" for a release without a note,
plus a Republished-From: <sha> trailer that Releases returns as
`republishOf`.

Releases also returns `serving`: the release the site reports serving, from
its telemetry in the stats lake (deco.release on the upstream-fetch
histogram and the error logs, last 15 min; a bundled snapshot's content
revision is matched to the newest release with that content). A source
that fails (no grant on the histogram yet, a timeout) is skipped; none
answering is `{ source: "none" }`, the pointer fallback.

makeCurrent and its { sha, confirm } route are gone; releases/current keeps
only { head: true }, Publish's "Try again". Content clients gain
readCommit; insights commits carry the message body.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01WNwbSEePYNcY5YCgqZURig
…ds; releases/retry

Reapplying a version (POST hosted/:vmcp/releases/:sha/reapply) still rolls
forward: a new commit on main with that version's .deco/blocks/*.json (only
the files that differ), then Publish's release path with the same main-moved
check. A version made for another schema is no longer refused or asked
about twice: it is reapplied, and the result carries `schemaChanged` (also
logged) so the screen can say how to go back. GET releases/:sha/reapply
answers `{ schemaChanged }` before the user confirms: it compares the
schema's blob ids at both commits and only hashes the schemas when they
differ (a formatting-only change is not a change).

The message is "Reapply: <note>" (never chained; "Reapply: version from
<date> UTC" without a note) with a Reapplied-From: <sha> trailer, returned
by Releases as `reapplyOf`.

Releases no longer reads what the site serves: hosted/serving.ts and the
`serving` field are gone. `current` is the latest.json pointer, nothing
more. Publish's "Try again" moves from releases/current to releases/retry
(releaseMainHead); releases/current no longer exists.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01WNwbSEePYNcY5YCgqZURig
…s date

reapplyVersion looked for .deco/schema.gen.json in listDecofileEntries,
which (on GitHub, GitLab and Bitbucket) lists only blocks.gen.json and
.deco/blocks/*, so schemaChanged was always false and the toast never
said how to go back. Both the check and the reapply now read the schema's
entry with getEntriesAtPaths. The test fake's listDecofileEntries now lists
what the real providers list, which is what hid this.

Releases also reads the date of a reapplied version's original when it is
not on the same page (one commit read each), so the row can still say
"Same content as the version from <date>".

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01WNwbSEePYNcY5YCgqZURig
….2.1)

Pins @decocms/blocks to 8.2.1 (content protocol 1.1) and gives both
Studio content storages the three new primitives, so changes.list,
changes.get and changes.discard answer on every v8 source.

- Hosted: the base is main's head. The changes are the files the draft
  makes differ from main (its own names; a set byte-equal to main isn't
  one), base bodies come from main by blob sha, and a discard drops the
  names from the draft so main shows through whatever its bytes or
  spellings. expectedBase is checked against main, and a discard's
  expected versions inside the draft lock.
- Sandbox: the base is HEAD, read in the same listing (one bash call per
  poll): commit, branch, ls-tree blob ids, and git's filters confirm
  files that only differ by a checkout conversion. Base bodies come from
  cat-file --filters as base64. A discard unstages what it restores
  (reset / rm --cached, both sides of a staged rename) and puts the index
  back if a write fails, as deco serve 8.2.1 does. No daemon changes.
- The v7-main storage answers an empty base.
- The v8 answers on /git/status, /git/diff and /git/discard are gone:
  hosted/draft-publish-status.ts is deleted and sandbox-proxy.ts is back
  to main's text for those routes; the editor uses changes.* instead.

Tests: the published 8.2.1 conformance suite (changes cases included)
over hosted (stub main + draft store, baseEntry) and sandbox (committed
base, and an unborn one), the parity run with changes.* calls against a
deterministic commit, CRLF, unstaging, app root and stale-base cases;
the same suites pass over the real Go daemon.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01WNwbSEePYNcY5YCgqZURig
…p unused exports

The hosted discard case the web branch carried (it drove the deleted
draftGitDiscard) now discards through the content protocol, and checks
the discard's revision is the next read's. draftFileChanges and the
sandbox suite's base entry name are module-private again.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01WNwbSEePYNcY5YCgqZURig
…date>"

The Releases screen says "release", never "version": the server-written
fallback note follows ("Reapply: release from <date>", "Reapply: earlier
release").

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01WNwbSEePYNcY5YCgqZURig
…, and when

GET /api/:org/decofile/:project/:branch/changed-by?block=<key> (1 to 5 keys,
signed-in members only) answers { changedBy: { [key]: { name?, email?,
avatarUrl?, at, you? } } } for the "someone else changed this" dialog. The
editor asks once per version the dialog shows, never per poll.

- Fast Preview (v7): nothing new is stored. The block file's latest commit on
  the draft branch (insights listCommits with a new `path` filter, limit 1:
  one GitHub call per block) gives the Co-authored-by trailer the coalescer
  appends, else the commit author when it is a person, and the commit time.
- v8 hosted drafts are not git: each draft save now records, per draft name,
  the Studio user and time in the org KV record next to the draft slug
  (never in the draft object, which anyone with its URL can read). Discarded
  or published names drop their record. A block the draft doesn't hold falls
  back to main's history, like v7.
- The identity is mapped to the org member (name, avatar) by user id or
  email, else the git name; `you` when it is the viewer. Unknown parts are
  left out.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016ZsmzpZ2zahRBoATBb2tBu
…d times only

PO: "write on the public draft, no worries. write the user_id and grab user
data on the front maybe". Each hosted draft save writes, per name it
changed, { userId, at } to sites/<site>/drafts/<slug>.edits.json, next to
the draft, instead of the org KV. The draft object itself stays exactly
{ set, delete }: every released @decocms/blocks 8 refuses a draft with any
other field (parseDraftChanges: "unexpected field"), and the SDK never
reads the sibling, so the ids can't reach a rendered page. Publish removes
both objects; the KV record is the slug again.

The session GET answers `edits` with `?edits=1`: every name the draft holds,
{ userId, at } or null when not recorded; the editor resolves the people
from the org's members. changed-by no longer reads the draft: on a v8
project it answers main's history for the keys asked (the editor asks only
for names the draft doesn't hold).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016ZsmzpZ2zahRBoATBb2tBu
…`); no sidecar

PO: "just add, on the block a metadata … something that tells last edited
by. but on the same json" and "do not create an edits.json please".

- Removed: the draft's `<slug>.edits.json` sidecar (written, read, deleted
  on publish), DraftStore.edits / stampDraftEdits / heldDraftEdits, the
  session GET's `?edits=1`, and the ref's `editor`. The draft is the one
  object a save writes, `{ set, delete }`, and publish copies its blocks to
  main as they are, `__meta` included (blocks drops it when resolving).
- @decocms/shared: BLOCK_META_KEY (`__meta`: { lastEditedBy: <Studio user
  id>, lastEditedAt: <ISO 8601> }), blockMetaOf, stampBlockMeta (the editor
  stamps every saved block). It isn't content: canonicalBlockJson (so
  decoBlockFingerprint, Fast Preview's `expect`) ignores it, and
  mergeBlockJson keeps the preferred side's record without a conflict.
- Hosted draft storage: a put of main's content with a new `__meta` is
  still main's content (no draft entry).
- changed-by stays the fallback for blocks without `__meta` (git history:
  the draft branch on Fast Preview, main on v8).

Tests: shared fingerprint/merge (ignored, stamped, dropped without a user,
no conflict), draft-content-storage "a save writes only the draft object"
(one object, one put, `__meta` kept in it; main's content restamped is no
change); draft-store.test.ts (the sidecar's) removed, publish logs back to
one delete.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016ZsmzpZ2zahRBoATBb2tBu
This reverts commits d3df85b, 92038d9 and e3544e9. PO (final): "only
have metadata and changed by on v8 hosted". Fast Preview (v7) and Localhost
show no "changed by" line, so the changed-by route, the commit trailer and
author parsing, insights' `path` filter, block `__meta` (shared helpers,
canonical-JSON ignore, merge rule) and the draft's edits record all go; the
next commit keeps who and when in the hosted draft object's metadata.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016ZsmzpZ2zahRBoATBb2tBu
…ject metadata

PO: "only have metadata and changed by on v8 hosted". Each draft save writes
`x-amz-meta-deco-edited` on the draft object (S3 metadata, which R2 keeps):
`<name>,<userId>,<base-36 seconds>` entries joined by `;`, name and id
URI-escaped (ASCII), oldest first, capped at 1900 bytes under the 2 KB of
user metadata an object may carry, dropping the oldest entries first. The
JSON stays exactly { set, delete }; no block carries anything.

- DeliveryStore.putJson takes metadata; get returns it.
- DraftStore: load decodes the editors from the GET it already makes, and
  update stamps the names a save changed with the ref's editor (the session
  user), keeps the others, drops names no longer in the draft, and writes
  them with the draft: no extra HEAD per save.
- The session GET answers `changedBy: { [name]: { userId, at } }` next to the
  draft pointer, read from the same GET.

Tests: draft-editors (encode/decode with any characters, malformed values,
the cap dropping the oldest, stamping), draft-store (carried forward across
saves, one object, JSON free of ids, one put per save, discard and publish).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016ZsmzpZ2zahRBoATBb2tBu
@tlgimenes

Copy link
Copy Markdown
Contributor Author

Superseded by #8062

@tlgimenes

Copy link
Copy Markdown
Contributor Author

Superseded by #8062 (API + web in one PR, rebased on main with #8027).

@tlgimenes tlgimenes closed this Oct 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

claude PR authored by a coding agent

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants