Skip to content

Commit a71564f

Browse files
fix(app-shell): the approval step line draws the route the request's run took, not the flow graph's first branch (#26666)
<!-- claude-projects-attribution: {"github_login":"zhuangjianguo"} --> _Requested by **Steedos** · [project thread](https://claude.ai/code/project/chan_018ETKaNwMZCNRYD7D8Q9Ubb?thread=cmsg_018ETKaNwMZCNRYD7D8Q9UbbEUMTQYvfyB64ouDjzAxUjd)_ Fixes #26563 Clause-②: no Metadata-protocol: none ## 维护者速读 - **改了什么**:审批步骤线不再画服务端 `flow_steps`(流程图从起点沿 approve/true/第一条边走出的那一条主干),改为只画本次流程运行真实走过的步骤:同一 `flow_run_id` 下已通过的审批请求,按到达先后排列,最后是当前待审步骤;当前步骤之后一概不画。业务记录的审批面板照此绘制;审批请求页只持有自身这一行,证明不了任何已走步骤,所以暂不画步骤线。 - **为什么改**:hotclm 的合同审批走「直属上级 → 仅财务」时,步骤线却写着「直属上级 · 法务负责人 + 财务负责人(会签) · 分管领导 · 总经理」,审批人被告知要与法务会签、后面还有两级,实际都不会发生。分诊裁定:⛔ 永不画猜测的路径。 - **风险与回滚**:纯 UI 显示改动,无契约、无元数据、无服务端改动。代价是过渡期内审批请求页不再显示步骤线,业务记录面板上看不到自己未参与的步骤(列表读只对参与者开放)。回滚 = revert 本 PR。 - **先看**:① `ui/packages/app-shell/src/views/RecordApprovalsPanel.tsx` 新增的 `visitedApprovalSteps`(哪些请求算「已走过」);② `ui/packages/app-shell/src/views/approval-decision/ApprovalDecisionPanel.tsx` 删去的那一行步骤线;③ `RecordApprovalsPanel.visitedRoute-26563.test.tsx`。 - **两分钟验证**:`pnpm --dir ui exec vitest run packages/app-shell/src/views/RecordApprovalsPanel.visitedRoute-26563.test.tsx`,预期 11 个测试全绿,其中报告的路由只画出「直属上级、财务负责人」两步。 - **需要你做的**:无,席位落地。 ## What changes The approval step line drew the request's `flow_steps`. That field is built by `plugin-approvals`' `attachFlowSteps`, which walks the flow graph from its start node and takes the `approve` edge, else the `true` edge, else the first edge at each node. It marks done, current and upcoming against that one trunk. It is not the route the request takes. A request that a decision sent down another branch was drawn on rungs it never visits. When the request's own node is off the trunk, it is drawn on none of the trunk's rungs as current. A rung reached after a side branch rejoins showed the trunk's branch as done. Measured first, as the triage asked: the single request read (`GET /api/v1/approvals/requests/:id`) carries neither a resolved route nor the visited nodes. Beyond `flow_steps`, the row names only its own node (`flow_node_id`, `current_step`, `step_label`) and its run (`flow_run_id`). So the route read is a `plugin-approvals` child (see Acceptance notes), and this PR draws only what a request row proves: - **Business record approvals panel.** `visitedApprovalSteps(pendingRequest, requests)` builds the line from the request rows the panel already holds (the list read, no new request). A passed step is a request with the same `flow_run_id`, on another node, `approved`, and opened before the pending one. A node approved in several rounds is drawn once, at its latest round. The pending request comes last. Nothing ahead of it is drawn, because no request row says which branch the run takes next. - **Approval request page** (`record:approval_decision`). The decision panel no longer draws a step line. Its bound row proves only its own step, which the page header already names, and one step is no line. - `ApprovalRequestLite` declares the served `flow_run_id` and `flow_node_id`. The `flow_steps` doc says why no surface draws it. - `ApprovalStepLine`'s markup is unchanged. Its header now says the caller owns the proof of the steps it hands in, and the stale paragraph about the inbox sheet's copy of the stepper is gone (that sheet no longer draws one). - The app-shell README's two approval paragraphs say the same. ## Tests - New `RecordApprovalsPanel.visitedRoute-26563.test.tsx`, 11 tests. The panel cases use the reported route (manager → finance only) with the served trunk attached. They pin a branch that rejoins the trunk (manager → legal only → executive), a request at the run's first rung, and a viewer served only the pending row. The unit cases for `visitedApprovalSteps` pin ordering, another run, a step not approved (`returned`, `rejected`), a row opened after the pending one, round dedup, an earlier round of the pending node, a decided request, an unlabeled step, and the controls for a missing run, node or open time. - `RecordApprovalsPanel.stepProgressVertical.test.tsx`: the layout contract is unchanged. Its fixtures are now a run's request rows, so they reach the line the way the panel builds it. The connector-tint case now pins that every segment is green, because the line draws nothing ahead of the pending step. - `ApprovalDecisionPanel.stepLine-12491.test.tsx`: rewritten to pin the absence of the line. The reported row with its served trunk draws no line and none of the trunk's rungs, a decided row draws none either, and the tally still draws above the decisions. The deleted layout cases duplicate the ones `RecordApprovalsPanel.stepProgressVertical.test.tsx` pins over the same `ApprovalStepLine` markup. - `approvalRequestsDataSource.servedPageStepLine-12491.test.tsx` (console, the real served page): the step-line cases now pin that no line and no other trunk rung is drawn, at pending, at decided, and for a person-submitted request. The flow-origin cases are unchanged. <details><summary>Test readings, head 4743eb8 (all under scripts/pm/os-verify-lock.sh, run from ui/)</summary> - The four touched suites: `vitest run` over `RecordApprovalsPanel.visitedRoute-26563`, `RecordApprovalsPanel.stepProgressVertical`, `ApprovalDecisionPanel.stepLine-12491` and the console `approvalRequestsDataSource.servedPageStepLine-12491`: Test Files 4 passed (4), Tests 24 passed (24), VERDICT command-exit 0. - Every approval test file in `packages/app-shell` and `apps/console` (by file name, plus every test that names `RecordApprovalsPanel`, `ApprovalDecisionPanel`, `ApprovalStepLine`, `useRecordApprovals`, `approval-decision` or `approval-progress`): Test Files 68 passed (68), Tests 765 passed (765), VERDICT command-exit 0, 7m00s. The whole `packages/app-shell` suite (1757 test files) was not run locally; CI's Test UI shards run it. - `pnpm --filter @object-ui/app-shell run type-check` (both projects; `tsconfig.test.json --listFilesOnly` lists the three touched app-shell test files): VERDICT command-exit 0. `pnpm --filter @object-ui/console run type-check` (`--listFilesOnly` lists the touched console test): VERDICT command-exit 0. </details> <details><summary>Reverse verification, one-shot (no test file kept for it)</summary> - **Record panel.** `node scripts/ablation-replace.mjs` replaced the panel's step line `steps={visitedApprovalSteps(pendingRequest, requests)}` with the old `steps={pendingRequest?.flow_steps}`. The mutation landed: anchor 1 to 0, blob `ddd69d0e14eb` to `347c203eb6ff`. `RecordApprovalsPanel.visitedRoute-26563` then failed its 4 panel tests (Tests 4 failed, 7 passed; the 7 are the unit cases, which call `visitedApprovalSteps` directly). The tool restored the file: blob `ddd69d0e14eb` equal to HEAD, `git diff HEAD` empty. - **Request page.** `ApprovalDecisionPanel.tsx` was restored to the merge base blob (`f61253e4b319`, which still draws `steps={request.flow_steps}`) under an EXIT trap. The decision panel suite and the console served-page suite then failed 6 of 9 tests (Test Files 2 failed). The 3 still passing are the page-parse case, the flow-origin case and the one-step control. Restored to HEAD blob `4bf7bdb3f704`, with `git status` clean. </details> ## Acceptance notes - **Out of scope, for the seat to file (class a): the route read belongs to `plugin-approvals`.** `ApprovalService.attachFlowSteps` serves the flow graph's trunk as `flow_steps` on every single read. For the reported request (node `finance_only`), every trunk entry is `upcoming` and its own node is absent. The child should serve the route the run took and only the steps ahead that the run's state determines. Then the request page can draw its line again, and `visitedApprovalSteps` can be deleted in favour of the served route. `flow_steps`' contract text in `packages/spec/src/contracts/approval-service.ts` reads "The owning flow's approval steps in graph order", so the child either changes that text or adds a field. Either way it is a contract change. - **Viewer-scoped steps.** The list read serves a request only to its participants (slate, submitter, override actor). On the business record a viewer who took no part in an earlier rung does not see it, so the line can be shorter than the run's route, never wrong. The finance controller in the report sees no line on the record panel (one step). The submitter sees the whole route. - **Request page: no line rather than a one-step line.** The seat suggested a one-step "current step" line there. A one-step line would repeat the step the page header already names, and `ApprovalStepLine`'s own gate draws nothing under two steps, so the page draws none. - **Steps not drawn.** A rung a `reject` edge routes to an approval node, and a rung sent back for revision, are not "passed" (not `approved`), so they are left out. A route that passes through them shows only its approved rungs. - The `upcoming` styling in `ApprovalStepLine` has no caller today. It stays for the served route the child brings back. ## Verification <details><summary>Derived gate sweep, head 4743eb8</summary> `node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstack` derived 34 commands from the change set against merge base `fb91e9793`. Each command ran with its exit code captured before any pipe, and all 34 exited 0. `check:type-check-debt` ran under the verify lock, with VERDICT command-exit 0. The PR-body gates (`check-changeset-no-major`, `check-closing-keyword-parity`, `check-adr-0087-registration`) read this body through `GITHUB_EVENT_PATH`. `dispatch-gates --ran` reconciliation: `✓ 34 derived famil(ies) accounted for — 34 run, 0 NOT-MEASURED`. </details> - `origin/main` gained 12 commits after the branch point, and none of them touches a file of this diff. The branch was not merged with main before opening, and CI runs on the merge ref. - No dogfood battery: the title carries no `!` and `Clause-②` carries no `(narrowing)` arm. --- _Generated by [Claude Code](https://claude.ai/code/session_01QsR2jThx2NXgeJ4uCUi1qo)_ Co-authored-by: Claude <noreply@anthropic.com>
1 parent d434481 commit a71564f

10 files changed

Lines changed: 487 additions & 267 deletions
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
'@object-ui/app-shell': patch
3+
'@object-ui/console': patch
4+
---
5+
6+
fix(app-shell): the approval step line draws the route the request's run took, not the flow graph's first branch
7+
8+
Clause-②: no
9+
Metadata-protocol: none
10+
11+
The approval step line used to draw the request's `flow_steps`. The approvals read builds that list by walking the flow from its start and taking the `approve` edge, else the `true` edge, else the first edge at every node. So a request that a decision routed down another branch showed rungs it never reaches. A contract routed from the manager to the finance-only rung read "manager · legal + finance (joint) · executive · general manager" while it waited on the finance controller.
12+
13+
What changes:
14+
15+
- On a business record's approvals panel, the line now shows the steps the pending request's flow run has passed, oldest first, then the pending step. Each step comes from a request the run actually opened: same flow run, another node, approved, and opened before the pending one. A step approved in several rounds is shown once. Nothing ahead of the pending step is shown, because no request row says which branch the run takes next.
16+
- The approvals list serves a request only to its participants, so a step the viewer had no part in is left out rather than guessed. With fewer than two steps, no line is drawn.
17+
- On the approval request page, the decision panel no longer draws a step line. Its row proves only its own step, which the page header already names. The line returns there once the approvals read serves the route the run takes.
18+
19+
What to do: nothing. Nothing a flow, page or object declares changes.

‎ui/apps/console/src/services/approvalRequestsDataSource.servedPageStepLine-12491.test.tsx‎

Lines changed: 30 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,15 @@
44
*
55
* objectui#12491 (face 5 of ruling C on objectui#12438, the seat's Q1 A, Q2 A
66
* and Q3 A): on the page objectstack serves for an approval request, a
7-
* multi-step request shows its vertical step line, and a request no person
8-
* submitted shows its flow origin, as the approvals inbox's request sheet
9-
* shows both.
7+
* request no person submitted shows its flow origin, as the approvals inbox's
8+
* request sheet shows it.
9+
*
10+
* objectstack#26563: the same page draws NO step line. The row's `flow_steps`
11+
* is the flow graph's trunk (`attachFlowSteps` walks it from the start,
12+
* preferring `approve`, then `true`, then the first edge), not the route this
13+
* request takes, so a request a decision sent down another branch was drawn on
14+
* rungs it never visits. The row proves only its own step, so the page draws
15+
* none until the approvals read serves the route the run takes.
1016
*
1117
* Mounted as the other served-page pins mount it: the REAL `RecordDetailView`,
1218
* opened by the generic record route under the console's `ApprovalRecordReads`,
@@ -283,51 +289,54 @@ afterEach(() => {
283289
served = FLOW_ROW;
284290
});
285291

