Skip to content

Commit 6206939

Browse files
fix(console): approvals inbox row figure is the object's declared highlightFields entry, not a name guess (#36698)
<!-- 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 #36477 repo:objectstack#3 · os-support-ai · session_01WGufzi4PechTRCTBrfxV8W Clause-②: no Metadata-protocol: none ## 维护者速读 - 审批人在控制台审批收件箱里,每条申请旁的数字改为该对象「重点字段」里第一个数值字段的值;没声明这类字段的对象不再显示数字,按金额排序也跟着走。 - 属于「审批收尾」专题,替应用作者解决「收件箱按字段名猜金额、可能显示错数字且无法纠正」的问题。 - 出错时审批人看到的行内数字或排序不对,但打开申请页仍能看到全部正确数值;改动可直接撤回。 - 无 ## What changes The figure each approvals-inbox queue row shows after the object name, and the "Amount (high→low)" sort, now come from the request object's declared `highlightFields` (ADR-0085: one curated list of the object's most important fields, every surface; the spec docblock: "first entry wins where only one fits"). - **Rule:** the figure is the first `highlightFields` entry that names a numeric field of the object — `number`, `currency`, `percent`, `summary`, or a `formula` whose `returnType` is `number` / `currency` / `percent` — and that the object does not declare `hidden: true`. The value is read from the request's snapshot; `payload_display` formatting is kept. - **Removed:** `AMOUNT_KEY_RE` and the name-matching scan (`decisionAmountEntry` becomes `declaredFigureEntry`). No new key (`approval.summaryField` / `listFigureField` are not built — seat route). - **No declaration, no figure.** An object with no numeric `highlightFields` entry shows no figure and sinks in the amount sort. ⚠ **Visible change:** objects that show a guessed figure today and declare no numeric highlight lose it. Also stated in the changeset. - **Zero-skip dropped:** a declared figure of 0 shows. The skip existed because a zero from a *guessed* key might not be the request's amount; a declared field's 0 is its value. - **Hidden filter kept:** a highlight entry declared `hidden: true` is skipped (the next numeric entry wins); the sort never orders on it. - **Same read, no new request:** the figure comes from the per-object `getObjectSchema` read the page already makes (one per distinct object per mount; the pinned cost test still asserts 2 reads for 3 rows across 2 objects). That read's hook lived in `hiddenFields.ts` and kept only the hidden-field names, so it now derives the figure field per object (`inboxFigureField` / `readInboxFigureField` / `useInboxFigureFieldByObject`). Until the read answers, or when it fails, the row shows no figure (before: a guessed one). Files to read first, by risk: 1. `ui/apps/console/src/pages/system/hiddenFields.ts` — `inboxFigureField` (the rule) and the hook. 2. `ui/apps/console/src/pages/system/ApprovalsInboxPage.tsx` — `declaredFigureEntry` and the amount-sort comparator. 3. `ui/apps/console/src/pages/system/ApprovalsInboxPage.queueHiddenAmount.test.tsx` — the fixture table in its header. ## Tests Run at head `e6dddc0f`. <details><summary>Affected test files: 2 files, 22 tests passed</summary> `pnpm --dir ui exec vitest run --maxWorkers=2 apps/console/src/pages/system/ApprovalsInboxPage.queueHiddenAmount.test.tsx apps/console/src/pages/system/hiddenFields.test.ts` under `os-verify-lock.sh`: `Test Files 2 passed (2)`, `Tests 22 passed (22)`, `VERDICT command-exit 0`. - `ApprovalsInboxPage.queueHiddenAmount.test.tsx` was rewritten in place for the new rule. The fixture puts a money-named key (`total_amount`, `overdue_amount`, `service_fee`) before the declared field on every row, across two objects with different declarations. It pins the card's repro (`overdue_amount` 80,000 declared before the highlighted `total_score` 81 now shows 81), a hidden highlight entry being skipped, a declared 0 showing, no figure without a declaration, no figure when the read fails, the one-read-per-object cost, and the sort following the declaration (with a counter-probe and a hidden case). - `hiddenFields.test.ts`: `inboxFigureField` order, both `fields` shapes, the numeric type set, formula `returnType`, hidden and undefined entries skipped, no declaration means null; `readInboxFigureField` never rejects. </details> <details><summary>Ablation: the new page test against the base page and module</summary> Both source files were put back to the base commit with `git restore --source=BASE` (test files kept). On disk afterwards: `AMOUNT_KEY_RE` 3 hits in the page, `inboxFigureField` 0 hits in the module. Result: `Tests 4 failed | 3 passed (7)`. The 4 behaviour pins went red (declared figure, no declaration, unknown declaration, sort sink). The 3 that pass are behaviour the base already had: the cost pin, the counter-probe (`service_fee` matches the old regex) and the hidden-sort case (the base trims hidden fields too). Restore: `git checkout HEAD -- …`, hash-checked against the HEAD blobs, `git diff HEAD` empty. A first attempt restored only the page file. Its run was void: 7/7 failed on `useHiddenFieldsByObject is not a function`, an import error, not an assertion. It is not counted. </details> ## Acceptance notes - **File surface:** the order's surface is `ApprovalsInboxPage*.tsx` plus its tests. `hiddenFields.ts` and `hiddenFields.test.ts` are outside it. They are touched because the existing per-object read lives there, and the order says to reuse it rather than fetch twice. Declared as a deviation in the report. - `isBookkeepingKey` was removed from the page; its only reader was the name scan. The `@object-ui/types` `isSystemManagedField` import went with it. A declared highlight is taken as the author's choice. - The module keeps its file name `hiddenFields.ts`. Its header now describes both declarations it reads. - The sort option keeps its label "Amount (high→low)". It now orders on the declared figure, which can be a score or a count rather than an amount (observation; no change made). - No docs page describes the inbox figure today (`content/docs/automation/approvals.mdx` and `content/docs/capabilities/approvals.mdx` do not mention it), so no docs edit. ## Verification Two-minute check: run the vitest command under Tests. Expected: `Tests 22 passed (22)`. In the running console, an object whose `highlightFields` lists a numeric field shows that field's value on each inbox row. An object without one shows no figure. All readings below were taken at head `e6dddc0f`. <details><summary>Local gates: type-check, lint, 37/37 derived families exit 0</summary> - `pnpm exec turbo run type-check --concurrency=2 --filter=@object-ui/console` under the lock: `Tasks: 76 successful, 76 total`, console `cache miss, executing`, `VERDICT command-exit 0`. The console `tsconfig.json` `include` is `src`, `dev`, `scripts` with no exclude, so it reaches the test files. (A first bare `pnpm --filter @object-ui/console run type-check` exited 2 on `Cannot find module '@object-ui/*'`: the dependency `dist` was not built yet. That was a prerequisite failure, not a verdict.) - `pnpm --dir ui exec eslint` over the 4 changed source/test files: exit 0. - `node scripts/pm/dispatch-gates.mjs --commands` derived 37 commands. Each was run, and each exited 0, with the exit code captured before any pipe. `--ran` reconciliation: `37 derived famil(ies) accounted for — 37 run, 0 NOT-MEASURED`. - Dogfood battery: n/a. The title has no `!` and there is no `(narrowing)` arm. - Every family CI runs (the required UI lanes included) is CI's verdict on this PR. </details> --- _Generated by [Claude Code](https://claude.ai/code/session_01WGufzi4PechTRCTBrfxV8W)_ <!-- signed: repo:objectstack#3 · os-support-ai · session_01WGufzi4PechTRCTBrfxV8W --> --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 70d07fd commit 6206939

