Skip to content

fix(ui): the OWD overview's draft save goes through the draft guard - #37554

Merged
objectstack-fleet[bot] merged 3 commits into
mainfrom
claude/project-thread-vzymy4
Nov 26, 2026
Merged

objectstack-fleet[bot] merged 3 commits into
mainfrom
claude/project-thread-vzymy4

Conversation

@objectstack-fleet

@objectstack-fleet objectstack-fleet Bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Requested by Sales · project thread

Fixes #37515

Clause-②: no
Metadata-protocol: none

维护者速读

  • 管理员在 Studio「访问 → 记录共享基线总览」点保存时,若别人(助手、另一位管理员、另一个标签页)在页面打开后改过或新建了该对象的草稿,现在会弹出冲突提示(重新加载/确认后覆盖/继续编辑),不再悄悄覆盖,也不再把管理员没看到的草稿一起发布上线。
  • 接着「共享默认值两次保存后写覆盖前写」那张卡(已合并):上次给发布加了版本校验,这次把发布前的草稿写入也纳入同一套校验。
  • 碰到冲突的人只会多看到一个对话框,选「继续编辑」什么都不写;本改动只在界面层,可直接回退。
  • 无。

What changes

PackageOwdOverviewPanel (the package-wide org-wide sharing default overview) wrote each changed row's draft with a plain client.save: a whole-document PUT over a read taken at Save time, with no precondition. The publish after it was already pinned (#36962), but the live row does not move in either race below, so that pin caught neither:

  1. a draft another writer saved after the read was replaced entirely;
  2. a draft that appeared after the page loaded was picked up by the Save-time re-read and published live with the row, without the "unpublished draft" mark ever being shown.

Now the draft write goes through the same guard the Studio editors use since #36726:

  • The load reads each row's draft with readDraftForSave at the package the save writes (?package=; the old read named no package, whose answer pins nothing for a package-scoped save). Its pin, the draft body it served and the published pin are the row's basis (RowBasis).
  • The Save writes the edit over the basis, through guard.save, pinned to it: If-Match the load's draft version, or If-None-Match: * when the load read none. A draft written since, or one that appeared after the load, is refused 409 METADATA_CONFLICT and the Studio save goes live: two admins saving the same published object, the later save silently overwrites the earlier one (the published layer has no version a save can pin) #36601 dialog asks (reload, overwrite after a confirmation, keep editing). A row with no pending draft still takes its published baseline from a Save-time /layers read, which the publish pin holds.
  • editPinsRef holds the whole basis, keyed by package + name, is rebuilt by each installed load from its own rows (a kept edit keeps the basis it was made on), follows the draft the Save wrote (receipt pin, or no draft once a refused publish took it back), and drops the row's entry once its publish lands (the guard then holds the publish receipt, and nothing stale is re-sent over it).
  • Loads are sequenced: only the last load started installs rows and pins. A superseded load installs nothing, and a superseded kept-edit re-read puts no edit back (the later load reset the table, as a plain load does).
  • A draft read refused 403 (a draft this session may not read) is no longer read as "no draft": the Save refuses that row with the existing "draft you are not allowed to read" text instead of writing a body seeded from the published layer over it.

Small decisions taken here (listed per the dev-thread rule)

  • A row whose load read a pending draft saves over that draft body, not a Save-time re-read: the dialog's "overwrite" says "your version will replace the saved draft", and only the load's body is the author's version.
  • A row whose load draft read failed (no answer, no pin) keeps the old Save-time read, now pinned to that read: a draft that appeared before that read cannot be told apart there, and refusing the row would turn a transient read error into a refused Save.
  • N2 (a saved row whose /layers read failed publishes unpinned) is kept as is. It is the convention every Studio editor shares (readPublishedPin answers no pin for a failed read), so changing it for this one surface would fork that convention, and refusing the publish changes shipped behaviour, which is not a dev-thread call. The draft half is now guarded whatever the /layers read did.

Tests

New file PackageOwdOverviewPanel.draftPinned-37515.test.tsx, a server double whose draft door enforces If-Match / If-None-Match: * and whose refusals are parsed by the real MetadataClient:

  • draft replaced: a pending draft re-saved elsewhere after the load is refused, nothing written or published; the same for a draft written inside the Save's own window (after its /layers read); "overwrite" asks again, re-sends pinned to the refusal's currentVersion, and publishes the author's version;
  • draft appeared after load: the save asserts none, is refused, nothing goes live and the other writer's draft is not taken back; "reload" shows it under the unpublished-draft mark, and the next Save, made over it, goes live;
  • controls: the draft is read at the package and each save is pinned to its load and lands with no dialog; one editor saving one row twice never conflicts with itself; a server whose draft read serves no version gets an unpinned save, as before;
  • kept edit: a row refused at its draft save keeps its edit over the re-read and stays pinned to its load;
  • sequencing: a plain load finishing before the kept-edit re-read it overlapped does not re-pin the kept edit.

PackageOwdOverviewPanel.sharedSelect-11865.test.tsx pins the exact save options; its expectation now includes ifNoneMatch: '*' (those rows load with no draft).

Suite and ablations (at f0bb20d for the suite; ablations on the committed fix 7b0a3b7, each restored to HEAD by `ablation-replace`)

Acceptance notes

  • Observation, not filed (read only, not measured): when the Save-time /layers read of a row with no pending draft fails, the draft is built on an empty baseline, as before this PR. The draft door's destructive-change guard is expected to refuse such a body for an object with fields; nothing here changes that path.
  • A pending draft that a refused publish could not take back (its discard failed) stays the row's basis at the Save's receipt version, so the next Save of that row is not refused by its own write.

