Repository navigation
Commit fa345c4
fix(console): a parent's whole-record hand lock locks its inline master-detail lines in the edit form (#38388)
Fixes #38249
Clause-②: yes (widening)
Metadata-protocol: none
## 维护者速读
-
用户能看到什么变化:对象上写了「整单人手锁定」条件的单据(如已确认的订单),在控制台编辑对话框里,明细行也一并锁住:不能加行、复制行、删行、拖动排序或改单元格;明细字段自己写了「始终可改」的那一列仍可编辑;整单与明细都没有可改之处时,记录页的「编辑」按钮置灰并说明原因。
-
为什么做:对象级整单锁定上线后,表头字段锁住了,明细行却还能手改,与「整单人手锁定」的承诺不符,维护者裁定按字面先落地、再立此跟进卡补上明细这一半。
-
出错会怎样:漏锁时用户仍能手改明细行,服务端校验照常兜底;误锁时只影响手工编辑,按钮、接口、导入、流程照常写入;去掉对象上的锁定条件即可撤回。
- 要你做什么:无。
## What changes
Governing ruling: the maintainer on PR #38169 (the object-level hand
lock), 「本 PR 按字面落地+立跟进卡」; this card is that follow-up. The opt-out reads
the existing override rule of the two-tier lock model (ruling on #36806,
Q1 = B on #37402): a field that declares a hand lock of its own —
`uiReadonly: true` or a `uiReadonlyWhen` — is judged by it instead of
any object-level default, and `uiReadonly: false` is not such a
declaration. No key, value or schema property is added.
**`@object-ui/plugin-form`**
- `MasterDetailForm.tsx` (the edit dialog's line grids): the header
record feed also lands the parent object's `uiReadonlyWhen` with its
field names. On an EDIT form the lines judge it over the live header
record (every header field seeded `null`, the stored row as `previous`,
the host's predicate scope) through the one hand-lock verdict
(`fieldReadOnlyByHand` of a field that declares nothing, i.e. the object
lock itself, failing closed). While it holds: no Add, Duplicate, Remove
or drag-reorder, no per-row editor, and every line column whose child
field owns no hand lock is locked on every row. A create is not judged.
- `deriveMasterDetail.ts`: derived and hydrated line columns carry an
in-memory mark when their child field owns a hand lock
(`childFieldOwnsHandLock`, which asks `effectiveUiReadonlyWhen` itself
rather than restating the rule). `lockColumnsByParentHandLock` locks
every unmarked column. `childLinesOpenUnderParentHandLock` answers
whether some child field owns a non-static hand lock (exported from the
root and from `/core`).
**`@object-ui/app-shell`**
- `editFormLockedByState.ts`: an object that places an inline child
collection no longer keeps Edit live unconditionally. It greys Edit when
the object's own `uiReadonlyWhen` holds over the record, every drawn
header field is read-only, and no placed child object has a field that
could open a line cell. That needs the child definitions, through a new
optional `childObjectDef` argument; without it, or for a child it cannot
answer, Edit stays live (fail open, as before).
- `RecordDetailView.tsx`: passes the served object list as that
resolver.
Declared writes (REST, import, actions, flows) are untouched: nothing on
the server reads either key (ruling on #36806).
Published surface, both additive (a non-protocol widening, so `patch`):
`@object-ui/plugin-form` exports `childLinesOpenUnderParentHandLock`
from its `.` and `./core` entries, and the exported
`editFormLockedByState` of `@object-ui/app-shell` takes an optional
fourth argument, `childObjectDef`; a caller that omits it behaves as
before.
## Why
PR #38169's acceptance notes recorded that a parent's object lock did
not reach its line rows, and its contract review (record 7236877945)
escalated it. The maintainer summary of #37402 promises 「整单人手锁定」 for a
confirmed order, while a person could still edit its lines.
## Tests
- New `MasterDetailForm.parentHandLock-38249.test.tsx` (real
`MasterDetailForm` and `GridField`): a locked parent offers no add /
duplicate / remove / reorder and locks a line cell; a child field with
its own `uiReadonlyWhen: 'false'` stays editable while its sibling is
locked; `uiReadonly: true` stays locked; a fully configured entry (no
child schema read) locks every cell; CONTROL draft parent edits as
before; CONTROL a create is not judged.
- `__tests__/dialogHandLock-36806.test.ts`, new top-level describe:
`childFieldOwnsHandLock` over each spelling (`uiReadonly: false` and a
server lock are not ownership); derived and authored (typed and untyped)
columns; an unmarked column fails closed;
`childLinesOpenUnderParentHandLock`.
- `editFormLockedByState.test.ts`, new describe: true when the lock
holds and no child field can open; false with a `'false'` child
override; true with only a static child lock; false when the predicate
does not hold; false when the header is locked field by field only;
fail-open without child definitions.
- `RecordDetailView.editLockedByState-32756.test.tsx`, new top-level
describe: Edit disabled with the state reason on a locked document with
lines; CONTROL a `'false'` child override and a draft record keep it
live.
## Acceptance notes
- Measured on `main` first: the new rendered pin against the unfixed
code, 4 failed / 2 passed (a confirmed parent's line cell was editable;
both controls green).
- Precedence, as the existing override rule gives it: a child field with
its own conditional `uiReadonlyWhen` (say over the line's own columns)
is judged by that predicate, so the parent's lock does not reach that
cell. Its default (no declaration) is now the child object's lock OR the
parent's.
- A row-level opt-out for adding or removing lines does not exist: under
a locked parent no line is added, duplicated, removed or reordered,
whatever the child fields declare. A field-level declaration opens only
that field's cell on stored lines.
- The per-row editor is not offered under a locked parent, because it
edits every child field. So in a form-factor collection (`inlineEdit:
'form'`, lines shown as a list) a child field's own opt-out has no
surface while the parent is locked: that collection reads fully locked.
- A fully configured entry (typed columns and the relationship field)
reads no child schema, so its columns carry no ownership mark and all
lock under the parent lock (the hand lock fails closed).
- Before the header record lands, the parent predicate is judged over
`null`-seeded header fields; a predicate such as `record.status ==
'confirmed'` then reads open until the record lands. This is the same
window as the grid's own object-definition read noted on PR #38169.
- Scope: the console edit form and the record page's Edit state. The
record page's own line-items panel (`LineItemsPanel` / the record body
table editor) is not changed here; whether it should follow the parent's
lock is for its own card.
- The four commits' `Claude-Session:` trailers name the dispatching
seat's session (`session_017xRBcSAaBEfQpU2yJexSJ8`) instead of this dev
session (`session_017xRBcSPkRxFWubkD5XfiDh`), a transcription slip; the
history is left as pushed.
- File surface beyond the two claimed files, each `check-handover.mjs
--inflight` clear: `MasterDetailForm.tsx` (the line grid),
`RecordDetailView.tsx` (the Edit state's caller), `core.ts` and
`index.tsx` (one export each).
## Verification
Patch round (seat claim amendment 7247687945, head `1933251b`):
`Clause-②` corrected to `yes (widening)` here and in both changesets
(still `patch`, `Metadata-protocol: none`); `origin/main` merged twice
(`212babcf`, `1933251b`), no incoming commit touching this diff's files.
On `1933251b`: the four pin files 4/4 files, 42/42 tests;
`dispatch-gates.mjs --commands` 38 families, all run, all exit 0 (the ui
`scripts/` suite 172 files passed, 2 skipped / 5,159 tests); `--ran`:
"38 run, 0 NOT-MEASURED"; `overlap-check.mjs` VERDICT clean exit 0;
`check:nul-bytes` OK. The readings below are the first round's.
Two-minute check: `cd ui && pnpm exec vitest run
packages/plugin-form/src/MasterDetailForm.parentHandLock-38249.test.tsx`
— expect 6 passed.
First files to read (by risk):
`ui/packages/plugin-form/src/MasterDetailForm.tsx` (the
`parentHandLocked` verdict and the three grid props it gates);
`ui/packages/plugin-form/src/deriveMasterDetail.ts`
(`childFieldOwnsHandLock` and the mark);
`ui/packages/app-shell/src/utils/editFormLockedByState.ts` (the subform
branch).
Readings on `objectstack-ai/objectstack`, head `9166fa40` (the gate
union on `81f9ef2c`; the one later commit adds only the record-page test
describe, and the derived list on `9166fa40` is byte-identical).
<details><summary>Tests</summary>
- `@object-ui/plugin-form` full suite: 249 files / 2,816 passed, 1
skipped.
- `@object-ui/plugin-form` and `@object-ui/app-shell` `type-check` (both
`tsc --noEmit` and the test tsconfig): exit 0.
- app-shell targeted:
`RecordDetailView.editLockedByState-32756.test.tsx` +
`editFormLockedByState.test.ts` 27/27. The app-shell full suite is not
run locally (CI `Test UI` runs it).
- New and extended pins together (plugin-form + app-shell utils): 35/35.
</details>
<details><summary>Shown red without the fix
(scripts/ablation-replace.mjs, restored to HEAD each time, blob equal
and git diff HEAD empty)</summary>
- `MasterDetailForm.tsx` parent verdict forced `false`: rendered pin 4
failed / 2 passed (controls green).
- `editFormLockedByState.ts` back to returning false for any subform: 2
failed / 18 passed (the two "is true" cases).
- `deriveMasterDetail.ts` ownership mark removed: 3 failed (derived and
authored column cases, and the rendered `'false'` override case).
- `RecordDetailView.tsx` resolver dropped: 1 failed / 6 passed (the
Edit-disabled case).
</details>
<details><summary>Gates</summary>
- `node scripts/pm/dispatch-gates.mjs --commands`: 38 families, all run
on `81f9ef2c`; 37 exit 0. `pnpm --dir ui exec vitest run scripts/` exit
1: SIGKILLed by the container's memory limit while the plugin-form suite
ran beside it, so not measured on that run. Rerun alone under the verify
lock with `--maxWorkers=2`: 172 files passed, 2 skipped / 5,159 tests,
exit 0.
- `dispatch-gates.mjs --ran`: "38 derived famil(ies) accounted for — 38
run, 0 NOT-MEASURED" over the raw record (the exit 1 above as recorded).
- `overlap-check.mjs` before every push: VERDICT clean exit 0.
- `pnpm check:nul-bytes`: OK.
- Full dogfood battery: n/a (no `!`, no `(narrowing)` arm).
</details>
## Human Minimum
- [x] 1. Schemas start as Zod; `packages/spec` holds no runtime logic.
- [x] 2. Every name I added uses the casing for its kind.
- [x] 3. No formatter ran; `pnpm lint` passes (CI).
- [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.
- [x] 6. `packages/spec` touched: 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.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_017xRBcSPkRxFWubkD5XfiDh
---
_Generated by [Claude
Code](https://claude.ai/code/session_017xRBcSPkRxFWubkD5XfiDh)_
<!-- signed: repo:objectstack#8 · sunhaolin ·
session_017xRBcSPkRxFWubkD5XfiDh -->
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent ec087c2 commit fa345c4
12 files changed
Lines changed: 518 additions & 22 deletions
File tree
- .changeset
- ui/packages
- app-shell/src
- utils
- views
- plugin-form/src
- __tests__
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
118 | 118 | | |
119 | 119 | | |
120 | 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 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
32 | | - | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
33 | 39 | | |
34 | 40 | | |
35 | 41 | | |
36 | 42 | | |
37 | 43 | | |
38 | | - | |
39 | | - | |
| 44 | + | |
| 45 | + | |
40 | 46 | | |
41 | 47 | | |
42 | 48 | | |
| |||
66 | 72 | | |
67 | 73 | | |
68 | 74 | | |
| 75 | + | |
69 | 76 | | |
70 | 77 | | |
71 | | - | |
| 78 | + | |
| 79 | + | |
72 | 80 | | |
73 | 81 | | |
74 | 82 | | |
| |||
87 | 95 | | |
88 | 96 | | |
89 | 97 | | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
90 | 116 | | |
91 | 117 | | |
92 | 118 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
133 | 133 | | |
134 | 134 | | |
135 | 135 | | |
136 | | - | |
137 | | - | |
| 136 | + | |
| 137 | + | |
138 | 138 | | |
139 | 139 | | |
140 | 140 | | |
| |||
245 | 245 | | |
246 | 246 | | |
247 | 247 | | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3108 | 3108 | | |
3109 | 3109 | | |
3110 | 3110 | | |
3111 | | - | |
3112 | | - | |
| 3111 | + | |
| 3112 | + | |
| 3113 | + | |
| 3114 | + | |
| 3115 | + | |
| 3116 | + | |
| 3117 | + | |
| 3118 | + | |
| 3119 | + | |
| 3120 | + | |
3113 | 3121 | | |
3114 | 3122 | | |
3115 | 3123 | | |
| |||
| 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 | + | |
0 commit comments