286-
describe('the served request page shows the flow origin and the step line (objectui#12491)', () => {
292+
describe('the served request page shows the flow origin (objectui#12491) and no guessed step line (objectstack#26563)', () => {
287293
it('the served page parses as a spec page, with no node or prop added for either', () => {
288294
const parsed = PageSchema.safeParse(SERVED_PAGE);
289295
expect(parsed.success, JSON.stringify(parsed.error?.issues ?? [])).toBe(true);
290296
expect(SERVED_PAGE.slots.actions).toEqual([{ type: 'record:approval_decision' }]);
291297
});
292298

293-
it('a multi-step request shows its vertical step line, every step in order, the current one marked', async () => {
299+
it('a multi-step request served with its flow trunk draws no step line, and none of the trunk\'s other rungs', async () => {
294300
const panel = await openServedPage(FLOW_ROW);
295-
const line = await within(panel).findByLabelText(PACK.stepProgress, undefined, { timeout: 8000 });
296-
expect(line.tagName).toBe('OL');
297-
expect(line.getAttribute('class')?.split(/\s+/)).toContain('flex-col');
298-
const rows = within(line).getAllByRole('listitem');
299-
expect(rows.map((r) => r.textContent)).toEqual(['Manager review', '2Finance review', '3Director sign-off', '4CFO sign-off']);
300-
expect(within(rows[1]).getByText('Finance review').getAttribute('class')?.split(/\s+/)).toContain('font-medium');
301-
// A first_response node carries no tally; the line is drawn without one.
301+
await within(panel).findByRole('button', { name: 'Approve' }, { timeout: 8000 });
302+
expect(within(panel).queryByLabelText(PACK.stepProgress)).toBeNull();
303+
expect(within(panel).queryByRole('list')).toBeNull();
304+
// The trunk's rungs past this request's own node are guesses: none is drawn.
305+
for (const rung of ['Manager review', 'Director sign-off', 'CFO sign-off']) {
306+
expect(pageText()).not.toContain(rung);
307+
}
308+
// A first_response node carries no tally.
302309
expect(within(panel).queryByRole('progressbar')).toBeNull();
303310
});
304311

305312
it('a request served with no submitter is marked with the flow origin', async () => {
306313
expect('submitter_id' in FLOW_ROW).toBe(false);
307314
const panel = await openServedPage(FLOW_ROW);
308-
await within(panel).findByLabelText(PACK.stepProgress, undefined, { timeout: 8000 });
309-
expect(marker(panel)?.textContent).toBe(PACK.flowOrigin);
315+
const origin = await within(panel).findByTestId('approval-decision-flow-origin', undefined, { timeout: 8000 });
316+
expect(origin.textContent).toBe(PACK.flowOrigin);
310317
});
311318

312-
it('a decided request still shows its line and its origin', async () => {
319+
it('a decided request shows its origin and still no step line', async () => {
313320
const decided = {
314321
...FLOW_ROW,
315322
status: 'approved',
316323
flow_steps: FLOW_STEPS.map((s) => ({ ...s, state: 'done' })),
317324
viewer: { can_act: false, is_submitter: false, can_override: false },
318325
};
319326
const panel = await openServedPage(decided);
320-
const line = await within(panel).findByLabelText(PACK.stepProgress, undefined, { timeout: 8000 });
321-
expect(within(line).getAllByRole('listitem')).toHaveLength(FLOW_STEPS.length);
322-
expect(marker(panel)?.textContent).toBe(PACK.flowOrigin);
327+
const origin = await within(panel).findByTestId('approval-decision-flow-origin', undefined, { timeout: 8000 });
328+
expect(origin.textContent).toBe(PACK.flowOrigin);
329+
expect(within(panel).queryByLabelText(PACK.stepProgress)).toBeNull();
323330
});
324331

325-
it('CONTROL: a request a person submitted carries no flow-origin marker, and its line is unchanged', async () => {
332+
it('CONTROL: a request a person submitted carries no flow-origin marker, and no step line either', async () => {
326333
const panel = await openServedPage(HUMAN_ROW);
327-
const line = await within(panel).findByLabelText(PACK.stepProgress, undefined, { timeout: 8000 });
328-
expect(within(line).getAllByRole('listitem')).toHaveLength(FLOW_STEPS.length);
334+
// The decision button gates on the served row's `viewer`, which only the
335+
// approvals get carries: once it shows, the panel is bound to that row.
336+
await within(panel).findByRole('button', { name: 'Approve' }, { timeout: 8000 });
329337
expect(marker(panel)).toBeNull();
330338
expect(pageText()).not.toContain(PACK.flowOrigin);
339+
expect(within(panel).queryByLabelText(PACK.stepProgress)).toBeNull();
331340
});
332341

333342
it('CONTROL: a one-step flow draws no line', async () => {

‎ui/packages/app-shell/README.md‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1180,7 +1180,8 @@ for a longer walkthrough.
11801180

11811181
When a record has approval requests, its detail page grows an **Approvals
11821182
tab** — a peer of Details/Related with a request-count badge (#3461):
1183-
which step the approval sits at (with the flow's step strip), the
1183+
which step the approval sits at (with the step line of the route its flow
1184+
run took: the steps it passed, then the pending one), the
11841185
server-computed decision progress (quorum tally, per-group 会签 ticks), the
11851186
**waiting-on** approvers resolved to display names (group approvers labeled
11861187
with their group), one chronological decision timeline merged across all of
@@ -1251,13 +1252,12 @@ summary is not drawn.
12511252
Two more parts come from the same request row. A request no person submitted
12521253
(its `submitter_id` absent or null, as the approvals get serves a request a
12531254
flow run opened with no user context) is marked "Flow-initiated", above the
1254-
summary; a request a person submitted carries no marker. Below the summary,
1255-
when the owning flow has more than one approval step (`flow_steps`), the
1256-
block draws the flow's vertical step line, done / current / upcoming, at any
1257-
status: a decided request and a node with no progress tally draw it too. The
1258-
line is the same stepper the record approvals panel draws, and it never
1259-
scrolls sideways. The marker and the line's accessible name are the
1260-
Approval Center's `approvalsInbox.*` rows.
1255+
summary; a request a person submitted carries no marker. The block draws no
1256+
step line: the row's `flow_steps` is the flow graph's first branch at every
1257+
decision, not the route this request takes, and the row proves only its own
1258+
step, which the page header names. The record approvals panel draws the line
1259+
from the run's own request rows instead. The marker is the Approval Center's
1260+
`approvalsInbox.flowOrigin` row.
12611261

12621262
## User-scoped state (favorites, recent items)
12631263

‎ui/packages/app-shell/src/hooks/useRecordApprovals.ts‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,17 @@ export interface ApprovalRequestLite {
106106
step_label?: string;
107107
/** Display name of the submitter (`sys_user.name`), when resolvable. */
108108
submitter_name?: string;
109-
/** Owning flow's approval steps for progress display (single reads only). */
109+
/**
110+
* Owning flow's approval steps in graph order (single reads only). ⚠️ The
111+
* server walks one trunk of the graph, so this is NOT the route the request
112+
* takes past a decision, and no surface draws it (objectstack#26563): the
113+
* record's step line is read off `flow_run_id` / `flow_node_id` instead.
114+
*/
110115
flow_steps?: Array<{ id: string; label: string; state: 'done' | 'current' | 'upcoming' }>;
116+
/** The flow run that opened this request; every request of one run shares it. */
117+
flow_run_id?: string;
118+
/** The approval node of the run this request was opened for. */
119+
flow_node_id?: string;
111120
/**
112121
* Server-computed capability of the current viewer (framework#3310), attached
113122
* by `getRequest`. `is_submitter` gates the record page's remind affordance

‎ui/packages/app-shell/src/views/RecordApprovalsPanel.stepProgressVertical.test.tsx‎

Lines changed: 34 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,12 @@
4545
* CJK labels, verbatim) is exercised directly, and the invariance test rules
4646
* out a count threshold that could put some other length back on the old path.
4747
*
48+
* The steps reach the line as the panel builds them since objectstack#26563:
49+
* off the pending request's run, one approved request per passed step and the
50+
* pending request last (`visitedApprovalSteps`). So each fixture below is a
51+
* run's request rows, every step but the last passed, and no step is ahead of
52+
* the pending one.
53+
*
4854
* No build artifact sits between the edit and this test — the root Vitest
4955
* config aliases every `@object-ui` specifier at that package's source.
5056
*/
@@ -67,7 +73,8 @@ import { RecordApprovalsPanel } from './RecordApprovalsPanel';
6773
/** The strip's accessible name, as the panel spells it through `tr`. */
6874
const STEPPER_LABEL = 'Approval steps';
6975

70-
type Step = NonNullable<ApprovalRequestLite['flow_steps']>[number];
76+
/** One step of a run: the approval node a request was opened for, and its label. */
77+
type Step = { id: string; label: string };
7178

7279
/**
7380
* The reporter's actual 6-step flow, labels verbatim (objectui#5554). They are
@@ -78,44 +85,49 @@ type Step = NonNullable<ApprovalRequestLite['flow_steps']>[number];
7885
* would quietly move the fixture out of the failing regime.
7986
*/
8087
const REPORTED_STEPS: Step[] = [
81-
{ id: 's1', label: '需求部门负责人初审', state: 'done' },
82-
{ id: 's2', label: '工厂生产工艺负责人审核', state: 'done' },
83-
{ id: 's3', label: '工厂业财审核(确认单价/派工工时)', state: 'current' },
84-
{ id: 's4', label: '事业部成本改善经理加审', state: 'upcoming' },
85-
{ id: 's5', label: '区域总经理+事业部业财运营总监会审', state: 'upcoming' },
86-
{ id: 's6', label: '工厂厂长审批', state: 'upcoming' },
88+
{ id: 's1', label: '需求部门负责人初审' },
89+
{ id: 's2', label: '工厂生产工艺负责人审核' },
90+
{ id: 's3', label: '工厂业财审核(确认单价/派工工时)' },
91+
{ id: 's4', label: '事业部成本改善经理加审' },
92+
{ id: 's5', label: '区域总经理+事业部业财运营总监会审' },
93+
{ id: 's6', label: '工厂厂长审批' },
8794
];
8895

8996
/** A synthetic flow of `n` steps, for the step-count invariance sweep. */
9097
function stepsOfLength(n: number): Step[] {
9198
return Array.from({ length: n }, (_, i) => ({
9299
id: `syn_${i}`,
93100
label: `区域总经理+事业部业财运营总监会审 ${i + 1}`,
94-
state: i === 0 ? 'current' : 'upcoming',
95-
})) as Step[];
101+
}));
96102
}
97103

98-
function pendingWith(flow_steps: Step[]): ApprovalRequestLite {
104+
/** The request the run opened at `step`, the `i`-th step it reached. */
105+
function requestAt(step: Step, i: number, status: string): ApprovalRequestLite {
99106
return {
100-
id: 'req_pending',
107+
id: `req_${step.id}`,
101108
process_name: 'flow:purchase',
102109
process_label: 'Purchase Approval',
103110
object_name: 'purchase_order',
104111
record_id: 'rec_1',
105-
status: 'pending',
112+
status,
106113
submitter_id: 'u_submitter',
107114
submitter_name: 'Zhou Ming',
108-
submitted_at: '2026-08-20T08:00:00Z',
115+
submitted_at: `2026-08-20T08:${String(i).padStart(2, '0')}:00Z`,
116+
flow_run_id: 'run_1',
117+
flow_node_id: step.id,
118+
current_step: step.id,
119+
step_label: step.label,
109120
viewer: { can_act: false, is_submitter: false },
110-
flow_steps,
111121
};
112122
}
113123

114-
function renderWithSteps(flow_steps: Step[]) {
115-
const pending = pendingWith(flow_steps);
124+
/** A run that passed every step but the last, and waits on the last. */
125+
function renderWithSteps(steps: Step[]) {
126+
const rows = steps.map((s, i) => requestAt(s, i, i === steps.length - 1 ? 'pending' : 'approved'));
127+
const pending = rows[rows.length - 1];
116128
return render(
117129
<RecordApprovalsPanel
118-
approvals={{ available: true, requests: [pending], pendingRequest: pending }}
130+
approvals={{ available: true, requests: [...rows].reverse(), pendingRequest: pending }}
119131
currentUserId="u_viewer"
120132
/>,
121133
);
@@ -254,10 +266,10 @@ describe('RecordApprovalsPanel — vertical step stepper (objectui#5554)', () =>
254266
expect(rows.slice(0, -1).every((r) => rail(r) !== undefined)).toBe(true);
255267
expect(rail(rows[rows.length - 1])).toBeUndefined();
256268

257-
// s2 (done) and s3 (current) are the steps rows 1 and 2 lead into, so
258-
// those segments are green; s4 is upcoming, so row 2's successor is not.
259-
expect(tokens(rail(rows[0])!)).toContain('bg-emerald-300');
260-
expect(tokens(rail(rows[1])!)).toContain('bg-emerald-300');
261-
expect(tokens(rail(rows[2])!)).toContain('bg-border');
269+
// Every step a segment leads into is passed or pending, so every segment
270+
// is green: the line draws nothing ahead of the pending step.
271+
for (const row of rows.slice(0, -1)) {
272+
expect(tokens(rail(row)!)).toContain('bg-emerald-300');
273+
}
262274
});
263275
});

‎ui/packages/app-shell/src/views/RecordApprovalsPanel.tsx‎

Lines changed: 64 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ import {
3535
useApproverDirectory,
3636
type ApproverDirectory,
3737
} from '../hooks/useApproverDirectory.js';
38-
import { ApprovalStepLine } from './approval-progress/ApprovalStepLine.js';
38+
import { ApprovalStepLine, type ApprovalFlowStep } from './approval-progress/ApprovalStepLine.js';
3939
import { DecisionProgressIndicator } from './approval-progress/DecisionProgressIndicator.js';
4040
import { eligibleApproverCount } from './approval-progress/eligibleApprovers.js';
4141

@@ -206,6 +206,63 @@ function stepDisplayText(
206206
return label || (machineName ? prettifyMachineName(machineName) : null);
207207
}
208208

209+
/**
210+
* The steps the record's step line draws for `current`: the approval steps
211+
* its flow run has already passed, oldest first, then `current` itself
212+
* (objectstack#26563). Every step is read off a request row the run really
213+
* opened, never off the flow's graph.
214+
*
215+
* The approvals get's `flow_steps` is not this request's route: the server
216+
* walks the flow from its start preferring `approve`, then `true`, then the
217+
* first edge, and marks done / current / upcoming against that one trunk. A
218+
* request a decision sent down another branch is then shown on rungs it never
219+
* visits, and a rung a branch rejoins after shows the trunk's side-step as
220+
* done. So the line is built from facts instead, until that read serves the
221+
* route itself:
222+
*
223+
* - a passed step is a request of the same `flow_run_id`, on another node,
224+
* `approved`, opened before `current`; a node approved in several rounds
225+
* (ADR-0044) is drawn once, at its latest round;
226+
* - nothing ahead of `current` is drawn: no request row says which branch the
227+
* run takes next.
228+
*
229+
* `requests` is the list read, which serves a request only to its
230+
* participants, so a step this viewer took no part in is missing from the
231+
* line rather than guessed. A row without a run, node or open time draws no
232+
* line at all.
233+
*/
234+
export function visitedApprovalSteps(
235+
current: ApprovalRequestLite | null | undefined,
236+
requests: ReadonlyArray<ApprovalRequestLite>,
237+
): ApprovalFlowStep[] {
238+
const runId = current?.flow_run_id;
239+
const nodeId = current?.flow_node_id;
240+
const openedAt = current?.submitted_at;
241+
if (!current || !runId || !nodeId || !openedAt) return [];
242+
243+
const passed = new Map<string, { row: ApprovalRequestLite; at: string }>();
244+
for (const r of requests) {
245+
const node = r.flow_node_id;
246+
const at = r.submitted_at;
247+
if (r.flow_run_id !== runId || !node || node === nodeId) continue;
248+
if (r.status !== 'approved' || !at || at >= openedAt) continue;
249+
const prev = passed.get(node);
250+
if (!prev || prev.at < at) passed.set(node, { row: r, at });
251+
}
252+
253+
const step = (r: ApprovalRequestLite, id: string, state: ApprovalFlowStep['state']): ApprovalFlowStep => ({
254+
id,
255+
label: stepDisplayText(r.step_label, r.current_step || id) ?? id,
256+
state,
257+
});
258+
return [
259+
...[...passed.entries()]
260+
.sort(([, a], [, b]) => a.at.localeCompare(b.at))
261+
.map(([node, { row }]) => step(row, node, 'done')),
262+
step(current, nodeId, current.status === 'approved' ? 'done' : 'current'),
263+
];
264+
}
265+
209266
/**
210267
* Merge the per-request action threads into one chronological (oldest-first)
211268
* timeline. Explicit sort — the panel must not depend on per-request server
@@ -424,12 +481,12 @@ export const RecordApprovalsPanel: React.FC<RecordApprovalsPanelProps> = ({
424481
</div>
425482

426483
<div className="px-4 py-3 space-y-3">
427-
{/* Flow-level step strip — where in the multi-level flow this record
428-
sits; present on the enriched pending row only (single reads).
429-
Vertical at every step count (objectui#5554); the markup is the
430-
one `ApprovalStepLine` the approval request page's decision panel
431-
draws too (objectui#12491), and it draws nothing under two steps. */}
432-
<ApprovalStepLine steps={pendingRequest?.flow_steps} />
484+
{/* Flow-level step line — the steps the pending request's run has
485+
passed, then the pending one, read off the run's own request rows
486+
and never off the flow graph (objectstack#26563, see
487+
`visitedApprovalSteps`). Vertical at every step count
488+
(objectui#5554); it draws nothing under two steps. */}
489+
<ApprovalStepLine steps={visitedApprovalSteps(pendingRequest, requests)} />
433490

434491
{/* Aggregation progress — the pending node's server-computed tally
435492
(unanimous / quorum approvals, per-group countersign), drawn by

0 commit comments

Comments
 (0)