Skip to content

fix(decofile): stop stale editor copies from reverting other drafts' block changes - #7909

Merged
viktormarinho merged 4 commits into
mainfrom
fix/decofile-stale-block-overwrite
Oct 14, 2026
Merged

viktormarinho merged 4 commits into
mainfrom
fix/decofile-stale-block-overwrite

Conversation

@viktormarinho

@viktormarinho viktormarinho commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

What is this contribution about?

In Fast Preview projects, one draft's publish can silently undo another draft's edits.

The problem

Every CMS save replaces a whole block. The payload is the copy the editor holds plus the field the user just changed. Nothing checks whether that copy is still what the branch has.

Here is the sequence we traced in a production project. Two editors were on separate drafts and both edited the same global header block:

  1. Editor A publishes a change to the header menu.
  2. Editor B's draft has no commits of its own yet, so the header's automatic "get latest" fast-forwards it onto production. B's draft now contains A's change.
  3. B's section form for the header is still open. Its formValue was seeded when the section was selected, and a refetch of the decofile does not re-seed it.
  4. B changes one field. The autosave sends the whole stale block. The commit lands on top of A's change and reverts it.
  5. B publishes, and production loses A's menu change. The diff of B's publish is the exact inverse of A's diff, plus B's one-field change.

There is a second, rarer path. When the sync before a publish hits a git conflict, repoGitRebase lets the branch's whole file win for every path it touched. That also drops the base's edits in parts of the file the branch never changed.

The fix

1. The server refuses stale writes (commit-coalescer.ts, routes/decofile.ts)

  • PATCH /api/:org/decofile/:vmcp/:branch accepts an optional expect: { [blockKey]: fingerprint | null }. The fingerprint is a SHA-256 of the block's JSON with keys sorted and secrets sanitized (decoBlockFingerprint in @decocms/shared/decofile). null means "I saw no such block".
  • The coalescer checks each patch's expectations against the head it is about to commit on. Within a coalesced batch it checks them in arrival order, so a later patch is compared with what the earlier ones leave behind. A stale patch is rejected with 409 { code: "block-conflict", blocks } and none of it is written; the other patches in the batch still land.
  • Requests without expect behave exactly as before.

