Skip to content

Commit 5777b1a

Browse files
os-zhuangos-zhuangclaude
authored
fix(plugin-audit): localize tracked-change labels and render lookup titles (#7230) (#7291)
`sys_activity.summary`'s tracked-change branch (ADR-0052 §5b) shipped strings like `Rating Owner: ∅ → oBK25…` onto every feed surface at once. Two causes, both fixed here: - `renderTrackedChangeSummary` was the one summary branch never handed the locale-bound `translate` its three siblings resolve through (ADR-0053 / #3039). The field label now resolves through it on the bundles' own key shape, falling back to the authored label and then the machine key. - `displayFieldValue` resolved select option labels only, so a lookup / master_detail / user value printed its raw id. It now renders the referenced record's title via ADR-0079's `resolveDisplayField`, falling back to the raw id when unresolvable. The resolution is batched: 0 added reads unless a tracked reference field actually moved, then exactly one `id: { $in: [...] }` per distinct target object — so #6656 / PR #6977's retirement of the redundant pre-image read from this write path is not handed back. Read counts are pinned with the same counting driver that measured that retirement. Claude-Session: https://claude.ai/code/session_01BM1tNf5U3nEbHKR4fo5qVQ Co-authored-by: os-zhuang <steve@objectstack.ai> Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
1 parent 4bda5f8 commit 5777b1a

3 files changed

Lines changed: 790 additions & 8 deletions

File tree

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
---
2+
"@objectstack/plugin-audit": patch
3+
---
4+
5+
fix(plugin-audit): localize the tracked-change activity label and render lookup titles instead of raw ids (#7230)
6+
7+
`sys_activity.summary` is composed at write time and shipped verbatim to every
8+
feed surface at once — the record discussion feed, console home activity, the
9+
header inbox, the Setup `sys_activity` list, and mobile/REST/SDUI. Its
10+
tracked-change branch (ADR-0052 §5b, `"<label>: <old> → <new>"`) was producing
11+
strings like `Rating Owner: ∅ → oBK25…` at the bottom of an otherwise
12+
fully-localized page. Two independent causes, both fixed here:
13+
14+
- **The label was never localized.** `renderTrackedChangeSummary` was the one
15+
summary branch never handed the locale-bound `translate` its three siblings
16+
(`messages.activityCreated` / `messages.activityDeleted` /
17+
`messages.activityUpdated`, plus the object label via `displayLabelFor`) all
18+
resolve through — an oversight against ADR-0053 / #3039 write-time
19+
localization. The field label now resolves through the same translator, on the
20+
bundles' own key shape (`objects.<object>.fields.<field>.label`), and falls
21+
back to the authored `label`, then the machine key, exactly as before.
22+
- **A reference value printed its raw id.** `displayFieldValue` resolved
23+
select/picklist option labels only, so a `lookup` / `master_detail` / `user`
24+
value fell through to `String(value)` — the stored 32-char id. It now renders
25+
the referenced record's title, resolved through ADR-0079's
26+
`resolveDisplayField` (`nameField` → deprecated `displayNameField` alias →
27+
derivation) rather than a local name-guessing heuristic.
28+
29+
The `∅ →` notation is unchanged, and so is every other summary branch. The
30+
change is restore-invariant: an id that cannot be resolved — a target removed
31+
out of band, an unregistered object, a failing read — renders exactly as it did
32+
before.
33+
34+
**Read cost, measured with a counting driver** (the same technique that measured
35+
#6656 / PR #6977's retirement of the redundant pre-image read from this write
36+
path, and pinned as cases in `audit-lookup-summary.test.ts`):
37+
38+
- **0 added reads** on every create, every delete, every update that moves no
39+
tracked reference field, and every update that moves an *untracked* one —
40+
including on rows that do carry references. #6977's counts (1 `findOne` per
41+
single-id write, 0 per predicate write) are untouched.
42+
- **1 read per distinct target object** on an update that does move a tracked
43+
reference: both sides of the change are answered by a single
44+
`id: { $in: [...] }` selecting only the id and title columns, however many
45+
tracked reference fields point at that object.
46+
47+
Historical `sys_activity` rows keep their original write-time composition — only
48+
new writes improve.

0 commit comments

Comments
 (0)