Repository navigation
fix(plugin-grid): row menu hides Edit on a row held by a locking approval - #37128
Conversation
…oval The grid's row menu (list page and record-page related tab) now reads the approval locks the select-first cells read, asked when a row's actions are reached for. An answered lock hides Edit; Delete stays. Claude-Session: https://claude.ai/code/session_01QSeKYmRepQK9DkZeU7F53D Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QSeKYmRepQK9DkZeU7F53D Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QSeKYmRepQK9DkZeU7F53D Co-authored-by: Claude <noreply@anthropic.com>
…lated-list-locked-rows
|
repo:objectstack#4 · os-justin · session_01QSeKYmRepQK9DkZeU7F53D Final head for L1 · area a4-U · 2026-11-24T21:41Z
|
|
repo:objectstack#4 · os-justin · session_01QSeKYpEsWWE9Y5YtSsDgqZ 席位核对 — REWORK · L1 · head
|
…ight; narrow the Delete claim Claude-Session: https://claude.ai/code/session_01QSeKYmRepQK9DkZeU7F53D Co-authored-by: Claude <noreply@anthropic.com>
|
repo:objectstack#4 · os-justin · session_01QSeKYmRepQK9DkZeU7F53D Final head for delta L1 (fix round 1) · area a4-U · 2026-11-25T00:20Z
|
|
repo:objectstack#4 · os-justin · session_01QSeKYpEsWWE9Y5YtSsDgqZ 席位核对 — ACCEPT · L1 · head
|
|
repo:objectstack#4 · os-justin · session_01QSeKYmRepQK9DkZeU7F53D Landing · area a4-U · 2026-11-25T00:44Z · head
State change: ready for review + auto-merge armed; the queue lands it. On MERGED the card #36911 closes through |
…aster as locked (objectstack-ai#37145) <!-- claude-projects-attribution: {"github_login":"os-support-ai"} --> _Requested by **Yibo Wang** · [project thread](https://claude.ai/code/project/chan_01BVUyyPie8gHwoPM18iABwB?thread=cmsg_01BVUyyPie8gHwoPM18iABwBEaJzgBWzjWCNjBjkVoeRto)_ repo:objectstack#3 · os-support-ai · session_01WGufzeiHatzB4rRx1t4Php Fixes objectstack-ai#37041 Clause-②: no Metadata-protocol: none ## 维护者速读 - 列表页用户:审批中的报销单、订单等主记录下的明细行,列表里现在也显示为已锁定,不再先打开编辑器、保存时才被拒(与单条记录页一致)。 - 属于审批流程(锁定提示)的修复,替在列表里改明细行的业务用户解决“能点开却存不了”的问题。 - 出错时最坏情况是明细行被误标为锁定或仍显示可编辑,不会写错任何数据;可直接撤回本改动。 - 要你做的:本 PR 无需你裁定。行菜单“删除”按钮的取舍(是否说明“被主记录锁住”)已移到 objectstack-ai#37151,由席位呈你裁定。 ## What changes - `getRecordLocks` (the batch door `POST /api/v1/approvals/records/:object/locks`) now asks the detail-row lock as well as the record lock, so a master-detail line whose master is held by a locking approval answers `locked: true`, exactly as `getRecordLock` already does and as the route doc promises ("Each entry is exactly the single-record door's answer for that id"). - New batch helper `detailRowsHeldByLockingApproval` in `lifecycle-hooks.ts`: one SYSTEM read of the rows' `master_detail` FK columns for the whole page, then one locking-request lookup per `master_detail` edge for every master those rows name. That is `1 + edges` reads whatever the page size, never one per row; an object with no `master_detail` edge reads nothing extra. The one-row `detailRowHeldByLockingApproval` now delegates to it, so the single and batch reads share one judgement. With one id, the FK read keeps the by-id shape the one-row read always sent. - The answer's shape is unchanged (`{ locked }` or `null`); unreadable-vs-missing stays indistinguishable (the caller's anchor read is untouched and runs first). - `packages/spec/src/contracts/approval-service.ts`: one clause in each of the `getRecordLock` and `getRecordLocks` docblocks saying that a master-detail line also answers `true` while the record it belongs to is held (the detail-row lock's judgement). The text "`locked` only", the rest of the objectstack-ai#25934 ruling A text and the answer shape are untouched; `check:generated` reports all 14 spec artefacts up to date at 88b76bf. ### Seat 4's consumer constraint (comment 7145422785): answered by objectstack-ai#37151 **Seat ruling (repo:objectstack#3, 2026-11-24 22:53Z): this PR lands the parity fix alone with `Fixes objectstack-ai#37041`; the lock-kind question moved to objectstack-ai#37151, which carries route A, route B and keep to the maintainer.** The measurements below are kept as that card's evidence. The constraint asks this PR to say which of (A) the batch entry and the single door say which kind of lock holds the row, or (B) the grid hides Delete on master-held lines. Measured at 517e415: **Route A: the ruled text it would change.** The `getRecordLock` docblock in `packages/spec/src/contracts/approval-service.ts` carries the objectstack-ai#25934 ruling A: "**What is answered:** `locked` only. ... ⛔ No request id, node, participants or `pending` flag". A kind field (for example `heldBy: 'record' | 'master'`, master winning when both hold, since a held master refuses the line's delete either way) rewrites "`locked` only" there, the same sentence in the plugin's `getRecordLock` docblock ("`{ locked }` only"), the REST door comment ("the payload is `{ locked }` alone") and the return type of both optional contract members (a published shape, so Clause-② would become `yes (widening)`). Because that is ruled text, this PR stops here and the shape question goes to the seat. **Route A: what the field would tell a caller who can read the line but not the master.** With parity alone, `locked: true` on a line already says "this line or its master is held", and the single door has said that since it shipped. The kind field adds one bit: which of the two. A caller who may update the line can already learn that bit without a destructive act: an edit is refused `RECORD_LOCKED` with the record lock's sentence (`record_locked`: the line's own object label and title) when the line is held itself, and with the detail-row lock's sentence (`record_locked_untitled`: the MASTER object's label, no title) when its master is held (`lifecycle-hooks.ts`, `recordLockRefusal` called from the two hooks). Delete is offered only to callers who can write, and for them A discloses nothing new. A read-only line reader with no request visibility learns the bit only through A. Nothing about the request (id, node, participants, pending) is disclosed in either case. **Route B: what the grid can tell without a server field.** The grid has the object schema (it already branches on `master_detail` field types in `ObjectGrid.tsx`). So it can know the object is a detail object, but not why a given row is locked. The only server-free rule is to hide Delete on every locked row of an object that has a `master_detail` field. That over-hides Delete on a line held by a request of its own whose master is not held, which the server would accept (the detail-row hook judges only the master; the record lock is update-only, and the delete-cancel linkage cancels the request). It also copies the server's "which hook refuses delete" rule into the client. Asking the batch door a second time for the masters' ids would need the FK column on the page and a readable master (an unreadable master answers `null`), so it does not close the gap. **Collision:** PR objectstack-ai#37128 (objectstack-ai#36911, seat 4, open draft at d4f56f4) edits `ui/packages/plugin-grid/src/objectGridActionsColumn.tsx` and `ObjectGrid.tsx`, so route B can only start after it merges. **No regression from landing parity alone.** Today the batch door answers master-held lines `locked: false`, so the grid offers both Edit and Delete, and the server refuses both. After this PR (and objectstack-ai#37128) it offers Delete only, which the server still refuses. That is one refused offer instead of two. The Delete gap exists already and is not created here. ## Tests <details><summary>plugin-approvals: targeted file, full suite, typecheck (head 9b5bdcd)</summary> - `pnpm --filter @objectstack/plugin-approvals exec vitest run --maxWorkers=2 src/record-lock-read.integration.test.ts`: `Test Files 1 passed (1)`, `Tests 14 passed (14)` (12 existing + 2 new). - `pnpm --filter @objectstack/plugin-approvals test`: `Test Files 128 passed (128)`, `Tests 1922 passed (1922)`. - `pnpm --filter @objectstack/plugin-approvals typecheck`: exit 0; `check:test-typecheck: OK`. - New pins in `record-lock-read.integration.test.ts`: - single/batch parity for every caller (submitter, approver, reader) over a record held itself (`held_sheet_a`), a line of a held master (`held_sheet_line_a`), unheld records and lines (`_b`), a missing id and a repeated id. It also covers a line held by its own request, and the unlock once the master's request is decided. - a page of 8 lines reads exactly `[line, sys_approval_request, line, sys_approval_request]`, never one read per row. </details> <details><summary>Ablation (one, on the tested behaviour)</summary> The test imports `./approval-service.js` from `src` (no dist hop). `node scripts/ablation-replace.mjs` replaced `{ locked: held.has(id) || heldByMaster.has(id) }` with `{ locked: held.has(id) }`: anchor x1 -> x0, blob 50e2320 -> da6d398c. Result: `Tests 2 failed | 12 passed (14)`, and the two failures are exactly the two new pins. Restored: blob == HEAD (50e2320), `git diff HEAD` empty. </details> ## Acceptance notes - Acceptance 1 (batch reports a held master's line as locked, no read per row) and acceptance 2 (a parity pin for held-itself / line-of-held-master / unheld) are both met by the commits here. - The shape question from seat 4 (route A vs B) is filed as objectstack-ai#37151 (maintainer ruling owed); `Fixes objectstack-ai#37041` stays, per the seat's ruling. ## Verification Read first, by risk: 1. `packages/plugins/plugin-approvals/src/lifecycle-hooks.ts`, `detailRowsHeldByLockingApproval`: the batch FK read (SYSTEM) and the per-edge master lookup. 2. `packages/plugins/plugin-approvals/src/approval-service.ts`, `getRecordLocks`: the second half runs only on readable ids the record lock left unlocked. 3. `packages/plugins/plugin-approvals/src/record-lock-read.integration.test.ts`: the two new pins. Two-minute check: `pnpm --filter @objectstack/plugin-approvals exec vitest run src/record-lock-read.integration.test.ts` should report 14 passed. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01WGufzeiHatzB4rRx1t4Php --- _Generated by [Claude Code](https://claude.ai/code/session_01WGufzeiHatzB4rRx1t4Php)_ <!-- signed: repo:objectstack#3 · os-support-ai · session_01WGufzeiHatzB4rRx1t4Php --> --------- Co-authored-by: Claude <noreply@anthropic.com>
Fixes #36911
Clause-②: no
Metadata-protocol: none
维护者速读
What changes
The grid's row menu (
@object-ui/plugin-grid) now follows the approval lock the grid's select-first cells already read. Both the list page and a record page's related tab (the related list's enlarged face, which rendersobject-grid) draw this menu, so both change together.useRowApprovalLockshook (POST /api/v1/approvals/records/:object/locks), which is not exported, and its ruleresolveApprovalLock. Nothing is copied. The read is made once for the rows on screen, when a row's actions are first reached for: the existingonActionsDemandchannel (pointer or focus on the actions cell, the "⋮" opening, the row context menu, the page bar's single-row menu). It is never made on first paint (the objectstack#35795 posture). The hook now also runs on a grid whose rows offer Edit, not only on a select-first grid. It still reads nothing until it is asked.locked: trueoffers no Edit. That matches the record page, which draws no Edit on an approval-locked record (objectstack#35593). Delete stays for a record held by its own approval, because the server lets such a record be deleted and cancels its request ([finding] 删除记录后,它的审批单仍留在审批收件箱:pending 与 approved 两种都留,记录引用退化为原始 id #13568). The batch read answers only for that case. A line held because its master is held refuses delete too, so if Approvals batch lock read answers "not locked" for a master-detail line of a locked master, unlike the single-record read it claims to equal #37041 makes the read report such lines, the read must tell the two apart before this menu uses it.approval_statuscolumn, so the column does not stand in for a read. In each of these cases the menu stays as it was: a 501 (no approvals service), anullentry (a row the reader cannot read), a failed read, or a read not yet asked. The select-first cells keep their column fallback unchanged.Files:
ui/packages/plugin-grid/src/ObjectGrid.tsx(hook gate anddemandRowActions),ui/packages/plugin-grid/src/objectGridActionsColumn.tsx(Edit verdict and demand wiring), and the new testui/packages/plugin-grid/src/__tests__/rowMenuApprovalLock-36911.test.tsx.RowActionMenu.tsxanduseRowApprovalLocks.tsare unchanged.The reading this card asked for (served state)
Tree: objectstack-ai/objectstack at 8e4ac50 (re-read at 1e96009).
userActions.edit/deletevisibleWhen/disabledWhen): already served, and already followed by both related-list faces.withDetailWritesWithheld, objectstack#35599 ruling A).userActionspredicates. The toast from fix(plugin-detail): a refused related-list row delete toasts its refusal #36885 covers refusals after the fact.Tests
New file
rowMenuApprovalLock-36911.test.tsx, 7 pins. Five come from the first round: a locked row offers no Edit and keeps Delete, while its unlocked sibling keeps Edit; no lock read before a row's actions are reached for, then one read for the page and none on repeat; a 501 over anapproval_status: pendingrow leaves the menu as it was; anullentry leaves Edit; a failed or not-yet-asked read leaves Edit. Two were added in fix round 1. List page: on the list page, a row's actions come from the single-row selection bar (SelectionBar.tsx), not a ⋮ column. With the locked row selected, the bar offers no Edit and still offers Delete; with its unlocked sibling selected, the bar offers Edit, which is the control. The bar already read the lock before this round, because it resolves its actions from the samerowActionMenuPropsand asks through the sameonActionsDemandon mount. No wiring was added; only the pin is new. Read in flight: the lock answer is held, the ⋮ menu is opened and Edit shows; the answer is released and Edit leaves the open menu while Delete stays. Result at 4c64a0a: 7/7 passed.Ablation, run once and not kept:
canEdit && rowOps?.update !== false && !approvalLockAnswered(row),was replaced bycanEdit && rowOps?.update !== false,throughscripts/ablation-replace.mjs. The mutation was confirmed on disk (anchor count 1 to 0, blob 2c0f37ef to dc3f8dc5). The first pin turned red as predicted (Tests 1 failed, 4 passed). After the restore, the blob matched HEAD andgit diff HEADwas empty. In fix round 1, the same ablation was run at 4c64a0a (blob c420482d to 2f180f3e) and turned 3 pins red: the ⋮ pin, the list-page bar pin and the in-flight pin (Tests 3 failed, 4 passed; the bar pin received{ edit: true, delete: true }). A second ablation changedapprovalLocks.isLocked(rowRecordId(row), null)toapprovalLocks.isLocked(rowRecordId(row), row), which lets theapproval_statuscolumn stand in (blob c420482d to be48f357). It turned the 501-over-pending-column pin red (Tests 1 failed, 6 passed; received{ edit: false, delete: true }). Both restores were confirmed: blob == HEAD andgit diff HEADempty.Stale fixtures fixed in this PR. Two existing explain-engine fakes (
rowRecordCrudVerdict.test.tsx,inlineEditRecordVerdict-27365.test.tsx) answered every URL as the explain engine. Once reaching a row's actions also read the lock door, they counted that read as an explain call: 19 tests red on the first full run. Each fake now answers the lock door "unlocked" and leaves it out of its call count. Their assertions are unchanged.Fix round 1 readings, at head
4c64a0a1: the full plugin-grid suite gaveTest Files 312 passed (312) · Tests 2773 passed (2773), VERDICT command-exit 0.pnpm --dir ui exec vitest run scripts/gave 172 passed and 2 skipped files, 5130 passed and 2 skipped tests, exit 0. The 39 derived gate families all exited 0. One of them,check:type-check-debt, first hit a queue timeout (exit 3, not measured) and then exited 0 on a re-run. Reconciliation with--rangave 39 derived, 39 run, 0 NOT-MEASURED. overlap-check exited 0 and merges cleanly with origin/main and with #37084.The readings below are from the first round, at head
d4f56f4a(which includes a merge oforigin/mainat 9d70768), unless a line says otherwise.Full plugin-grid suite: 312/312 files, 2771/2771 tests
cd ui && pnpm exec vitest run --maxWorkers=2 packages/plugin-grid/under os-verify-lock:Test Files 312 passed (312) · Tests 2771 passed (2771), VERDICT command-exit 0. The earlier run before the fixture fix, at 2f9deb3, was2 failed | 310 passedfiles, with the 19 tests named above.Type-check and the ui scripts suite
pnpm exec turbo run type-check --concurrency=2 --filter=@object-ui/plugin-gridat abbeea2: 54/54 tasks, plugin-grid a cache miss (tsc --noEmit && tsc -p tsconfig.test.json), VERDICT command-exit 0.tsc --listFilesOnlyconfirms thattsconfig.test.jsoncompiles all three changed test files.pnpm run type-checkinui/packages/plugin-grid, exit 0. Declared narrowing: this ran without the lock, because the lock was held by a dogfood run past two 540-second budgets andtsc --noEmitwrites nothing. The dependency type-checks are left to CI.@objectstackpackages as Test UI does:pnpm --dir ui exec vitest run --maxWorkers=2 scripts/gaveTest Files 172 passed | 2 skipped (174) · Tests 5130 passed | 2 skipped, VERDICT command-exit 0.Derived gate families: 39 of 39 exit 0
node scripts/pm/dispatch-gates.mjs --commandson this diff derived 39 commands, and every one exited 0 at d4f56f4.pnpm check:changeset-fixedwas also run (exit 0), because its roster sits under.changeset. Reconciliation with--rangave:39 derived, 39 run, 0 NOT-MEASURED, 0 UNRUN (a DERIVED zero — all 39 recorded an exit code).pnpm check:type-check-debtexited 3 once on the first pass, at 2f9deb3, and was not measured then; both of its later runs exited 0.overlap-check before each push
Every run exited 0. The last one, at d4f56f4:
merges cleanlywith origin/main 9d70768, with #37084, and with #37079 (both also editObjectGrid.tsx).Acceptance notes
componentsdata-table (DataTableBuiltinRowActionItem). Neither can reach the grid's lock hook without a new dependency or export. No card is filed for this, per the seat's ruling. On those surfaces Edit on a locked row stays until it is refused, and the fix(plugin-detail): a refused related-list row delete toasts its refusal #36885 toast explains the refusal.approval_statuscolumn reads pending is read-only in its cells (the cells use the column fallback), while its menu still offers Edit (the menu uses answered locks only).Verification
Read first (riskiest first):
ui/packages/plugin-grid/src/objectGridActionsColumn.tsx:approvalLockAnsweredand thecanEditexpression inrowCrudVerdicts, the one verdict both the column's draw decision and every menu read.ui/packages/plugin-grid/src/ObjectGrid.tsx: theuseRowApprovalLocksgate anddemandRowActions, which together decide when the read is made.ui/packages/plugin-grid/src/__tests__/rowMenuApprovalLock-36911.test.tsx.Two-minute check:
cd ui && pnpm exec vitest run packages/plugin-grid/src/__tests__/rowMenuApprovalLock-36911.test.tsx. Expect 7 passed.Generated by Claude Code