Repository navigation
fix(console): a parent's whole-record hand lock locks its inline master-detail lines in the edit form - #38388
Conversation
…ine lines Claude-Session: https://claude.ai/code/session_017xRBcSAaBEfQpU2yJexSJ8 Co-authored-by: Claude <noreply@anthropic.com>
…s in the edit form The edit dialog's master-detail lines now follow the parent object's uiReadonlyWhen: while it holds, no line is added, duplicated, removed, reordered or opened in the row editor, and every line cell whose child field owns no hand lock is locked. A child field that declares its own (uiReadonly: true or a uiReadonlyWhen) is judged by it, so uiReadonlyWhen 'false' keeps that cell editable. The record page's Edit greys when the lock holds and no child field can open a line. Claude-Session: https://claude.ai/code/session_017xRBcSAaBEfQpU2yJexSJ8 Co-authored-by: Claude <noreply@anthropic.com>
… lock Claude-Session: https://claude.ai/code/session_017xRBcSAaBEfQpU2yJexSJ8 Co-authored-by: Claude <noreply@anthropic.com>
… with inline lines Claude-Session: https://claude.ai/code/session_017xRBcSAaBEfQpU2yJexSJ8 Co-authored-by: Claude <noreply@anthropic.com>
…line-lines-hand-lock
The new plugin-form export and the optional editFormLockedByState argument widen published surface: Clause-② yes (widening), patch, protocol none. Claude-Session: https://claude.ai/code/session_017xRBcSPkRxFWubkD5XfiDh Co-authored-by: Claude <noreply@anthropic.com>
…line-lines-hand-lock
|
repo:objectstack#8 · sunhaolin · session_017xRBcSAaBEfQpU2yJexSJ8 Contract reviewServed-tier: Face: the ① Derived judgments
② Semver level
③ Boundary flags
Implemented-by: No must-fix, no should-fix. VERDICT: PASS |
|
repo:objectstack#8 · sunhaolin · session_017xRBcSAaBEfQpU2yJexSJ8 L1: ACCEPT · head 席位核对
Landing: non-governed, ≤3000 lines, L2 PASS on this head. The seat lands it through the ordinary queue. |
…page's line panels (objectstack-ai#38547) Fixes objectstack-ai#38521 Clause-②: no Metadata-protocol: none ## 维护者速读 - 用户能看到什么变化:控制台记录详情页上,父单据整单手动锁定时,明细行面板和详情页编辑状态里的明细表不能再手动增、删、改、排序明细行;之前这两处都能改。 - 为什么做:上一次修复只锁住了编辑表单里的明细行,这次把详情页上另外两处能手改明细的地方按同一套规则锁住。 - 出错会怎样:只影响控制台里人手编辑明细行;接口、导入、动作和流程写入不变;可以直接撤回。 - 要你做什么:无。 ## What changes Measured first on `main` (`63acc6cd`): a parent whose object-level `uiReadonlyWhen` holds, with one stored line, on both record-page line surfaces. On both, the first line cell was an enabled input (`expected false to be true` on `disabled`). Add, Duplicate, Remove and reorder read only the child grants and `schema.readonly`, and the parent's lock never entered. So a person could add, edit, remove and reorder lines by hand on a locked document. The record page keeps Edit live on such a document whenever a header field or a child field owns a lock that can still open (the rule PR objectstack-ai#38388 gave `editFormLockedByState`), so the edit state's body-table editor was reachable too. Both surfaces now follow the rule PR objectstack-ai#38388 gave the edit form, and add no new key: - **`parentHandLockHolds`** (new, in `deriveMasterDetail.ts`, not exported from `.` or `./core`) is the parent verdict through `fieldReadOnlyByHand`. It reads `fieldReadOnlyByHand({}, row, { object: { uiReadonlyWhen } })` over the parent row, with every parent field seeded `null` and `previous` set to the stored row, in the host's predicate scope. It answers `false` when the parent declares no `uiReadonlyWhen`. With no row yet, the predicate is judged over an empty record, which locks: the hand lock fails closed. - **`LineItemsPanel`** (`record:line_items`) judges the lock when the record context is the panel's parent (same object, same id): the record page it sits on, with its served definition (`objectSchema`) and row (`data`). - **`RecordBodyTableEditor`** (the edit state's body table) judges it over the record as the user has it in the open edit (`data` plus the inline draft), with the stored row as `previous`, as `MasterDetailForm` judges its header. - While the lock holds, both withhold `allowAdd` (Add, the entry row and Duplicate), `allowDelete` and reorder (`allowReorder: false`). Every column whose child field owns no hand lock goes through `lockColumnsByParentHandLock`. A child field's own `uiReadonlyWhen` or `uiReadonly: true` judges its cell instead, so `uiReadonlyWhen: 'false'` keeps that one cell editable. - Declared writes (REST, import, actions, flows) are untouched, per the ruling on objectstack-ai#36806: nothing on the server reads either key. No file under `ui/packages/app-shell/src/views/` is touched. ## Tests `LineItemsPanel.parentHandLock-38521.test.tsx` (7) and `RecordBodyTableEditor.parentHandLock-38521.test.tsx` (5), through the real components and `GridField`: - a locked parent offers no add, duplicate, remove or reorder, and locks a cell whose child field owns no lock; - `uiReadonlyWhen: 'false'` on a child field keeps that cell editable while its sibling stays locked; - `uiReadonly: true` on a child field stays locked; - panel only: a parent row the record context has not loaded yet locks the lines (fails closed); - CONTROL: the predicate does not hold, so everything is offered and editable; - CONTROL: the parent declares no `uiReadonlyWhen`, so the lines are open; - CONTROL (panel): a panel bound to another parent id than the record context's is not judged by that record. <details><summary>Measurement on main, the fix, ablations, package suite (head 37ef5d5)</summary> - On `main`'s source (fix set aside): `Tests 6 failed | 4 passed (10)`. Every lock pin failed on `expected false to be true` (the first line cell enabled), and every control passed. - With the fix: `Test Files 2 passed (2)`, `Tests 12 passed (12)`. - Ablations via `scripts/ablation-replace.mjs` (anchor hit 1 to 0, blob moved, then restored to HEAD with `git diff HEAD` empty each time): - panel verdict `() => false`: 4 failed | 8 passed; - panel column lock removed: 4 failed | 8 passed; - panel reorder line deleted: 3 failed | 9 passed; - editor verdict `() => false`: 3 failed | 9 passed; - editor column lock removed: 3 failed | 9 passed; - editor reorder line deleted: 2 failed | 10 passed. - Controls stayed green in every run. - `pnpm --filter @object-ui/plugin-form test`: `Test Files 252 passed (252)`, `Tests 2830 passed | 1 skipped (2831)`. - `pnpm --filter @object-ui/plugin-form type-check`: exit 0. `tsc -p tsconfig.test.json --listFiles` lists both new test files. - eslint on the five changed files: 0 errors. </details> <details><summary>Derived gates (head 37ef5d5)</summary> `node scripts/pm/dispatch-gates.mjs --commands`: 39 families, each run with its exit code captured before any pipe, all `exit 0`. `--ran` reconciliation: `39 derived famil(ies) accounted for — 39 run, 0 NOT-MEASURED (a DERIVED zero)`. `overlap-check.mjs` against `origin/main` `d1a06a3d`: `VERDICT clean exit 0`. </details> ## Acceptance notes - File surface: the claim's two files and their co-located tests, plus `ui/packages/plugin-form/src/deriveMasterDetail.ts` for the shared verdict (`check-handover.mjs --inflight`: clear). - A `record:line_items` panel bound to a parent other than the record page's own record (an authored `parentId` on another record's page) has neither the parent's row nor its definition in context, so it is not judged, as before. That case is pinned as a control. - `MasterDetailForm` keeps its own inline judgement of the same verdict. Moving it onto `parentHandLockHolds` is a possible later tidy-up, left out of this card. - `main` moved to `d1a06a3d` after the branch point. The incoming commits touch only `ui/packages/plugin-chatbot` under `ui/` and merge cleanly, so they were not merged. ## Verification Files to read first, by risk: 1. `ui/packages/plugin-form/src/deriveMasterDetail.ts`: `parentHandLockHolds` (seeding, and the empty record when there is no row). 2. `ui/packages/plugin-form/src/LineItemsPanel.tsx`: the `recordIsParent` gate. 3. `ui/packages/plugin-form/src/RecordBodyTableEditor.tsx`: live row versus `previous`. Two-minute check: from `ui/`, `npx vitest run packages/plugin-form/src/LineItemsPanel.parentHandLock-38521.test.tsx packages/plugin-form/src/RecordBodyTableEditor.parentHandLock-38521.test.tsx`. Expected: 12 passed. --- _Generated by [Claude Code](https://claude.ai/code/session_017xRBcSccr4AxYAvAhMKBw1)_ --------- Co-authored-by: Claude <noreply@anthropic.com>
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: trueor auiReadonlyWhen— is judged by it instead of any object-level default, anduiReadonly: falseis not such a declaration. No key, value or schema property is added.@object-ui/plugin-formMasterDetailForm.tsx(the edit dialog's line grids): the header record feed also lands the parent object'suiReadonlyWhenwith its field names. On an EDIT form the lines judge it over the live header record (every header field seedednull, the stored row asprevious, the host's predicate scope) through the one hand-lock verdict (fieldReadOnlyByHandof 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 askseffectiveUiReadonlyWhenitself rather than restating the rule).lockColumnsByParentHandLocklocks every unmarked column.childLinesOpenUnderParentHandLockanswers whether some child field owns a non-static hand lock (exported from the root and from/core).@object-ui/app-shelleditFormLockedByState.ts: an object that places an inline child collection no longer keeps Edit live unconditionally. It greys Edit when the object's ownuiReadonlyWhenholds 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 optionalchildObjectDefargument; 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-formexportschildLinesOpenUnderParentHandLockfrom its.and./coreentries, and the exportededitFormLockedByStateof@object-ui/app-shelltakes 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
MasterDetailForm.parentHandLock-38249.test.tsx(realMasterDetailFormandGridField): a locked parent offers no add / duplicate / remove / reorder and locks a line cell; a child field with its ownuiReadonlyWhen: 'false'stays editable while its sibling is locked;uiReadonly: truestays 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:childFieldOwnsHandLockover each spelling (uiReadonly: falseand 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
mainfirst: the new rendered pin against the unfixed code, 4 failed / 2 passed (a confirmed parent's line cell was editable; both controls green).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.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.null-seeded header fields; a predicate such asrecord.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 feat(spec,ui): an object declares when a whole record is read-only by hand (object-level uiReadonlyWhen) #38169.LineItemsPanel/ the record body table editor) is not changed here; whether it should follow the parent's lock is for its own card.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.check-handover.mjs --inflightclear:MasterDetailForm.tsx(the line grid),RecordDetailView.tsx(the Edit state's caller),core.tsandindex.tsx(one export each).Verification
Patch round (seat claim amendment 7247687945, head
1933251b):Clause-②corrected toyes (widening)here and in both changesets (stillpatch,Metadata-protocol: none);origin/mainmerged twice (212babcf,1933251b), no incoming commit touching this diff's files. On1933251b: the four pin files 4/4 files, 42/42 tests;dispatch-gates.mjs --commands38 families, all run, all exit 0 (the uiscripts/suite 172 files passed, 2 skipped / 5,159 tests);--ran: "38 run, 0 NOT-MEASURED";overlap-check.mjsVERDICT clean exit 0;check:nul-bytesOK. 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(theparentHandLockedverdict and the three grid props it gates);ui/packages/plugin-form/src/deriveMasterDetail.ts(childFieldOwnsHandLockand the mark);ui/packages/app-shell/src/utils/editFormLockedByState.ts(the subform branch).Readings on
objectstack-ai/objectstack, head9166fa40(the gate union on81f9ef2c; the one later commit adds only the record-page test describe, and the derived list on9166fa40is byte-identical).Tests
@object-ui/plugin-formfull suite: 249 files / 2,816 passed, 1 skipped.@object-ui/plugin-formand@object-ui/app-shelltype-check(bothtsc --noEmitand the test tsconfig): exit 0.RecordDetailView.editLockedByState-32756.test.tsx+editFormLockedByState.test.ts27/27. The app-shell full suite is not run locally (CITest UIruns it).Shown red without the fix (scripts/ablation-replace.mjs, restored to HEAD each time, blob equal and git diff HEAD empty)
MasterDetailForm.tsxparent verdict forcedfalse: rendered pin 4 failed / 2 passed (controls green).editFormLockedByState.tsback to returning false for any subform: 2 failed / 18 passed (the two "is true" cases).deriveMasterDetail.tsownership mark removed: 3 failed (derived and authored column cases, and the rendered'false'override case).RecordDetailView.tsxresolver dropped: 1 failed / 6 passed (the Edit-disabled case).Gates
node scripts/pm/dispatch-gates.mjs --commands: 38 families, all run on81f9ef2c; 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.mjsbefore every push: VERDICT clean exit 0.pnpm check:nul-bytes: OK.!, no(narrowing)arm).Human Minimum
packages/specholds no runtime logic.pnpm lintpasses (CI).main, one pull request.packages/spectouched: not touched.content/docs/references/,packages/*/CHANGELOG.mdorcontent/docs/releases/.🤖 Generated with Claude Code
https://claude.ai/code/session_017xRBcSPkRxFWubkD5XfiDh
Generated by Claude Code