Skip to content

Commit 98cc0e4

Browse files
fix(studio): the OWD overview's Save publishes each object pinned to the published row its load read (#37501)
Fixes #36962 Clause-②: no Metadata-protocol: none ## 维护者速读 - 用户能看到什么变化:Studio 的「记录共享基线」总览页里,两位管理员同时改同一个对象的共享默认值时,后保存的那位不再悄悄覆盖前一位,而是弹出冲突对话框(重新加载 / 确认覆盖 / 继续编辑);同一次保存里的其他对象各自照样核对,别人也改过的同样会问。 - 为什么做:Studio 各编辑器已经按「加载时读到的已发布版本」防止互相覆盖,唯独这张总览页的保存被漏掉了;共享默认值关系到谁能看到哪些记录。 - 出错会怎样:若判断有误,管理员可能在无人并发时也看到冲突对话框,选「重新加载」或「确认覆盖」即可继续;本改动只在前端,可直接回退,不改数据。 - 要你做什么:无 ## What changes `PackageOwdOverviewPanel.tsx` (the Studio OWD overview, one Save for every changed object): - The load records, per row, the published row it read (`publishedPinOfLayers` over the row's layers read, at the package the publish writes) into a `useDraftSaveGuard` held by the panel (`recordPublished`). - A row the package's published list does not hold, whose layers are not asked while its draft is in hand, is pinned `If-None-Match: *` (no published row of its name). A saved row whose layers read failed pins nothing. - The Save's per-row publish now passes the guard's pinned publish to `publishSavedItem` (its existing fourth parameter; `studioSaveBar.tsx` untouched). A publish over a row another writer published since is refused `409 METADATA_CONFLICT` and the existing conflict dialog asks: reload, overwrite after a confirmation, or keep editing. - The panel keeps its own record of the pin each row's edit was made on, and sends that row's pin to the guard again immediately before the row's publish. A conflict answered "reload" clears every pin the guard holds, for every row; without the re-send the rows after it in the same pass, and a confirm of the controlled-by-parent prerequisite after a re-read that failed, would publish unpinned. - Partial save (objectstack#36511) is kept: a refused row is named and keeps its edit; the other rows carry on, each still published over the row its own load read, whatever an earlier row was answered, so another row a second admin changed is asked about too. - A row answered "reload" is read back once the pass ends, and the Save reads as declined. The draft the Save wrote is taken back first, unless a draft was pending before the Save (a copilot's): that draft is kept, now carrying the edit, and is shown as the row's value under the unpublished-draft mark while the live row is the other admin's; its next Save stays pinned to the version the conflict was raised on and is asked again (the guard's rule 9). - The table re-read after a partial save keeps each unsaved row pinned to the read its edit was made on (never the fresh read), so the next Save over a row that moved is asked again instead of slipping through. - The guard's own reload callback is a no-op: the Save that met the conflict re-reads the table itself once its pass ends, keeping the edits of the rows it did not save. One changeset (`@object-ui/app-shell` patch). ## Tests New `PackageOwdOverviewPanel.publishPinned-36962.test.tsx`, against a server double whose publish door honours `If-Match` / `If-None-Match` and answers its 409 through the real `MetadataClient` error parser: - race: another admin publishes between load and Save, the Save is refused at its publish and the live-change conflict dialog opens; keep editing leaves the edit unsaved and takes the written draft back; - reload: the other admin's value is read back and the next Save is pinned to it; - overwrite: asked twice, then re-published pinned to the refusal's `currentVersion`; - two rows, one raced: the other goes live pinned to its own read; the kept edit stays pinned to its original read, so the next Save is asked again; - one editor: consecutive Saves pinned to the version the last one left, no self-conflict; - a draft-only row publishes `If-None-Match: *`; - control: a server that serves no `overlayVersion` gets an unpinned publish, as before; - reload in a pass of several rows: both rows raced, reload on the first, and the second is still refused and asked, its publish carrying its own load's `If-Match`; - the first row refused and kept, the second reloaded: the kept edit's next Save is still pinned to its own load and asked; - a row with a draft pending before the Save, raced, reload: the draft is kept carrying the edit, shown under the unpublished-draft mark, and the next Save is asked again, pinned to the version the conflict was raised on; - control: a draft-only row whose name another writer published since is refused on `If-None-Match: *`, not published over. Ablation 1 (drop the pin from the publish call): 10 of 11 red, the unpinned control green. Ablation 2 (never keep a kept edit's original pin across the re-read): exactly the two kept-edit cases red. Ablation 3 (drop the re-send before each publish): exactly the reload-on-the-first-row case red. All restored, blob equals HEAD. ## Acceptance notes - The overview's draft save still goes through `client.save` unguarded (no draft pin). It is a whole-document write over a read made a moment earlier, so a draft another writer wrote in between is replaced; and `hasDraft` is the load's reading, not the Save's. A concurrent change to the live `sharingModel` is still caught at the publish this PR pins. Both, with the panel's pin-record housekeeping, are carried by #37515. - A Save in which the author chose "reload" for one row reports `declined` to the top bar even when other rows went live in the same pass (no "saved" toast); the rows that went live read back as saved on the page. Same answer the object page gives for a reloaded Save. ## Verification Read first, by risk: 1. `PackageOwdOverviewPanel.tsx`, the `recordPublished` re-send just before `publishSavedItem` in `doSave`, then the load's pin loop (`editPinsRef`) and the `reloadedNames` branch. 2. The new test file's "reload on the first row" and "a row with a draft pending before the Save" cases. Two-minute check: `pnpm --dir ui exec vitest run packages/app-shell/src/views/studio-design/PackageOwdOverviewPanel.publishPinned-36962.test.tsx`, expect 11 passed. All readings at head `dd92c2751` (objectstack-ai/objectstack), after building the app-shell dependency closure (`turbo run build --filter='@object-ui/app-shell^...'`, lock VERDICT command-exit 0). <details><summary>Tests: OWD panel suites</summary> ``` pnpm --dir ui exec vitest run --maxWorkers=2 packages/app-shell/src/views/studio-design/PackageOwdOverviewPanel Test Files 12 passed (12) Tests 60 passed (60) VERDICT command-exit 0 (new file alone, verbose) Test Files 1 passed (1) · Tests 11 passed (11) ``` </details> <details><summary>Ablations (scripts/ablation-replace.mjs, restored to the HEAD blob f3046b3 each time)</summary> ``` 1) anchor "publishPinned," deleted from the publishSavedItem call: anchor 1 -> 0 Tests 10 failed | 1 passed (11) (the unpinned control stays green) 2) "const kept = keep?.has(r.name) && editPinsRef.current.has(r.name);" -> "const kept = false;" Tests 2 failed | 9 passed (11) (one row refused among two; first refused and kept, second reloaded) 3) the recordPublished re-send line before publishSavedItem deleted: anchor 1 -> 0 Tests 1 failed | 10 passed (11) (reload on the first row: the row after it is still asked) each: restored, blob == HEAD, git diff HEAD empty ``` </details> <details><summary>Typecheck and lint (app-shell)</summary> ``` pnpm --filter @object-ui/app-shell type-check (tsc --noEmit, then tsc -p tsconfig.test.json) VERDICT command-exit 0 eslint on the two touched source files: exit 0, 0 errors, 2 warnings; the same 2 react-hooks/set-state-in-effect warnings as on the origin/main copy of the panel (pre-existing) pnpm --dir ui run check:new-line-citations: 0 new citation(s), exit 0 ``` </details> <details><summary>Derived gate families (dispatch-gates --commands, 38)</summary> ``` At e572eb2: 38 derived, 38 run, every one exit 0 (incl. pnpm --dir ui exec vitest run scripts/: Test Files 172 passed | 2 skipped) At dd92c27 (same three paths): re-run the changeset-reading families, each exit 0: check-adr-0087-registration --base origin/main, check-changeset-no-major, check-empty-changeset, check:nul-bytes, check-closing-keyword-parity ``` </details> --- _Generated by [Claude Code](https://claude.ai/code/session_01Utp6CY2uhJ1AYNPw5TUSVS)_ <!-- signed: repo:objectstack#5 · os-bill · session_01Utp6CY2uhJ1AYNPw5TUSVS --> --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 5f34d65 commit 98cc0e4

3 files changed

Lines changed: 497 additions & 9 deletions

File tree

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
'@object-ui/app-shell': patch
3+
---
4+
5+
fix(app-shell): the Studio sharing-defaults overview's Save no longer publishes over a change another admin published since the page loaded
6+
7+
Clause-②: no
8+
Metadata-protocol: none
9+
10+
The overview of every object's org-wide sharing default (Studio → Access) publishes each changed object over the published row its load read, as the object page and the extension, hook, action and flow editors already do. When another admin published the same object between the load and the Save, that object's publish is refused and the conflict dialog asks: reload the live value, overwrite it after a confirmation, or keep editing. The other changed objects in the same Save carry on, each still published over the row its own load read, whichever answer an earlier object got, so a second object another admin changed is asked about too. An object kept unsaved stays pinned to the row its edit was made on, so the next Save asks again. An object reloaded is read back; when it had a draft pending before the Save, that draft is kept, now carrying the edit, and its next Save is asked again. Against a server that serves no published version, the publish goes unpinned, as before.

0 commit comments

Comments
 (0)