Repository navigation
Commit 942ffb2
fix(app-shell): an edit a Studio pillar holds unsent guards departure like a dirty pillar (#26839)
<!-- claude-projects-attribution: {"github_login":"os-warren"} -->
_Requested by **Warren** · [project
thread](https://claude.ai/code/project/chan_01U5RdnAAmkSQmZbqh6FtqZ8?thread=cmsg_01U5RdnAAmkSQmZbqh6FtqZ8WL2sva4QpvpyNanwaBxGsw)_
Fixes #26705
Clause-②: no
Metadata-protocol: none
## 维护者速读
- 改了什么:Studio
把「暂存未发的编辑」(还不能保存的字段、步骤、组件)也算作未保存工作;离开支柱、刷新页面、在左侧栏切换到别的对象/流程/页面时,会先弹出与
Access 相同的确认框。
- 为什么改:之前 Data、Automations、Interfaces
支柱暂存的编辑只拦发布,不拦离开,一次误点就静默丢失;分诊裁决是「confirm 加 beforeunload,共用一个守卫」。
- 风险与回滚:只多问一句,不改保存与发布逻辑;暂存与否沿用已有判定。有问题直接 revert 本 PR。
- 先看:`StudioDesignSurface.tsx` 里的 `confirmDropUnsavedWork` 和
`unsavedPillarWork`,然后三处左侧栏 onClick / onPick 的守卫行,最后
`StudioDesignSurface.heldDataLeave-26705.test.tsx`。
- 两分钟验证:`pnpm --dir ui exec vitest run
packages/app-shell/src/views/studio-design/StudioDesignSurface.heldDataLeave-26705.test.tsx`,预期
4 个测试全绿。
- 需要你做的:无,席位落地。
## What changes
Base `607d3bb1`, then `origin/main` `55b5042e` merged in (no conflict;
nothing it brought touches these files). Then `d33bfcf7`: the zh
catalogue preload in two metadata-admin suites (test-only, scope widened
by the seat, Claim 6452362760). One shared guard, read by every
departure that drops a pillar's buffer:
- **`confirmDropUnsavedWork(unsaved, locale)`**, a module function
beside `useHeldEditReport`: the one question
(`engine.edit.unsavedLeaveConfirm`, the text Access already asks) or
`true` when nothing would be lost. Access's own `confirmDiscardEdits`
now calls it too, so the question has one spelling.
- **Surface:** `heldEdit` moves up beside `pillarDirty`, and
`unsavedPillarWork = pillarDirty || heldEdit !== null` replaces
`pillarDirty` in `confirmLeavePillar`, the `beforeunload` effect and
`useRegisterUnsavedEdits`. That covers the pillar links (the shell
seam's link guard asks while registered), Home, the package switcher,
the cross-pillar `?surface=` request, Create app, the shell's own
departures and reload. Pillars already take their held report back on
unmount, so a confirmed leave clears the guard.
- **Rail item switch** (a pillar-local path the surface cannot see;
another item's load replaces the one buffer the held edit lives in): the
Data object rail asks on `objHeld`, the Automations flow rail on
`flowHeld`, the Interfaces nav rail on `leafHeld`. Re-picking the open
item (same object, same flow, an entry for the same leaf) drops nothing
and asks nothing, mirroring Access's rail.
- Unchanged by design: how a held edit is judged and saved, and
Publish's refusal while one is held.
## Why
Triage first grade on the card, verbatim: "Guard departure the way the
Access pillar and the Interfaces navigation already do (confirm plus
`beforeunload`), with one shared guard." A held edit lives only in the
pillar's buffer, so before this change one stray click dropped a
half-added field, step or widget that the strip had just promised was
"kept here".
## Tests
Three new files, one per pillar, each through the real
`StudioDesignSurface` on the real route shape (the held edit is produced
the way an author does it: a Picklist with no option, a Notify step with
no Title, a Metric widget with no dataset):
- `StudioDesignSurface.heldDataLeave-26705.test.tsx`,
`StudioDesignSurface.heldFlowLeave-26705.test.tsx`,
`StudioDesignSurface.heldWidgetLeave-26705.test.tsx`, four cases each:
leaving the pillar asks (Cancel keeps the held edit, OK leaves, and
walking back asks nothing); the rail switch asks (Cancel keeps it,
re-picking the open item asks nothing, OK opens the other item and the
hold is gone); a reload asks only once the edit is held; and the
CONTROL: with nothing held, the rail, the reload and the pillar link
never ask.
<details><summary>Runs</summary>
- New files: 3 files, 12/12 passed (lock VERDICT command-exit 0).
- `pnpm --dir ui exec vitest run
packages/app-shell/src/views/studio-design/
packages/app-shell/src/chrome/`: 244 files, 1773/1773 passed, exit 0
(pre-merge head `d2e66f47`).
- After merging `origin/main`: the three new files plus
`pillarNavGuard`, `heldPublish-11786`, `heldWidgetPublish-11910`, re-run
on the merge head `b8d23d79`: 6 files, 28/28 passed, exit 0.
- Two metadata-admin suites, `ResourceEditPage.discardDraftLabel-12690`
and `PackageFormDialog.validationTiming`, now load the zh studio
catalogue at module scope (`await loadStudioCatalogue('zh')`), as other
zh-reading suites do since the studio namespace became lazy (#25922).
The first went red on `Test UI` at `0a856a7d`. With the zh catalogue
held back 4 s, each is red without its preload (1/3, 3/5) and green with
it (3/3, 5/5).
- `pnpm --filter @object-ui/app-shell type-check`: exit 0.
</details>
<details><summary>Ablation (one-shot, through
scripts/ablation-replace.mjs; each leg restored to the HEAD blob with an
empty git diff HEAD)</summary>
- Leg A, drop the held term from the surface (`unsavedPillarWork =
pillarDirty`): 6 of 12 red, exactly the leave and reload cases of all
three pillars; the rail and control cases stay green.
- Leg B, drop the held term from each rail guard (replace `objHeld !==
null` / `flowHeld !== null` / `leafHeld !== null` with `false`): each
pillar's rail-switch case red (1 of 4 per file), nothing else.
</details>
## Acceptance notes
- Not guarded, measured and left as they were: creating a new object,
flow or Interfaces item while another item's edit is held opens the new
item (the create has already been written), and a same-pillar
`?surface=` request from the pending-changes sheet opens the requested
item without asking. Both drop the held edit the same way a rail switch
did. The card names leaving the pillar, the rail switch and reload;
these two are left for a follow-up if wanted.
- Browser Back/Forward is still not vetoed, as the shell seam's docblock
already states for every page.
- `@object-ui/app-shell` is `private: true`, so no changeset.
## Verification
Gates derived by `node scripts/pm/dispatch-gates.mjs --commands --repo
objectstack-ai/objectstack`: 24 families, all run, reconciled with
`--ran` (24 run, 0 NOT-MEASURED). `pnpm --dir ui exec vitest run
scripts/` reported one timeout in `check-vi-mock-inherit.test.ts` (15 s,
shared box under load) and passed 83/83 when that file was re-run alone.
`pnpm check:new-line-citations` (ui): 0 new citations.
## Human Minimum
- [x] 1. Schemas start as Zod; `packages/spec` holds no runtime logic.
(Not touched.)
- [x] 2. Every name I added uses the casing for its kind.
- [x] 3. No formatter ran; `pnpm lint` passes. (eslint on the four
files: 0 errors; `StudioDesignSurface.tsx` carries the same 16 warnings
as on the base, the three tests none.)
- [x] 4. One issue, one branch off an up-to-date `main`, one pull
request.
- [x] 5. A change that publishes carries a changeset, and both
declaration lines are filled in here and in the changeset. (Publishes
nothing: `@object-ui/app-shell` is private.)
- [x] 6. `packages/spec` touched: its generated artifacts are
regenerated and committed. (Not touched.)
- [x] 7. No hand edits to `content/docs/references/`,
`packages/*/CHANGELOG.md` or `content/docs/releases/`.
- [x] 8. Title, body and comments are in English, apart from the
maintainer brief above.
- [x] The *Before Submitting* list in CONTRIBUTING.md is done.
---
_Generated by [Claude
Code](https://claude.ai/code/session_01JQwxbZJiPgbGWj5B2jNkYx)_
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent 1d7816d commit 942ffb2
6 files changed
Lines changed: 773 additions & 18 deletions
File tree
- ui/packages/app-shell/src/views
- metadata-admin
- studio-design
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
23 | 28 | | |
24 | 29 | | |
25 | 30 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
103 | 103 | | |
104 | 104 | | |
105 | 105 | | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
106 | 111 | | |
107 | 112 | | |
108 | 113 | | |
| |||
| 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 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 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 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
0 commit comments