This repository was archived by the owner on Nov 4, 2026. It is now read-only.
Repository navigation
fix(core): localize built-in aggregate chart labels via builtinAggregate (#7258) - #7535
Merged
Merged
Conversation
A dataset chart's aggregate axis / legend title read the analytics service's hard-coded English `Count` on a zh console whose category labels were already Chinese. `buildChartSeries` passed `fields[].label` through verbatim — right for an author-declared measure — and had no way to tell the server's built-in default apart from an author's label. Consumer half of the objectstack contract that adds an OPTIONAL structural discriminator, `AnalyticsResult.fields[].builtinAggregate`, populated only on the server-side built-in defaults: - core: `buildChartSeries` accepts `ChartMeasureField[]` (`ChartResultField` plus the optional `BuiltinAggregateCarrier`, declared beside the renderer shape because the spec this tree is built against does not carry the key yet); `BUILTIN_AGGREGATES` / `isBuiltinAggregate` / `resolveMeasureLabel`; `ChartSeriesOptions.builtinAggregateLabels` carries the locale strings in. - i18n: `builtinAggregateLabels(tt)` resolves the six strings through the existing `report.aggregate.*` keys. - plugin-charts / plugin-dashboard / plugin-report: pass the resolved map to `buildChartSeries`. A field carrying a recognised discriminator resolves through the map; every other field keeps its wire label verbatim — never by matching the label's text or the field's name. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Contributor
✅ Console Performance Budget
The eager closure is every chunk the entry reaches through static imports — what the browser fetches and parses before the app renders. The entry chunk on its own is a small fraction of it. 📦 Bundle Size Report
Size Limits
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #7258
Part of objectstack-ai/cloud#1841 — the CONSUMER half of maintainer ruling B (2026-09-02); the producer half is objectstack-ai/objectstack#14492.
Depends on objectstack#14492 landing upstream for the field to be populated. Until then the wire carries no
builtinAggregate, and every chart renders exactly as today — this PR is inert by construction on the current spec, and stays a draft until the producer merges.The defect
An AI-built customer dashboard's "customers by status" bar shows three localized category labels (合作中 / 已流失 / 潜在) under an aggregate axis title that reads
Counton a zh console. The literal is not minted in this repo:buildChartSeriespassesfields[].labelthrough verbatim — correctly, for an author-declared measure (objectui#4106 pins'Tasks') — and the analytics service hard-codeslabel: 'Count'on its built-in default measure with no i18n hook. The renderer had no way to tell the two apart, and guessing from the label's text or the field's name (option A) was rejected.Consumer contract — what this PR reads
AnalyticsResult.fields[]gains an OPTIONAL structural discriminator,builtinAggregate, with the closed enum'count' | 'sum' | 'avg' | 'min' | 'max' | 'count_distinct'(the spec's own measure-aggregate spelling), populated ONLY on the server-side built-in default measures. An author-declared measure never carries it.isBuiltinAggregatechecks the wire value against the closed vocabulary; a recognised value resolves through the caller's locale map; an unrecognised value (or none) is treated as absent and the field keeps its wirelabelverbatim, then itsname.countand labelledCount, without the discriminator, keeps its own label — pinned at both the pure and the surface level.How
@objectstack/specis consumed here, and whether a pin bump is needed@object-ui/coredeclares@objectstack/spec^17.2.0(root^17.0.0), the lockfile resolves 17.2.0. This repo has no.objectstack-sha-style pin.AnalyticsResult.fields[]element has nobuiltinAggregate, andpackages/core/src/utils/__tests__/dataset-result-field-spec-parity.test.tspinskeyof ChartResultFieldas a subset of the spec element's keys at compile time. Adding the key ONChartResultFieldturned that pin red (measured: TS2344 at line 121,Extendsdistributing toboolean). So the key lives BESIDE it asBuiltinAggregateCarrier, andbuildChartSeriestakesChartMeasureField[](ChartResultFieldintersected with the carrier): a spec-typedDatasetResultField[]flows in unchanged today and carries the key the moment the spec does, with no cast at any call site. The parity suite stays green on 17.2.0.@objectstack/specto that minor, foldbuiltinAggregateintoChartResultFieldasDatasetResultField['builtinAggregate'], retire the carrier, and pin the two closed enums to each other in the parity suite — recorded asTODO(objectstack#14492)inchart-series.ts.Before / after
{ name: 'count', label: 'Count', builtinAggregate: 'count' }Count计数CountCount{ name: 'task_count', label: 'Tasks' }(author, no discriminator)TasksTasks{ name: 'count', label: 'Count' }(author, no discriminator)CountCount{ …, builtinAggregate: 'median' }(outside the vocabulary)CountCountWhat changed, and the file-surface note
packages/core/src/utils/chart-series.ts—BuiltinAggregateCarrier,ChartMeasureField,BUILTIN_AGGREGATES,BuiltinAggregate,isBuiltinAggregate,BuiltinAggregateLabels,resolveMeasureLabel;ChartSeriesOptions.builtinAggregateLabels;labelOfresolves throughresolveMeasureLabel.packages/i18n/src/builtinAggregateLabels.ts(+index.tsexport) —builtinAggregateLabels(tt)resolves the six strings through the existingreport.aggregate.*keys (count_distinctmaps to the bundle'scountDistinct); English fallbacks byte-equal to theenpack.ObjectChart.tsx,DatasetWidget.tsx,DatasetReportRenderer.tsx— passbuiltinAggregateLabels(tt)besidenullCategoryLabel..changeset/7258-chart-builtin-aggregate-label.md.The claim's surface was
chart-series.ts, the locale bundles, and tests beside it. Three things sit outside it, each necessary for the fix to reach a user rather than stay a seam nothing wires:@object-ui/coreis React-free and i18n-free (its own doctrine fornullCategoryLabel), so the locale strings MUST be resolved by the layer holding the provider and passed in.tt()calls copied into three renderers. The locale bundles themselves are untouched: all ten packs already carryreport.aggregate.{count, countDistinct, sum, avg, min, max}(now pinned per pack).DatasetWidget.builtinAggregateLabel.test.tsx— the surface pin under a realI18nProvider, on the widget the card was measured on.Tests
chart-series.builtinAggregate.test.ts(14): zh 计数 / en Count; every enum member; verbatim author label (objectui#4106); authoredcountkeepsCount; unknown discriminator → label / → name; no labels, missing entry, empty string → wire label; pivot branch untouched;resolveMeasureLabelorder;isBuiltinAggregatetruth table.builtinAggregateLabels-locale-parity-7258.test.ts(15): all ten packs carry a non-empty label for every member; the seam maps exactly the closed vocabulary; per-pack value identity; zh / en literal pins; provider-less fallbacks equal the en pack.DatasetWidget.builtinAggregateLabel.test.tsx(4): zh 计数 / en Count / verbatimOpportunities/ authoredcountkeepsCount, read off the series the widget hands the chart renderer.Reverse verification (ablation) — at
799c84a27, after the commitMutation:
labelOfback to the pre-fixfield?.label ?? name(on-disk proof: injected marker count 1, removed call count 0). Ran the core + dashboard pins: 4 failed / 14 passed — red exactly where predicted: zh built-in count (core), every-member, multi-measure, zh built-in count (surface). Direction note, recorded rather than fitted: theenpins stayed green under the mutation because theenlocale label IS the wireCount— they are controls, not discriminating pins. Restore:git checkout HEAD -- path;git hash-objectequals the HEAD blob (bcae7ca08…),git diff HEADempty, marker count 0. Nodist/is involved in either leg: the root vitest config aliases@object-ui/*tosrc/and the core test imports relatively.Verification — union at
799c84a27(the final commit)pnpm --filtercore / i18n / plugin-charts / plugin-dashboard / plugin-reportrun type-check(tsc --noEmit && tsc -p tsconfig.test.json): all five Done, exit 0, afterpnpm --filter 'plugin-{dashboard,report,charts}^...' build.--listFilesshows each new test file inside its package's test project (1 / 1 / 1), so "type-check clean" covers the new tests.pnpm exec vitest run --maxWorkers=2over 16 files (the 3 new + every chart-series / dataset-format / spec-parity / label-net sibling +ObjectChart.datasetMeasureLabel+ twoDatasetWidgetlabel suites): Test Files 16 passed, Tests 256 passed, exit 0.--format json) over the 9.ts/.tsxfiles this diff touches (the 10th changed file is the changeset, outsidefiles: ['**/*.{ts,tsx}']): exit 0, 0 errors, 74 warnings — 0 on any line this diff added (measured againstgit diff -U0hunks; the 74 are pre-existing: ObjectChart.tsx 58, DatasetWidget.tsx 11, DatasetReportRenderer.tsx 5). Narrowing proof: the universe is eslint's ownfilesglob; the count is the JSON output's 9 entries;grep -cE 'projectService|parserOptions|project:' eslint.config.js= 0 (controlfiles:|ignores:= 9), so type-aware linting is off and no untouched file's verdict can move.check-changeset-presence(9 source files of 5 released packages, 1 changeset declared),check-changeset-fixed,check-changeset-no-major,check-changeset-overwrite: exit 0 each.check-control-bytes: OK (6206 tracked files); targeted perl scan over the diff files: 0 hits.check-i18n-call-site-keys: every in-scope key resolves and every positional default matches the en pack;check-i18n-en-drift: no en value changed;check-phantom-dependencies: OK.check:readme-exports(257 "type entry not on disk" — 22 packages this worktree never built) andcheck:spec-floors(12 findings, allno-artifacton those same unbuilt packages; the 19 built ones, including all five touched here, judged 185 subpath/symbol pairs clean). This diff changes no manifest and imports no new spec symbol; CI builds the workspace and measures both.os-verify-lock.shran in DECLARED UNLOCKED MODE (no usableflockon this macOS host) — nothing was serialized.Changeset
.changeset/7258-chart-builtin-aggregate-label.md— core and i18nminor(new exports), plugin-charts / plugin-dashboard / plugin-reportpatch.Out of scope, filed
buildDatasetFieldHelpers().headerLabel(KPI caption, table / pivot headers, report metric caption,DatasetPreview) still prints the wireCount; the resolver from this PR makes it a mechanical follow-up across five call sites (including app-shell). It remains open; nothing here addresses it.Session:
session_c5c0ce54-bb9c-478c-9e5b-cf44b80d4569🤖 Generated with Claude Code