Skip to content

fix(core): dashboard measures follow the display locale (#4566) - #4577

Merged
yinlianghui merged 1 commit into
mainfrom
claude/issue-4566-measure-locale
Aug 13, 2026
Merged

fix(core): dashboard measures follow the display locale (#4566)#4577
yinlianghui merged 1 commit into
mainfrom
claude/issue-4566-measure-locale

Conversation

@yinlianghui

Copy link
Copy Markdown
Collaborator

Fixes #4566

formatMeasure / formatDimensionValue in @object-ui/core formatted every value with a bare undefined locale tag at all three of their Intl sites. undefined is not "the user's locale", it is the MACHINE's — neither of the repo's two locale channels. Both take the display locale as a new optional last parameter, and DatasetWidget threads useDisplayLocale() into every site it formats through.

The fork, measured before choosing

The ruling preferred (b) route through formatDisplayNumber and retire the duplicate, with (a) as the fallback if the mapping was lossy. Both halves were measured.

The behavioural mapping is LOSSLESS. A harness replayed the current implementation against a candidate routed through formatDisplayNumber across 32,760 combinations (26 values times 10 formats times 6 currencies times 3 percentScales times 7 locales): 0 byte-level differences. The reason is worth recording — the policy layer formatDisplayNumber adds over plain Intl is grouping suppression keyed on a field's declared scale, and a measure has no scale to feed it (its decimals come from a numeral format PATTERN), so shouldGroupDisplayNumber returns true every time and the two agree everywhere. The duplicate is not missing the policy; it is unreachable by it.

The routing is blocked by the package boundary, not by behaviour. @object-ui/core is the React-free engine (AGENTS.md section 3: "No UI-lib deps. Logic only.", and dataset-format.ts's own header says purity is why it lives there). @object-ui/i18n depends on i18next / react-i18next, peer-depends on React, and publishes no pure-utility subpath — its exports map is . and ./locales/*. A core to i18n edge would put React into the dependency closure of the React-FREE consumers of core, measured as: the object-ui VS Code extension and @object-ui/data-objectstack, both of which take @object-ui/core as a runtime dependency and declare no React.

So this is (a), per the ruling's fallback, and the surviving duplication is recorded at BOTH ends (dataset-format.ts and number-display.ts). Retiring it for real means moving formatDisplayNumber DOWN into @object-ui/core and re-exporting from @object-ui/i18n — the right direction, since core is the lower layer — but that relocates a published export across a package boundary and is left to its own card.

English does not move — the discriminator against #4553

These sites already went through Intl with default grouping, so the only thing that changes is whose locale is used. Contrast #4553, where formatPercent had never grouped and moving en 1235% to 1,235% WAS the fix.

before after
en, 1234.5 0.0 1,234.5 1,234.5 (unchanged)
de, 1234.5 0.0 1,234.5 1.234,5
de, 1234.5 EUR €1,234.50 1.234,50 € (sign last, U+00A0)
de, 0.6083 0.0% 60.8% 60,8%

Omitting the new argument reproduces the previous output byte for byte, which is what makes the parameter safe to land ahead of the consumers that do not thread it yet.

Consumer census — deviates from the presumed list

The dispatch presumed DatasetWidget / ObjectMetric / a pivot path. Measured reality:

Red-first, predicted in writing before the run

Predictions are recorded in each test file's header. Runner machine locale measured as en-US.

Reverse verification by patch, never git stash; fix restored and confirmed byte-identical by sha256 (929c5a34...).

  • Pre-fix: 13 failed | 11 passed — every de/fr case red, e.g. AssertionError: expected '1,234.5' to be '1.234,5', expected '€1,234.50' to be '1.234,50 €', and expected [ '9,876.5', '1,234.5' ] to deeply equal [ '9.876,5', '1.234,5' ] for buildPivot.
  • Post-fix: 24 passed.

Every case pins two locales (de and en) rather than one, because a lone de assertion is not falsifiable: on a German runner it would pass before the fix too. With both pinned, at least one must fail on any machine — and that is also exactly the property the fix delivers, namely that the machine locale stops being an input.

Honestly labelled as NOT defect pins (green on both sides, and each says so in its own comment): the malformed-tag guard, the zh-CN case, the integer-verbatim cases, and the cellIndex invariance case.

  • zh-CN is not a discriminator. Measured, its number conventions are byte-identical to en-US (group ,, decimal .), so a Chinese session cannot produce the inverted-separator signal a German one does. The case is kept to record why zh is absent from the red-first set, not as coverage it cannot provide.

A hazard the fix itself introduces, and closes

Threading a real tag where a literal undefined used to sit is not free: undefined never throws, but a malformed tag does. Measured, en_US (underscore instead of hyphen, the likeliest tenant-config typo), !!, e and de-DE-u-nu- all throw RangeError from a bare toLocaleString, and none of the three sites had a catch — that would have taken the whole widget down. A local formatNumberInLocale mirrors formatDisplayNumber's retry-without-locale, so a bad tag degrades to the runtime default while a bad CURRENCY still throws out of both attempts, which is what keeps the existing unknown-currency fallthrough reachable.

Two behaviours deliberately preserved, both measured

  • Integers stay verbatim. That branch renders no separator and no decimal mark, so a locale has nothing to change — and routing it through Intl WOULD change it: ar-EG re-digits 1234 to its Arabic-Indic spelling, and 1e21 expands from 1e+21 to 22 digits.
  • The percent sign stays a literal suffix. Intl's style: 'percent' re-scales by 100 and the round trip loses precision at the top of the range (en 100,000,000,000,000,000,000,000% becomes 99,999,999,999,999,990,000,000% — 24 of the 32,760 combinations move, all at 1e21 / MAX_SAFE_INTEGER). Since en byte-identity is this card's discriminator, that swap cannot ride along here. Its real consequence — a German list cell writing 1.234,5 % where a dashboard measure writes 1.234,5% — is filed as [core][fields] A percent renders as 1.234,5 % in a list cell and 1.234,5% as a dashboard measure — two percent conventions for one number #4576 with the decision it needs, rather than smuggled in behind a locale fix.

Verification

.d.ts, measured both ways

Built before and after with dist/ and tsconfig.tsbuildinfo cleared between runs:

  • @object-ui/coreformatMeasure and formatDimensionValue each gain locale?: string. Both are ENTRY exports (export * from './utils/dataset-format.js'), so an optional parameter on the published surface makes this minor.
  • @object-ui/plugin-dashboardbuildPivot gains locale?: string, but it is not on the package's exports surface (absent from the built index.d.ts), so no published declaration changes: patch.
  • @object-ui/i18n — comment only, declarations byte-identical; deliberately absent from the changeset rather than releasing a version for a comment.

Generated by Claude Code

`formatMeasure` and `formatDimensionValue` formatted every value with a bare
`undefined` locale tag at all three of their `Intl` sites. `undefined` is not
"the user's locale", it is the MACHINE's — neither of the repo's two locale
channels. A German session read a dashboard KPI as `1,234.5` next to a grid
cell rendering the same number as `1.234,5`.

Both take the display locale as a new optional LAST parameter; `DatasetWidget`
threads `useDisplayLocale()` into every site it formats through (KPI, grouped
table measure and dimension cells, cross-tab headers and cells).

English output does not move — these sites already grouped through `Intl`, so
the only change is whose locale is used. Omitting the argument reproduces the
previous output byte for byte.

Measured: routing through `formatDisplayNumber` is behaviourally LOSSLESS
(0 diffs across 32,760 combinations) but blocked by the package boundary —
`@object-ui/core` is React-free and consumed by React-free packages, while
`@object-ui/i18n` peer-depends on React and exports no pure-utility subpath.
The surviving duplication is recorded at both ends.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017Qqyix2QcnpUC9XeYVDzx3
@vercel

vercel Bot commented Aug 13, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
objectui Ignored Ignored Aug 13, 2026 12:15pm

Request Review

@github-actions

Copy link
Copy Markdown
Contributor

✅ Console Performance Budget

Metric Value Budget
Main entry (gzip) 24.7 KB 350 KB
Entry file index-nUP4gvQZ.js
Status PASS

📦 Bundle Size Report

Package Size Gzipped
app-shell (index.js) 9.56KB 3.59KB
app-shell (runtime-config.js) 7.42KB 2.32KB
app-shell (types.js) 0.01KB 0.04KB
app-shell (urlParams.js) 8.92KB 3.41KB
auth (AuthContext.js) 0.31KB 0.24KB
auth (AuthGuard.js) 1.17KB 0.53KB
auth (AuthProvider.js) 25.13KB 5.40KB
auth (AuthShell.js) 3.49KB 1.40KB
auth (ForgotPasswordForm.js) 12.21KB 3.45KB
auth (LoginForm.js) 18.13KB 5.39KB
auth (PreviewBanner.js) 0.90KB 0.50KB
auth (RegisterForm.js) 6.64KB 2.21KB
auth (SocialSignInButtons.js) 9.60KB 3.89KB
auth (UserMenu.js) 3.40KB 1.22KB
auth (auth-gate-events.js) 1.29KB 0.66KB
auth (authStyles.js) 5.04KB 1.72KB
auth (createAuthClient.js) 38.46KB 10.17KB
auth (createAuthenticatedFetch.js) 6.34KB 2.43KB
auth (index.js) 2.35KB 1.07KB
auth (org-roles.js) 6.66KB 2.78KB
auth (phone-identifier.js) 1.11KB 0.66KB
auth (types.js) 0.59KB 0.35KB
auth (useAuth.js) 5.02KB 0.88KB
auth (useIsWorkspaceAdmin.js) 1.61KB 0.85KB
collaboration (CommentThread.js) 26.07KB 7.56KB
collaboration (LiveCursors.js) 3.17KB 1.27KB
collaboration (PresenceAvatars.js) 6.49KB 2.64KB
collaboration (PresenceProvider.js) 2.79KB 1.13KB
collaboration (index.js) 1.65KB 0.73KB
collaboration (useCollaborationTranslation.js) 6.05KB 2.52KB
collaboration (useCommentSearch.js) 1.98KB 0.88KB
collaboration (useConflictResolution.js) 7.75KB 1.86KB
collaboration (useMentionNotifications.js) 1.81KB 0.68KB
collaboration (usePresence.js) 6.33KB 1.84KB
collaboration (useRealtimeSubscription.js) 7.91KB 2.01KB
components (index.js) 489.32KB 108.45KB
core (index.js) 3.37KB 1.34KB
create-plugin (index.js) 10.08KB 3.26KB
data-objectstack (index.js) 163.56KB 44.83KB
fields (index.js) 230.37KB 57.17KB
i18n (LocalizationContext.js) 1.76KB 0.96KB
i18n (currency.js) 1.22KB 0.64KB
i18n (i18n.js) 4.32KB 1.77KB
i18n (index.js) 3.35KB 1.38KB
i18n (pickLocalized.js) 3.69KB 1.73KB
i18n (provider.js) 23.12KB 7.62KB
i18n (useDisplayLocale.js) 2.84KB 1.45KB
i18n (useObjectLabel.js) 27.59KB 6.63KB
i18n (useSafeTranslation.js) 7.77KB 3.13KB
layout (index.js) 38.98KB 10.85KB
mobile (MobileProvider.js) 0.92KB 0.49KB
mobile (ResponsiveContainer.js) 0.94KB 0.38KB
mobile (breakpoints.js) 1.51KB 0.70KB
mobile (createOfflineDataSource.js) 5.61KB 1.74KB
mobile (index.js) 1.50KB 0.62KB
mobile (offlineQueue.js) 3.91KB 1.35KB
mobile (pwa.js) 0.97KB 0.49KB
mobile (serviceWorker.js) 1.48KB 0.62KB
mobile (serviceWorkerSource.js) 3.41KB 1.48KB
mobile (useBreakpoint.js) 1.54KB 0.65KB
mobile (useGesture.js) 6.96KB 1.98KB
mobile (useOfflineSync.js) 1.99KB 0.72KB
mobile (usePullToRefresh.js) 2.53KB 0.85KB
mobile (useResponsive.js) 0.71KB 0.42KB
mobile (useResponsiveConfig.js) 1.36KB 0.63KB
mobile (useSpecGesture.js) 4.32KB 1.64KB
mobile (useTouchTarget.js) 1.01KB 0.54KB
permissions (MePermissionsProvider.js) 8.75KB 3.06KB
permissions (PermissionContext.js) 0.31KB 0.25KB
permissions (PermissionGuard.js) 0.89KB 0.45KB
permissions (PermissionProvider.js) 3.67KB 1.12KB
permissions (evaluator.js) 4.41KB 1.44KB
permissions (index.js) 0.91KB 0.41KB
permissions (store.js) 0.91KB 0.42KB
permissions (useFieldPermissions.js) 1.28KB 0.52KB
permissions (usePermissions.js) 1.55KB 0.71KB
plugin-ai (index.js) 15.75KB 3.80KB
plugin-calendar (index.js) 46.86KB 12.91KB
plugin-charts (index.js) 62.10KB 17.67KB
plugin-chatbot (index.js) 181.21KB 43.14KB
plugin-dashboard (index.js) 121.04KB 31.57KB
plugin-designer (index.js) 212.58KB 42.83KB
plugin-detail (index.js) 239.88KB 59.99KB
plugin-editor (index.js) 2.46KB 1.10KB
plugin-form (index.js) 114.58KB 27.68KB
plugin-gantt (index.js) 164.30KB 40.02KB
plugin-grid (index.js) 189.37KB 50.33KB
plugin-kanban (index.js) 52.74KB 14.53KB
plugin-list (index.js) 111.13KB 27.12KB
plugin-map (index.js) 18.16KB 5.81KB
plugin-markdown (index.js) 13.72KB 4.69KB
plugin-report (index.js) 41.16KB 10.96KB
plugin-timeline (index.js) 26.68KB 7.66KB
plugin-tree (index.js) 8.50KB 2.88KB
plugin-view (index.js) 84.08KB 20.55KB
providers (DataSourceProvider.js) 0.75KB 0.39KB
providers (MetadataProvider.js) 1.37KB 0.59KB
providers (ThemeProvider.js) 1.90KB 0.85KB
providers (UploadProvider.js) 11.71KB 3.53KB
providers (index.js) 0.44KB 0.22KB
providers (types.js) 0.01KB 0.04KB
react-runtime (index.js) 5.67KB 2.37KB
react (LazyPluginLoader.js) 3.77KB 1.33KB
react (SchemaRenderer.js) 23.73KB 7.96KB
react (data-invalidation.js) 5.05KB 2.08KB
react (index.js) 1.23KB 0.66KB
react (spec-input.js) 0.20KB 0.18KB
sdui-parser (codegen.js) 4.09KB 1.74KB
sdui-parser (index.js) 4.47KB 2.03KB
sdui-parser (parse.js) 10.04KB 2.82KB
sdui-parser (types.js) 0.29KB 0.24KB
sdui-parser (validate.js) 4.69KB 1.48KB
types (ai.js) 0.20KB 0.17KB
types (api-types.js) 0.20KB 0.18KB
types (app.js) 2.87KB 0.99KB
types (base.js) 0.20KB 0.18KB
types (blocks.js) 0.20KB 0.18KB
types (complex.js) 0.20KB 0.18KB
types (crud.js) 0.20KB 0.18KB
types (dashboard-filter-alias.js) 6.23KB 2.74KB
types (data-display.js) 0.20KB 0.18KB
types (data-protocol.js) 0.20KB 0.19KB
types (data.js) 0.20KB 0.18KB
types (designer.js) 1.87KB 0.85KB
types (disclosure.js) 0.20KB 0.18KB
types (error-code.js) 1.54KB 0.88KB
types (feedback.js) 0.20KB 0.18KB
types (field-types.js) 0.20KB 0.18KB
types (form.js) 0.20KB 0.18KB
types (http-retry.js) 4.32KB 2.02KB
types (index.js) 3.05KB 1.52KB
types (layout.js) 0.20KB 0.18KB
types (managed-by.js) 0.19KB 0.18KB
types (mobile.js) 2.59KB 1.31KB
types (navigation.js) 0.20KB 0.18KB
types (objectql.js) 0.20KB 0.18KB
types (overlay.js) 0.20KB 0.18KB
types (permissions.js) 0.20KB 0.18KB
types (plugin-scope.js) 0.20KB 0.18KB
types (record-components.js) 0.20KB 0.19KB
types (record-semantics.js) 1.28KB 0.67KB
types (registry.js) 0.20KB 0.18KB
types (reports.js) 0.20KB 0.18KB
types (spec-report.js) 5.05KB 1.93KB
types (system-fields.js) 3.33KB 1.54KB
types (theme.js) 0.20KB 0.18KB
types (ui-action.js) 3.40KB 1.71KB
types (views.js) 0.20KB 0.18KB
types (widget.js) 0.20KB 0.18KB

Size Limits

  • ✅ Core packages should be < 50KB gzipped
  • ✅ Component packages should be < 100KB gzipped
  • ⚠️ Plugin packages should be < 150KB gzipped

Copy link
Copy Markdown
Collaborator Author

PM step-7 复核 — ACCEPT (session_017Qqyix2QcnpUC9XeYVDzx3)

  • The fork was resolved exactly as the ruling's fallback clause intended, with the blocker MEASURED rather than assumed: the 32,760-combination harness proves the behavioural mapping lossless (and records WHY — the grouping policy is unreachable without a scale), while the package edge is architecturally closed (core is React-free by charter; i18n carries i18next/react-i18next; the real consumers of core's purity are named). Fallback (a) taken, duplication recorded at BOTH ends with the correct retirement direction (formatDisplayNumber moves DOWN into core) stated where the next author will read it.
  • The hazard-found-and-closed section is the reason we measure: a real tag where a literal undefined sat means en_US-style tenant typos would have CRASHED the widget from three catch-less sites — the retry-without-locale mirror closes it while keeping the unknown-currency fallthrough reachable, verified.
  • The census corrected the dispatch twice (ObjectMetric renders through the already-threaded MetricWidget; no memos exist so no dep case — stated explicitly), and the falsifiability design is the new house standard for locale pins: every case pins TWO locales so at least one must fail on ANY runner — the machine locale stops being an input to the test, which is precisely the property the fix delivers. The zh correction (byte-identical conventions to en-US — cannot produce the signal) fixes my own dispatch's expectation and is kept as a labelled coincidence pin.
  • Both deliberately-preserved behaviours (integer String(v) against ar-EG re-digiting and 1e21 expansion; literal percent suffix against Intl's precision loss at extremes) are measured, and preserving them is what keeps en byte-identity — this card's discriminator — honest.
  • Grading exact per shape (core minor entry-reachable, dashboard patch non-surface, i18n comment-only correctly absent). Findings [plugin-report][app-shell] Dataset measures still render in the MACHINE locale — the consumers #4566 could not reach #4575/[core][fields] A percent renders as 1.234,5 % in a list cell and 1.234,5% as a dashboard measure — two percent conventions for one number #4576 filed properly.
  • Rulings on the two open questions: Q2 = A, Fixes #4566 stands — the card scopes the dashboard surfaces and the ruled surface is fully covered; [plugin-report][app-shell] Dataset measures still render in the MACHINE locale — the consumers #4566 could not reach #4575 tracks the rest. Q1 = the recommendation adopted: option B (move formatDisplayNumber down, i18n re-exports) is endorsed as its OWN card, not urgent at zero measured drift — and [core][fields] A percent renders as 1.234,5 % in a list cell and 1.234,5% as a dashboard measure — two percent conventions for one number #4576's percent-NBSP split is the live symptom of exactly that two-homes drift, so the two should be ruled together when triage takes them.

Auto-merge armed (squash) — landing verified per the merge-queue discipline. #4575 dispatches next, gated on this landing.


Generated by Claude Code


Generated by Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[core] formatMeasure renders every dashboard measure in the MACHINE locale — the last parallel implementation outside the display-locale channel

2 participants