Repository navigation
fix(plugin-charts): honour series[].type override on a dataKey-shaped series too - #8080
Conversation
… series too `ChartRenderer`'s `isInternalShaped` fast path (introduced by #2945 to fix a different bug) took the raw authored series array untouched whenever every entry already carried `dataKey`, bypassing `normalizeSeries` entirely — the only place `type` is translated to the renderer-internal `chartType`. An author who wrote the documented `dataKey` binding and the documented `type` override together (both independently valid on `ChartDataSeriesSchema`) got neither the override nor a derived combo chart, silently (objectui#7681). `ChartRenderer` now always routes the series array through the one normalization layer (objectui#2880 S1) instead of special-casing the `dataKey` shape around it. `normalizeSeries` is a no-op on a well-formed internal-shaped entry, so no existing internal caller changes behaviour. Adds the card's probe-table regression pin to ChartRenderer.specSeries.test.tsx, plus an eager `./AdvancedChartImpl` import in that file to avoid a documented flaky-under-parallel-load failure mode (AGENTS.md "测试纪律") that the new assertion made visible. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01YBWFb5YgMU5dw8p2VKj16S
✅ 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
|
Contract review on #7681 caught two issues, mechanism unchanged: - Changeset bump patch -> minor. This changes rendered output on unmodified documents (the card's own regression case: two bars become a bar and a line) and changes the delivered key set for a dataKey-shaped series array (i18n label objects are now resolved to strings; entries with no resolvable dataKey are now filtered out) -- both now disclosed in the changeset body, matching #2945's precedent (f1c04b6, shipped minor for the same sentence on the other dialect). - packages/core/src/utils/chart-presentation.ts:108-115's docblock asserted, as the reason for seriesPresentation's own type narrowing, that "ChartRenderer forwards a dataKey-shaped array untouched, so normalizeChartSchema's own identical narrowing never sees it" -- false after this PR's fix. Corrected the docblock; seriesPresentation's logic is untouched, the double narrowing stays and is idempotent. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01YBWFb5YgMU5dw8p2VKj16S
✅ 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
|
Landing — patch round verified, contract review satisfied, standing down on one red that is not this PR'sBy the dispatching seat ( Both FAIL points verified ON THE TREE, ⛔ not from the reportCommit
⭐ Why the review that caught these was worth its costNeither defect was reachable by any gate. No check enforces the bump level — CI and tier32 of 32 check runs enumerated (returned count equals ⛔ Standing down on
Stripping Generated by Claude Code |
… declares `type` (objectui#8086) (objectstack-ai#10554) Fixes objectstack-ai#8086 Clause-②: yes A published TS union widens to what `ChartDataSeriesSchema` and the renderer already accept. This executes ruling `5809905710` (align) on objectui#8086, dispatched by the `domain:ui` seat 2 (claim comment `5828875764`). ## What changed - `packages/plugin-charts/src/ChartRenderer.tsx`: the `dataKey` arm of `ChartRendererProps.schema.series` gains `type?: string`, the same member type the `name` arm declares. No other member of either arm changes. The docblock that PR objectstack-ai#8080 added ("This TS union stays as declared …") is replaced by the aligned statement. The component-body comment said `normalizeSeries` round-trips "every key the internal arm declares" unchanged. That comment is updated for the new member, because `type` is translated to `chartType` and not passed through. - `ChartRenderer.specSeries.test.tsx`: the `as any` on the `{ dataKey, type }` case is removed. The one other `as any`, on the `categories` case, stays, and a comment now gives the reason: it covers `categories`, which `ChartRendererProps.schema` does not declare. Leg B below measures this. - `ChartRenderer.seriesTypeArm-8086.test.ts` (new, in the same folder): compile-time pins against each arm. - `packages/types/src/objectql.ts`: a prose-only change. The `ObjectChartSchema.series` docblock said its element type is the internal arm "VERBATIM". After this change that arm carries `type` and the copy does not, so the sentence is rewritten. The type itself is unchanged. See Deviations. - `.changeset/8086-chart-series-type-arm.md`: `'@object-ui/plugin-charts': minor`. ## Premise measurement: the old `as any` was not needed `series` is a union with no literal discriminant. TypeScript's excess-property check on an object literal therefore only asks whether each key is known to at least one arm. On the base declaration, the specSeries literal with `{ dataKey: 'margin', type: 'line' }` compiles without the cast, because `type` is known to the `name` arm. Leg A shows this: with the cast already removed, `ChartRenderer.specSeries.test.tsx` reports zero errors. For the same reason, a `{ name, chartType }` literal compiles against the whole union on both base and head, because `chartType` is known to the `dataKey` arm. The gap the card names is real, but it is in the arm, not the union. On base, a value typed as the `dataKey` arm cannot carry `type` (TS2353), and an entry narrowed with `'dataKey' in entry` cannot read it (TS2339). So each new pin is written against a single arm, the `Extract` of the union on its binding key. Pins written against the whole union would pass on both sides of the change. ## Evidence (HEAD `ff726c28c`) **Red on base (leg A).** This leg removes only the new member from `ChartRenderer.tsx`, which restores the base declaration, and keeps every test at HEAD. The edit went through `node ../objectstack/scripts/ablation-replace.mjs`: the anchor went from 1 hit to 0, the blob changed from `e0dac80c6e03` to `ad7bb3165aac`, and after restore the blob matched HEAD and `git diff HEAD` was empty. It then ran `tsc -p tsconfig.test.json --listFiles` in `packages/plugin-charts`. The file list includes `ChartRenderer.tsx`, `ChartRenderer.seriesTypeArm-8086.test.ts` and `ChartRenderer.specSeries.test.tsx`. Line and column numbers are removed from the output below: ```text ChartRenderer.seriesTypeArm-8086.test.ts TS2339 Property 'type' does not exist on type '{ dataKey: string; ... }' (the Equal pin) ChartRenderer.seriesTypeArm-8086.test.ts TS2353 'type' does not exist in type '{ dataKey: string; ... }' (value typed as the dataKey arm) ChartRenderer.seriesTypeArm-8086.test.ts TS2339 Property 'type' does not exist on type '{ dataKey: string; ... }' (reading it back) ChartRenderer.seriesTypeArm-8086.test.ts TS2339 Property 'type' does not exist on type '{ dataKey: string; ... }' (read after narrowing with 'dataKey' in e) TSC_EXIT=2 ``` Leg A also reports no error in `ChartRenderer.specSeries.test.tsx`, which is the premise measurement above. The control `@ts-expect-error` raised no TS2578, so a `{ name, chartType }` value typed as the `name` arm is refused on base, as it is on head. **Green on head.** `pnpm run type-check` in `packages/plugin-charts` (`tsc --noEmit && tsc -p tsconfig.test.json`) printed `VERDICT command-exit 0`. **Kept cast (leg B).** With the `as any` removed from the `categories` case at HEAD, tsc reports `ChartRenderer.specSeries.test.tsx TS2353: Object literal may only specify known properties, and 'categories' does not exist in type '{ type: string; ... }'` and `TSC_EXIT=2`. After restore, the blob matched HEAD. **Tests** (repo-root form, through the shared verify lock): - `pnpm exec vitest run --maxWorkers=2 packages/plugin-charts/`: `Test Files 73 passed (73)`, `Tests 831 passed (831)`. - `pnpm exec vitest run --reporter=verbose` on the two touched test files: 2 files, 9 tests passed, 3 of them in the new pin file. - `pnpm run type-check` in `packages/types`: exit 0. - `pnpm exec vitest run --maxWorkers=2 packages/types/`: `Test Files 233 passed (233)`, `Tests 5184 passed (5184)`. **Gates** (verdict lines as printed): - `node scripts/check-changeset-presence.mjs`: `✅ 4 source file(s) of 2 released package(s) changed, and this change declares 1 changeset(s)`. - `check-changeset-no-major` ✅, `check-changeset-overwrite` ✅, `check-changeset-fixed` ✅, `check-changeset-claims`: both sections PASS. - `pnpm check:new-line-citations`: `VERDICT new-cross-file-line-citations: 0 new citation(s)`. - `pnpm check:control-bytes`: `✅ check-control-bytes: OK`. - `check:pending-changeset-literals`, `check:test-path-roots`, `check-vi-mock-specifiers` / `-inherit` / `-override-shape`, `check-type-check-coverage` (43/43), `check:published-tsconfig-exclude` and `check:unreferenced-sources`: all OK. - `node scripts/check-governed-queue-guard.mjs --test` on the five paths: `NOT GOVERNED`. - Lint was scoped to the four touched source files, with three pieces of evidence that the scoping skips nothing. First, `eslint --print-config` finds the root `eslint.config.js` for each file (117 to 118 rules), so none is ignored. Second, `--format json` shows 4 files and 0 errors; the only warnings are the existing `no-explicit-any` ones, and the specSeries file has one fewer than on base. Third, `eslint.config.js` has no `parserOptions.project` or `projectService`, so type-aware linting is off, and no local rule under `eslint-rules/` reads the filesystem. This diff therefore cannot change the lint result of any file it does not touch. The full `pnpm lint` runs in CI. - Doc and README gates: not reached. The diff touches no doc, README or doc fence, and the charts doc already lists `type` as a per-series key for either binding. ## Deviations 1. **File surface.** The claim listed `ChartRenderer.tsx` (only the `dataKey` arm and the docblock), the specSeries test with a pin next to it, and the changeset. Two edits fall outside that list. Both are prose that this change would otherwise leave false: - the component-body comment in `ChartRenderer.tsx` (same file, but not the docblock); - the `ObjectChartSchema.series` docblock in `packages/types/src/objectql.ts` (the "VERBATIM" claim). The dispatch order says to stop on a breach. The os-dev role file says published text that the change makes false must be fixed, and that the role file wins when the two conflict. So both edits are made and listed here. The claim's file surface needs the seat to add them. If the seat wants them out, removing those two hunks is enough, and the type change does not depend on them. 2. **Commit trailer.** Commit `ff726c28c` ends with the harness-supplied `Co-Authored-By` trailer, which names the model, instead of the model-free pair. History is not rewritten, because force-push is banned here. ## Acceptance notes - `ChartRendererProps` is not re-exported by name from the `@object-ui/plugin-charts` entry. Consumers reach it as the props type of the exported `ChartRenderer`. In the published 17.6.0 dist it is declared in `dist/ChartRenderer.d.ts` and used by the registry map type in `dist/index.d.ts`, and its `dataKey` arm has no `type`. The runtime half, objectui#7681, is still a pending changeset, so the declaration and the behaviour ship in the same release. - `ObjectChartSchema.series` in `@object-ui/types` (the TS interface and its zod mirror) is a copy of the internal arm and does not have `type`. Whether that published copy should follow is a separate Clause-② decision that this PR does not take. Carrier: none. - A comment in `widget-schema-anchors-7946.test.ts` says `series`' element type "is" the internal arm. Its assertion only pins `dataKey: string`, which still holds. The comment is test-only and not published, so it is left unchanged. - The `series` union has no literal discriminant, so object literals get union-wide excess-property checks, and a `{ name, chartType }` literal type-checks against the union. This PR leaves that as it is, because the ruling allows no other arm change. --- _Generated by [Claude Code](https://claude.ai/code/session_014mXUNuFomfj24w7s1pZzhN)_ Co-authored-by: Claude <noreply@anthropic.com>
Fixes #7681
What changed
ChartRenderer'sisInternalShapedfast path (added by #2945 to fix a different bug —a
name-shaped authorseriesshadowing the normalizeddataKey-shaped one) took theraw authored series array untouched whenever every entry already carried
dataKey. Thatbypassed
normalizeSeriesentirely — the ONE placestr(raw.chartType) ?? str(raw.type)translates the declared per-series override (
ChartDataSeries.type, objectui#6121) tothe renderer-internal
chartType. So an author who wrote the documenteddataKeybinding and the documented
typeoverride together — both independently valid onChartDataSeriesSchema— got neither the override nor a derived combo chart, silently.ChartRenderernow always takes the series array through the one normalization layer(objectui#2880 S1) instead of special-casing the
dataKeyshape around it:normalizeSeriesis a no-op on a well-formed internal-shaped entry — it round-tripsevery key the internal arm of
ChartRendererProps.seriesdeclares (dataKey/label/chartType/variant/opacity/dashArray/stack/yAxis/color) unchanged — so thisis not a second read site for
type(AGENTS.md #0.1); it routes every entry, of eithershape, through the same translation
normalizeChartSchemaalready applies to aname-shaped series.The
ChartRendererProps.seriesTS union is left as declared (notypeon thedataKeyarm) — widening it is a separate, public-face decision this fix does not make (see the
updated docblock in the diff).
This is a
minor, user-visible change (see Changeset below): it changes renderedoutput on unmodified documents (two bars become a bar and a line — the card's own
regression case), and it changes the delivered key set for a
dataKey-shaped seriesarray in two more ways — an i18n
labelrecord is now resolved to a string, and anentry with no resolvable
dataKeyis now dropped rather than forwarded as-is. Precedent:#2945 shipped
minor(f1c04b6) for the identical sentence on thenamedialect.Why
ChartDataSeries.type(objectui#6121 ruling: "declared because therenderer already READS it") was enforced on one binding dialect and silently dropped
on the other —
declared !== enforcedon a published member.normalization layer, rather than Option B (a second
typeread site inAdvancedChartImpl— the AGENTS.md #0.1 fallback pattern) or Option C (narrowing thedeclaration, which contradicts the declared "both shapes" series contract).
Verification
mainat the time(
0caacca373f). PR fix(plugin-charts): pie / donut / radar / scatter render as the family they name #8034 (ed4a2f1, merged 12:36Z that day) moved chart-familyresolution for the CHART-LEVEL
chartType/type(objectui#7401's surface) — adifferent key on a different surface from this card's per-SERIES
type. It does notchange this bug's premise:
normalizeChartSchema.ts'sstr(raw.chartType) ?? str(raw.type)(now at line 361, was line 244 in triage's reading) remains the onlyread of
raw.typein the package, andAdvancedChartImpl.tsxstill has zero reads ofs.type(onlys.chartType).ChartRenderer.specSeries.test.tsx, plus thename-dialect control (already presentin that file). All 3 probe-table rows, plus the pre-existing mixed-shape and
Tremor-adapter cases, pass.
isInternalShapedfast path in place, re-ran —exactly the new probe test went red at
{bars: 2, lines: 0}(matching the card'spre-registered prediction), the other 5 cases in the file stayed green. Restored the
fix (confirmed byte-identical to the pre-mutation version) and re-confirmed green.
mixed-shape series through
spec.seriesexactly as Vocabulary consolidation (#2901): what shipped, and why Track C items 1–3 are not planned #2945 already did (unchangedbehaviour for those two cases, still pinned by the existing tests in the same file);
only the
dataKey-only case changes, and only in that it now honourstypetoo.pnpm --filter @object-ui/plugin-charts test: 47 files / 434 tests green. Twocontainer-load flakes were hit along the way in files this PR does not touch
(
ObjectChart.elementDataSource.test.tsx,ChartRenderer.catalogRender-6939.test.tsx,ObjectChart.datasetMeasureLabel.test.tsx— a different subset each run) — all threereproduce the documented pattern in AGENTS.md "测试纪律" (Suspense-fallback-stuck under
parallel transform load) and pass cleanly in isolation. The new test's own file
(
ChartRenderer.specSeries.test.tsx) hit the same pattern once before this PR added aneager
import './AdvancedChartImpl'to it (matching the file's own lazy-loadspecifier), after which it was green across every full-suite rerun.
pnpm --filter @object-ui/plugin-charts type-check: clean, after building thepackage's dependency closure (
pnpm --filter '@object-ui/plugin-charts^...' build).check:control-bytes,check:published-tsconfig-exclude,changeset:check: allgreen.
check:sdui-registration-pinsandcheck:published-distneed a fullconsole / near-full-monorepo build respectively (unrelated packages this diff does not
touch) — not run locally given the cost; this diff adds no export, no registration
entry, and no package.json field change, so the regression risk on either is null.
Left for CI.
Review round
Contract review flagged two issues, both fixed, mechanism unchanged:
patch→minor, with the two undisclosed delivered-key-seteffects (i18n
labelresolution, dropped-unresolvable-dataKeyfiltering) added tothe changeset body — see "Why" above.
packages/core/src/utils/chart-presentation.ts:108-115gave, asthe reason for
seriesPresentation's owntypenarrowing, "ChartRendererforwardsa
dataKey-shaped array untouched, sonormalizeChartSchema's own identicalnarrowing never sees it" — false after this PR. Corrected the docblock;
seriesPresentation's logic is untouched (comment-only change), the double narrowingstays and is idempotent (verified: rebuilt
@object-ui/coreclean, reran the fullplugin-chartssuite green).Confirmed still correct and unchanged: #2945 cannot regress (the new form prefers the
normalized array strictly more often);
normalizeSeriesis a no-op on everywell-formed internal entry; declining to widen the
dataKeyTS arm (Clause-② staysno) — routing throughnormalizeSeriesonly filters/narrows, never accepts more.Changeset
.changeset/7681-chart-series-type-override-dataKey.md—@object-ui/plugin-charts: minor.Generated by Claude Code