6 files changed

Lines changed: 437 additions & 329 deletions

File tree

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
'@object-ui/console': patch
3+
---
4+
5+
fix(console): the approvals inbox row figure is the field the object declares, not a guess from field names
6+
7+
Clause-②: no
8+
Metadata-protocol: none
9+
10+
Each request row in the console's approvals inbox shows a figure after the object name, and the inbox's "Amount (high→low)" sort orders on it. That figure is now the first `highlightFields` entry of the request's object (ADR-0085: the object's one curated list of its most important fields, first entry wins where only one fits) that names a numeric field — `number`, `currency`, `percent`, `summary`, or a `formula` whose `returnType` is `number`, `currency` or `percent` — and that the object does not declare `hidden: true`. The value comes from the request's submitted snapshot, formatted as before.
11+
12+
Before, the console picked the first snapshot key whose NAME looked like money (`amount`, `total`, `fee`, `budget`, …) with a non-zero value, so an incidental money-named field declared before the headline figure was shown instead of it, and an app could not change the choice without renaming or reordering its fields.
13+
14+
Visible change: an object whose `highlightFields` names no numeric field (or that declares no `highlightFields`) no longer shows a figure on its inbox rows, and those rows sink to the bottom of the amount sort. To show one, list the headline numeric field in the object's `highlightFields`. A declared figure of 0 is now shown (the old guess skipped zeros). The figure is read from the same per-object metadata read the inbox already made, so no request is added.

‎ui/apps/console/src/pages/consoleFaces.displayLocale-9909.test.tsx‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,13 @@ const { STORED, approvalsApiStub, ADAPTER, AUTH, I18N } = vi.hoisted(() => {
7878
};
7979
const ADAPTER = {
8080
find: async () => ({ data: [{ id: 'po_1' }] }),
81-
getObjectSchema: async () => ({ fields: {} }),
81+
// The queue row's figure is the object's first numeric `highlightFields`
82+
// entry (ADR-0085), so the object declares `amount` as one; without the
83+
// declaration the row shows no figure and there is nothing to format.
84+
getObjectSchema: async () => ({
85+
highlightFields: ['amount'],
86+
fields: { amount: { type: 'number' }, quantity: { type: 'number' } },
87+
}),
8288
getClient: () => client,
8389
};
8490
const AUTH = { user: { id: 'u_1', email: 'approver@example.com' } };
@@ -169,6 +175,9 @@ const SURFACES: Surface[] = [
169175
);
170176
await screen.findAllByText('Purchase Approval');
171177
await screen.findAllByText(/Sam Submitter/);
178+
// The figure renders once the object's metadata read answers; wait for
179+
// it in either locale's spelling, then read the face.
180+
await screen.findAllByText(/1[.,]234[.,]5/);
172181
const text = faceOf(document.body);
173182
cleanup();
174183
return text;

0 commit comments

Comments
 (0)