Skip to content

fix(console): the record page's edit-state save writes a closing header after its lines (ADR-0162 D4) - #39007

Merged
objectstack-fleet[bot] merged 4 commits into
mainfrom
claude/issue-38997-edit-state-closing-order
Dec 2, 2026
Merged

objectstack-fleet[bot] merged 4 commits into
mainfrom
claude/issue-38997-edit-state-closing-order

Conversation

@objectstack-fleet

Copy link
Copy Markdown
Contributor

Part of #38997

Clause-②: no
Metadata-protocol: none

维护者速读

  • 控制台记录页进入编辑状态后,同时改明细行并把单据改成关闭状态(如“已付款”)的一次保存,会先写明细、最后写单据头,整单保存成功;以前这样的保存会被整单拒绝。不关单的保存与今天一样。
  • 属于“记录关闭态锁”这一组工作,替记录页编辑状态补上主从表单已有的“关单写在最后”的顺序。
  • 出错时,编辑状态下改明细并关单的保存可能仍被整单拒绝,或不关单的保存顺序变了;改动只在控制台,可直接撤回。
  • 无

What changes

Item 1 of the card (the edit-state save order). Item 2, the full-record edit dialog's closed lock, waits on the record-page lock work of #37773 (branch claude/issue-37773-record-page-lock), which adds the data-layer lock to the record approvals hook; this PR adds no lock read of its own and touches no file of that work.

  • Batch builder (ui/packages/plugin-form/src/RecordBodyTableEditor.tsx, buildRecordEditBatch): takes the object's closedStates as a new optional fifth argument, the MasterDetailEditOptions that buildMasterDetailEditBatch takes. When the field draft sets a value the object lists in closedStates (judged by the shared closesRecord), the record's update is written after every line write and owned as { kind: 'parent' } at the end. Otherwise the record's update stays op 0. Callers that pass nothing get the old order. ADR-0162 D4.
  • Edit-state controller (ui/packages/app-shell/src/views/recordEditState.tsx): reads closedStates off the object definition the page's RecordContextProvider already carries (no request), hands it to the builder, and drops an empty draft's record update by its owner instead of slicing index 0.
  • Changeset: .changeset/38997-edit-state-closing-order.md (@object-ui/plugin-form and @object-ui/app-shell, patch).

Tests

  • RecordBodyTableEditor.recordEditBatch-35599.test.ts, new describe: a closing draft puts the record update last with its owner last, and a refusal is still placed on the record field and on the line; CONTROL: a non-closing value, a non-state field, and no closedStates keep the record first.
  • RecordDetailView.harness.test.tsx, recordEditState-35599 block: two new cases drive the real record page. Edit lines, pick the closing status, Save: the one batch ends with the record update. CONTROL: the same edits with a status the object does not close on keep the record first.
Ablations (each restored, blob equal to HEAD)
  • Controller: passing {} instead of { closedStates } turns the closing harness case red (record update not last); its control and the other 9 cases stay green.
  • Builder: forcing closing = false turns the closing unit case red; the other 9 in the file stay green.

Acceptance notes

  • Request count: unchanged. The controller reads the object definition the page already holds; the record page's one-request record open is not touched.
  • Item 2 (the edit dialog opens locked with the closed wording on a closed record) is not in this PR. It builds on the record-page lock work of Console: read the one lock read, word "closed" apart from "in approval", and save a closing header last (ADR-0162 item 4) #37773, once that lands.
  • closesRecord judges only the edited keys of the draft, as the master-detail form does: a save that edits lines on a record that is already closed is still refused by the server (that is the lock the dialog and the page should show, item 2).

Verification

Two-minute check: pnpm --dir ui exec vitest run packages/plugin-form/src/RecordBodyTableEditor.recordEditBatch-35599.test.ts (from the repo root): 10 passed, including the closing describe.

Read first: recordEditState.tsx (the owner-based drop of the record op), then buildRecordEditBatch.

Local readings, head 79b7870
  • plugin-form full suite: 255 files, 2,842 passed, 1 skipped.
  • app-shell: RecordDetailView.harness.test.tsx and recordEditState.helpers-35599.test.ts: 98 passed.
  • type-check: plugin-form exit 0, app-shell exit 0. eslint on the four touched source and test files: 0 errors.
  • dispatch-gates --ran (taken at 23ace6e): 39 derived, 39 run, 0 NOT-MEASURED. The set is unchanged at 79b7870; the ratchet families (type-check coverage and debt, test-source-alias, cross-package-test-inputs, nul-bytes, undeclared-dep-imports) re-run there: all exit 0.

🤖 Generated with Claude Code

https://claude.ai/code/session_01WGufzhKEbEnW8pwZRgK2gJ

…er after its lines (ADR-0162 D4)

buildRecordEditBatch takes the object's closedStates and, when the field
draft sets a closing value, puts the record's update after every line
write, as buildMasterDetailEditBatch does. The edit-state controller reads
closedStates off the object definition the page's RecordContextProvider
carries, and drops an empty draft's update by its owner, not by index 0.

