Repository navigation
Commit ed0edb1
feat(studio): the object page saves with Cancel and Save in the top bar, live at once (#36597)
<!-- claude-projects-attribution: {"github_login":"os-steve"} -->
_Requested by **Steve** · [project
thread](https://claude.ai/code/project/chan_01FdL1XeUyvVNxLreh3F4Qi9?thread=cmsg_01FdL1XeUyvVNxLreh3F4Qi96kzyjcbK53dPTb3U2Eb422)_
Part of #36511
Clause-②: no
Metadata-protocol: none
This is the first of three PRs for the card. It covers the object page.
Still to come:
- PR 2: flows, the enable switch, permissions, and the object page's
hooks and an installed app's own actions.
- PR 3: field layout, the AI-draft notice with its 「放弃 AI 的改动」 button,
and the card's closing line.
## 维护者速读
- 用户能看到什么变化:在 Studio
的对象页(字段、校验规则、动作、设置)改完后,顶栏右侧原来「发布」的位置出现「取消」「保存」。点保存后改动立刻生效,不再每隔一秒半自动存草稿。「变更」「发布」只在有待发布草稿时出现。
- 为什么做:维护者裁定,人类改一项就确认一项、点保存直接生效。本单是「保存即生效」这一系列的第一步,先做对象页。
-
出错会怎样:保存被服务器拒绝时,改动留在页面上,并写明原因;同一次保存里成功的项会被列出来。删掉或改类型已生效的字段前会先问一句。出问题可以直接撤回本单,回到原来的自动存草稿。
- 要你做什么:无。两人同时改同一对象时后保存的人可能覆盖先生效的改动,这件事已交席位按决策卡流程处理。
## What changes
**Mechanism.** A new top-bar coordinator in `studioSaveBar.tsx` does the
following:
- Editors register their buffers with `useStudioSaveEntry`.
- The surface draws Cancel and Save at the right of the top bar, where
Publish was, and only while a registered buffer is dirty. They are the
column's last actions; only the right-slot icon follows them, as it
followed Publish.
- One Save sends every dirty buffer in order. A refused buffer does not
stop the others.
- When something is refused, the toast names each refused item with its
reason, then lists the items that were saved.
- If any buffer holds an edit it cannot send yet, Save refuses before
anything is written.
- Save first waits out the editors' expression check of the last
keystroke. That is `LINT_DEBOUNCE_MS`, now in its own module
`celLintDebounce.ts` (which `CelPredicateField` imports), plus 50 ms.
Without the wait, a formula or rule guard typed and saved at once could
be sent before its check had judged it (the objectui#4306 rule).
**Save = draft + that item's publish.** `publishSavedItem` calls
`MetadataClient.publish(type, name, { packageId })`, which is `POST
/api/v1/meta/:type/:name/publish?package=` at the package the draft was
written to. It is never the package batch.
If the publish is refused:
- The draft the Save wrote is discarded, unless a draft was already
pending before the Save (a copilot's). A pending draft is kept: it now
carries the page's edits too.
- The edits stay on the page, unsaved, and the reason is shown in the
refusal strip.
**Editors moved to explicit save in this PR.** All of them are on the
object page, as one buffer with one Save:
- Fields:
- Add, from the Records grid's plus column and from the Form toolbar.
- Edit in the field inspector.
- Remove.
- Column reorder. This is now a buffer edit, not a save of its own.
- Validation rules.
- The object's own actions.
- Settings.
- Field groups.
- An installed app's object: base-field patches and added `__c` fields.
These are saved into its `.custom` pair as an `object_extension` and
published there, so they take effect at once.
**Editors not changed here** (they keep their draft autosave):
- Hooks. The hooks buffer lives in `ObjectHooksPanel` and unmounts on a
tab switch, so it has to be lifted into the pillar first.
- An installed app's own actions in the pair (`pairObjectActions`).
- List and form views, navigation, flows and permissions.
**Top bar.**
- Changes and Publish are drawn only while drafts are pending. The "No
drafts pending publish" disabled state is gone, because nothing is drawn
in its place.
- Publish refuses, with a toast, while the page holds edits Save has not
sent: its re-read would drop them.
- The surface's comment saying there is no per-item publish is
corrected.
**Confirmations.** Save asks before it sends a change that removes or
retypes a published field (`objectSaveConfirm.ts`). The field-remove
dialog at edit time stays, and its body now says the field leaves once
the change is saved and live. Studio has no delete-object affordance
(measured: none in the Data pillar or its item tools), so no dialog was
added for that.
**Leaving.** Opening another object with unsaved edits asks through
`confirmDropUnsavedWork`. The switch sends nothing. The unsaved-edit
registry the console's leave prompt reads now includes the Save bar's
dirty state.
**i18n** (`namespaces/studio`, en + zh):
- New keys:
`engine.studio.save.{save,saving,cancel,title,cancelTitle,done,refused,refusedLine,savedLine,itemSeparator,held,publishFirst,confirmIrreversible,confirmRemoveField,confirmRetypeField}`
and `engine.studio.held.lineExplicit`.
- `designer.field.removeConfirmBody` is reworded.
- Alternatives considered: `engine.studio.saveBar.*` and
`engine.studio.commit.*`. The name `save` matches the button's word.
## Tests
New files, named for this card:
- `DataPillar.saveCancel-36511.test.tsx`. Covers:
- Nothing is sent before Save. Save sends a PUT of the draft with
`?package=`, then a POST to publish with `?package=`.
- Cancel re-reads the object with no writes.
- A refused publish discards the draft. A refusal strip appears, the
edit is kept, and Save is still offered.
- A held picklist blocks Save.
- Removing a published field asks at Save. Declined, nothing is sent;
accepted, PUT then publish.
- `studioSaveBar.partialSave-36511.test.tsx`. Covers ordering, a partial
refusal naming the item and its reason, the saved list, a held buffer,
and Cancel.
- `StudioDesignSurface.saveBar-36511.test.tsx`. Covers:
- With no draft, the top bar has no Changes or Publish, and Cancel then
Save are the last actions.
- With a draft, the order is Changes, Publish, Cancel, Save, and Publish
waits for Save.
- `__tests__/studioSaveHarness.tsx`. A harness so a pillar mounted alone
gets the same coordinator and buttons.
**Retired, with the reason:**
- `DataPillar.savedAtDisplayLocale-10232.test.tsx` (3 tests). The "Saved
HH:MM" hint they pinned is gone: there is no autosave left to time.
- `StudioDesignSurface.draftVersionConflict-11773`, the case where two
editors each load and save once with no draft pending. A Save now
publishes, so no draft is left for the second editor's `If-None-Match:
*` to collide with. See Acceptance notes.
- `StudioDesignSurface.publishReadOnlyReason-12303`, the
objectstack#31495 "nothing pending" block (3 tests). Replaced by one
case: no Publish and no reason are drawn.
- `StudioDesignSurface.interfacePolish`, "no draft: disabled Publish
with visible reason". Replaced by: no Publish at all.
**Rewritten to the new semantics.** Each flipped pin asserts nothing
sent before Save, then the draft write and the item's publish after
Save, or that Cancel or a declined question leaves the page as it was:
- DataPillar, Save-gate suites: `celGate`, `panelGate`,
`panelHold-27629`, `heldIncomplete-11786`, `choiceWithoutOptions-11253`,
`summaryHeld-27461`, `authorRefusal-11785`, `actionRefusal-26736`,
`showMeFocus-26730`, `picklistServedOptions-10202`.
- DataPillar, other suites:
- `hiddenSystemFields-11780`, `recordsTab-34794`,
`addFieldPopover-12516`, `copilotDraftMarks-12725`.
- `destructiveChange-34931`, `draftSavedNamed-28984` (the toast is now
"Saved, live now: Task" under one sonner id), `draftUnreadable-29148`.
- `authoredBuffer-29793`, `pairActions-30088` (only its writable
control), `baseObjectExtension-28575` (its double now publishes the
pair's extension).
- `validationVerdictHold-27644` (its double's publish refuses the guard
the door refuses), `railSwitchFlush-27511` (the switch asks and sends
nothing; a saved edit leaves nothing to ask about).
- StudioDesignSurface suites: `autosaveInFlight-11204` (Data block: an
edit taken during a Save is the next Save's), `autosaveSwitch-11232`
(Data cases), `draftVersionConflict-11773` (the race over a pending
draft is refused, with reload and overwrite), `customizePublish-28562`,
`narrowHeader-12509`, `packageListErrorPosture`, `publishPosture-12517`.
- `DataPillar.internalFormRetired-36425`, added on main by #36543 while
this branch was open, now presses Save before its two Add group saves.
`DataPillar.formViewLayout-30057` was deleted on main by that PR, and
its one Data-page edit went with it.
- 17 edited suites gained a module-top `import '@objectstack/lint'`, as
`check:test-source-alias` asks of an edited file that reaches the
linter.
<details><summary>Studio-design suite after the last commit</summary>
Final head `1d6c0845`, same tree as the run except the registry method
rename, which the scripts run below covered.
```
cd ui && pnpm exec vitest run --maxWorkers=2 packages/app-shell/src/views/studio-design \
(+ CelPredicateField, ObjectFieldInspector.celGate, ResourceEditPage.celGate,
PermissionMatrixEditor.saveSurface-12725, i18n studio-namespace, studio-namespace-lazy)
Test Files 359 passed (359)
Tests 2774 passed (2774)
cd ui && pnpm exec vitest run --maxWorkers=2 scripts/ (+ the three new 36511 suites)
Test Files 175 passed | 2 skipped (177)
Tests 5138 passed | 2 skipped (5140)
os-verify-lock: VERDICT command-exit 0
```
Before the pins were rewritten, the same studio-design run read: 33
failed files and 89 failed tests out of 2733. Those are the pins this PR
flips.
</details>
<details><summary>Type-check (both configs) and dependency
build</summary>
```
pnpm --filter @object-ui/app-shell type-check (tsc --noEmit && tsc -p tsconfig.test.json)
os-verify-lock: VERDICT command-exit 0 · held the lock 119s
pnpm --workspace-concurrency=2 --filter '@object-ui/app-shell^...' build (after merging origin/main)
os-verify-lock: VERDICT command-exit 0 · held the lock 433s
```
</details>
<details><summary>Gates (dispatch-gates --ran)</summary>
Head `1d6c0845`. `node scripts/pm/dispatch-gates.mjs --repo
objectstack-ai/objectstack --ran FILE`:
```
Run reconciliation — 39 derived, 39 run, 0 NOT-MEASURED, 0 UNRUN.
✓ dispatch-gates --ran: 39 derived famil(ies) accounted for — 39 run, 0 NOT-MEASURED
```
```
node scripts/check-adr-0087-registration.mjs --base origin/main :: exit 0
node scripts/check-adr-0087-registration.mjs --self-test :: exit 0
node scripts/check-changeset-no-major.mjs --base origin/main :: exit 0
node scripts/check-closing-keyword-parity.mjs :: exit 0
node scripts/check-closing-keyword-parity.mjs --self-test :: exit 0
node scripts/check-comment-mask-corpus.mjs :: exit 0
node scripts/check-empty-changeset.mjs --base origin/main :: exit 0
node scripts/check-empty-changeset.mjs --self-test :: exit 0
node scripts/check-sdui-manifest.mjs :: exit 0
node scripts/check-sdui-manifest.mjs --self-test :: exit 0
node scripts/ci/snapshot-next.mjs --self-test :: exit 0
node scripts/pm/check-governed-queue-guard.mjs --self-test :: exit 0
node scripts/pm/release-rehearsal-clone.mjs --self-test :: exit 0
node scripts/release-pending-publish.mjs --self-test :: exit 0
pnpm --filter @objectstack/spec run check:duration-unit-keys :: exit 0
pnpm --filter @objectstack/spec run check:error-code-provenance :: exit 0
pnpm check:adr-anchors :: exit 0
pnpm check:changeset-gate-self-tests :: exit 0
pnpm check:closed-ceremony-text :: exit 0
pnpm check:cross-package-test-inputs :: exit 0
pnpm check:dispatcher-error-vocabulary :: exit 0
pnpm check:driver-memory-census :: exit 0
pnpm check:engine-double-contract :: exit 0
pnpm check:gitlink-declared :: exit 0
pnpm check:nul-bytes :: exit 0
pnpm check:published-files :: exit 0
pnpm check:query-options-erasure :: exit 0
pnpm check:refd-timer-probe :: exit 0
pnpm check:registry-log-declared :: exit 0
pnpm check:rest-log-spy-declared :: exit 0
pnpm check:skill-identifier-liveness :: exit 0
pnpm check:test-source-alias :: exit 0
pnpm check:tier-file-adoption :: exit 0
pnpm check:type-check-coverage :: exit 0
pnpm check:type-check-debt :: exit 0
pnpm check:undeclared-dep-imports :: exit 0
pnpm check:watch-hint-literal :: exit 0
pnpm check:where-matcher :: exit 0
pnpm --dir ui exec vitest run scripts/ :: exit 0
```
`node scripts/check-nul-bytes.mjs`: OK. `node
scripts/pm/overlap-check.mjs`: VERDICT clean exit 0 (against #36580 and
#36579, which share the studio namespace files).
</details>
## Acceptance notes
- **Concurrent editors over a published object** (seat ruling 7089589821
on #36511: accepted as a transitional window; the server guard is
tracked on #36601, not awaited here). The draft-version guard pins
drafts only. After a Save publishes, no draft is left, so the second
editor's next Save asserts no draft and succeeds over the first editor's
live change. The server serves no published-layer version a save could
pin. When a draft was pending at open, the race is still refused with
the conflict dialog; that case is pinned in
`draftVersionConflict-11773`. Until #36601 lands, the second editor's
Save overwrites the first editor's live change.
- **AI and a human on one item.** While the page holds unsaved edits,
the refresh pulse is held, so a copilot draft written meanwhile is not
shown over them. Save is pinned to the draft read: if the copilot wrote
a draft in between, the conflict dialog offers reload or overwrite, so
neither side is lost silently. If the publish is refused, a pending
copilot draft is kept and carries the page's edits.
- **A rule guard refused by the publish.** The object publish locator
does not place a `validations.N.condition` path, so the strip reads "Not
published: the server refused this draft. Details say why." and the
rule's reason is under Details. This is the locator's existing reach,
not new here.
- **The served-verdict hold** (objectstack#27644) still holds a rule
whose stored draft the door refused, when that draft was pending at
open. A Save the publish refuses now shows the reason at once instead of
leaving a draft whose re-read holds the next edit.
- **Removing a published field** asks twice: once in the remove dialog
at edit time, and once at Save. The card names a confirmation for both
removal and type changes. Folding them into one is a product call left
to the card.
- **ADR sentences the new behaviour contradicts**, for
objectstack#36086:
- ADR-0027 M2, "explicit, batched publish".
- ADR-0037, "Publish remains the single commit gate".
- The surface comment "There is no per-item publish". This one is
corrected in code.
- **Not measured.**
- The single-item publish was not run against a live server in this run.
The route `POST /api/v1/meta/:type/:name/publish` (`publishMetaItem`)
and the existing caller `saveAndPublishRuntimeMetadata` are cited.
- The full-farm CI families were not run locally (local scope rule).
## Verification
Read first:
1. `ui/packages/app-shell/src/views/studio-design/studioSaveBar.tsx`.
The coordinator's held and settle check, and `publishSavedItem`'s
discard rule.
2. `StudioDesignSurface.tsx`, the DataPillar `doSave` and `doSaveExt`
hunk. Riskiest: the refused-publish restore of `objStoredRef` and
`hasDraft`.
3. `DataPillar.saveCancel-36511.test.tsx`.
Two-minute check: `cd ui && pnpm exec vitest run
packages/app-shell/src/views/studio-design/DataPillar.saveCancel-36511.test.tsx`.
Expected: 5 passed, including the case where nothing is sent before
Save, then a PUT with `mode=draft&package=` followed by a POST to
`/publish?package=`.
Session: https://claude.ai/code/session_01ADHkmPsv99YG2tCHoSe8Nb
🤖 Generated with [Claude Code](https://claude.com/claude-code)
<!-- signed: repo:objectstack#2 · os-steve ·
session_01ADHkmPsv99YG2tCHoSe8Nb -->
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent ceaa70e commit ed0edb1
48 files changed
Lines changed: 1903 additions & 847 deletions
File tree
- .changeset
- ui
- e2e/live
- packages
- app-shell/src/views
- metadata-admin
- studio-design
- __tests__
- i18n/src/namespaces/studio
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| 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 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
16 | | - | |
17 | | - | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
18 | 19 | | |
19 | 20 | | |
20 | 21 | | |
| |||
230 | 231 | | |
231 | 232 | | |
232 | 233 | | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
233 | 249 | | |
234 | 250 | | |
235 | 251 | | |
236 | | - | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
237 | 256 | | |
238 | 257 | | |
239 | 258 | | |
| 259 | + | |
240 | 260 | | |
241 | 261 | | |
242 | 262 | | |
243 | 263 | | |
244 | | - | |
245 | | - | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
246 | 273 | | |
247 | 274 | | |
248 | 275 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
79 | 79 | | |
80 | 80 | | |
81 | 81 | | |
82 | | - | |
| 82 | + | |
83 | 83 | | |
84 | 84 | | |
85 | 85 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
30 | | - | |
| 30 | + | |
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
| |||
63 | 63 | | |
64 | 64 | | |
65 | 65 | | |
| 66 | + | |
| 67 | + | |
66 | 68 | | |
67 | 69 | | |
68 | 70 | | |
| |||
128 | 130 | | |
129 | 131 | | |
130 | 132 | | |
| 133 | + | |
| 134 | + | |
131 | 135 | | |
| 136 | + | |
132 | 137 | | |
133 | 138 | | |
134 | 139 | | |
| |||
144 | 149 | | |
145 | 150 | | |
146 | 151 | | |
147 | | - | |
148 | | - | |
149 | | - | |
150 | | - | |
151 | | - | |
152 | | - | |
153 | | - | |
154 | 152 | | |
155 | 153 | | |
156 | 154 | | |
157 | | - | |
| 155 | + | |
158 | 156 | | |
159 | | - | |
| 157 | + | |
160 | 158 | | |
161 | 159 | | |
162 | 160 | | |
| |||
179 | 177 | | |
180 | 178 | | |
181 | 179 | | |
182 | | - | |
| 180 | + | |
183 | 181 | | |
184 | 182 | | |
185 | 183 | | |
| |||
198 | 196 | | |
199 | 197 | | |
200 | 198 | | |
201 | | - | |
| 199 | + | |
202 | 200 | | |
203 | 201 | | |
204 | 202 | | |
| |||
211 | 209 | | |
212 | 210 | | |
213 | 211 | | |
214 | | - | |
| 212 | + | |
215 | 213 | | |
216 | 214 | | |
217 | 215 | | |
218 | | - | |
| 216 | + | |
219 | 217 | | |
220 | 218 | | |
221 | 219 | | |
| |||
225 | 223 | | |
226 | 224 | | |
227 | 225 | | |
228 | | - | |
| 226 | + | |
229 | 227 | | |
230 | 228 | | |
231 | 229 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
| 35 | + | |
35 | 36 | | |
36 | 37 | | |
37 | 38 | | |
| |||
68 | 69 | | |
69 | 70 | | |
70 | 71 | | |
| 72 | + | |
| 73 | + | |
71 | 74 | | |
| 75 | + | |
72 | 76 | | |
73 | 77 | | |
74 | 78 | | |
| |||
98 | 102 | | |
99 | 103 | | |
100 | 104 | | |
101 | | - | |
| 105 | + | |
102 | 106 | | |
103 | | - | |
| 107 | + | |
104 | 108 | | |
105 | 109 | | |
106 | 110 | | |
| |||
115 | 119 | | |
116 | 120 | | |
117 | 121 | | |
| 122 | + | |
118 | 123 | | |
119 | 124 | | |
120 | 125 | | |
| |||
205 | 210 | | |
206 | 211 | | |
207 | 212 | | |
208 | | - | |
209 | | - | |
210 | | - | |
211 | | - | |
212 | | - | |
| 213 | + | |
| 214 | + | |
213 | 215 | | |
214 | 216 | | |
215 | 217 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
30 | | - | |
| 30 | + | |
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
| |||
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
| 44 | + | |
| 45 | + | |
44 | 46 | | |
45 | 47 | | |
46 | 48 | | |
| |||
74 | 76 | | |
75 | 77 | | |
76 | 78 | | |
| 79 | + | |
| 80 | + | |
77 | 81 | | |
| 82 | + | |
78 | 83 | | |
79 | 84 | | |
80 | 85 | | |
| |||
98 | 103 | | |
99 | 104 | | |
100 | 105 | | |
101 | | - | |
| 106 | + | |
102 | 107 | | |
103 | | - | |
| 108 | + | |
104 | 109 | | |
105 | 110 | | |
106 | 111 | | |
| |||
112 | 117 | | |
113 | 118 | | |
114 | 119 | | |
115 | | - | |
116 | | - | |
117 | | - | |
118 | | - | |
| 120 | + | |
| 121 | + | |
119 | 122 | | |
120 | 123 | | |
121 | 124 | | |
122 | 125 | | |
123 | 126 | | |
124 | 127 | | |
125 | | - | |
| 128 | + | |
126 | 129 | | |
127 | 130 | | |
128 | 131 | | |
| |||
134 | 137 | | |
135 | 138 | | |
136 | 139 | | |
137 | | - | |
| 140 | + | |
138 | 141 | | |
139 | | - | |
| 142 | + | |
140 | 143 | | |
141 | 144 | | |
142 | 145 | | |
143 | 146 | | |
144 | 147 | | |
145 | 148 | | |
146 | 149 | | |
147 | | - | |
148 | | - | |
149 | | - | |
| 150 | + | |
150 | 151 | | |
151 | 152 | | |
152 | 153 | | |
| |||
0 commit comments