Repository navigation
Commit f590f3e
feat(studio): hooks, an installed app's added actions and flows save with Cancel and Save, live at once (#36634)
<!-- 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 second PR for the card, on top of #36597 (the object page,
merged). It covers the object page's hooks, the actions an installed
app's object gains in its customization package, and flows. Permission
sets in the Studio's Access pillar are done too, but are left out of
this PR to keep it under the 3000-line budget: they wait on the branch
`claude/issue-36511-studio-save-cancel-3`, about 380 more lines on top
of this one. Field layout and the AI-draft notice stay with the third
PR.
## 维护者速读
- 用户能看到什么变化:在 Studio
里,对象页的「钩子」「新增动作(已安装应用的定制)」和「自动化流程」不再每隔一秒半自动存草稿。改完点顶栏「保存」立即生效,点「取消」回到原样。流程的启用开关一按就生效,新建的流程一创建就上线(默认关闭),打开开关即刻运行。
-
为什么做:维护者裁定人类改一项就确认一项、点保存直接生效。这是「保存即生效」系列的第二步,接在已合入的对象页之后;权限集因行数预算另起一单紧随其后。
- 出错会怎样:保存被服务器拒绝时,改动留在页面上并写明原因,这次保存写下的草稿会被收回。可以直接撤回本单,回到原来的自动存草稿。
- 要你做什么:无。
## What changes
**Mechanism.** Nothing new. Each editor below registers its buffer with
the top bar's coordinator from #36597 (`useStudioSaveEntry` in
`studioSaveBar.tsx`). Save writes the item's draft, then publishes that
one item with `publishSavedItem`. A refused publish takes back the draft
that Save wrote, unless a draft was already pending before the Save.
**Editors moved to explicit save in this PR.**
- **Hooks**, on the object page's Hooks tab (`ObjectHooksPanel.tsx`):
- The buffer moved out of the panel into a new `objectHooksBuffer.ts`.
It is owned by the Data pillar, so an edit survives a tab switch and is
still sent by Save.
- It is read the first time the Hooks tab opens for an object, so
opening an object reads nothing new.
- A new hook ("+ New", and the empty block's button) is written only by
Save, under the first-write pin (`If-None-Match: *`).
- A rename or an expression that does not parse holds the whole Save and
names why.
- The panel is now presentational. Its saved-at line is gone; the toast
names what was saved.
- **An installed app's added actions**, on the object page's Actions tab
(`pairObjectActions.ts`, `ObjectActionsPanel.tsx`):
- The same lift: the Data pillar owns the buffer.
- A preset adds the action locally; nothing is written and the ensure
door is not asked until Save.
- Delete takes the row off the page; Save deletes its draft and its
published row in the pair.
- Save writes each new or edited action's draft in the pair and
publishes it there.
- **Flows**, on the canvas and in the properties aside
(`AutomationsPillar` in `StudioDesignSurface.tsx`):
- The flow's autosave is gone. Save writes the draft (into the pair for
a customized flow) and publishes that flow. Cancel reloads it as the
server holds it.
- **The enable switch needs no Save.** A flip writes the stored flow
with the new `status` and publishes it at once. An unsaved canvas edit
is not sent with it and stays on the page for Save. A refused flip rolls
the switch back.
- **A new flow is published as it is created**, switched off as before,
so turning it on makes it live straight away. Self-built and installed
apps take the same path. An installed app's flows that are switched
through the ledger (`FlowLedgerSwitch`) were already immediate.
- The header's 已保存 badge retired with the autosave. A Save also re-reads
the flow's verdict, so a stale problem clears.
**Words.**
- The switch's titles and toasts say a flip is live now, not "publish to
apply".
- The inspector footers and the Studio landing lead say Save makes a
change live.
- A customized item's pillar footer has its own key,
`engine.studio.customize.saveFooter`. The shared `customize.draftFooter`
stays as written for the All-metadata item page, which still autosaves.
- Three held clauses are new: `held.hookRename`, `held.celInvalidHook`,
`held.pairActionRename`.
- Three keys only the badge read are removed: `autoSaved`,
`flowSavedNamed`, `flowSaveFailed`.
**Two people saving the same item.** The later Save can overwrite one
that already went live. The seat accepted this for the transition
(ruling on the card, 7089589821); the server-side guard is #36601.
## Tests
New suites, each asserting no write before Save (past the retired 1.5 s
debounce), then the draft write followed by the single-item publish, and
Cancel putting the page back with nothing sent:
- `ObjectHooksPanel.saveCancel-36511.test.tsx`: edit, Save, Cancel; "+
New" under `If-None-Match: *`; a refused publish keeps the edit and
takes back the draft; a rename holds Save.
- `AutomationsPillar.saveCancel-36511.test.tsx`: edit, Save, Cancel. The
switch is live at once without the unsaved edit. A new flow is published
off, and switched on it is published on.
- `DataPillar.pairActions-30088.test.tsx` (rewritten): a preset writes
nothing and asks no pair until Save; an edit is saved and published at
the pair; Delete is sent by Save. A new Cancel case covers an added
action plus an edit.
Rewritten onto the top bar's Save (the same assertions, with Save
pressed where the autosave used to fire):
- Hooks: `ObjectHooksPanel.celGate`, `.firstSavePinned-11773` (a
re-opened hook now asserts no draft again, since Save published the last
one), `.draftUnreadable-29148`, `.newHookTarget-11820`,
`.designerRegistryMissing`, `StudioEmptyState.panels-12514` (Hooks
block), `ObjectPanels.lateRegistration-11939`. The panel is mounted
through a new test host, `__tests__/hooksPanelHost.tsx`.
- Flows: `AutomationsPillar.customizeFlow-28570`,
`.problemsAgree-27799`, `.serverVerdict-26858`, `.heldIncomplete-11786`,
`StudioDesignSurface.autosaveInFlight-11204` (flow case),
`.autosaveSwitch-11232` (two flow cases), `.publishRefusal-26730` (the
switch's publish takes the draft off the pending feed),
`.heldPublish-11786`.
- `DirectoryPage.stateVocabulary-29705` pins the new
`customize.saveFooter` key to 定制.
Retired:
- `ObjectHooksPanel.autosave-11787.test.tsx`: the hook autosave it
pinned is gone. Its rename hold moved into the new hooks suite, and its
in-flight case has no autosave left to race.
- The three badge cases of
`StudioDesignSurface.flowAutosave-34818.test.tsx`: the badge is gone,
and the Save toast is pinned in the new flow suite. Its Interfaces,
Debug and Runs cases stay.
<details><summary>Local test readings</summary>
All runs went through `os-verify-lock.sh`, after a fresh build of the
app-shell dependency closure following the merge of main.
- At c496e8b, the code as in this PR's head: `vitest run` over
`app-shell/src/views/studio-design`, the `PermissionMatrix*` suites,
`DirectoryPage.stateVocabulary-29705`, `studioAutomationCopy*` and the
whole `packages/i18n`. Result: `Test Files 509 passed (509)`, `Tests
5138 passed | 13 skipped (5151)`, VERDICT command-exit 0.
- At bf7dbf0, the head. The only change since c496e8b is a
collection-time `import '@objectstack/lint'` in 13 suites, asked for by
`check:test-source-alias`. Those 13 suites plus the new flow suite and
the pair-actions suite: `Test Files 15 passed (15)`, `Tests 71 passed
(71)`, VERDICT command-exit 0.
- At bf7dbf0, app-shell `pnpm type-check` (both tsconfig and
tsconfig.test) and `pnpm lint`: VERDICT command-exit 0, lint 0 errors.
- `Test UI`, `Lint UI`, `Type Check UI` and the Live E2E run in CI.
</details>
## Acceptance notes
- Permission sets: they are on `claude/issue-36511-studio-save-cancel-3`
(the Access matrix sends with Save and publishes the set; the banners
say Save). They were left out only for the line budget: this PR is 30
files, +1773/−1008 against main.
- The create dialogs still read "Save as draft"
(`engine.studio.createDraft`, one label pinned for every create dialog
by `CreateItemDialog.oneLabel-11787`). Objects since #36597, and flows
now, are live when created. The label is left for the card to settle in
one place.
- The Access pillar's OWD overview keeps its own Save, which writes
object drafts for Publish. It was not named in this PR's scope.
- After a Save, the Problems tab reads the live flow's verdict, because
no draft is left. A publish the server refuses still names the problem
in the refusal strip.
## Verification
Read first:
1.
`ui/packages/app-shell/src/views/studio-design/StudioDesignSurface.tsx`,
AutomationsPillar `doSave` and `toggleEnabled`: the publish after the
draft, and the switch writing the stored flow, not the buffer.
2. `ui/packages/app-shell/src/views/studio-design/objectHooksBuffer.ts`,
`save`: a new hook versus an existing one, and the re-pin after a
refused or a landed publish.
3. `ui/packages/app-shell/src/views/studio-design/pairObjectActions.ts`,
`save`: deletes first, then each draft and its publish, with refusals
collected.
Two minutes: open Studio on a self-built app, then Automations. Change a
step's label: Cancel and Save appear at the top right. Press Save: the
toast says the flow is saved, and reopening the app shows the label.
Flip the switch: the toast says it is live now, with no Save and no
Publish.
<details><summary>Local gates at bf7dbf0</summary>
Derived with `node scripts/pm/dispatch-gates.mjs --commands --repo
objectstack-ai/objectstack` at bf7dbf0: 38 families, all run with
exit 0. `pnpm --dir ui exec vitest run scripts/` ran under the lock:
`Test Files 172 passed | 2 skipped`.
Reconciled with `--ran`: `38 derived famil(ies) accounted for — 38 run,
0 NOT-MEASURED (a DERIVED zero — all 38 recorded an exit code and none
of them is 3)`.
`overlap-check`: clean against origin/main 4ef1ea9.
</details>
🤖 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 e9fa6b5 commit f590f3e
32 files changed
Lines changed: 1806 additions & 1023 deletions
File tree
- .changeset
- ui
- packages
- app-shell/src/views
- metadata-admin
- studio-design
- __tests__
- i18n/src/namespaces/studio
- scripts
- __tests__
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
362 | 362 | | |
363 | 363 | | |
364 | 364 | | |
| 365 | + | |
365 | 366 | | |
366 | 367 | | |
367 | 368 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
92 | 92 | | |
93 | 93 | | |
94 | 94 | | |
| 95 | + | |
95 | 96 | | |
96 | 97 | | |
97 | 98 | | |
| |||
137 | 138 | | |
138 | 139 | | |
139 | 140 | | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
140 | 151 | | |
141 | 152 | | |
142 | 153 | | |
| |||
159 | 170 | | |
160 | 171 | | |
161 | 172 | | |
| 173 | + | |
| 174 | + | |
162 | 175 | | |
163 | 176 | | |
164 | 177 | | |
165 | 178 | | |
166 | 179 | | |
167 | 180 | | |
| 181 | + | |
168 | 182 | | |
169 | 183 | | |
170 | 184 | | |
| |||
221 | 235 | | |
222 | 236 | | |
223 | 237 | | |
| 238 | + | |
224 | 239 | | |
225 | 240 | | |
226 | 241 | | |
| |||
262 | 277 | | |
263 | 278 | | |
264 | 279 | | |
265 | | - | |
266 | | - | |
267 | | - | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
268 | 285 | | |
269 | 286 | | |
270 | 287 | | |
| |||
331 | 348 | | |
332 | 349 | | |
333 | 350 | | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
334 | 354 | | |
| 355 | + | |
| 356 | + | |
335 | 357 | | |
336 | 358 | | |
337 | 359 | | |
| |||
353 | 375 | | |
354 | 376 | | |
355 | 377 | | |
356 | | - | |
| 378 | + | |
| 379 | + | |
357 | 380 | | |
| 381 | + | |
358 | 382 | | |
359 | 383 | | |
360 | | - | |
| 384 | + | |
361 | 385 | | |
362 | 386 | | |
363 | 387 | | |
| |||
385 | 409 | | |
386 | 410 | | |
387 | 411 | | |
| 412 | + | |
388 | 413 | | |
389 | 414 | | |
390 | 415 | | |
| |||
436 | 461 | | |
437 | 462 | | |
438 | 463 | | |
| 464 | + | |
439 | 465 | | |
440 | 466 | | |
441 | 467 | | |
| |||
470 | 496 | | |
471 | 497 | | |
472 | 498 | | |
| 499 | + | |
473 | 500 | | |
474 | 501 | | |
475 | 502 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
87 | 87 | | |
88 | 88 | | |
89 | 89 | | |
| 90 | + | |
| 91 | + | |
90 | 92 | | |
| 93 | + | |
91 | 94 | | |
92 | 95 | | |
93 | 96 | | |
| |||
131 | 134 | | |
132 | 135 | | |
133 | 136 | | |
134 | | - | |
135 | | - | |
136 | | - | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
137 | 142 | | |
138 | 143 | | |
139 | 144 | | |
| |||
168 | 173 | | |
169 | 174 | | |
170 | 175 | | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
171 | 179 | | |
172 | 180 | | |
173 | 181 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
126 | 126 | | |
127 | 127 | | |
128 | 128 | | |
| 129 | + | |
129 | 130 | | |
130 | 131 | | |
131 | 132 | | |
| |||
173 | 174 | | |
174 | 175 | | |
175 | 176 | | |
176 | | - | |
177 | | - | |
178 | | - | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
179 | 182 | | |
180 | 183 | | |
181 | 184 | | |
| |||
209 | 212 | | |
210 | 213 | | |
211 | 214 | | |
212 | | - | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
213 | 218 | | |
214 | 219 | | |
215 | 220 | | |
| |||
227 | 232 | | |
228 | 233 | | |
229 | 234 | | |
| 235 | + | |
230 | 236 | | |
231 | 237 | | |
232 | 238 | | |
| |||
237 | 243 | | |
238 | 244 | | |
239 | 245 | | |
| 246 | + | |
240 | 247 | | |
241 | 248 | | |
242 | 249 | | |
| |||
0 commit comments