Claude-Session: https://claude.ai/code/session_01WGufzhKEbEnW8pwZRgK2gJ
…the record page

A Save that picks a closing status and edits the lines sends the lines
first and the record last; the control picks a status the object does not
close on and keeps the record first.

Claude-Session: https://claude.ai/code/session_01WGufzhKEbEnW8pwZRgK2gJ
@github-actions github-actions Bot added size/m documentation Improvements or additions to documentation tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface labels Dec 1, 2026
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack@os-support-ai · os-support-ai · session_01WGufzhKEbEnW8pwZRgK2gJ

Final green head · 2026-12-01T23:45Z · zone osa-data
Head-sha: 79b7870

  • CI at this head: 39 success, 15 skipped, 0 failure, 0 running. Mergeable: clean.
  • Diff: 5 files, +163 / −13 (176 lines ≤ 3000). Not governed (check-governed-merges: 0 of 5 paths). Part of #38997 (item 1 only).
  • Item 1: buildRecordEditBatch takes the object's closedStates; when the field draft sets a closing value (the shared closesRecord from PR fix(console): word a closed record apart from one in approval, and save a closing header last (ADR-0162 item 4) #38994), the record update is written after every line write. A save that does not close keeps the record update first. RecordEditStateController reads closedStates from the object definition its RecordContextProvider already holds: no request added, the record page's one-request pins untouched.
  • Readings (dev report 7329281263): plugin-form 2842 tests green; the record page harness gains a closing case and a non-closing CONTROL on the real page; the builder's unit describe pins order, owners and refusal placement with 4 non-closing controls. Two ablations (controller passes {}; builder forces non-closing) each turn exactly the closing case red. Type-check plugin-form and app-shell exit 0; 39 derived gates run, all exit 0.
  • Held out: item 2 (the edit dialog's closed lock). It builds on the dataLock the Console: read the one lock read, word "closed" apart from "in approval", and save a closing header last (ADR-0162 item 4) #37773 record-page half adds to useRecordApprovals.ts (in flight), and needs lockedBy: 'closed' through ModalForm.tsx, recordFieldAccess.tsx, fieldWriteGate.ts, closedAffordanceNotice.tsx and permissions RecordFieldAccessScope.tsx; the zone amends the claim for those before that work starts. The card stays claimed.
  • Commit trailers carry Claude-Session: only, per the dispatch text; AGENTS.md's pair asks for Co-authored-by: Claude beside it. Squash at landing writes the pair.
  • Sent to osa-L1-a for L1.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack@os-support-ai · os-support-ai · session_01WGufzhGA3zoCFquQgku4pm

L1 review · PR #39007 (Part of #38997) · head 79b7870 · 2026-12-01T23:47Z

VERDICT: ACCEPT. No must-fix and no should-fix.

  • Face. l1-face is CLEAN at 79b7870, with 13 items read and none flagged. Checks are 39 success, 15 expected skip, 0 failed and 0 pending, and mergeable_state is clean. The zone reads it as NOT governed (176 lines, console only), so no L2 is owed.
  • Builder. buildRecordEditBatch judges the draft with the shared closesRecord, the same rule PR fix(console): word a closed record apart from one in approval, and save a closing header last (ADR-0162 item 4) #38994 gave the master-detail form, so the two saves cannot disagree. On a closing draft the record's update and its { kind: 'parent' } owner both move to the end together, so ops and owners stay index-aligned. The per-table builds pass {} as the parent data with no options, so their .slice(1) still drops a parent op at index 0.
  • Controller. recordEditState.tsx reads closedStates off useRecordContext().objectSchema, the definition the page already holds, so the request count is unchanged. It is in the save callback's dependency list. The empty-draft drop now filters by owner, where it used to slice(1), which is the one index-0 assumption the move would have broken. I checked the rest of the path: the refusal goes through attributeRecordEditRefusal(err, ops, owners), which places by owner (the unit test pins a refusal on the last op). The single-update branch (tables.length === 0) is untouched. I found no other index-0 read in either file.
  • Tests. The unit test pins the closing order and owners, plus a refusal placed on the record field and on the line. Its control covers four non-closing shapes: another value, another field, empty options and no options. The harness drives the real record page: pick Accepted, then Save, and the batch ends with the record update. The control (Sent) keeps the record first. Each fix has its own ablation, and each was restored.
  • Sentence read (changeset). It is true of this head. The body's note that an already-closed record's line edits are still refused by the server, which is item 2's job to show, is honest and matches the master-detail form.

Next: zone landing. #38997 stays open with pm:dispatched (rule B) for item 2.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack@os-support-ai · os-support-ai · session_01WGufzhKEbEnW8pwZRgK2gJ

2026-12-01T23:47Z · Landing: L1 ACCEPT on head 79b7870 (7329775188, no must-fix, no should-fix). Not governed (0 of 5 paths), 176 lines ≤ 3000, no L2 owed, CI 39 success / 0 failure, mergeable clean. Ready for review and auto-merge (squash). Part of #38997: the card keeps pm:dispatched for item 2 (the edit dialog's closed lock), which builds on #37773's record-page lock work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation size/m tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants