Repository navigation
Commit 67d87f3
feat(console): the record page reads a closed record from its one payload request (ADR-0162 item 4) (#39011)
Fixes #37773
Clause-②: no
Metadata-protocol: none
## 维护者速读
-
用户能看到什么变化:在记录详情页上打开一张已关闭的单据(如已付款发票),「编辑」按钮变灰并提示「此记录已关闭,无法修改」,「删除」不再出现;打开记录页仍只发一个请求。
- 为什么做:属于「关闭态单据」(ADR-0162)这条线,网格那一半已合并,本次补上记录详情页,让读者不再把「已关闭」误认为「审批中」。
- 出错会怎样:最坏情况是按钮显示与服务端不一致,但服务端照样拒绝对已关闭记录的写入,数据不会被改坏;本改动只动界面,可直接撤回。
- 要你做什么:无。
## What changes
This is the record-page half of #37773. The grid, line grid and
closing-header-last save landed in #38994; this half waited for the
record page payload to carry the data lock, which #38999 added.
- **The record page reads the data layer's lock from its one request.**
The page's payload request (`POST /api/v1/data/{object}/{id}/page`) now
asks `dataLock: true`. `seedRecordPageReaders` hands that part to
`useRecordApprovals` through `seedRecordApprovals`, and the hook
publishes it as `dataLock` in the same publish as the approvals answer.
Opening a record page sends no lock read of its own. This is the one
change against the backup branch, which sent a second `GET
/data/:object/:id/lock`.
- **Edit and Delete read `dataLock`, not the approvals-family lock.**
- Closed record (`lockReason: 'closed_state'`, its own state or its
master's): Edit is drawn greyed with "This record is closed, so it can't
be changed.", a "Closed" chip shows where the header draws tags, Delete
is hidden for either `lockSource`, and master-detail lines draw no New,
Edit or Delete.
- Closed and also held by an approval: reads as closed.
- Held by an approval (`lockReason: 'approval'`): unchanged. The
record's own approval keeps Delete; a line under a held master does not
(`recordDeleteRefusedByLock`, which replaces
`recordDeleteHeldByMaster`).
- The approvals panel and the header's approval tag keep the
approvals-family `recordLock`.
- **Reads the hook sends itself still ask `GET
/data/:object/:id/lock`.** That means `refresh()` after the record
changes, and a consumer with no page payload behind it. A part refused
`501` latches like the GET's `501`, so neither is asked again.
- **The console's full-record edit dialog** (`AppContent`, not edited
here; #38997 owns that file) reads `openApprovalOf(formApprovals)` as
before, which now reads `dataLock`. Request counts, measured in the
browser and pinned where noted:
- Edit pressed on a record page: the dialog joins the page's answer and
sends **0** lock or approvals reads.
- Opened over a list (`?form=ID`): 3 reads, pinned in
`AppContent.editDialogApprovalLock-27138`: approvals list, approvals
lock, and the data lock read. On main it sends 2.
- Deep-linked straight to a record page with `?form=ID`: the dialog's
hook mounts before the page asks its payload, so the dialog sends its
own 3 reads. The page still sends its one payload request.
- `recordClosedByLock` and `DataRecordLock` stay exported for #38997's
dialog wording.
- `RecordPagePayload` (`@object-ui/types`) declares the payload's
`dataLock` part as the spec's `RecordLock` or a part refusal.
- New strings `detail.lockedClosed` and `detail.lockedClosedTooltip` in
all 11 console locales.
Read first, by risk:
1. `ui/packages/app-shell/src/hooks/useRecordApprovals.ts`:
`startRead`'s `dataLockRead` choice (seeded vs own read) and
`settleSeededDataLock`.
2. `ui/packages/app-shell/src/views/recordPagePayload.ts`: the
`dataLock` seed passed beside the approvals seed.
3. `ui/packages/app-shell/src/views/RecordDetailView.tsx`:
`recordClosed` in the Edit item (`editOff`, `editReason`) and the Delete
affordance.
Two-minute check: `pnpm --dir ui exec vitest run
packages/app-shell/src/views/RecordDetailView.recordPagePayload-27627.test.tsx`.
Expect 11 passed. Its last block opens a closed record and asserts one
page request, no lock read and a greyed Edit.
## Tests
All run at `fef530c6` (this branch's head) unless marked.
- `RecordDetailView.recordPagePayload-27627`: the cold-open pin now also
asserts `dataLock: true` in the one request body. A new block mounts the
adapter the way the console's `AdapterProvider` does, which is what lets
the hook send reads of its own:
- a closed record opens with one page request, no lock read, Edit
greyed, and the Closed chip carrying the sentence;
- CONTROL: an unlocked record gets the same single request and a live
Edit;
- ablation: with no payload behind the page, the hook reads `GET
/data/.../lock` itself, which shows the detector can see that read.
- `useRecordApprovals.lockSource-37195`:
- the seeded data lock is published with no lock GET;
- no render sees `answered` without `dataLock`;
- an approval-held record opens an approval;
- CONTROL: the approvals-family lock alone opens none;
- `refresh()` asks the data lock door once;
- a `501` part latches, so no later GET goes out.
- `RecordDetailView.harness` (`closedLock-37773`,
`deleteFollowsLockSource-37195`) and
`RecordDetailView.approvalLock-25934`: the hook's own-read path, carried
over from the backup. They cover:
- closed, line of a closed master, closed and held, approval-held
CONTROL, unlocked CONTROL;
- a reader whose object has no state field still gets the closed
wording, with no field or value on the page.
- `AppContent.editDialogApprovalLock-27138`: plus the request-set pin
for the dialog over a list.
<details><summary>Test and type-check readings</summary>
- `pnpm --dir ui exec vitest run
packages/app-shell/src/hooks/useRecordApprovals.lockSource-37195.test.tsx
packages/app-shell/src/views/RecordDetailView.recordPagePayload-27627.test.tsx`:
11 passed, 11 passed.
- `pnpm --dir ui exec vitest run` on the harness, `approvalLock-25934`,
`AppContent.editDialogApprovalLock-27138`, `recordOpenOneRequest-28470`,
`feedLoadFailure-29188`, `recordReadFailure-11902` and
`approvalRequestPage-28546`: Test Files 7 passed, Tests 139 passed. The
27138 file was re-run after its new pin: 6 passed.
- Ablation, run once and restored. `startRead` was mutated so that
seeded reads send the GET instead of taking the payload part. On-disk
marker count 1, original anchor 0. Result: 13 failed across the two
files, including every one-request pin in 27627 and the five payload
tests in 37195. Restored with `git checkout HEAD`: `git diff HEAD` empty
and the blob hash matches HEAD.
- `pnpm --filter @object-ui/app-shell run type-check`,
`@object-ui/types`, `@object-ui/i18n`: exit 0, after rebuilding types
and i18n.
- `eslint` on the 21 changed ts/tsx files under `ui/`: 0 errors. The 266
warnings are existing `no-explicit-any` warnings in the touched files.
- Derived gates (`dispatch-gates.mjs --commands`, reconciled with
`--ran`): 41 derived, 39 run (all exit 0, including `pnpm --dir ui exec
vitest run scripts/`: 172 files passed, 2 skipped), 2 NOT MEASURED:
`check:query-options-erasure` and `check:type-check-debt`, both killed
by a 200 s timeout on the shared box and left to CI.
- `node scripts/check-platform-checklist.mjs --changed-from
origin/main`: 0 anchored files. Run because `recordDeleteHeldByMaster`
was renamed.
- `pnpm --dir ui run check:new-line-citations`: exit 0.
</details>
## Acceptance notes
- **The changeset is a new file**,
`.changeset/37773-record-page-closed-lock.md`. The dispatch named
`.changeset/37773-console-closed-lock.md`, but that file landed on main
with #38994 and describes the grid half. Re-wording it would rewrite
that half's pending note, so this half gets its own.
- **The edit dialog over a list sends one more read than main** (3
instead of 2): the data lock read. The approvals lock read it still
sends decides nothing in the dialog, which draws no approvals panel.
Dropping it would change what the hook reads for its other consumers,
which is out of scope.
- **Pressing Edit on a record page re-asks the page payload** (the same
body twice). Measured identical on main by restoring the four app-shell
files to `77d15643` under the same dev server, so it does not come from
this change.
- **The Closed chip shows only where the page header draws tags.** It
shows on the invoice line page but not on the showcase invoice's
authored page; the greyed Edit and its sentence show on both. The
state-lock chip on main is placed the same way.
- **The approval-held case was not browser-verified.** The showcase's
invoice sign-off flow does not lock the record: after submitting
INV-1002, both lock doors answered `locked: false`. That case is pinned
by the unit tests above.
- **The record page re-reads the data lock after a change.** On a
record-invalidation refresh, `refresh()` asks `GET
/data/:object/:id/lock`, so a record closed by an edit on the page reads
as closed without a reload. This is a read after a change, not an open.
## Verification
Local showcase app on this branch: our own backend on a random port plus
the console dev server proxied to it, 1440 x 900, signed in as admin.
Every open sent one `POST .../page` carrying `dataLock: true` and no
`.../lock` request.
| | |
|:--|:--|
| Paid invoice INV-1003: Edit greyed, closed sentence on hover | Paid
invoice: overflow has no Delete |
| 
| 
|
| A line of the paid invoice (closed by its master, no authored
predicate): Closed chip, Edit greyed with the sentence | The same line:
overflow has no Delete |
| 
| 
|
| CONTROL: draft invoice INV-1004: live Edit, Delete offered | CONTROL:
a line of the draft invoice: Delete offered |
|

| 
|
The paid invoice also carries authored `edit.disabledWhen` and
`delete.visibleWhen` predicates, so its greyed Edit and missing Delete
are not by themselves evidence for this change. Its Edit reason now
reads the closed sentence. The invoice line has no such predicates, so
the line rows isolate this change, with the draft-invoice line as
control.
Claim on the card for this branch: #37773 comment 7330313783 (re-stating
claim 7317217442 on `claude/issue-37773-record-page-lock`).
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_01WGufzhKEbEnW8pwZRgK2gJ
<!-- signed: repo:objectstack@os-support-ai · os-support-ai ·
session_01WGufzhKEbEnW8pwZRgK2gJ -->
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent 270d160 commit 67d87f3
22 files changed
Lines changed: 768 additions & 83 deletions
File tree
- .changeset
- ui/packages
- app-shell/src
- console/__tests__
- hooks
- views
- i18n/src/locales
- types/src
| 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 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
| 34 | + | |
| 35 | + | |
34 | 36 | | |
35 | 37 | | |
36 | 38 | | |
| |||
138 | 140 | | |
139 | 141 | | |
140 | 142 | | |
141 | | - | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
142 | 148 | | |
143 | 149 | | |
144 | 150 | | |
| |||
203 | 209 | | |
204 | 210 | | |
205 | 211 | | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
206 | 232 | | |
207 | 233 | | |
208 | 234 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
16 | 23 | | |
17 | 24 | | |
18 | | - | |
| 25 | + | |
| 26 | + | |
19 | 27 | | |
| 28 | + | |
20 | 29 | | |
21 | 30 | | |
| 31 | + | |
| 32 | + | |
22 | 33 | | |
23 | 34 | | |
24 | 35 | | |
| 36 | + | |
25 | 37 | | |
26 | 38 | | |
27 | 39 | | |
| |||
36 | 48 | | |
37 | 49 | | |
38 | 50 | | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
39 | 67 | | |
40 | 68 | | |
| 69 | + | |
| 70 | + | |
41 | 71 | | |
42 | 72 | | |
43 | | - | |
| 73 | + | |
44 | 74 | | |
45 | | - | |
46 | | - | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
47 | 79 | | |
48 | 80 | | |
49 | | - | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
50 | 86 | | |
51 | 87 | | |
52 | 88 | | |
| |||
87 | 123 | | |
88 | 124 | | |
89 | 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 | + | |
0 commit comments