Skip to content

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

Merged
objectstack-fleet[bot] merged 5 commits into
mainfrom
claude/issue-35734-percent-formula-return
Nov 20, 2026
Merged

objectstack-fleet[bot] merged 5 commits into
mainfrom
claude/issue-35734-percent-formula-return

Conversation

@objectstack-fleet

@objectstack-fleet objectstack-fleet Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

repo:objectstack#7 · os-tesla · session_01L9qibvVRcFWKrfWeG5jzPb

Requested by Tesla · project thread
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.
Ablations (each fix committed first, mutated through scripts/ablation-replace.mjs, restored to the HEAD blob)
  • 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.
Test runs
  • 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.

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 Record header summary chip: a percent, currency or date formula is drawn as its raw value, because the chip picks its arm from the field type formula #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


Body refreshed 2026-11-20T08:41Z for the L1 prose delta (amendment 7034399489), head 117c845.

…eturn type; lint names all six return types

Claude-Session: https://claude.ai/code/session_01L9qibvVRcFWKrfWeG5jzPb
Co-authored-by: Claude <noreply@anthropic.com>
…return-type list

Claude-Session: https://claude.ai/code/session_01L9qibvVRcFWKrfWeG5jzPb
Co-authored-by: Claude <noreply@anthropic.com>
…he storage ledger names it

Claude-Session: https://claude.ai/code/session_01L9qibvVRcFWKrfWeG5jzPb
Co-authored-by: Claude <noreply@anthropic.com>
@github-actions github-actions Bot added size/m documentation Improvements or additions to documentation tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface labels Nov 20, 2026
@github-actions

github-actions Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

Nothing in this diff resolved to a documentable surface (no symbol, route or SDK anchor derived from 1 changed package(s)), so this run has no opinion about the docs.

What this run could not see

Coarse fallback — 4 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): node scripts/docs-audit/affected-docs.mjs --json df81f4c0010b63842d67d70e50b32611a4b6ca23 → packageMentionDocs.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#7 · os-tesla · session_01L9qibyQBB3KuDoNobNq9LH

Seat check

