Repository navigation
Commit 674f877
<!-- claude-projects-attribution: {"github_login":"os-project-manager"}
-->
_Requested by **Leehom** · [project
thread](https://claude.ai/code/project/chan_01TenzsRopZj4jMbvjX8uz1X?thread=cmsg_01TenzsRopZj4jMbvjX8uz1XURgXCZHcjPoyo5g9cMEATi)_
Fixes #36137
Clause-②: yes (widening) — `ViewConfigPanel`'s `onSave` host prop gains
an optional second parameter, the panel's draft-version guard
(`saveDraft`), which the panel always passes; a host that takes one
argument is called as before; nothing removed or renamed
Metadata-protocol: none
## 维护者速读
-
管理员在视图设置里保存时,若另一位管理员正好在「保存到这个视图」,这次保存会被拒绝,并弹出“草稿已被改动”的提示,可选重新加载、覆盖或继续编辑;平时保存无感。新建视图时若同名视图已有未发布的修改,也会被拒绝,而不是盖掉它。
- 属于共享视图「确认后立即对所有人生效」那件事的收尾:保证一个人的未发布修改不会被另一个人的保存顺带发布。
- 出错时最多是管理员偶尔多看到一次冲突提示、需要重新加载或确认覆盖;可直接撤回本改动,恢复原来的保存方式。
- 无。
Route: direction B of the card, client-only (area claim 7073591363). No
`/meta` door, server or `packages/spec` change.
## What changes
**The view settings panel's draft save is pinned** (`ViewConfigPanel`,
`handleViewConfigSave`, `persistRuntimeMetadata`)
- The panel's load already reads the stored view (`layered`) and the
served draft. The draft read is now `MetadataClient.getDraft`, the
envelope, so its `version` pins the buffer's saves through the Studio
editors' guard (`useDraftSaveGuard`, `draftPinOf`): `If-Match` with the
version the load read, `If-None-Match: *` when the view had no draft. A
save that lands holds its receipt's version for the next one. Read and
save both name no package, the address the server resolves the same way
for both.
- The panel hands its guard to the host as `onSave`'s second argument;
`handleViewConfigSave` passes it to `persistRuntimeMetadata`, which
writes through it when given (a report's save still goes unpinned,
untouched).
- A `409 METADATA_CONFLICT` opens the guard's dialog
(`DraftConflictDialog`, its existing `engine.draftConflict.*` text:
"This draft changed since you opened it … saved elsewhere — by someone
else or in another tab"): **Reload saved version** re-reads the stored
view into the panel and refreshes the host's list (the path a draft-bar
publish or discard takes); **Overwrite…** re-sends pinned to the
refusal's `currentVersion` after a second confirmation; **Keep editing**
saves nothing, keeps the edit in the panel and Save live, and says "Not
saved" through the host's existing refusal toast.
- A draft-bar Publish or Discard re-reads the view (as before), so the
next save is pinned to "no draft" again.
- The panel renders the conflict dialog while closed too (it portals out
of the hidden container). A save still in flight when the panel closes
(Discard, another view tab) and refused after it closed still asks the
author; once answered, the host hears the outcome and the save is no
longer in flight, so Save is live when the panel reopens.
**A view create carries the first-write pin** (`createRuntimeMetadata`)
- `{ mode: 'draft', ifNoneMatch: '*' }` (with the app's package when
there is one): a create over a name that already holds a pending draft
is refused instead of written over it. `createRuntimeMetadata` has two
non-test callers at this head, both views: `handleViewCreate` in
`objectViewViewCrud.tsx` (the Create View dialog and the panel's create
mode) and `handleSaveAsView` in `ObjectDataPage.tsx` (Save as view);
measured by `git grep -n createRuntimeMetadata` outside test files.
**Docs**: `content/docs/ui/views.mdx`, the Save to this view bullet, one
sentence. Changeset `36137-pinned-view-draft-writes.md`
(`@object-ui/app-shell` patch).
## Tests
- New `ViewConfigPanel.pinnedDraftSave-36137.test.tsx`, against a
`fetch` double of the `/meta` view doors with the real `MetadataClient`
and the real panel:
- the card's interleave: Save to this view's pinned draft write lands,
its publish is parked; a settings save then goes out `If-None-Match: *`,
is refused 409 and opens the dialog, and the Save's draft is untouched;
the publish then publishes exactly the Save's body. Keep editing leaves
the edit on screen and Save live, with nothing written;
- the same interleave, then Reload: nothing written, the panel holds the
published view, and its next save goes `If-None-Match: *` and lands;
- the same interleave with the settings save parked at the door and the
panel closed (Discard) before the door answers: the refusal still opens
the dialog, Keep editing reaches the host as a refusal, and after
reopening an edit leaves Save live;
- over no draft: the first save `If-None-Match: *`, the next `If-Match`
on the first receipt's version;
- over its own loaded draft: `If-Match` on the version the load read;
- a create over a name holding a pending draft is refused with `status:
409` and `code: 'METADATA_CONFLICT'`, sent `If-None-Match: *`, and the
draft is unchanged; a create of a new name lands (control).
- `ObjectView.viewConfigSaveWiring-10210.test.tsx` (+1 describe):
`ObjectView`'s handler writes through the guard the panel hands it,
never straight to the client.
- Updated to the pinned create options (`ifNoneMatch: '*'`), same
assertion otherwise: `runtime-metadata-persistence.test.ts` (2),
`runtime-metadata-persistence.otherTypesUntouched-35624.test.ts`,
`ObjectView.createChartView-11576.test.tsx`,
`ObjectView.createKanbanView-11581.test.tsx`;
`ViewConfigPanel.resumeEnvelope-10210.test.tsx`'s client serves the
draft read through `getDraft`.
## Acceptance notes
- **Every Console writer of a view draft, measured at the merge base**
(`git grep "mode: 'draft'"` under `ui/packages`, cited by symbol):
- view settings save, `handleViewConfigSave` → `persistRuntimeMetadata`:
was unpinned, pinned here;
- view create, `createRuntimeMetadata` (`handleViewCreate`,
`ObjectDataPage`'s Save as view): was unpinned, pinned here;
- Save to this view, `saveAndPublishRuntimeMetadata`: already
`If-None-Match: *`;
- Studio writers (`ObjectListViewInspector`, `useFormViewDraft`,
`ResourceEditPage`, `StudioBundleItemEditor`, `StudioDesignSurface`'s
creates and leaf drafts): already through `useDraftSaveGuard` or the
first-write pin;
- the footer calculation: no longer a server writer since it became a
part of the list draft, so nothing to pin;
- `ObjectStackAdapter.updateView`'s draft half (rename, pin, set as
default on a view with a pending draft): unpinned, **not changed here**.
It reads the draft and writes it back in one call, so both requests can
fall inside the window; a pin on its own read would carry the Save's
draft version and pass. Only a publish precondition (the card's
direction A) closes it. Routed to a follow-up card: filed #36350
(direction A, protocol face).
- The card's second acceptance line: no docs or changeset text in the
tree carries the "known edge" note (`git grep -i "known edge"` and the
card number: zero hits outside an unrelated ADR's "Known edges"
heading); it lives only in the merged PR #36123's body, which is landed
history and not edited here.
- `DraftConflictDialog`'s module header says a draft read naming no
package serves `version: null` for a package-bound draft; the server's
`readVersionToken` now serves the token of the draft a package-less save
overwrites. Both of this panel's requests name no package, so they agree
either way. Not changed.
## Verification
Final head `c7898258` (review round: `da52918b` the create refusal's
`code` and the test header, `55cbba6f` the changeset sentence,
`c7898258` the closed-panel dialog and its test). CI on `c7898258`: 60
check-runs, 48 success, 12 skipped, 0 failed, 0 pending (Test UI, Type
Check UI, Lint UI, Build & E2E UI, Live E2E UI, Test Core, TypeScript
Type Check, Lint & Repo Gates, Governed Surface Queue Guard, Dogfood
Regression Gate, Check Changeset among them).
<details><summary>Local runs at c789825 (under the shared verification
lock)</summary>
- Dependency closure `pnpm --filter '@object-ui/app-shell^...' build`:
VERDICT command-exit 0.
- `pnpm --dir ui exec vitest run` over `app-shell/src/views/`
`ViewConfigPanel*`, `ObjectView*`, `runtime-metadata*`,
`objectViewViewCrud*`, `metadata-admin/DraftConflictDialog*`,
`ObjectDataPage*`, `CreateViewDialog*`, `RuntimeDraftBar*`,
`ReportView*`, `viewCacheInvalidation*`: Test Files 142 passed (142);
Tests 1290 passed (1290). The new file alone: Tests 7 passed (7).
- `pnpm --filter @object-ui/app-shell run type-check` (both programs):
VERDICT command-exit 0.
- Ablation of the closed-panel dialog (`scripts/ablation-replace.mjs`,
anchor hit 1 to 0, blob `d5040af2` to `c3ef1c2c`; no build involved, the
test imports the source): the new file reads Tests 1 failed, 6 passed
(7), the closed-panel case red on `Unable to find an element by:
[data-testid="draft-conflict-dialog"]`; restored, blob equals HEAD and
`git diff HEAD` is empty.
- Gates narrowed to the files this round changed (the panel, its test,
the changeset), exit 0 each: `check-adr-0087-registration`,
`check-changeset-no-major`, `check-empty-changeset`,
`check-closing-keyword-parity`, `check:nul-bytes`,
`check:test-source-alias`, `check:cross-package-test-inputs`,
`check:changeset-gate-self-tests`, `check:doc-authoring`,
`check:refd-timer-probe`, `check:tier-file-adoption`. The rest of the
derived list is CI's (green above). eslint on the two changed files: 0
errors.
- `node scripts/pm/overlap-check.mjs`: `VERDICT clean exit 0` against
`origin/main` `c448c615`.
- The previous round's runs (at `7f297043` and `f86ba5fc`) are in the
dev report on the card.
</details>
**Read first**: `ViewConfigPanel.tsx` (the load's pin, the guard's
reload, and the closed branch that keeps the dialog),
`runtime-metadata-persistence.ts` (`persistRuntimeMetadata`'s
`'reloaded'` path writes and announces nothing),
`ViewConfigPanel.pinnedDraftSave-36137.test.tsx`.
**Two-minute check**: `pnpm --dir ui exec vitest run
packages/app-shell/src/views/ViewConfigPanel.pinnedDraftSave-36137.test.tsx`
— 7 tests pass (the first is the card's interleave: the settings save is
refused 409 and the publish carries only the Save's body; the third
closes the panel before the refusal lands).
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_01QsR2jUc3qp6bHKSWijbjds
<!-- signed: repo:objectstack#7 · zhuangjianguo ·
session_01QsR2jUc3qp6bHKSWijbjds -->
---------
Co-authored-by: Claude <noreply@anthropic.com>
1 parent 97b9d1e commit 674f877
13 files changed
Lines changed: 612 additions & 56 deletions
File tree
- .changeset
- content/docs/ui
- ui/packages/app-shell/src/views
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
641 | 641 | | |
642 | 642 | | |
643 | 643 | | |
644 | | - | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
645 | 648 | | |
646 | 649 | | |
647 | 650 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
205 | 205 | | |
206 | 206 | | |
207 | 207 | | |
208 | | - | |
| 208 | + | |
209 | 209 | | |
210 | 210 | | |
211 | 211 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
164 | 164 | | |
165 | 165 | | |
166 | 166 | | |
167 | | - | |
| 167 | + | |
168 | 168 | | |
169 | 169 | | |
170 | 170 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
81 | 81 | | |
82 | 82 | | |
83 | 83 | | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
84 | 87 | | |
85 | | - | |
86 | | - | |
87 | | - | |
88 | | - | |
89 | | - | |
90 | | - | |
91 | | - | |
92 | | - | |
93 | | - | |
94 | | - | |
95 | | - | |
96 | | - | |
97 | | - | |
98 | | - | |
99 | | - | |
100 | | - | |
101 | | - | |
102 | | - | |
103 | | - | |
104 | | - | |
105 | | - | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
106 | 116 | | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
107 | 120 | | |
108 | 121 | | |
109 | 122 | | |
| |||
154 | 167 | | |
155 | 168 | | |
156 | 169 | | |
157 | | - | |
158 | | - | |
| 170 | + | |
159 | 171 | | |
160 | 172 | | |
161 | 173 | | |
| |||
168 | 180 | | |
169 | 181 | | |
170 | 182 | | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
171 | 188 | | |
172 | 189 | | |
173 | 190 | | |
| |||
186 | 203 | | |
187 | 204 | | |
188 | 205 | | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
0 commit comments