Skip to content

Commit b8c9590

Browse files
fix(plugin-approvals): the approval request Timeline shows each step by its label, not the node id (#25526)
<!-- claude-projects-attribution: {"github_login":"os-sales"} --> _Requested by **Sales** · [project thread](https://claude.ai/code/project/chan_01D5bWFY3rFzgJcytD5gD4Uu?thread=cmsg_01D5bWFY3rFzgJcytD5gD4UuACdPWFJTLDcTrByFCHLzqb)_ Fixes #25501 Clause-②: no Metadata-protocol: none ## What was wrong The `sys_approval_request` record page (`packages/plugins/plugin-approvals/src/sys-approval-request.page.ts`) has a Timeline tab. That tab is a `record:related_list` over `sys_approval_action`, and its columns asked for `step_name`. Every action row stores two step fields, both declared on `sys-approval-action.object.ts`: - `step_name`: "Machine name of the step at the time of the action". Every writer in `approval-service.ts` sets it to the Approval node id (`step_name: nodeId`, or `raw.flow_node_id ?? raw.current_step`). - `step_label`: "Label of the step at the time of the action". `ApprovalService.actionRow` writes it on every row from the request's `current_step_label`, and `display-label-backfill.ts` fills it on older rows. So every Timeline row showed the node id (`dual_signoff`), while the highlights strip right above it showed the label (`current_step_label`). The object's own list views (`recent`, `by_actor`, `all_actions`) already use `step_label`. The card's premise holds with one correction: `step_name` is not missing. It is a declared, stored field that holds the machine id, so the column named a real field. It was the wrong one of the two. ## The change - The Timeline column `step_name` is now `step_label`. Nothing else on the page changes, and the page's doc comment says why the step column is `step_label`. - Landing: the file the claim names. `packages/spec` is not touched. - I checked every other field the page names against its object. The Timeline columns `created_at`, `action`, `actor_id`, `comment` and `attachments` and its sort field `created_at` are all `sys_approval_action` fields. The highlights strip's `process_label`, `status`, `current_step_label`, `submitter_id` and `updated_at` are all `sys_approval_request` fields, and none of them is a machine id where a label exists. ## Tests `src/sys-approval-request-page.test.ts` gains `names each Timeline step by its label, step_label, never by the node's machine id, step_name`. It reads the page's Timeline columns and asserts two things: `step_label` is listed and `step_name` is not, and `step_label` is the declared `Approval Step` text field. A control asserts that `step_name` stays a declared field. The file's existing test `every field the page names exists on its object` already checks that each Timeline column names a field of `sys_approval_action`. It stayed green on the defect, because `step_name` is a declared field. That is why this test pins the choice, the way the strip's `current_step_label` is already pinned. Ablation, at head `4e80cfeeaf`, under the verify lock. `node scripts/ablation-replace.mjs --file packages/plugins/plugin-approvals/src/sys-approval-request.page.ts --anchor "'actor_id', 'step_label', 'comment'" --replacement "'actor_id', 'step_name', 'comment'" -- pnpm --filter @objectstack/plugin-approvals exec vitest run --maxWorkers=2 src/sys-approval-request-page.test.ts`: - `mutation landed: anchor 1 -> 0, blob 1b31bf2 -> 48f41780fd75` - `× names each Timeline step by its label, step_label, never by the node's machine id, step_name` and `Tests 1 failed | 19 passed (20)`. Only the new test went red, and the existence test stayed green, as described above. - `restored: blob == HEAD (1b31bf2) and git diff HEAD is empty` The test imports the page from `src` through a relative import, so the ablation needs no `dist/` rebuild. ## Local verification (head `4e80cfeeaf`) - `pnpm --filter '@objectstack/plugin-approvals^...' build` (dependency closure): VERDICT command-exit 0. - `pnpm --filter @objectstack/plugin-approvals test`: `Test Files 95 passed (95)`, `Tests 1234 passed (1234)`. - `pnpm --filter @objectstack/plugin-approvals typecheck`: exit 0, and `check:test-typecheck: OK`. - `node scripts/pm/dispatch-gates.mjs --commands` derived 69 commands. 68 exit 0. `pnpm check:i18n` exited 3 at first because its prerequisite build was missing; after its named build closure it gave `check-i18n-bundles: OK`. - `pnpm check:dual-build-cjs-loads` exited 3: PREREQUISITE NOT MET, because it needs a whole-workspace `pnpm build`. NOT MEASURED locally; CI runs it. - `--ran`: `69 derived famil(ies) accounted for — 68 run, 1 NOT-MEASURED (1 DERIVED from a recorded exit 3)`. ## Acceptance notes - The `sys_approval_action` object itself still names the step by `step_name` in three places that this card does not cover: - its `titleFormat` (`'{action} · {step_name}'`); - its `display_title` formula, the record title (`nameField`); - its `highlightFields`. So an action record's own title and strip read for example `approve · dual_signoff`. This is not filed: it is a separate surface (the action record's own page and title, not the request page's Timeline), and changing a formula's record title has a wider reach than one column. Carrier: none. --- _Generated by [Claude Code](https://claude.ai/code/session_016g7nYP9wdNx1GDa5XDr7Uy)_ 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_016g7nYP9wdNx1GDa5XDr7Uy Co-authored-by: Claude <noreply@anthropic.com>
1 parent 1ff43b6 commit b8c9590

3 files changed

Lines changed: 32 additions & 2 deletions

File tree

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
'@objectstack/plugin-approvals': patch
3+
---
4+
5+
fix: the approval request page's Timeline shows each action's step by its label, not the node's machine id
6+
7+
Clause-②: no
8+
Metadata-protocol: none
9+
10+
The Timeline tab of the `sys_approval_request` record page lists the request's `sys_approval_action` rows. Its step column asked for `step_name`, which holds the Approval node's id (for example `dual_signoff`), so every row showed that id. The column is now `step_label`, the step's label that the service writes on every row and the boot backfill fills on older rows. The strip's step chip (`current_step_label`) and the object's own lists already show this label.

‎packages/plugins/plugin-approvals/src/sys-approval-request-page.test.ts‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,23 @@ describe('sys_approval_request detail page — the slot map', () => {
217217
expect((SysApprovalAction.fields as AnyRec).request_id).toMatchObject({ type: 'lookup', reference: 'sys_approval_request' });
218218
});
219219

220+
it('names each Timeline step by its label, step_label, never by the node\'s machine id, step_name', () => {
221+
// Both are stored on every `sys_approval_action` row: `step_name` is the
222+
// Approval node's id (`dual_signoff`), `step_label` the step's label the
223+
// service copies from the request (`actionRow`). The existence check below
224+
// cannot tell them apart, since both are declared fields, so the choice is
225+
// pinned here, the way the strip's `current_step_label` is.
226+
const [timeline] = TAB_ITEMS[1].children as AnyRec[];
227+
const columns = timeline.properties.columns as string[];
228+
const fields = SysApprovalAction.fields as AnyRec;
229+
expect({ label: columns.includes('step_label'), machine: columns.includes('step_name') })
230+
.toEqual({ label: true, machine: false });
231+
expect(fields.step_label).toMatchObject({ type: 'text', label: 'Approval Step' });
232+
// Control: the machine id stays a declared field. It is dropped from the
233+
// Timeline, not from the object.
234+
expect(fields.step_name).toMatchObject({ type: 'text' });
235+
});
236+
220237
it('every field the page names exists on its object', () => {
221238
const requestFields = Object.keys(SysApprovalRequest.fields);
222239
const actionFields = Object.keys(SysApprovalAction.fields);

‎packages/plugins/plugin-approvals/src/sys-approval-request.page.ts‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,10 @@ import type { Page } from '@objectstack/spec/ui';
6161
* above, so the Details tab does not draw it as a row.
6262
* - `tabs` is authored: Details (`record:details`, a bare node: see the
6363
* strip above) and Timeline — `sys_approval_action` as a
64-
* related list keyed on `request_id`, newest first. The `tabs` slot is
64+
* related list keyed on `request_id`, newest first. Its step column is
65+
* `step_label` (the step's label, stored on every row), not `step_name`
66+
* (the node's machine id, such as `dual_signoff`), as the strip's step
67+
* chip is `current_step_label`. The `tabs` slot is
6568
* authored rather than `details` because the console builds the tab strip
6669
* from `tabs` when both are present; the details body therefore lives in
6770
* the first tab here, and the page authors no `details` slot.
@@ -120,7 +123,7 @@ export const SysApprovalRequestDetailPage: Page = {
120123
properties: {
121124
objectName: 'sys_approval_action',
122125
relationshipField: 'request_id',
123-
columns: ['created_at', 'action', 'actor_id', 'step_name', 'comment', 'attachments'],
126+
columns: ['created_at', 'action', 'actor_id', 'step_label', 'comment', 'attachments'],
124127
sort: [{ field: 'created_at', order: 'desc' }],
125128
limit: 50,
126129
showViewAll: true,

0 commit comments

Comments
 (0)