L1: ACCEPT (L1-a, for area d7-C) at head e62abfdbd851fc2269af488d29e1015c256077b7, read 2026-11-20T08:24Z.

  • Condition: CI at this head finishes green, and that includes all 16 Test UI shards. Those shards carry the whole plugin-grid and plugin-detail packages, which the dev declared to CI instead of running locally (the narrowed 29-file run). When I read, 15 runs were success, 10 skipped and 39 in progress, with none red.
  • No L2 is owed. I confirm d7-C's reading:
    • No file is under packages/spec/src/** (the lint test imports the enum and changes nothing there).
    • packages/lint/** is not a governed path in SKILL.md's governed list.
    • The declaration is Clause-②: no, with no (narrowing) arm.
  • Clause-②: no holds. The lint text names an existing enum member and widens no accept set. The footer and chip changes are display only.

Code

  • Grid footer (useColumnSummary.ts).
    • formatSummaryLabel now resolves a formula column through formulaValueType, beside the existing summary → summaryValueType line.
    • Only currency and percent change arms. Every other declared or absent returnType answers 'formula', the arm it took before.
    • The percent arm makes two calls:
      • resolveFieldScale({ ...column, type: 'percent' }) mirrors FormulaCellRenderer, which hands PercentCellRenderer type: 'percent' for the same reason.
      • percentCellScale(column) reads only max (its type test is progress alone), so the formula's own max decides storage, as the cell's does.
    • The currency arm goes through resolveFieldCurrency(column, tenantDefault) exactly as a currency field's footer does, record mode included.
    • returnType is threaded into the column slice from objectSchema.fields, next to max.
  • Header strip (HeaderHighlight.tsx).
    • isKpi reads formulaReadsAsFieldType(resolvedType, objectDefField?.returnType) ?? resolvedType, which answers only for resolvedType === 'formula'.
    • The renderer (drawnType), the wide-basis rule and the editability gate are untouched.
    • The value was already drawn by FormulaCellRenderer's percent and currency branches, so only the chip class moves, as the body says.
  • Lint (rule-explanations.ts). The list now names all six members of FormulaField.returnType (field.zod.ts:2405), and the rest of the sentence is unchanged.

Scope

currency goes beyond the card's done-when, which names percent. I accept it:

  • it is the same resolution line in both faces;
  • the spec's returnType describe reads both currency and percent "as" a field type;
  • it is pinned, and the changeset and body state it;
  • every file is inside claim 7032912001's surface, so no amendment is owed.

Tests and controls

  • Footer:
    • a percent formula gives Sum: 75%, equal to a percent field's label;
    • a declared scale gives Sum: 75.0%;
    • with max: 100 it equals a percent field with the same max;
    • a fixed-USD currency formula gives Sum: $1,234.00 under a CNY tenant;
    • CONTROL: a number formula gives Sum: 0.75, equal to a formula with no returnType.
  • Chip:
    • the percent formula carries tabular-nums with classes identical to a percent field's, and its text is 25%;
    • the currency formula carries tabular-nums;
    • CONTROL: the number formula does not.
  • Lint: the listed types equal FieldSchema.shape.returnType's options, so a seventh member reds the test.
  • Ablations A1, A3 and A4 each red their own pins and leave the controls green.
  • A2 moved nothing, and the dev states why: an absent percent width and formatPercent's default are both 0 today. I agree it is a no-op face, recorded rather than counted.

Prose, sentence by sentence

  • Changeset.
    • "drew percentages in its list cells while the grid footer summed it as a plain number (Sum: 0.75 …)" matches the pre-change arm and the CONTROL pin.
    • "without the figure typography a percent field's chip has" matches isKpi.
    • "the two return types the spec reads as a field type" matches the describe text quoted above.
    • "at its declared scale and max, as a percent field does" is pinned.
    • "in the currency its currencyConfig declares, as a currency field does" is pinned, and an absent config falls to the tenant default as the describe says.
    • "Both are KPI chips" is pinned.
    • "A formula of any other return type totals and chips as before" holds by construction and by the CONTROLs.
    • The lint paragraph is exact.
    • Three patch bumps are right for display and text fixes.
  • PR body. I checked the What-changes bullets, the A1–A4 accounts and the Acceptance notes against the diff, and they agree.

Nit (not owed)

The max: 100 case asserts only equality with a percent field. If both faces regressed together it would stay green. An absolute label (Sum: 0.75%, per the comment above it) would make it a pin of its own.

Out-of-scope findings (the dev's four)

  1. Date formula footer min/max, and date formula chip basis. File these as one p3 card, "a date-returning formula's footer and header chip read the field type". Do it only if d7-C first confirms that a min/max footer can be chosen on a date-formula column at the grid door. A min/max over an ISO text read as a year is a wrong number. The chip cuts the same "2026/10/2…" that objectstack#25897 fixed for date fields. Both are read from code only, so that re-measure is the business-test evidence.
  2. DetailView summary chip. File this as its own p3 card. It is the same defect as Formula returnType percent: the lint return-type list still names five types, and the record header chip and grid footer summary do not treat a percent-returning formula as a percentage #35734 on a third face (percent and currency arms keyed on ftype), so it passes the business test on this card's own rationale.
  3. No shared helper. Do not file it on its own. Name it as context in the DetailView card, because five spellings is what let three faces miss percent. Leave whether to extract one to that card's dev.

Gates and routing

After CI is green at e62abfdb, check-governed-merges.mjs --pr 35793 decides the landing route. No L2 record is owed.


Generated by Claude Code

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#7 · os-tesla · session_01L9qibyQBB3KuDoNobNq9LH

Seat check: amendment to ACCEPT 7034338665

L1: prose delta owed at head e62abfdbd851fc2269af488d29e1015c256077b7, read 2026-11-20T08:28Z. The code stays accepted as it is. The prose check in 7034338665 missed one point, which I correct here.

What I missed

sum, avg, min and max over a formula field are refused whatever its returnType says:

  • aggregate-field-type-compatibility.ts refuses them through VALUE_READING_AGGREGATES on its storage ground. A formula is virtual, so it has no column, and the prescription is a stored field of the return type with the same expression.
  • list-view-summary-field-type-refused therefore makes summary: 'sum' on a percent or currency formula column an error at os validate. Its message says "a one-page browser footer is no exception".
  • The whole-set footer query answers 400 INVALID_FIELD.

So the footer leg draws only in an ungrouped one-page browser footer over a declaration that lint refuses. The changeset's "a percent formula totals as a percentage (Sum: 75%) … and a currency formula totals as money" reads as a supported authoring shape, and it is not one. I called that sentence accurate, and it is accurate about the code but not about the platform.

Owed (prose only, with no code and no L2)

  • Changeset and PR body: say that the footer leg formats a browser-computed footer over a declaration that os validate refuses, and point to the stored-field prescription (a field of the formula's returnType carrying the same expression) as the way to a supported total.
  • Unchanged: the header-chip leg, the lint-text leg, count / count_unique over a formula (not value-reading), and the code and tests.

That makes this a delta L1 on the prose only. The CI condition from 7034338665 still stands.

Out-of-scope finding (1), withdrawn

My recommendation to file the date-formula footer min/max is withdrawn for the same reason: that pair is refused at the door and by lint. The date-formula chip's narrow basis is cosmetic and is left to d7-C's judgement. Finding (2), the DetailView summary chip, still stands.


Generated by Claude Code

… the footer leg formats a browser-only footer

Claude-Session: https://claude.ai/code/session_01L9qibvVRcFWKrfWeG5jzPb
Co-authored-by: Claude <noreply@anthropic.com>
@objectstack-fleet objectstack-fleet Bot changed the title fix(formula): a percent or currency formula totals and chips as its return type; lint names all six return types 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 Nov 20, 2026
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#7 · os-tesla · session_01L9qibyQBB3KuDoNobNq9LH

Seat check (delta)

L1: ACCEPT (L1-a, for area d7-C) at head 117c84536ff03dc0969ddfa37e5b7c63b589f11e, read 2026-11-20T08:44Z. This closes the prose delta owed by amendment 7034399489. No L2 is owed.

  • Condition: CI at this head finishes green. When I read, 10 runs were success, 14 skipped, 1 cancelled (superseded) and 18 in progress, with none red.
  • The whole-package condition is already evidenced. All 16 Test UI shards finished success at e62abfdb, and git diff e62abfdb 117c8453 touches only the changeset, so the code and tests they ran are byte-identical here.

The delta

One commit, .changeset/35734-percent-formula-return.md only.

  • Subject and first paragraph. They lead with the header chip and the lint text, the two supported legs.
  • New footer paragraph. I checked it sentence by sentence:
    • "a browser-computed footer over a percent formula reads Sum: 75% rather than Sum: 0.75" is pinned.
    • "not a supported authoring shape … refused at authoring by list-view-summary-field-type-refused, whatever its returnType" matches VALUE_READING_AGGREGATES in aggregate-field-type-compatibility.ts and columnSummaryRefusal.
    • "computed on read and stored in no column" matches that module's storage ground.
    • "the whole-set footer query answers 400 INVALID_FIELD" matches the refusal message.
    • The stored-field prescription matches virtualFieldAggregateRemedy's mechanism, and now names percent by the lint fix in this very PR.
  • The lint paragraph is unchanged and exact.

The PR title and body (refreshed at 08:41Z):

Nit (not owed; a body edit, not a head)

The Acceptance note on the date finding gives one reason for both halves: "the aggregate door refuses min and max over a formula". That reason covers the footer half only. The chip's wide basis is not an aggregate. It was left as cosmetic by d7-C's judgement, which is what my amendment said, and the note could say so.

The stale report comment

No note on #35734 is needed. Report 7034234321 is that round's record, and this PR's changeset, body and seat checks carry the correction.

Gates and routing

After CI is green at 117c8453, check-governed-merges.mjs --pr 35793 decides the landing route.


Generated by Claude Code

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#7 · os-tesla · session_01L9qibvVRcFWKrfWeG5jzPb

Landing (2026-11-20T09:11Z), area d7-C under the standing go-ahead for pm-dispatch-reviewed PRs.

  • L1: ACCEPT 7034338665 at e62abfdb, amended 7034399489 (prose delta owed), delta ACCEPT 7034728914 at 117c8453. No L2 owed: no published-schema or governed face, Clause-②: no (L1 confirmed).
  • 117c8453 differs from e62abfdb in the changeset only; all 16 Test UI shards were success at e62abfdb, as the L1 condition asked.
  • Checks at 117c84536ff03dc0969ddfa37e5b7c63b589f11e: 61 success, 14 skipped, 0 failed or pending (one Check Changeset run cancelled as superseded by a later success on the same head); mergeable clean; check-governed-merges --pr 35793: NOT governed, 225 lines; landing-k: K = 2.
  • Follow-up card filed from the dev's out-of-scope findings: Record header summary chip: a percent, currency or date formula is drawn as its raw value, because the chip picks its arm from the field type formula #35798 (record header summary chip). The date-formula finding was withdrawn (the aggregate door refuses min/max over a formula; the chip basis is cosmetic).
    Marking ready and arming auto-merge.

@objectstack-fleet
objectstack-fleet Bot marked this pull request as ready for review November 20, 2026 09:11
@objectstack-fleet
objectstack-fleet Bot added this pull request to the merge queue Nov 20, 2026
Merged via the queue into main with commit 65fddc8 Nov 20, 2026
76 of 77 checks passed
@objectstack-fleet
objectstack-fleet Bot deleted the claude/issue-35734-percent-formula-return branch November 20, 2026 09:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation size/m tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface

Projects

None yet

2 participants