Skip to content

Commit d57d6ee

Browse files
feat(app-shell): fold the approver's decision band on a record under approval (#34641)
<!-- claude-projects-attribution: {"github_login":"os-support-ai"} --> _Requested by **Yibo Wang** · [project thread](https://claude.ai/code/project/chan_01BVUyyPie8gHwoPM18iABwB?thread=cmsg_01BVUyyPie8gHwoPM18iABwBLW6dHPW6sSheA32XPKZzPV)_ repo:objectstack#3 · os-support-ai · session_01WGufzg2evNa1V3zxrQq3KX Fixes #34361 Clause-②: yes (widening — new @object-ui/i18n en keys only; no metadata/schema accept set) Metadata-protocol: none ## 维护者速读 - 改了什么:审批人打开审批中的记录时,原来平铺的 7 个审批按钮收成一条审批条:前面一行状态「待你审批 · 第 N 步 · 步骤名 · 提交人 X」,只露出「通过」「拒绝」两个按钮,转签 / 退回修改 / 退回补充 / 回复(审批人兼提交人还有撤回、催办)都放进一个「更多」菜单。业务记录页和审批请求页是同一条。记录自己标题栏的按钮不动。 - 为什么改:裁决 A(6917968848)。客户反馈记录页上有「两层菜单」,分不清哪一排是自己要做的事。 - 风险与回滚:只改按钮摆放,谁能审批、每个按钮的显示条件、对话框和发出的请求都不变;越权管理员的折叠(琥珀色菜单)和只是提交人的查看者都不变。回滚就是 revert 本 PR。 - 先看:① `ui/packages/app-shell/src/views/DeclaredActionsBar.tsx` 里 `decisionBand` 那段(决定哪些按钮留在外面、何时收进菜单);② `ui/packages/app-shell/src/utils/approvalDecisionFold.ts`(按动作声明的 variant 判断,不按名字);③ 两个调用点各加了一个 `foldDecisions`。 - 两分钟验证:以审批人身份打开一条审批中的业务记录(或它的审批请求页),应看到一行「待你审批 · 第 N 步 …」,右边只有「通过」「拒绝」和一个「⋯ 更多」,点开「更多」能看到转签、退回修改、退回补充、回复。 - 需要你做的:无,席位落地。 ## What changes Ruling A (6917968848), executed as the coordinator's plan (6936836041) lays it out. - **`DeclaredActionsBar` gains a second fold, `foldDecisions`** (the approver fold). It applies to a viewer the server says can act (`viewer.can_act === true`) once more than two of the bar's actions are shown: - a status line names the task (「待你审批」 / "Awaiting your approval"), the step's number on the served route (`flow_route`), the step's label (`step_label`), and the submitter (`submitter_name`, or the existing "You submitted this" when `viewer.is_submitter` is true); - the actions whose declared `variant` is `primary` or `danger` stay buttons (today `approval_approve` and `approval_reject`); the split is read off metadata (`isLeadDecision`), never off a name list, so an action shipped as metadata alone lands in the menu; - every other permitted action goes into one neutral "More approval actions" menu (`DropdownMenu` plus `DeclaredActionButton asMenuItem`, the same mechanism the override fold uses). The trigger is a plain outline button: the amber shield stays the override path's mark; - phone: the status line on top, then one row with the two decisions at equal width (`flex-1`) and the menu trigger at its end. - **Gates and dispatch unchanged.** Every folded action keeps its own `visible`, `disabled` and capability gates and its dialog, and sends the same request. - **`onDrawnActionsChange` semantics unchanged.** Menu actions still count as drawn: a closed menu's actions report through the same visibility probe the override fold uses. The only internal change is that the drawn-set reporter now records a `false` verdict as a key too, so "every action has reported" can be read; the drawn list itself still holds `true` verdicts only. - **Until every action has reported its `visible` verdict, the band folds**, so the usual case never paints a flat row first. With two or fewer shown, the rest stay buttons. - **Disjoint from the admin override fold by construction**: that viewer's `can_act` is `false`. `foldOverrides`, `isOverrideOnlyViewer`, `data-approval-override-folded` and their tests are unchanged. - **Both call sites** pass `foldDecisions`: the business record page (`RecordDetailView`, beside its existing `foldOverrides`) and the request page (`ApprovalDecisionPanel`). - **Deviation from ruling A's wording — reply (`approval_comment`) stays in the band's menu on both pages, not in the approvals panel.** Ruling 6917968848 and the card body say 回复 moves to the approvals panel or the discussion. The complaint (two stacked bars, reply in the button row) is still fixed: reply leaves the button row. Seat repo:objectstack#3 accepted the deviation on this reason; a line on #34361 lets the maintainer ask for a panel entry later. Moving it into the `RecordApprovalsPanel` timeline is more than a modest change here: - on the synthesized record page the panel is a tab (`record:approvals`), or a right-column block whose placement depends on the page tier; - the bar cannot tell whether a mounted panel is actually on screen, so a panel entry plus a menu fallback can draw reply twice or not at all; - the panel has no action runtime of its own: it would need a second `ActionProvider` and the request definition just to run one declared action. In the menu, reply is reachable on every layout. - **Recall for an approver who also submitted**: in the menu (allowed by the plan). - **Waited-days hint: not added.** No threshold logic for it exists in `app-shell`. The only age logic is the console inbox's relative-time formatter plus an SLA due date that the record page's request row does not carry. So there was nothing to reuse, and inventing a threshold is out of scope. - **New `@object-ui/i18n` keys (four), in every pack**: `approvalsInbox.awaitingYourDecision`, `approvalsInbox.stepNumber`, `approvalsInbox.submittedByName`, `approvalsInbox.moreDecisionActions`. en and zh-Hans are hand-written, zh-Hant is regenerated by `gen:zh-hant` (byte-identical to what was written), and the other packs are translated. Reused keys: `approvalsInbox.submittedByYou`, `common.more`, `common.actions`. ## Why Ruling A: 「A 收成一条“待你审批”」 — the approver's decision actions stay in their own band above the page body, folded: a status line that names the step, 通过 and 拒绝 as the only buttons, the other decision actions in one menu; the record's header actions do not move; no protocol change. ## Tests - New `ui/packages/app-shell/src/views/__tests__/DeclaredActionsBar.approverFold-34361.test.tsx` (12 tests): - approver: status line, two buttons, every other lever in the menu, in declaration order; - phone layout: `flex-1` on the decisions, the trigger last in the row; - a menu lever dispatches exactly as its button would; - approver plus submitter: remind and recall are in the menu, and the line says "You submitted this"; - an action declared with no variant lands in the menu, not as a button; - the submitter-only viewer is unchanged; - the override-only admin stays on the override fold; - a host without `foldDecisions` is unchanged; - with two or fewer shown, the levers stay buttons; - drawn-set reports: menu levers counted, hidden ones not, and an empty set on unmount; - the request page (`ApprovalDecisionPanel`, real bar) draws the same band, remind included because that page excludes nothing. - New `ui/packages/app-shell/src/utils/approvalDecisionFold.test.ts` (7 tests). - Updated `RecordDetailView.approvalDeclaredActions.test.tsx`: the approver's reassign, send back and request info are read from the band's menu (the override fold set this precedent for the same file). The submitter, override and fail-closed cases are untouched. - `DeclaredActionsBar.foldOverrides-25877.test.tsx` and `utils/approvalOverride.test.ts` are unchanged and green. ## Acceptance notes - **Claim surface amendment 6938979625** (area o3-A, per L1-a 6938968708): the existing test `ui/packages/app-shell/src/views/RecordDetailView.approvalDeclaredActions.test.tsx` is edited (assertion edits only: three approver pins read reassign / send back / request info from the band's menu). - **Sticky band on scroll**: not in ruling A, so not done. The coordinator's plan (6936836041) asks for the maintainer's confirmation first. - **Reply in the panel**: kept in the menu; reasons under What changes. - **Waited-days hint**: not added, because no threshold logic exists to reuse. - **Docs**: `ui/AGENTS.md` #2 asks for a matching `content/docs/frontend/` page. `content/docs/**` is outside this card's claimed file surface, and the bar has no SDUI node type and no page that documents its props today. - **Hot files**: #34631 (#34588, request page) rewrites `ApprovalDecisionPanel.tsx`. `overlap-check` reports a textual conflict with that head in this file. This PR's change there is one prop (`foldDecisions`) on the bar's call site, so whichever lands second keeps that one prop. ## Verification All on head `48d70e28` (origin/main merged at `97defd60` plus later; the merge brought locale-pack and app-shell changes, so the closure was rebuilt and the suites re-run after it). <details><summary>Build of the app-shell dependency closure</summary> `bash scripts/pm/os-verify-lock.sh -c "pnpm turbo run build --filter='@object-ui/app-shell^...' --concurrency=2 && pnpm --dir ui exec vitest run --maxWorkers=2 packages/i18n/ packages/app-shell/src/views/__tests__/DeclaredActionsBar.approverFold-34361.test.tsx packages/app-shell/src/views/__tests__/DeclaredActionsBar.foldOverrides-25877.test.tsx packages/app-shell/src/utils/approvalDecisionFold.test.ts packages/app-shell/src/utils/approvalOverride.test.ts packages/app-shell/src/views/RecordDetailView.approvalDeclaredActions.test.tsx packages/app-shell/src/views/RecordDetailView.approvalRecallGate.test.tsx packages/app-shell/src/views/approval-decision/ apps/console/src/services/approvalRequestsDataSource.decisionPage.test.tsx"` ``` Tasks: 68 successful, 68 total Test Files 115 passed (115) Tests 2059 passed | 13 skipped (2072) os-verify-lock: VERDICT command-exit 0 ``` </details> <details><summary>Wider app-shell sweep (pre-merge tree, same diff)</summary> `pnpm --dir ui exec vitest run --maxWorkers=2 packages/app-shell/src/views/__tests__/ packages/app-shell/src/views/RecordDetailView.approval*.test.tsx … packages/app-shell/src/views/approval-decision/ … apps/console/src/services/approvalRequestsDataSource.decisionPage.test.tsx` ``` Test Files 110 passed (110) Tests 956 passed (956) os-verify-lock: VERDICT command-exit 0 ``` </details> <details><summary>Type check</summary> `pnpm --filter @object-ui/i18n run type-check && pnpm --filter @object-ui/app-shell run type-check` (each runs `tsc --noEmit` and `tsc -p tsconfig.test.json`, so the new tests are compiled): `VERDICT command-exit 0`. </details> <details><summary>Ablation (one, on the variant split)</summary> `node scripts/ablation-replace.mjs --file ui/packages/app-shell/src/utils/approvalDecisionFold.ts --anchor "return typeof variant === 'string' && LEAD_VARIANTS.has(variant);" --replacement "return true; // ABLATION-34361" -- …vitest run …approverFold-34361.test.tsx` ``` ablation-replace: ok mutation landed: anchor 1 -> 0, blob 99b38f5 -> d6d63595670c Tests 6 failed | 6 passed (12) ablation-replace: ok restored: blob == HEAD (99b38f5) and `git diff HEAD` is empty ``` The six failures are exactly the tests that need a non-lead lever in the menu; the six that stayed green do not depend on the split (unchanged viewers, the two-or-fewer case, drawn-set reports). </details> <details><summary>Gates</summary> - `node scripts/pm/dispatch-gates.mjs --commands`: 41 derived commands, all `exit 0`. `--ran` reconciliation: `41 derived, 41 run, 0 NOT-MEASURED, 0 UNRUN (a DERIVED zero — all 41 recorded an exit code)`. That includes `pnpm --dir ui exec vitest run scripts/` (173 files, 5077 passed, 2 skipped). - Run beyond the derivation, all `exit 0`: - `pnpm check:changeset-fixed`; - `pnpm --dir ui run check:i18n-keys` ("Every in-scope call-site key resolves against the en pack"); - `check:i18n-drift`; - `check:i18n-dead-keys` (none of the four new keys is listed); - `check:new-line-citations` (`0 new citation(s)`). - `pnpm --dir ui exec eslint` on the six changed ts/tsx files: exit 0, 0 errors. The warnings are `no-explicit-any`, in the sibling suites' style. - `node scripts/pm/overlap-check.mjs`: clean against origin/main, #34624 and #34628; textual conflict with #34631 in `ApprovalDecisionPanel.tsx` (see Acceptance notes). - Not run locally, CI's: the repo-wide `pnpm lint`, `Test UI` shards, `Type Check UI`. </details> ## Human Minimum - [x] 1. Schemas start as Zod; `packages/spec` holds no runtime logic. (not touched) - [x] 2. Every name I added uses the casing for its kind. - [x] 3. No formatter ran; `pnpm lint` passes. (changed files lint clean; repo-wide run is CI's) - [x] 4. One issue, one branch off an up-to-date `main`, one pull request. - [x] 5. A change that publishes carries a changeset, and both declaration lines are filled in here and in the changeset. - [x] 6. `packages/spec` touched: not touched. - [x] 7. No hand edits to `content/docs/references/`, `packages/*/CHANGELOG.md` or `content/docs/releases/`. - [x] 8. Title, body and comments are in English. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01WGufzg2evNa1V3zxrQq3KX <!-- signed: repo:objectstack#3 · os-support-ai · session_01WGufzg2evNa1V3zxrQq3KX --> --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent e533651 commit d57d6ee

19 files changed

Lines changed: 818 additions & 8 deletions
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
---
2+
'@object-ui/app-shell': patch
3+
'@object-ui/i18n': patch
4+
---
5+
6+
feat(app-shell): a record under approval shows the approver one folded band: a status line, the two decisions as buttons, and one menu for the rest
7+
8+
Clause-②: yes (widening — new @object-ui/i18n en keys only; no metadata/schema accept set)
9+
Metadata-protocol: none
10+
11+
An approver who opens a record under approval used to see every declared decision action as its own button above the page body (Approve, Reject, Reassign, Send back, Request info, Reply, and Recall for an approver who also submitted), beside the record's own action row in the header. The band is now folded for any viewer the server says can act (`viewer.can_act === true`) once more than two of its actions are shown:
12+
13+
- a status line names the task, the step's number on the served route and its label, and the submitter ("You submitted this" for an approver who also submitted);
14+
- the actions whose declared `variant` is `primary` or `danger` (today Approve and Reject) stay buttons; on a phone they share one row at equal width;
15+
- every other action, including one declared with no variant, goes into one neutral "More approval actions" menu. Reply stays in that menu, so it is reachable on every layout.
16+
17+
The business record page and the approval request page draw the same band. Each folded action keeps its own `visible`, `disabled` and permission gates and its own dialog, and sends the same request. Menu actions still count as drawn for `onDrawnActionsChange`. The record's header actions do not move.
18+
19+
Unchanged: the submitter who holds no slot, the override-only administrator (who keeps the existing admin-override fold), a backend that sends no `viewer` block, and any host that does not pass the new `foldDecisions` prop to `DeclaredActionsBar`.
20+
21+
New `@object-ui/i18n` keys, in every pack: `approvalsInbox.awaitingYourDecision`, `approvalsInbox.stepNumber`, `approvalsInbox.submittedByName`, `approvalsInbox.moreDecisionActions`.
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license.
2+
3+
/**
4+
* approvalDecisionFold (objectstack#34361) — the three readings the approver
5+
* band makes off metadata and the served request row.
6+
*/
7+
8+
import { describe, it, expect } from 'vitest';
9+
import { currentStepNumber, isActingApprover, isLeadDecision } from './approvalDecisionFold';
10+
11+
describe('isLeadDecision (objectstack#34361)', () => {
12+
it('keeps a primary or danger action out of the fold', () => {
13+
expect(isLeadDecision({ name: 'approval_approve', variant: 'primary' })).toBe(true);
14+
expect(isLeadDecision({ name: 'approval_reject', variant: 'danger' })).toBe(true);
15+
});
16+
17+
it('folds an action that declares no variant, or any other variant', () => {
18+
expect(isLeadDecision({ name: 'approval_reassign' })).toBe(false);
19+
expect(isLeadDecision({ name: 'approval_comment', variant: 'secondary' })).toBe(false);
20+
expect(isLeadDecision({ name: 'x', variant: 'ghost' })).toBe(false);
21+
expect(isLeadDecision(null)).toBe(false);
22+
});
23+
24+
it('reads the variant, not the name', () => {
25+
// A name the shipped set uses for a decision, without the variant, folds.
26+
expect(isLeadDecision({ name: 'approval_approve' })).toBe(false);
27+
// A metadata-only action an author marks primary stays a button.
28+
expect(isLeadDecision({ name: 'approval_escalate', variant: 'primary' })).toBe(true);
29+
});
30+
});
31+
32+
describe('isActingApprover (objectstack#34361)', () => {
33+
it('is true only for an explicit can_act: true', () => {
34+
expect(isActingApprover({ viewer: { can_act: true, is_submitter: true } })).toBe(true);
35+
expect(isActingApprover({ viewer: { can_act: false, can_override: true } })).toBe(false);
36+
expect(isActingApprover({ viewer: { can_act: false, is_submitter: true } })).toBe(false);
37+
});
38+
39+
it('cannot tell without a viewer block, and reads that as no', () => {
40+
expect(isActingApprover({})).toBe(false);
41+
expect(isActingApprover({ viewer: {} })).toBe(false);
42+
expect(isActingApprover({ viewer: { can_act: 'true' } })).toBe(false);
43+
expect(isActingApprover(null)).toBe(false);
44+
});
45+
});
46+
47+
describe('currentStepNumber (objectstack#34361)', () => {
48+
it('numbers the current step on the served route from 1', () => {
49+
const route = {
50+
steps: [
51+
{ id: 'a', label: 'Manager', state: 'done' },
52+
{ id: 'b', label: 'Finance', state: 'current' },
53+
{ id: 'c', label: 'CFO', state: 'upcoming' },
54+
],
55+
ahead: 'end',
56+
};
57+
expect(currentStepNumber({ flow_route: route })).toBe(2);
58+
});
59+
60+
it('says nothing when the route is absent or names no current step', () => {
61+
expect(currentStepNumber({})).toBeUndefined();
62+
expect(currentStepNumber({ flow_route: { steps: [{ id: 'a', state: 'done' }] } })).toBeUndefined();
63+
expect(currentStepNumber({ flow_route: { steps: 'nope' } })).toBeUndefined();
64+
expect(currentStepNumber(undefined)).toBeUndefined();
65+
});
66+
});
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
/**
2+
* ObjectUI
3+
* Copyright (c) 2024-present ObjectStack Inc.
4+
*
5+
* This source code is licensed under the MIT license found in the
6+
* LICENSE file in the root directory of this source tree.
7+
*/
8+
9+
/**
10+
* approvalDecisionFold — which of a pending request's declared actions the
11+
* APPROVER's band draws as buttons, and which go behind its one menu
12+
* (objectstack#34361, ruling A).
13+
*
14+
* The band keeps the step's two decisions in view and folds every other lever
15+
* (reassign, send back, request info, reply, and the submitter's own levers
16+
* for a viewer who is both). Which actions are "the decisions" is read off the
17+
* metadata each action already declares — its `variant` — never off an
18+
* action-name list, so an action shipped as metadata alone lands in the menu
19+
* unless its author marks it `primary` or `danger`. That is the same principle
20+
* the admin-override fold follows (`actionAdmittedByOverride` reads each
21+
* action's own `visible` gate).
22+
*
23+
* Placement only: nothing here decides who may act. The server's `viewer`
24+
* block and each action's own `visible` / `disabled` / capability gates stay
25+
* the authority, unchanged.
26+
*/
27+
28+
/** The spec action `variant` values that keep an action out of the fold. */
29+
const LEAD_VARIANTS: ReadonlySet<string> = new Set(['primary', 'danger']);
30+
31+
/**
32+
* Does this declared action stay a button on the approver's band?
33+
*
34+
* True for an action whose declared `variant` is `primary` or `danger`
35+
* (today `approval_approve` and `approval_reject`); every other action,
36+
* including one that declares no variant, belongs in the menu.
37+
*/
38+
export function isLeadDecision(action: unknown): boolean {
39+
if (!action || typeof action !== 'object') return false;
40+
const variant = (action as { variant?: unknown }).variant;
41+
return typeof variant === 'string' && LEAD_VARIANTS.has(variant);
42+
}
43+
44+
/**
45+
* May this viewer act on the request as one of its approvers?
46+
*
47+
* Reads the server's `viewer.can_act` and nothing else, strictly: a backend
48+
* that sent no `viewer` block, or one without `can_act`, cannot tell, and
49+
* "cannot tell" keeps today's unfolded bar. The override-only administrator
50+
* (`can_act: false`) and the submitter who holds no slot both read `false`.
51+
*/
52+
export function isActingApprover(record: unknown): boolean {
53+
if (!record || typeof record !== 'object') return false;
54+
const viewer = (record as { viewer?: unknown }).viewer;
55+
if (!viewer || typeof viewer !== 'object') return false;
56+
return (viewer as { can_act?: unknown }).can_act === true;
57+
}
58+
59+
/**
60+
* The 1-based number of the request's current step on its served route
61+
* (`flow_route.steps`, the list every step line draws), or `undefined` when
62+
* the route is absent or names no current step.
63+
*/
64+
export function currentStepNumber(record: unknown): number | undefined {
65+
if (!record || typeof record !== 'object') return undefined;
66+
const route = (record as { flow_route?: unknown }).flow_route;
67+
if (!route || typeof route !== 'object') return undefined;
68+
const steps = (route as { steps?: unknown }).steps;
69+
if (!Array.isArray(steps)) return undefined;
70+
const index = steps.findIndex(
71+
(step) => !!step && typeof step === 'object' && (step as { state?: unknown }).state === 'current',
72+
);
73+
return index >= 0 ? index + 1 : undefined;
74+
}

0 commit comments

Comments
 (0)