Repository navigation
Commit 543585d
feat(record-page): one field's change history, from the field and from a list cell's menu (#36661)
<!-- claude-projects-attribution: {"github_login":"os-warren"} -->
_Requested by **Warren** · [project
thread](https://claude.ai/code/project/chan_01U5RdnAAmkSQmZbqh6FtqZ8?thread=cmsg_01U5RdnAAmkSQmZbqh6FtqZ8X8kSCzcbcWxbzbjcuNrVrv)_
Fixes #36290
Fixes #36615
Clause-②: yes (widening)
Metadata-protocol: none
Part 3 of the card, the last one: the per-field change history, its two
entry points and the read-permission rule (card items 3, 4 and the 修改历史
half of item 5). Part 1 (#36399) made the server serve each changed
field's old → new values narrowed per reader; part 2 (#36613) drew them
under the record's activity entries; part 1 of the Studio producers
(#36641) moved them to `fieldHistory`. Ruling-ref: 7076513167 — a value
the viewer cannot read is never sent to the browser, and the
`sys_audit_log` grant is never widened. #36615 rides along: it is the
one sentence in `packages/spec` that still told authors to write
`trackHistory: true`.
## 维护者速读
-
记录页上会记录修改前后值的字段,值旁边多了一个「修改历史」小按钮(鼠标移上去或键盘聚焦时出现),列表里在这类字段的格子上右键也多了「修改历史」;点开就地弹一张小卡片,列出这一个字段改过几次、谁改的、什么时候、从什么改成什么,最新的在上,先给十条,可以继续加载。没开修改历史的字段(比如图片、附件、密码,或被设置关掉的字段)不显示这个入口。
-
属于「记录详情页重做」专题里的字段修改历史,这是最后一段:前几段让服务器把前后值按权限发出来、在动态里画出来,这一段让人能只看一个字段的历史。
-
出错时,用户会看到卡片排版不对或加载不出来;不会多看到任何没权限的字段,因为没有读取权限的字段既不显示入口、服务器也本来就不发值;可以整体撤回,数据不受影响。
- 无
## What changes
**The card** (`ui/packages/plugin-detail/src/FieldHistory.tsx`, new)
- `FieldHistoryCard` lists one field's changes on one record: `who ·
when` over `old → new`, newest first, the newest ten with **Load more**.
The values are worded exactly as the activity lines word them — an
option by the field's option label in the reader's language, a yes/no by
the pack's word, an empty side by the pack's word for empty — through
one new shared hook (`fieldChangeText.ts`, `useFieldChangeWording`),
which `RecordActivityTimeline` now reads too, so the two surfaces cannot
word the same change apart.
- A field never changed: **No changes recorded**, with who created the
record and when, read off the record's `created` activity row.
- A refused read (401 / 403) says the reader may not see this record's
activity; any other failure says the activity could not be loaded.
- `useFieldHistory` reads `sys_activity` **by record**, newest first,
fifty rows at a time (`$skip` / `$top`), keeping the rows whose served
change code names the field. One user action — the open, or one **Load
more** — reads at most `FIELD_HISTORY_SCAN_BATCHES_PER_LOAD` (4)
batches: it stops sooner when it has the page it shows or the rows run
out, and otherwise stops there and offers **Load more** to read on. When
those batches held no change of the field and older rows remain, the
card says **No changes in the recent activity** (new key
`detail.fieldHistoryNoneRecent`); **No changes recorded** needs every
row read. A row repeated by a `$skip` shifted under a concurrent write
is kept once. It reads no change column, because a query naming one is
refused for a reader withheld any field of the object
(`parent-field-query-guard.ts`), and it never reads `sys_audit_log`.
**The two entry points**
- The record page: `FieldHistoryButton`, a history icon beside the value
in `DetailSection`, revealed on hover and on keyboard focus like the
copy button, opening the card in a popover. Drawn only for a field the
object declares, on the page's own record, and only when
`fieldHistoryOffered` says so: not a platform record column (`id`,
`created_at`, …), not a field whose old → new values the writer never
records (`resolveFieldHistory(field, object)` from
`@objectstack/spec/data`, the one predicate plugin-audit's
`changeValuesShownFor` keeps values by — false for `fieldHistory:
false`, object `enable.fieldHistory: false`, a credential field, and a
default-off type such as image, file or JSON that does not opt in), and
not a field the reader may not read (`checkField(object, field,
'read')`).
- The list: `data-table` now names the data cell a context menu opened
on to its host (`context.column`, a new optional member of the context
`renderRowContextMenu` receives — a `data-cell-column` attribute on the
cell), `ObjectGrid` adds **Change history** for a cell of a declared
field that `fieldHistoryOffered` accepts (recorded and readable, the
same gate as the record page) when its data source can read activity,
and choosing it opens the same card at the pointer
(`FieldHistoryPopover`).
- `FieldChangeItem` draws no label for `label: ''`, so the card can name
the field once above its lines.
**`packages/spec`** — the unknown-key guidance row for the mistyped
field key `tracked` now names `fieldHistory: false` (and
`enable.fieldHistory: false` on the object) instead of `trackHistory:
true`, which after #36399 changes nothing for most field types. Wording
only: `tracked` stays rejected, no key, shape or default moves.
**Language packs** — `detail.fieldHistory`, `detail.fieldHistoryNone`
and `detail.fieldHistoryNoneRecent` in all 11 locales `@object-ui/i18n`
ships, mirrored byte-identically in `DETAIL_DEFAULT_TRANSLATIONS`.
## Tests
New pins at head `c429064ab8`:
- `ui/packages/plugin-detail/src/__tests__/FieldHistory-36290.test.tsx`
(13): only this field's changes, newest first, with actor and timestamp;
a save of two fields gives this field's line alone; the read names no
change column (`$filter` is the record, and the params hold no
`changed_fields` / `metadata`); an option side reads as its label and an
empty side as `Empty`; the newest ten, then **Load more** to the rest;
paging past a full batch of another field's rows to find this field's
changes (two reads, the second `$skip`ped); one open reads exactly 4
batches on a record whose field change lies past them, says `No changes
in the recent activity` (not `No changes recorded`), reads nothing more
without a click, and **Load more** reads the fifth batch at `$skip` 200
and finds the change; never changed → `No changes recorded` with the
creator and the creation time; a refused read. For the entry point:
every declared field offers it and `created_at` does not, nothing is
read until it is opened, a field the reader may not read has no entry
(CONTROL: the readable sibling keeps it), a field whose values are not
recorded has no entry — `fieldHistory: false`, a `json` field, a
`password` field (CONTROL: a `json` field with `fieldHistory: true`
keeps it) — an object with `enable.fieldHistory: false` offers none
(CONTROL: the same object without it offers both), and a section not
drawing the page's record offers none.
-
`ui/packages/plugin-grid/src/__tests__/fieldHistoryCellMenu-36290.test.tsx`
(5): the cell's menu item opens that record's changes of that field (and
the read is scoped to that record); a field the reader may not read has
no column, so no cell offers it (CONTROL: a readable field's cell still
does); a host-joined column the object does not declare offers none; a
cell of a `fieldHistory: false` field opens no row menu at all on a
table with no row actions (CONTROL: a recorded field's cell offers it);
a data source that cannot read activity offers none.
-
`ui/packages/components/src/renderers/complex/__tests__/data-table-row-context-menu-28434.test.tsx`:
the existing host-renderer pin now asserts `column`, plus one new case —
the column of the data cell the menu opened on, and no column off a data
cell (the row's "⋮" cell).
<details><summary>Runs</summary>
```
# the two new pin files, at c429064
Test Files 2 passed (2) Tests 18 passed (18)
# affected packages at c429064, under scripts/pm/os-verify-lock.sh (plugin-detail, plugin-grid, i18n,
# types, components/renderers/complex, app-shell defaults-maps-mirror-en-pack)
os-verify-lock: VERDICT command-exit 0
Test Files 1260 passed | 1 skipped (1261) Tests 19388 passed | 31 skipped (19419)
# + app-shell RecordDetailView.harness and the i18n call-site parity suite
Test Files 2 passed (2) Tests 234 passed (234)
# packages/spec (the tracked row; no spec file moved since 975c4c5)
packages/spec src/data/field.test.ts Test Files 1 passed Tests 308 passed (308)
# type-check at c429064, exit 0 each: plugin-detail, plugin-grid, i18n (components, types unchanged since 975c4c5, exit 0 there)
# dispatch-gates at c429064: the same 117 derived commands as at 975c4c5 (diffed), re-run, 117/117 exit 0
```
Ablations through `scripts/ablation-replace.mjs` (anchor hit and blob
move printed by the tool; each restored, `git diff HEAD` empty and the
file's blob equal to its `HEAD` blob afterwards):
| Mutation | Result |
|---|---|
| the read-permission gate in `fieldHistoryOffered` removed | 1 red: `a
field the reader may not read has no entry` |
| the batch read always marks itself exhausted | 1 red: `pages past rows
of other fields until it finds this field's changes` |
| the card keeps the first served change instead of the one naming the
field | 3 red, the field-identity pins |
| at c429064: the `resolveFieldHistory` gate in `fieldHistoryOffered`
made a no-op | 3 red: the two record-page history-off pins and the
grid's |
| at c429064: the per-action batch cap removed (`needsRead =
wantsMore`) | 1 red: `one open reads at most 4 batches, then "Load more"
reads on` |
</details>
## Acceptance notes
- Rework after contract review 7097637110 (FAIL, two should-fix, no
must-fix): **S1** the entry points are now gated by
`resolveFieldHistory`, so a field whose values are never recorded offers
no history instead of a card that would say 「No changes recorded」 of a
changed field; **S2** the scan is bounded per user action as described
above, and this body now says what the code does; the changeset's
Clause-② line names the exported constants and the third key. The two
notes taken as well: a row repeated by a shifted `$skip` is kept once.
Not taken: the keyboard-opened cell menu path stays unpinned (as the
review noted); a data source that ignores `$skip` now stops after four
reads per click instead of looping until the card closes.
- Card lines this PR covers: 「在记录页「客户备注」上打开修改历史:列出历次修改,和动态里的一致。」 — yes,
and worded by the one hook both surfaces now read.
「在列表的格子上右键「修改历史」:同一张卡片。」 — yes. 「一个没改过的字段:显示「没有修改记录」和创建信息。」 — yes.
「用一个没有某字段读取权限的账号:…那个字段上也没有「修改历史」。」 — yes, pinned on both entry points;
the 动态 half landed in #36613.
- Not done, as the card says: 「不做「恢复到某个历史值」」, no change to how the audit
log is stored or kept, no change to the 动态 tab's grouping or filters.
- The card's unchecked note on per-field reads is now measured, not
assumed: there is no server-side per-field history read, and adding one
would mean a query over a change column, which
`parent-field-query-guard.ts` refuses for exactly the readers this
feature is for. So the card reads the record's rows in batches of fifty,
at most four batches (200 rows) per open or 「Load more」. On a record
with thousands of activity rows and a field changed rarely, each click
reads the next 200; a server-side per-field door would be a separate
Feature card, not this one.
- The `FieldChangeItem` line inside the card clamps each side to its
line and offers **Show all**, as the activity lines do.
- `ui/AGENTS.md` #2's second half: the two package READMEs and the two
`content/docs/frontend/plugins/*.mdx` pages are updated in this PR.
- Screenshots: below, driven in the running Console
(`examples/app-showcase` + `apps/console`) as the seeded admin, on
`showcase_account`. GitHub's image store takes uploads only from the
browser, and `ui/AGENTS.md` #185 forbids committing screenshots into the
tree, so they are described here and handed to the requester in the
thread; the frames themselves are in the project files.
## Screenshots
Taken at `975c4c5576`. The rework leaves these frames as they are: every
field shown is a text or email field, whose values are recorded, so the
gate still offers it; the batch cap shows only on a record with more
than 200 activity rows. Driven at 1440×900, `deviceScaleFactor: 2`,
record **Stark Industries**, field **Billing Email** (edited three
times: `ap@…` → `accounts.payable@…` → `billing@…`).
1. **The button** — hovering the Billing Email row reveals a history
icon beside the existing copy icon; nothing else about the row moves
(`1-field-history-button.png`, crop `…-crop.png`).
2. **The card, from the field** — clicking it opens a popover anchored
to the value: a header `Billing Email` / `Change history`, then `Dev
Admin · Nov 23, 2026, 10:01 AM` over `accounts.payable…` struck through
`→ billing@sta…` with **Show all**, and the older change under it,
newest first (`2-field-history-card.png`).
3. **The list's entry point** — a right-click on the `Account Name` cell
of Stark Industries lists **Change history** between **Open in new tab**
and **Edit**, with the same history icon (`3-cell-context-menu.png`).
4. **The card, from the cell** — choosing it opens the same card at the
pointer, headed `Account Name`, listing that record's four changes of
that field, newest first (`4-cell-field-history-card.png`).
5. **A field never changed** — on a record created through the API, Tax
ID's card reads `No changes recorded` over `Created by Dev Admin · Nov
23, 2026, 10:03 AM` (`5-never-changed.png`).
A note worth having on the record: on a **seeded** row the same empty
card shows `No changes recorded` with **no** creator line, because the
seed writes no `created` activity row and the card states only what the
server served it — it does not fall back to `created_by`, which is a
column the reader may be withheld.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_01JQwxbZFiKZ188iQxqGgmnY
<!-- signed: repo:objectstack#1 · os-warren ·
session_01JQwxbZFiKZ188iQxqGgmnY -->
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent 4034a6d commit 543585d
32 files changed
Lines changed: 1448 additions & 67 deletions
File tree
- .changeset
- content/docs/frontend/plugins
- packages/spec/src/data
- ui/packages
- components/src/renderers/complex
- __tests__
- i18n/src/locales
- plugin-detail
- src
- __tests__
- plugin-grid
- src
- __tests__
- components
- 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 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
227 | 227 | | |
228 | 228 | | |
229 | 229 | | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
230 | 263 | | |
231 | 264 | | |
232 | 265 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
332 | 332 | | |
333 | 333 | | |
334 | 334 | | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
335 | 347 | | |
336 | 348 | | |
337 | 349 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
188 | 188 | | |
189 | 189 | | |
190 | 190 | | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
191 | 211 | | |
192 | 212 | | |
193 | 213 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1685 | 1685 | | |
1686 | 1686 | | |
1687 | 1687 | | |
1688 | | - | |
| 1688 | + | |
| 1689 | + | |
| 1690 | + | |
| 1691 | + | |
1689 | 1692 | | |
1690 | 1693 | | |
1691 | 1694 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
129 | 129 | | |
130 | 130 | | |
131 | 131 | | |
132 | | - | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
133 | 153 | | |
134 | 154 | | |
135 | 155 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2232 | 2232 | | |
2233 | 2233 | | |
2234 | 2234 | | |
2235 | | - | |
| 2235 | + | |
2236 | 2236 | | |
2237 | 2237 | | |
2238 | 2238 | | |
| |||
4426 | 4426 | | |
4427 | 4427 | | |
4428 | 4428 | | |
4429 | | - | |
| 4429 | + | |
4430 | 4430 | | |
4431 | | - | |
| 4431 | + | |
4432 | 4432 | | |
4433 | 4433 | | |
4434 | 4434 | | |
| |||
4472 | 4472 | | |
4473 | 4473 | | |
4474 | 4474 | | |
4475 | | - | |
| 4475 | + | |
| 4476 | + | |
| 4477 | + | |
| 4478 | + | |
4476 | 4479 | | |
4477 | 4480 | | |
4478 | 4481 | | |
| |||
4491 | 4494 | | |
4492 | 4495 | | |
4493 | 4496 | | |
4494 | | - | |
| 4497 | + | |
4495 | 4498 | | |
4496 | 4499 | | |
4497 | 4500 | | |
4498 | | - | |
| 4501 | + | |
4499 | 4502 | | |
4500 | 4503 | | |
4501 | 4504 | | |
| |||
5431 | 5434 | | |
5432 | 5435 | | |
5433 | 5436 | | |
| 5437 | + | |
| 5438 | + | |
5434 | 5439 | | |
5435 | 5440 | | |
5436 | 5441 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1707 | 1707 | | |
1708 | 1708 | | |
1709 | 1709 | | |
| 1710 | + | |
| 1711 | + | |
| 1712 | + | |
1710 | 1713 | | |
1711 | 1714 | | |
1712 | 1715 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1526 | 1526 | | |
1527 | 1527 | | |
1528 | 1528 | | |
| 1529 | + | |
| 1530 | + | |
| 1531 | + | |
1529 | 1532 | | |
1530 | 1533 | | |
1531 | 1534 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2068 | 2068 | | |
2069 | 2069 | | |
2070 | 2070 | | |
| 2071 | + | |
| 2072 | + | |
| 2073 | + | |
| 2074 | + | |
| 2075 | + | |
2071 | 2076 | | |
2072 | 2077 | | |
2073 | 2078 | | |
| |||
0 commit comments