Repository navigation
Commit 65fddc8
fix(formula): a percent or currency formula is a KPI chip on the record header and formats its browser footer as its return type; lint names all six return types (#35793)
repo:objectstack#7 · os-tesla · session_01L9qibvVRcFWKrfWeG5jzPb
<!-- claude-projects-attribution: {"github_login":"os-tesla"} -->
_Requested by **Tesla** · [project
thread](https://claude.ai/code/project/chan_01AXsQkLFKRdQCqQ3RTr6Jao?thread=cmsg_01AXsQkLFKRdQCqQ3RTr6JaoK8YCcS3hkJHvVLxZNeiKG8)_
Fixes #35734
Clause-②: no
Metadata-protocol: none
## 维护者速读
-
用户能看到什么变化:记录页顶部的要点条里,声明为百分比或金额结果的公式字段,现在和普通百分比、金额字段一样按数字样式显示;搭建者在解释文字里看到全部六种公式结果类型。对公式字段做合计在搭建时本就被拒绝,这里不把它当成可用写法。
- 为什么做:属于公式字段的显示一致性,替用公式表达比率或金额的搭建者解决要点条与同类字段样式不一致,并让解释文字不漏掉百分比类型。
- 出错会怎样:最坏是这两类公式的要点条字形回到旧样子,存储的数据不受影响,可直接撤回。
- 要你做什么:无。
## What changes
A `formula` field declares a `returnType` from `number`, `text`,
`boolean`, `date`, `currency`, `percent`. The spec reads two of them AS
a field type: `currency` is "an amount of money … as a currency field
declares it" and `percent` is "read and displayed as a `percent` field
reads its stored value". The list cell already draws them through the
currency and percent cells (`FormulaCellRenderer`); two other faces read
only the field's own `type`, and the lint prescription listed five
return types.
- **Grid footer formatting**
(`ui/packages/plugin-grid/src/useColumnSummary.ts`).
`formatSummaryLabel` resolves a `formula` column through a new
`formulaValueType` before picking its arm, as it already resolves a
`summary` column through `summaryValueType`, so a browser-computed
footer over a `percent` formula reads `Sum: 75%` rather than `Sum:
0.75`, and over a `currency` formula reads as money; any other formula
keeps the plain arm. **This is not a supported authoring shape.** A
`sum`, `avg`, `min` or `max` column summary over a `formula` field is
refused at authoring by `list-view-summary-field-type-refused`
(`columnSummaryRefusal` in
`packages/lint/src/validate-list-view-field-refs.ts`, through
`aggregateAcceptsDeclaration`): `VALUE_READING_AGGREGATES` in
`packages/spec/src/data/aggregate-field-type-compatibility.ts` refuses
the virtual `formula` type whatever its `returnType`, because a formula
is computed on read and stored in no column, and the whole-set footer
query answers `400 INVALID_FIELD`. So this leg formats only an
ungrouped, one-page footer the browser computes over a declaration `os
validate` refuses. The platform's prescription for totalling a formula
stands: make it a stored field of its own, of the formula's `returnType`
and carrying the same `expression`, which the engine computes and stores
on every write, and summarise that field. The percent arm asks
`resolveFieldScale` for the width as a `percent` (the cell hands the
percent cell `type: 'percent'` for the same reason) and
`percentCellScale(column)` for the storage, so the storage-caller ledger
(`ui/scripts/__tests__/percent-storage-callers-11475.test.ts`) stays as
it is.
- **Record header chip**
(`ui/packages/plugin-detail/src/HeaderHighlight.tsx`). `isKpi` reads
`formulaReadsAsFieldType(resolvedType, objectDefField?.returnType) ??
resolvedType`, so a `percent` or `currency` formula wears the KPI chip's
figure typography, as a field of that type does. The value itself was
already drawn correctly (`FormulaCellRenderer`); only the chip class
differed. A `number` formula is unchanged.
- **Lint prescription** (`packages/lint/src/rule-explanations.ts`). `os
explain dimension-virtual-field-refused` now names all six return types.
The module imports nothing (its header says why: a published entry the
CLI loads on every finding), so the list is written out and
`rule-explanations.test.ts` holds it to `FieldSchema.shape.returnType`'s
options, the way that file already holds the scan-root list to its
constant.
Read first, by risk:
1. `ui/packages/plugin-detail/src/HeaderHighlight.tsx`:
`formulaReadsAsFieldType` and the `isKpi` block.
2. `ui/packages/plugin-grid/src/useColumnSummary.ts`: `formulaValueType`
and the `colType` line in `formatSummaryLabel` (the browser-computed
footer formatting only, see above).
3. `packages/lint/src/rule-explanations.test.ts`: the new enum pin.
Two-minute check: `pnpm --dir ui exec vitest run
packages/plugin-grid/src/useColumnSummary.test.tsx
packages/plugin-detail/src/__tests__/HeaderHighlight.formulaReturnType-35734.test.tsx`
from the repository root; expect 17 passed, including `Sum: 75%` for the
percent formula and `Sum: 0.75` for the number formula control.
## Tests
- `ui/packages/plugin-grid/src/useColumnSummary.test.tsx`, new top-level
`describe` "useColumnSummary reads a formula by its declared
returnType", which drives the hook directly with a formula field's
metadata (the authoring door refuses that summary declaration, so these
pin the browser formatter only): a percent formula sums to `Sum: 75%`
and equals a `percent` field's label; it keeps a declared `scale` (`Sum:
75.0%`) and `max` (equal to a `percent` field with the same `max`); a
currency formula with a fixed USD `currencyConfig` sums to `Sum:
$1,234.00` under a CNY tenant; CONTROL: a `number` formula sums to `Sum:
0.75`, the same label as a formula declaring no `returnType`.
-
`ui/packages/plugin-detail/src/__tests__/HeaderHighlight.formulaReturnType-35734.test.tsx`
(the strip's pins are one file per subject today, no shared harness
file): a percent formula's value span carries `tabular-nums` and the
same classes as a `percent` field's; a currency formula's carries it
too; CONTROL: a `number` formula's does not.
- `packages/lint/src/rule-explanations.test.ts`: the prescription's
return-type list equals the spec enum.
<details>
<summary>Ablations (each fix committed first, mutated through
scripts/ablation-replace.mjs, restored to the HEAD blob)</summary>
- A1, footer resolution (`colType` line back to `column?.type`): 3
failed, the two percent cases and the currency case; the number control
stays green. Restored, `git diff HEAD` empty. A first attempt was
refused by the tool before any run, because its replacement text already
occurred in the file; the re-run used a unique marker.
- A2, percent width face (`resolveFieldScale` handed the formula column
as is): 17 passed, no test moved. Expected and stated: the platform's
absent `percent` width and `formatPercent`'s parameter default are both
0 today, so the face changes nothing observable; the equality pin
against a `percent` field is what goes red if the platform's absent
percent width ever moves.
- A3, chip resolution (`valueType` back to `resolvedType`): 2 failed,
the percent and currency chip cases; the number control stays green.
- A4, lint list back to five types: 1 failed, the enum pin.
</details>
<details>
<summary>Test runs</summary>
- `pnpm --filter @objectstack/lint exec vitest run --maxWorkers=2`: Test
Files 222 passed, Tests 9337 passed.
- `pnpm --filter @objectstack/lint typecheck`: exit 0,
`check:test-typecheck: OK`.
- `pnpm exec turbo run type-check --filter=@object-ui/plugin-grid
--filter=@object-ui/plugin-detail`: 55 tasks successful, both
`type-check` tasks executed (cache miss).
- `pnpm --dir ui exec vitest run` over every footer-summary and
highlights test of the two packages (28 files) plus
`scripts/__tests__/percent-storage-callers-11475.test.ts`: Test Files 29
passed, Tests 300 passed. The two whole packages (682 files) are
declared to CI's `Test UI`, which runs them; a local whole-package run
was stopped after 20 minutes holding the shared lock.
</details>
## Acceptance notes
- The chip and the footer formatter resolve `percent` and `currency` and
nothing else, on the spec's own wording that those two are read as a
field type; `number`, `text`, `boolean` and `date` formulas are
unchanged (the number control is pinned in both).
- A column summary over a `formula` field stays refused at authoring,
whatever its `returnType`; nothing here widens that door, and the
stored-field prescription above is the supported way to total a formula.
- The record page's summary chip in `DetailView.tsx` picks its currency
and percent arms from the field's own `type` too; outside this card's
file surface, it is the follow-up card #35798.
- The date-returning-formula finding (the footer's date-family test and
the chip's wide basis) was withdrawn by the seat: the aggregate door
refuses `min` and `max` over a formula, so no supported declaration
reaches that footer arm.
- No shared exported helper resolves a formula's value type today
(`FormulaCellRenderer`, `columnValueType` in plugin-form and
`alignsAsNumber` in plugin-grid each spell it); both new helpers are
module-local.
## Verification
Gates derived by `node scripts/pm/dispatch-gates.mjs --commands --repo
objectstack-ai/objectstack` from the branch's own change set and run
locally; CI runs the full farm. Readings are in the report comment on
the card.
---
_Generated by [Claude
Code](https://claude.ai/code/session_01L9qibvVRcFWKrfWeG5jzPb)_
---
Body refreshed 2026-11-20T08:41Z for the L1 prose delta (amendment
7034399489), head 117c845.
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent 7878cf0 commit 65fddc8
7 files changed
Lines changed: 214 additions & 11 deletions
File tree
- .changeset
- packages/lint/src
- ui/packages
- plugin-detail/src
- __tests__
- plugin-grid/src
| 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 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| 19 | + | |
19 | 20 | | |
20 | 21 | | |
21 | 22 | | |
22 | 23 | | |
23 | 24 | | |
| 25 | + | |
24 | 26 | | |
25 | 27 | | |
26 | 28 | | |
| |||
112 | 114 | | |
113 | 115 | | |
114 | 116 | | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
115 | 129 | | |
116 | 130 | | |
117 | 131 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2734 | 2734 | | |
2735 | 2735 | | |
2736 | 2736 | | |
2737 | | - | |
2738 | | - | |
| 2737 | + | |
| 2738 | + | |
| 2739 | + | |
2739 | 2740 | | |
2740 | 2741 | | |
2741 | 2742 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
38 | 50 | | |
39 | 51 | | |
40 | 52 | | |
| |||
256 | 268 | | |
257 | 269 | | |
258 | 270 | | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
259 | 276 | | |
260 | | - | |
261 | | - | |
262 | | - | |
263 | | - | |
264 | | - | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
265 | 282 | | |
266 | 283 | | |
267 | 284 | | |
| |||
| 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 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
148 | 148 | | |
149 | 149 | | |
150 | 150 | | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
376 | 376 | | |
377 | 377 | | |
378 | 378 | | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
379 | 399 | | |
380 | 400 | | |
381 | 401 | | |
382 | 402 | | |
383 | | - | |
| 403 | + | |
384 | 404 | | |
385 | 405 | | |
386 | 406 | | |
| |||
419 | 439 | | |
420 | 440 | | |
421 | 441 | | |
422 | | - | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
423 | 445 | | |
424 | 446 | | |
425 | 447 | | |
| |||
500 | 522 | | |
501 | 523 | | |
502 | 524 | | |
503 | | - | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
504 | 536 | | |
505 | 537 | | |
506 | 538 | | |
| |||
531 | 563 | | |
532 | 564 | | |
533 | 565 | | |
534 | | - | |
| 566 | + | |
535 | 567 | | |
536 | 568 | | |
537 | 569 | | |
| |||
724 | 756 | | |
725 | 757 | | |
726 | 758 | | |
| 759 | + | |
| 760 | + | |
| 761 | + | |
727 | 762 | | |
728 | 763 | | |
729 | 764 | | |
| |||
0 commit comments