2. The editor says what it edited from (use-save-block.ts, sections-editor.tsx, form-base.ts)

  • useSaveBlock sends the fingerprint of the cached block at call time. That is the right base for every write built from the cache.
  • An open section form now remembers the section value it started from. It updates that value after each of its own writes and resets it when something else replaces the form's value.
  • Before an autosave, the form compares that starting value with what is now stored. If someone else changed it, the editor does not discard anything. It applies the form's own edits on top of the stored section with the same three-way merge the sync uses (below), shows the merged section in the form, saves it, and shows an informational toast ("This block was updated while you were editing. Your changes were applied on top of the latest version."). It does not say who changed the block, because a publish synced in, a coding session on the same branch, another tab, and a discard all look the same from here.. The form only displays the merge while it is still on that section and has not emitted a newer value; otherwise its baseline stays what it displays, so the next save merges again.
  • For saved/global blocks, the save passes the version it built on as the expect base.
  • If the server still answers 409 (the client's cache was older than the branch), useSaveBlock re-reads the decofile and the editor retries once, merging against the fresh read. Only a second refusal falls back to reloading the form, with a neutral error toast. The rollback of the optimistic write is skipped on a conflict, so it can't put the stale copy back over the fresh read.

3. Sync conflicts merge blocks value by value (git-compat.ts, block-merge.ts in @decocms/shared, shared with the editor)

  • When the git merge conflicts, every .deco/blocks/*.json file modified on both sides gets a three-way JSON merge against the merge base:
    • Objects merge key by key.
    • The branch wins only values that both sides changed differently.
    • Arrays merge position by position only when neither side changed the length and no position changed on both sides. Otherwise the branch's whole array wins, so a reorder on one side and an edit on the other can't splice fields from two items together.
  • Files that are not blocks keep today's branch-wins behaviour, as do blocks added or removed on one side and files that aren't valid JSON. The squash message is unchanged.

Not in this PR

  • useMoveBlocks, useDeleteBlock, and the blog editor's patchDecofile calls don't send expect yet. They keep the old last-write-wins behaviour.
  • The automatic "get latest" fast-forward is unchanged. With the checks above, a stale form after a fast-forward now reloads instead of overwriting.

How did you verify your code works?

  • bun run verify (fmt, oxlint, knip, 10,910 unit tests) and bun run check (all workspaces' tsc) pass.
  • New unit tests:
    • fingerprint.test.ts: key order, JSON round trip, secret value ignored, plaintext secret refused.
    • block-merge.test.ts (shared): per-key merge, both-changed value, additions and deletions, array position merge, a reorder plus an edit keeping the branch's array, length change, key order.
    • form-base.test.ts: how the form's starting point is tracked and reset.
    • commit-coalescer.test.ts: accept/reject against head, null expectation, ordering inside one coalesced batch.
  • New and updated Playwright specs, run locally against the GitHub stub (decofile-api, fast-preview-git-sync, site-editor-stale-form, site-editor-breadcrumbs, cms-publish-surface): 30 passed.
    • decofile-api: a stale expect gets a 409 and leaves the branch head untouched. Redone against a fresh read, the edit lands on top. Covers null semantics and schema rejections.
    • fast-preview-git-sync: the conflict test now asserts that the base's edit to a block survives next to the branch's edit, and that the branch wins only the value both changed. It used to assert that the branch's whole file wins.
    • site-editor-stale-form (browser): for a saved block and for an inline section, open the form, change the block through the API as another editor would, then type in the form. The stored block ends up with both changes, the form shows the merged values (checked on the nested field the other editor changed), and a second edit keeps the other editor's change too.
    • site-editor-stale-form, the reported path end to end: the form is open on a draft, another draft publishes a change to the block, "get latest" fast-forwards this draft onto it, the editor re-reads the draft while the form keeps its old copy, and the user types. The editor merges before writing (asserted: no PATCH got a 409) and the draft stores both changes. On main's editor code the same steps store the block with the published change reverted, which is the bug as reported.
  • I checked that the new tests fail without the fix: the two new API assertions fail with the old coalescer and git-compat.ts, and both browser tests fail with the old use-save-block.ts and sections-editor.tsx.
  • Not run: the full e2e suite (CI will run it).

Checked against real project history

Before publishing, I checked how this would behave on three production projects with Fast Preview and heavy CMS use (roughly 1,400 draft PRs merged since September, 1.8k–2k blocks each):

  • Block data: none has invalid JSON blocks, block keys that decode to the same name, plaintext secrets, or blocks over 1 MB, which are the cases where a client and server fingerprint could disagree. Fingerprinting the largest block (~680 KB) takes about 2 ms.
  • Concurrent editors: in the last 30 days, only one draft branch had more than one editor's CMS chats, so 409s between two people on the same branch should be rare.
  • Syncs: about 700 draft syncs ran in that period, and 14 hit a git conflict and went branch-wins. I replayed those 14 with the new merge, estimating the merge base as the base's version of each file closest to the draft's:
    • In 5 of them, the old sync dropped the base's edits (up to 36 values in one block, in a block the draft had not really changed) and the new merge keeps them.
    • In the rest, the result is the same as before. Several page blocks fall back to the branch's whole sections array because one side changed the array's length.
    • None came out worse.
  • Not covered: one project lives in a nested package of a repository I can't read, so its history wasn't checked. The code paths handle a package path the same way.
  • Outside writer: two of the projects also get automated .deco syncs on the default branch from another system. Those are just more base-side changes, which is the case the value-level merge is for.

Screenshots/Demonstration

The form after another editor changed the saved block it was editing. The form's edit was applied on top of the stored block, and both changes were saved:

Section form after merging another editor's change

How to Test

  1. Open a Fast Preview project in two browsers as two users, each on its own draft.
  2. In browser A, open a global section (e.g. the header) in the Site Editor and leave the form open.
  3. In browser B, change a different field of the same section and publish.
  4. In browser A, click "Get latest" or wait for the automatic sync, then edit a field.
  5. Expected: A sees the "This block was updated while you were editing…" toast, the form shows B's value next to A's edit, and publishing A keeps both changes. Before this PR, A's save reverted B's change.

Migration Notes

None. The expect field is optional, so older clients keep the current behaviour. No flag: the check only runs for writes that ask for it.

Review Checklist

  • PR title is clear and descriptive
  • Changes are tested and working
  • Documentation is updated (if needed)
  • No breaking changes

…block changes

Every CMS save replaces a whole block with the copy the editor holds. When
another draft published to the same block while a section form was open (and
the draft branch was synced onto it), the next autosave wrote the old copy
back with the one field the user changed, silently reverting the other edit.

- PATCH /decofile accepts `expect`: per block, the fingerprint of the version
  the edit was made against (`null` for "no such block"). The coalescer checks
  it against the head it commits on, in arrival order within a batch, and
  rejects a stale patch with 409 `block-conflict` without writing it.
- The web save hook sends that fingerprint (the cached block by default, the
  form's starting copy for saved blocks). The sections editor remembers what
  an open form started from, skips an autosave whose section changed
  underneath, and reloads the form with the stored version on either check.
- When a publish/"get latest" sync hits a git conflict, blocks both sides
  modified now merge value by value instead of the branch's whole file
  winning, so the branch wins only the values both sides changed.
…g them

When the section an open form edits changed underneath it, the form used to
drop the pending edit, reload, and ask the user to redo it. Apply the form's
own edits on top of the stored section instead (three-way merge against the
copy the form last saved), show the merged section, and save that. A save the
server refuses as stale is retried once against the fresh read before falling
back to reloading the form.

The three-way block merge moves to @decocms/shared so the API sync and the
editor use the same rules.
The merge runs whenever the stored block moved under an open form: a publish
synced in, a coding session on the same branch, another tab, or a discard.
The toast no longer claims it was someone else.
…t's publish

The path behind the reported overwrite: the draft fast-forwards onto a publish,
the editor re-reads it, and the open form still holds its old copy. The editor
must merge before writing, with no save refused by the server.
@viktormarinho
viktormarinho enabled auto-merge (squash) October 14, 2026 16:47
@viktormarinho
viktormarinho merged commit f25b458 into main Oct 14, 2026
34 checks passed
@viktormarinho
viktormarinho deleted the fix/decofile-stale-block-overwrite branch October 14, 2026 16:49
decocms Bot pushed a commit that referenced this pull request Oct 14, 2026
PR: #7909 fix(decofile): stop stale editor copies from reverting other drafts' block changes
Bump type: patch

- decocms (apps/api/package.json): 4.481.4 -> 4.481.5
- @decocms/native (apps/native/package.json): 4.481.4 -> 4.481.5
- @decocms/e2e (packages/e2e/package.json): 1.110.1 -> 1.110.2
- @decocms/shared (packages/shared/package.json): 0.156.0 -> 0.156.1

Deploy-Scope: both
tlgimenes added a commit that referenced this pull request Oct 15, 2026
Brings in 114 commits from main, including #7909 (PATCH decofile `expect`
fingerprints, 409 block-conflict, value-by-value block merge on sync) and
guitavano's #7899/#7903.

One conflict, in apps/api/src/decofile/commit-coalescer.ts: this branch
moved the gen-artifact regeneration and the commit message into
gen-artifact.ts (shared with hosted publish), while #7909 changed the
message to name only the accepted patches. The resolution keeps the shared
helpers and passes them #7909's accepted `set`/`del`, so the legacy and
Fast Preview write path behaves exactly as on main.

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

Brings in fold/v8-api, which now carries origin/main (114 commits),
including #7909 and #7918 (section forms start from a known version, saves
send `expect`, a stale save is refused with 409 and replayed or reloaded).

Conflicts resolved:
- use-save-block.ts: main's Fast Preview save (`base` -> `expect`, rebase
  on 409, BlockConflictError, no rollback on a conflict, `written`) moves
  into this branch's `writeLegacy`; the content-protocol path and SaveGuard
  stay as they were. `mutate`/`mutateAsync` keep main's `withBase` default
  and the hook keeps `reportError`.
- sections-editor.tsx: both form reloads stay (the content-epoch reload for
  discards/publishes and #7909's `reloadStaleForm`); main's form-base
  tracking, three-way merge, section following and retry-once are kept;
  failed saves use this branch's `reportError`.
- serve-save-error.ts: a BlockConflictError's own message (#7909's copy) is
  the toast headline on every backend, with no Details line.
- resolve-schema.ts and its cache test: #7899/#7903 were already
  cherry-picked here; this branch's lazy-block handling and A9 test stay.
- cms-header-actions.tsx / cms-panel-state.ts: main dropped
  cmsHeaderButtonLabels; the hosted header helpers stay.
- playwright.config.ts: both env additions (hosted env, GraphQL stub URL,
  BOARD_TRANSITION_SETTLE_SECONDS).

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 15, 2026
…hanged

#7909 protects Fast Preview section saves with `expect` fingerprints and a
409. A v8 save (content protocol) now gets the same protection through
`blocks.apply`'s `ifMatch`, compared by the protocol against the entry's
current version (the opaque `version` that `blocks.list`, `blocks.apply`
and `changes.get` report):

- The editor keeps each block's version next to the blocks cache
  (`KEYS.contentVersions`): set by full `blocks.list` reads (a block being
  saved keeps its last landed version), and by each `blocks.apply` answer.
- `formSaveGuard` (form-base.ts) turns the open form's starting point into
  the save's guard: a saved block expects the version the form's copy was
  checked against (moved by each landed save of the form, re-read when the
  form's edits were rebased on the stored copy); a page expects its cached
  version. Both are read when the save runs, after earlier saves landed.
- A refused guarded save with `reloadOnConflict` re-reads the content,
  puts the stored block and its version in the cache (`changes.get`, or
  `blocks.list` on an older server), skips the optimistic rollback and fails
  with #7909's BlockConflictError and copy, so the form retries once on the
  stored block and otherwise reloads, exactly as on Fast Preview.

Tests: formSaveGuard, the version bookkeeping and reloadProtocolBlock, the
save hook's refused/landed/opt-out paths, and an e2e over deco serve where
another writer changes the block, the form saves, and both changes stay.

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 16, 2026
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
tlgimenes added a commit that referenced this pull request Oct 18, 2026
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
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]>
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.

1 participant