Repository navigation
Commit 27895d7
feat(record-page): each changed field is its own line under an activity entry, old → new (#36613)
<!-- claude-projects-attribution: {"github_login":"os-steve"} -->
_Requested by **Steve** · [project
thread](https://claude.ai/code/project/chan_01FdL1XeUyvVNxLreh3F4Qi9?thread=cmsg_01FdL1XeUyvVNxLreh3F4Qi9NRmimMwnUgR1DbqgHtBWM3)_
Part of #36290
Clause-②: yes (widening) — four new `detail.*` language-pack keys in
every locale `@object-ui/i18n` ships, and new optional props on the
exported `FieldChangeItem`; nothing removed or renamed
Metadata-protocol: none
PR 2 of 4 on the card (part ②: card items 1 and 2, and the activity half
of item 5). PR 1 (#36399, merged as `70194ffc`) made the activity stream
serve each changed field's old and new values, narrowed per reader. This
PR draws them on the record page. Part ① (the designer producers of
`fieldHistory`) waits for #36580; part ③ (the per-field history card and
the field and grid-cell entry points) closes the card. Ruling-ref:
7076513167.
## 维护者速读
- 记录页「动态」里,每次保存现在先写改了哪些字段,下面每个字段一行「字段名:旧值 →
新值」;旧值为空写「空」,长文字截成一行,点「展开」看全文;单选显示选项名,关联记录和人员显示名字。
- 属于「记录详情页重做」专题下的字段修改历史:以前动态里只写「更新了
客户备注」,看不到改前改后的值;服务器上周已经按读取权限发送这些值,这次是把它们画出来。
-
出错时,用户会看到动态里的修改行排版不对或展开按钮失灵;不会多看到任何字段,因为没有读取权限的字段服务器本来就不发送;可以整体撤回,数据不受影响。
- 无
## What changes
**The served values reach the timeline**
(`ui/packages/plugin-detail/src/renderers/recordActivityFeed.ts`)
- New `activityFieldChangesOf(row)`: reads the field-change code
plugin-audit serves in `sys_activity.metadata` (`summary_message`, key
`fieldChanges`) and turns it into one `FieldChangeEntry` per field.
`activityRowToFeedItem` puts it on the item as `fieldChanges`. An option
side keeps the option it matched; a yes/no side keeps the boolean; the
writer's empty mark (`∅`, or an empty text) becomes an empty side. A
code it cannot read whole gives nothing, and the row draws its summary
as before.
- Nothing is filtered in the browser. The server already drops a change
of a field the reader may not read, and a reference change whose record
title the reader is not served (PR 1, `activity-field-redaction.ts`).
The timeline draws exactly the changes it is handed.
**One line per changed field** (`RecordActivityTimeline.tsx`,
`FieldChangeItem.tsx`)
- An entry with changes (an activity row's served code, an audit-log
entry, or the audit entry paired onto an activity row) draws its usual
one-line row, then one line per changed field under it: `Label: old →
new`.
- The row's own text: for an entry whose changes are its own, `Updated
Phone, Email` (its stored summary would repeat the lines). An activity
row carrying its paired audit entry keeps its own summary. The record's
creation is unchanged (one row, values beside the summary).
- Each side: an option reads as the field's option label in the reader's
language (`fieldOptionLabel`, falling back to the schema label, then the
served text); a lookup or user reads as the record name the server
served; a yes/no reads as `common.yes` / `common.no`; an empty side as
`detail.fieldChangeEmpty`.
- Each side is cut to its line (`truncate`). A side that overflows
(measured), holds a line break, or is longer than 48 characters offers
`Show all`, which wraps both sides in full, and `Show less`.
- The row's markers (`data-stream-row`, `data-stream-system-row`) sit on
the whole entry (the line plus its field lines), so a reader of the row
reads both; the 30 px line is `data-stream-line`.
- The compact one-line change text (the activity panel's peek rows, the
creation row's diff) now uses the same label, words and empty word:
`Status: New → Contacted`, where it read `Status New → Contacted` with
`—` for empty.
- `FieldChangeItem` (exported, previously unused) is the line: new
optional `label`, `oldText` / `newText`, `emptyLabel`, `expandLabel` /
`collapseLabel`; with none of them it draws as before except the arrow
is text and the empty word defaults to `(empty)`.
**Language packs** (`ui/packages/i18n/src/locales/*.ts`, 11 locales;
`useDetailTranslation.ts` defaults mirror `en`)
- `detail.fieldChangeLabel` (`{{field}}:`; fullwidth colon in zh-Hans,
zh-Hant, ja; `{{field}} :` in fr), `detail.fieldChangeEmpty` (`Empty`,
`空`), `detail.fieldChangeExpand` (`Show all`, `展开`),
`detail.fieldChangeCollapse` (`Show less`, `收起`).
## Tests
New pins, as top-level describes in the existing harness files:
- `renderers/__tests__/record-activity.test.tsx` — `record:activity —
one line per changed field, old → new (objectstack#36290)`: one field
(`Customer notes: Old words → New words`); phone and email in one save
is ONE row with two lines; empty side reads `Empty`, never `∅`; select,
lookup, user and yes/no read as option label, record names and words;
only the served changes draw (a field left out of the code has no line);
a long value truncates and toggles; the stream fold opens to each save's
own lines; CONTROL: a short value has no toggle, and a row with no code
draws its summary.
- `renderers/__tests__/recordActivityFeed.test.ts` —
`activityFieldChangesOf`: mapping of text, option, boolean and the empty
mark; the item carries the changes beside its summary; no code, another
code, an empty or unreadable code give nothing.
Forced test changes (each because the line format moved from `Label old
→ new` on one element to `Label: old → new` drawn over several
elements):
- `__tests__/recordTimelineStream-27055.test.tsx`: a `changeLines()`
reader over `[data-field-change]`; the six `getByText(/… → …/)` matches
read it instead (a text matcher cannot see a line split over spans). The
negative `queryByText(/New → Contacted/)` was moved too, since it would
have become vacuous. The two creation-diff strings gain the colon.
- `__tests__/RecordTimelinePanel-27524.test.tsx`: the peek line reads
`Status: New → Contacted`.
- `ui/packages/app-shell/src/views/RecordDetailView.harness.test.tsx`:
the audit-date and currency diff readers read `[data-field-change]`
lines, and their expected strings gain the colon (`Close date: 3.3.2020
→ 4.3.2020`, `Amount: €1,500.00 → €2,500.00`). The values themselves are
unchanged.
- `ui/packages/i18n/src/__tests__/untranslated-identity-4376.test.ts`:
`detail.fieldChangeLabel` joins `LEGITIMATE_IDENTITIES` as a format
string (ko/ru/ar keep `:`), like `grid.summary.pattern`.
The permission half is the server's, pinned by PR 1 in
`packages/plugins/plugin-audit/src/activity-field-redaction.test.ts`
(`[#36290] masked: …`, `[#36290] not served: the code and the summary
are served without the change of the field not served`, `[#36290]
control: a reader served every field is served the whole code`). This PR
adds the UI side: the timeline draws only what is served.
## Acceptance notes
- Card lines, as this PR covers them: 「改一条客户的「客户备注」并保存:动态里出现「客户备注:旧文字 →
新文字」。」 — yes (zh-Hans label template `{{field}}:`).
「一次保存同时改电话和邮箱:一条动态,下面两行。」 — yes. 「单选、关联记录、人员字段:前后值显示的是选项名和记录名,不是内部编号。」 —
yes for single select, lookup and user (option label read per reader;
record names as served). 「用一个没有某字段读取权限的账号:动态里没有那个字段的修改行」 — the server
leaves the change out (PR 1); the UI draws what is served. The 「修改历史」
half of that line is part ③.
- Screenshots of the activity: NOT MEASURED in this PR (no local backend
and console build in this run). To reproduce: `OS_PORT=3000 pnpm dev`,
open a showcase record, edit a long text field and, in one save, two
short fields; the record's 动态 tab shows one entry per save with one line
per field; a long value shows `Show all`.
- The empty side is recognised by the writer's text `∅` (or an empty
text), the notation plugin-audit's `summaryValueOf` writes and its tests
pin; the served code carries no separate empty mark. A structural mark
would be a server change, outside this PR.
- Multi-select and `tree` sides still read as the stored text the writer
wrote (PR 1 nits, not taken there either).
- Docs: `ui/AGENTS.md` #2 asks for the package README and the
`content/docs/frontend/` page; both are outside this dispatch's file
surface, so neither is edited here.
- No change to which entries the activity shows, how consecutive edits
fold, the activity filters, or audit storage.
## Verification
Read first:
1. `ui/packages/plugin-detail/src/renderers/recordActivityFeed.ts` —
`activityFieldChangesOf` (the only new read of server data; the empty
mark).
2. `ui/packages/plugin-detail/src/RecordActivityTimeline.tsx` —
`fieldChangeLinesOf`, `changeSideText`, and `renderSystemLine` (which
entries get lines, and the row-marker move in `streamRow`).
3. `ui/packages/plugin-detail/src/FieldChangeItem.tsx` — truncation, the
measured overflow and the toggle.
Two-minute check: `pnpm --dir ui exec vitest run
packages/plugin-detail/src/renderers/__tests__/record-activity.test.tsx`
— expect 35 passed, among them the eight `one line per changed field`
tests.
Readings below are at head `f281417b` (after merging `origin/main`
once).
<details><summary>Tests (local, under the verify lock)</summary>
- `pnpm --dir ui exec vitest run packages/plugin-detail/ packages/i18n/
packages/app-shell/src/__tests__/defaults-maps-mirror-en-pack.test.tsx`
plus the 22 app-shell `RecordDetailView.*` / record-page activity test
files, at `f281417b`: `Test Files 543 passed | 1 skipped (544)`, `Tests
6159 passed | 31 skipped (6190)`, lock `VERDICT command-exit 0`.
- `pnpm --filter @object-ui/plugin-detail run type-check` and `pnpm
--filter @object-ui/i18n run type-check` (each `tsc --noEmit && tsc -p
tsconfig.test.json`; the test project lists the four edited test files):
exit 0, before the merge.
- `ui`: `check:i18n-keys` 0, `check:i18n-drift` 0,
`check:i18n-dead-keys` 0, `check:new-line-citations` 0 (`0 new
citation(s)`), before the merge.
</details>
<details><summary>Ablation</summary>
Committed head first, then `node scripts/ablation-replace.mjs` replaced
`const lines = fieldChangeLinesOf(item);` in `renderSystemLine` with
`const lines = null …` (anchor 1 → 0, blob `5cc789c3a1d9` →
`0061c6cdd8de`) and ran `record-activity.test.tsx` under the lock:
`Tests 8 failed | 27 passed (35)` — all eight `one line per changed
field` tests red, every older test green. Restored: blob after restore
`5cc789c3a1d9` == HEAD, `git diff HEAD` empty. No `dist` is involved:
the ui vitest config aliases `@object-ui/plugin-detail` to its source.
</details>
<details><summary>Gates</summary>
`node scripts/pm/dispatch-gates.mjs --commands` at `f281417b`: 41
commands, each run with its exit code recorded before any pipe; all 41
exit 0. `--ran`: `Run reconciliation — 41 derived, 41 run, 0
NOT-MEASURED, 0 UNRUN.` CI owns the rest (Lint UI, Type Check UI, Test
UI, the repo-wide lint); not re-run here.
</details>
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_01ADHkmPq6z7KER4Sr6Uu7Ht
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent ed0edb1 commit 27895d7
22 files changed
Lines changed: 657 additions & 54 deletions
File tree
- .changeset
- ui/packages
- app-shell/src/views
- i18n/src
- __tests__
- locales
- plugin-detail/src
- __tests__
- renderers
- __tests__
| 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 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
711 | 711 | | |
712 | 712 | | |
713 | 713 | | |
714 | | - | |
715 | | - | |
| 714 | + | |
| 715 | + | |
716 | 716 | | |
717 | 717 | | |
718 | 718 | | |
719 | 719 | | |
720 | 720 | | |
721 | | - | |
| 721 | + | |
722 | 722 | | |
723 | 723 | | |
724 | 724 | | |
| |||
729 | 729 | | |
730 | 730 | | |
731 | 731 | | |
732 | | - | |
| 732 | + | |
733 | 733 | | |
734 | 734 | | |
735 | 735 | | |
| |||
754 | 754 | | |
755 | 755 | | |
756 | 756 | | |
757 | | - | |
| 757 | + | |
758 | 758 | | |
759 | 759 | | |
760 | 760 | | |
761 | 761 | | |
762 | 762 | | |
763 | | - | |
| 763 | + | |
764 | 764 | | |
765 | 765 | | |
766 | 766 | | |
| |||
892 | 892 | | |
893 | 893 | | |
894 | 894 | | |
895 | | - | |
896 | | - | |
| 895 | + | |
| 896 | + | |
897 | 897 | | |
898 | 898 | | |
899 | | - | |
900 | | - | |
| 899 | + | |
| 900 | + | |
901 | 901 | | |
902 | | - | |
903 | | - | |
| 902 | + | |
904 | 903 | | |
905 | | - | |
| 904 | + | |
906 | 905 | | |
907 | 906 | | |
908 | 907 | | |
| |||
934 | 933 | | |
935 | 934 | | |
936 | 935 | | |
937 | | - | |
| 936 | + | |
938 | 937 | | |
939 | 938 | | |
940 | 939 | | |
941 | 940 | | |
942 | | - | |
| 941 | + | |
943 | 942 | | |
944 | 943 | | |
945 | 944 | | |
946 | 945 | | |
947 | | - | |
| 946 | + | |
948 | 947 | | |
949 | 948 | | |
950 | 949 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
126 | 126 | | |
127 | 127 | | |
128 | 128 | | |
| 129 | + | |
129 | 130 | | |
130 | 131 | | |
131 | 132 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1685 | 1685 | | |
1686 | 1686 | | |
1687 | 1687 | | |
| 1688 | + | |
| 1689 | + | |
| 1690 | + | |
| 1691 | + | |
1688 | 1692 | | |
1689 | 1693 | | |
1690 | 1694 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1504 | 1504 | | |
1505 | 1505 | | |
1506 | 1506 | | |
| 1507 | + | |
| 1508 | + | |
| 1509 | + | |
| 1510 | + | |
1507 | 1511 | | |
1508 | 1512 | | |
1509 | 1513 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2043 | 2043 | | |
2044 | 2044 | | |
2045 | 2045 | | |
| 2046 | + | |
| 2047 | + | |
| 2048 | + | |
| 2049 | + | |
| 2050 | + | |
| 2051 | + | |
| 2052 | + | |
2046 | 2053 | | |
2047 | 2054 | | |
2048 | 2055 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1549 | 1549 | | |
1550 | 1550 | | |
1551 | 1551 | | |
| 1552 | + | |
| 1553 | + | |
| 1554 | + | |
| 1555 | + | |
1552 | 1556 | | |
1553 | 1557 | | |
1554 | 1558 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1553 | 1553 | | |
1554 | 1554 | | |
1555 | 1555 | | |
| 1556 | + | |
| 1557 | + | |
| 1558 | + | |
| 1559 | + | |
1556 | 1560 | | |
1557 | 1561 | | |
1558 | 1562 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1588 | 1588 | | |
1589 | 1589 | | |
1590 | 1590 | | |
| 1591 | + | |
| 1592 | + | |
| 1593 | + | |
| 1594 | + | |
1591 | 1595 | | |
1592 | 1596 | | |
1593 | 1597 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1504 | 1504 | | |
1505 | 1505 | | |
1506 | 1506 | | |
| 1507 | + | |
| 1508 | + | |
| 1509 | + | |
| 1510 | + | |
1507 | 1511 | | |
1508 | 1512 | | |
1509 | 1513 | | |
| |||
0 commit comments