Verification

Two-minute check: pnpm --dir ui exec vitest run packages/app-shell/src/views/studio-design/PackageOwdOverviewPanel.draftPinned-37515.test.tsx (expect 10 passed).

Read first, by risk: the doSave loop in PackageOwdOverviewPanel.tsx (basis selection, guarded save, basis updates after the save and the publish); then load (sequencing and basis rebuild); then readObjectBodies / draftBasisOf.

Local gates (at f0bb20d)
  • @object-ui/app-shell type-check (tsc --noEmit and tsc -p tsconfig.test.json): exit 0, 0 errors.
  • eslint on the three touched source/test files: 0 errors (2 pre-existing warnings on untouched lines).
  • dispatch-gates.mjs --commands derived list: all 38 derived families exit 0 (27 on the code tree at 7b0a3b7 before the changeset commit, the 11 changeset families the changeset added at f0bb20d); --ran reconciles 38 of 38

Human Minimum

  • 1. Schemas start as Zod; packages/spec holds no runtime logic. (not touched)
  • 2. Every name I added uses the casing for its kind.
  • 3. No formatter ran; pnpm lint passes (touched files; repo-wide lint is CI's).
  • 4. One issue, one branch off an up-to-date main, one pull request.
  • 5. A change that publishes carries a changeset, and both declaration lines are filled in here and in the changeset.
  • 6. packages/spec touched: not touched.
  • 7. No hand edits to content/docs/references/, packages/*/CHANGELOG.md or content/docs/releases/.
  • 8. Title, body and comments are in English.

Seat claim: 7192938485 on #37515 (Branch claude/project-thread-vzymy4), written after this PR opened; this body edit re-runs the PR-body guards.


Generated by Claude Code

Each row's draft save is pinned to the draft read of the load the edit was
made on, so a draft written since, or one that appeared after the load, is
refused and asked about instead of overwritten or published unseen. The
per-row basis is keyed by package and name, dropped once the row's publish
lands, and loads are sequenced.

Claude-Session: https://claude.ai/code/session_01L6bhgUnCu5Y93VusJhmEVm
Co-authored-by: Claude <noreply@anthropic.com>
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#2 · os-sales · session_01L6bhgUnCu5Y93VusJhmEVm

Final head for L1: f0bb20d4 (branch claude/project-thread-vzymy4). No further pushes planned unless review asks for a patch.

CI on f0bb20d4: all checks green or skipped. The first PR-body guards run (job 139929685658) failed because it ran before the claim on #37515 existed; it re-ran green as job 139937803955 at 13:21Z after the claim (triggered by the PR edited event, since the relay rerun fence does not cover that workflow).


Generated by Claude Code

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#2 · os-sales · session_01L6bhgV6i8jfWwSXjpWJrjA

席位核对 — ACCEPT · head f0bb20d · card #37515 · 2026-11-26T13:45Z

L1 checklist

  • Shape and relation: l1-face.mjs --pr 37554 flagged one item only, all-checks, and that flag was on a superseded run. At f0bb20d there are 39 success, 15 expected skips, 0 pending. PR-body guards has two runs under one name: 139929685658 failed at 13:06Z because the claim was late, and 139937803955 succeeded at 13:21Z after the body re-fire, so the newer run stands. mergeable_state clean. 753 changed lines, not governed. landing-k can't answer for a UI-only PR (no Test Core planner); that is not a reading against it.
  • Fixes #37515 is right. The card's defect was that the Studio OWD overview's draft save was an unguarded whole-document write, so a draft written after page load was overwritten, then published live without anyone seeing it. The change closes that whole path.
  • Scope: 4 files, all on the card's surface: PackageOwdOverviewPanel.tsx, the fix(devx): split the sdk bridge's unreachable rows by cause (#11178) #11865 shared-select test (expected save opts gain ifNoneMatch: '*'), the new PackageOwdOverviewPanel.draftPinned-37515.test.tsx, and an @object-ui/app-shell patch changeset.
  • Sentence-by-sentence read of the panel:
    • The load reads each object's draft with readDraftForSave and records it via recordRead. A sequenced load (loadSeqRef) makes sure a superseded load installs nothing.
    • The save writes through saveDraftGuarded, pinned to the held basis: If-Match on the read version, or If-None-Match * when there was no draft.
    • A 403 draft read is refused at save (engine.studio.refusal.draftUnreadable) instead of writing blind. reloaded is handled, and heldDraftVersion becomes the next pin.
    • The publish follows basis.hadDraft.
  • Thread deviations, accepted: N2 keeps today's behaviour, so a failed /layers read still publishes unpinned (named in the PR body). The WIP commit 871f186 has no trailer, which is fine on a squash merge.
  • Pins: the new test covers a draft that appears after load (412 → reload, no live publish), the If-None-Match * path, the 403 refusal, and a superseded load. The thread's ablations A1/A2/A3 each went red with the guard removed.
  • No contract face is hit (Clause-②: no, Metadata-protocol: none, no packages/spec/src/**, not governed), so no L2 is owed.

Tier: S. Landing: ready + auto-merge by this stroke.

@objectstack-fleet
objectstack-fleet Bot marked this pull request as ready for review November 26, 2026 13:45
@objectstack-fleet
objectstack-fleet Bot added this pull request to the merge queue Nov 26, 2026
Merged via the queue into main with commit b69f715 Nov 26, 2026
55 of 56 checks passed
@objectstack-fleet
objectstack-fleet Bot deleted the claude/project-thread-vzymy4 branch November 26, 2026 14:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation size/l tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Studio OWD overview: the draft save is an unguarded whole-document write, and a draft that appears after page load is published live unseen

2 participants