Repository navigation
Commit a03c3d4
feat(plugin-approvals): approval steps reach the record activity stream as approval feed items (#37188)
<!-- claude-projects-attribution: {"github_login":"os-support-ai"} -->
_Requested by **Yibo Wang** · [project
thread](https://claude.ai/code/project/chan_01BVUyyPie8gHwoPM18iABwB?thread=cmsg_01BVUyyPie8gHwoPM18iABwBEaJzgBWzjWCNjBjkVoeRto)_
Fixes #35723
repo:objectstack#3 · os-support-ai · session_01WGufzg3KqwSpt61Y8ovKK7
Clause-②: no
Metadata-protocol: none
## 维护者速读
-
用户能看到什么变化:在走审批的记录详情页「动态」里,每个审批步骤(提交、通过、驳回、退回修改、重新提交、撤回、取消)都显示为一行,按读者的语言显示(中文读者看到「已批准
· 经理审批」),点「看审批」直接打开该记录的「审批」页签;以前这里看不到任何审批。
- 为什么做:记录详情页专题里「动态流审批一行」那一半——上一张卡只画了这一行的样子,但没有任何地方产出审批条目,这张卡补上产出方。
- 出错会怎样:最坏情况是动态里少了或多了审批行,或某行显示成英文;审批本身、审批页签和锁定都不受影响。撤回本 PR
后,已写入的审批行仍在动态表里保留最多 14 天,且失去本 PR 的可见性限制,会以普通系统行的样子展示给所有能看该记录的人。
- 要你做什么:无
## What changes
- **Producer (plugin-approvals, new module
`approval-activity-feed.ts`).** An `afterInsert` hook on the decision
log `sys_approval_action` appends one `sys_activity` row per step of
kind `submit`, `approve`, `reject`, `revise` (sent back for revision),
`resubmit`, `recall` and `cancel`, about the record the request governs.
Other kinds (reminder, reassign, thread comment, ...) write none, and no
decision comment rides on the row. An object with `enable.activities:
false` gets no entry, as the CRUD mirror writes none for it. Shape
follows ADR-0052 section 5, so no published vocabulary moves: `type:
'system'` (platform-only; the app activity door refuses it),
`metadata.kind: 'approval'` plus the step's action, its stored label and
the two machine names its label is translated by (`flow_name`,
`step_name`), `source_object: 'sys_approval_request'` / `source_id`
naming the request.
- **In the reader's language (route b, round 2).** `summary` stores the
English sentence from plugin-approvals' own catalog (`approvalActivity*`
in `translations/messages.ts`, ten ids added to all eleven shipped
packs); a new `sys_activity` middleware (`bindApprovalActivityLocale`)
re-composes it on `find` / `findOne` for a non-system read that carries
a locale, with the approvals door's own lookup (`readerLabelsFor`): the
sentence is `messages.approvalActivity*` in the reader's locale, and the
step label is `flows.FLOW.approvals.NODE.label` read the way the
approvals tab reads it, else the stored label. A list that projects
`summary` alone borrows the recognition columns and hands back only what
it asked for. A system read, a read with no locale or no `i18n` service,
or a key the pack misses serves the stored line. No `sys_activity` on
the deployment (no plugin-audit) means no write; a failed append never
fails the step and is logged once at `error` with consequence and fix.
`approval-service.ts` is untouched (overlap with PR #37145 and branch
`claude/project-thread-x90m5y` avoided).
- **Read gate (same module).** A `sys_activity` middleware narrows
`find` / `findOne` / `count` / `aggregate` so an approval row is served
only when the approvals service would serve the caller its request
(`RequestVisibilitySource`, the same source the request-table gates
read). A read pinning `object_name` + `record_id` asks with that record,
so an object that opts into `enable.approvalsVisibleToReaders` serves
its readers too. Every non-approval row passes untouched; plugin-audit's
parent-record gate still applies on top; failure to resolve fails closed
for approval rows only. Count and rows agree.
- **Console (plugin-detail).** `activityRowToFeedItem` reads the triple
`type: 'system'` + `metadata.kind: 'approval'` + `source_object:
'sys_approval_request'` as the `approval` feed kind
(`APPROVAL_ACTIVITY_FEED_TYPE`), so `PRODUCED_FEED_TYPES` now contains
`approval` and the unproduced-kind diagnostic no longer names it. New
`RecordViewApprovalsContext` carries the stream's 「看审批」 callback into
`RecordActivityRenderer` and `RecordChatterPanel`.
- **Host (app-shell `RecordDetailView`).** The approval tag's opener is
extracted as `openRecordApprovals` (approvals panel if drawn, else the
审批 tab) and supplied through `RecordViewApprovalsContext` only when the
reader is served approvals; otherwise the line has no link.
- **Docs.** `content/docs/frontend/plugins/plugin-detail.mdx`:
`approval` joins the produced-kinds table (six produced, seven not); the
unproduced example becomes `call`.
- **Ledgers.** `approver-address-readers.test.ts` classifies the two new
`actor_id` reads as `display`; the tenant-audit write census for
plugin-approvals is regenerated (one new elevated `sys_activity`
insert); `content/docs/permissions/system-context.mdx` row 17 owns the
new middleware's `isSystem` read (its register regenerated with
`--write`).
## Round 2 (L1 REWORK on dc76347)
- **S1, route (b): the server re-composes on read.** It is the #26167
precedent's own shape: plugin-audit's `activity-summary-message.ts`
stores the sentence plus its code and re-composes it per reader in a
`sys_activity` middleware, and this row's code is already on it
(`metadata.action`, now with `flow_name` / `step_name`). The step label
must be translated through the app's flows pack, which lives in the
server's `i18n` service and is read by the approvals door's
`reader-locale-labels` lookup; the console holds no such pack.
Server-side, every reader of the column (the record page, the API, an
export) gets the same line, and no console locale pack moves. Pinned for
a zh-CN reader: `已批准 · 经理审批` and `已提交审批`, with the step label from an
app flows pack.
- **S2:** handled by the zone (claim amended).
- **N1:** done in the same code path: `revise`, `resubmit` and `cancel`
write entries (`Sent back for revision · STEP`, `Resubmitted for
approval`, `Approval request cancelled`, the last attributed to no one),
each pinned.
- **N2:** the flag is honored, as the CRUD mirror honors it
(`audit-writers.ts` writes no activity row for an object with
`enable.activities: false`); pinned.
- **N3:** the step half is pinned exactly (`Approved · Manager review`,
`Rejected · Manager review`), plus the stored metadata.
- **N4:** the 维护者速读 revert sentence now says rows already written stay
up to 14 days and, without the read gate, are served to every record
reader as generic system lines.
## Tests
<details><summary>Readings, round 2 (head 06a3c76)</summary>
All local runs went through `scripts/pm/os-verify-lock.sh`; verdict
lines quoted. Round-2 head `06a3c7640b` (after merging `origin/main` at
`93bd45957b`).
- `pnpm --filter @objectstack/plugin-approvals exec vitest run` +
`typecheck` (head `06a3c764` minus the cancel pin): `Test Files 129
passed (129)`, `Tests 1929 passed (1929)`, `check:test-typecheck: OK`,
`VERDICT command-exit 0`.
- `src/approval-activity-feed-35723.integration.test.ts` at
`06a3c7640b`: `Tests 7 passed (7)` (approve/reject/recall, send back +
resubmit, cancel on record delete, muted timeline, zh-CN reader, reader
without approval access, record-reader opt-in).
- Ablation (S1): `node scripts/ablation-replace.mjs` replaced the
`bindApprovalActivityLocale(...)` call in `approvals-plugin.ts` with a
no-op (anchor 1 to 0, blob changed); the zh-CN pin went red (`Tests 1
failed | 6 passed (7)`, the six others green), restore verified (`blob
== HEAD`, `git diff HEAD` empty).
- Local gate subset: `dispatch-gates --ran` reconciles `106 derived, 104
run, 2 UNRUN`; 101 exit 0. `check:i18n` first exit 3 (PREREQUISITE NOT
MET), then its own one-command prerequisite build and re-run:
`check-i18n-bundles: OK (10 package(s) — all bundles in sync, no
undeclared authoring keys)`, `VERDICT command-exit 0`.
`check:system-context-census` (red in CI on `05d82f29`) fixed in
`f0b51c92`: `OK — 202 elevation read sites ... the generated register
(178 symbol(s)) matches the tree`, self-test all cases passed. NOT
MEASURED locally, CI runs them: `check:dual-build-cjs-loads`, `spec
check:skill-examples` (exit 3, unbuilt dist outside the closure); `pnpm
--dir ui exec vitest run scripts/` and `check:type-check-debt` (declared
narrowing: the first was OOM-killed in round 1, the second needs a
whole-workspace build; no `ui/` file and no package's type-check set
changed this round).
- `overlap-check --branch=claude/issue-35723-approval-feed-items`:
`VERDICT clean exit 0`.
- Round 1 readings (UI suites, record-page ablation) stand for the
unchanged `ui/` files: `RecordDetailView.*` 100 files / 858 tests,
plugin-detail 417 files, both `type-check` exit 0.
- Full dogfood: not owed (no `!` in the title, no `(narrowing)` arm).
</details>
## Acceptance notes
- `sys_activity` keeps its own lifecycle (rows reaped after 14 days);
the 审批 tab keeps the full history. Steps taken before this lands write
no backfilled rows.
- The console restates the three writer values (`recordActivityFeed.ts`)
because plugin-detail cannot depend on the server plugin; both sides are
pinned by tests.
- The producer reads the decision log rather than calling in from each
decision method, so a step the service learns to record elsewhere
reaches the stream with no second call site.
- New UI pin for the mapper and stream lives in a card-named file
`recordActivityFeed.approvalStep-35723.test.tsx` (it renders React; the
shared `recordActivityFeed.test.ts` is a non-JSX file). The record-page
pin joined the shared `RecordDetailView.harness.test.tsx` as its own
top-level block.
## Verification
First read (by risk):
1. `packages/plugins/plugin-approvals/src/approval-activity-feed.ts` —
`bindApprovalActivityReadGate` (who sees an approval row),
`bindApprovalActivityLocale` (the system-read pass-through and the
borrowed columns), and the producer hook's transaction and tenant
context.
2. `ui/packages/plugin-detail/src/renderers/recordActivityFeed.ts` —
`isApprovalStepRow`, the mapping branch.
3. `ui/packages/app-shell/src/views/RecordDetailView.tsx` —
`openRecordApprovals` / `viewApprovals`, a plain function below the
page's early returns (a hook there breaks hook order).
Two-minute check: `pnpm --filter @objectstack/plugin-approvals exec
vitest run --maxWorkers=2
src/approval-activity-feed-35723.integration.test.ts` — expect 7 passed:
one entry per step (approve / reject / recall, send back and resubmit,
cancel on record delete), none on a muted timeline, a zh-CN reader
served `已批准 · 经理审批`, none served to a reader without approval access
while other entries stay, and served under the record-reader opt-in.
---
_Generated by [Claude
Code](https://claude.ai/code/session_01WGufzg3KqwSpt61Y8ovKK7)_
https://claude.ai/code/session_01WGufzg3KqwSpt61Y8ovKK7
<!-- signed: repo:objectstack#3 · os-support-ai ·
session_01WGufzg3KqwSpt61Y8ovKK7 -->
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent 0a1b69c commit a03c3d4
19 files changed
Lines changed: 1409 additions & 52 deletions
File tree
- .changeset
- content/docs
- frontend/plugins
- permissions
- docs/audits/2026-08-tenant-audit-write-call-sites.counts/plugins
- packages/plugins/plugin-approvals/src
- translations
- ui/packages
- app-shell/src/views
- plugin-detail/src
- 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 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
510 | 510 | | |
511 | 511 | | |
512 | 512 | | |
513 | | - | |
| 513 | + | |
514 | 514 | | |
515 | 515 | | |
516 | 516 | | |
| |||
519 | 519 | | |
520 | 520 | | |
521 | 521 | | |
| 522 | + | |
522 | 523 | | |
523 | | - | |
524 | | - | |
| 524 | + | |
| 525 | + | |
525 | 526 | | |
526 | 527 | | |
527 | 528 | | |
528 | 529 | | |
529 | 530 | | |
530 | 531 | | |
531 | | - | |
| 532 | + | |
532 | 533 | | |
533 | 534 | | |
534 | 535 | | |
535 | 536 | | |
536 | 537 | | |
537 | | - | |
| 538 | + | |
538 | 539 | | |
539 | 540 | | |
540 | 541 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
120 | 120 | | |
121 | 121 | | |
122 | 122 | | |
123 | | - | |
| 123 | + | |
124 | 124 | | |
125 | 125 | | |
126 | 126 | | |
| |||
572 | 572 | | |
573 | 573 | | |
574 | 574 | | |
| 575 | + | |
575 | 576 | | |
576 | 577 | | |
577 | 578 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
17 | | - | |
18 | | - | |
| 17 | + | |
| 18 | + | |
19 | 19 | | |
20 | 20 | | |
21 | | - | |
| 21 | + | |
22 | 22 | | |
23 | 23 | | |
24 | | - | |
| 24 | + | |
25 | 25 | | |
26 | | - | |
| 26 | + | |
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
31 | | - | |
| 31 | + | |
32 | 32 | | |
33 | 33 | | |
34 | | - | |
| 34 | + | |
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
| |||
48 | 48 | | |
49 | 49 | | |
50 | 50 | | |
| 51 | + | |
51 | 52 | | |
52 | 53 | | |
53 | 54 | | |
| |||
0 commit comments