Skip to content
This repository was archived by the owner on Nov 4, 2026. It is now read-only.

Commit 6837bfa

Browse files
fix(plugin-charts): an object-chart whose family is on specType gets compareTo as its chartType twin does (objectui#11530) (#11537)
Fixes #11530 Clause-②: no Dispatched by the PM loop, round 1 (`domain:ui` seat 1), claim comment `5965044944`, session `https://claude.ai/code/session_01YLg8XqWGJ785fwQ5v4pH37`. Triage ruling `5964859128` executed as written. ## The defect, reproduced at BASE `06634afe7` `ObjectChart` gates the comparison fetch (`wantsComparison`) and the overlay series (`enableComparisonSeries`) on `chartTypeIgnoresCompareTo(schema.chartType)`. A family on `specType` was invisible to both. Measured through the real `SchemaRenderer` with the final pin and `ObjectChart.tsx` at BASE: - The card's document (`properties` bag, `specType: scatter`, `compareTo: { kind: 'previousYear' }`): **2** aggregate calls, then the `scatter-multi-series` refusal "A scatter plots one measure. Keep exactly one series: amount, amount__comparison", with no chart surface. - `specType` set to `pie`, `donut` or `funnel`: **2** calls, and one pie (or funnel) drawn. The comparison rows are never drawn. - The `chartType` twins: **1** call each, and the scatter draws. ## The fix - **One reader.** `chartFamily = normalizeChartSchema(schema, language).chartType`, memoised at component scope. That is the value `ChartRenderer` dispatches on (`schema.chartType ?? spec.chartType` over the same normalizer: `chartType`, else `specType`), so the gates read the family the chart is drawn as. It was already importable, so `normalizeChartSchema.ts` is untouched and nothing new is exported. There is no hand-rolled `chartType ?? specType`. - **One list.** Both gates read that family through `chartTypeIgnoresCompareTo`. Its family list in `@object-ui/core` is untouched (objectui#7495). - **The fetch key.** The fetch callback's dependency list keys on `chartFamily` instead of `schema.chartType`: it is the input of the same compare decision. A `specType` family change now re-runs the fetch under the new family's gate. - `language` is passed although no label is read off the result, so `resolveChartCategoryField` stays the package's one call without it, as the comment beside it says. - **Where `specType` sits.** The `SchemaRenderer` properties hoist copies `properties.*` flat onto the node before `ObjectChart` sees it, and `normalizeChartSchema` reads the flat key. So the bag form and the flat forms reach the same reader. The pin covers each shape. No other `schema.chartType` read in `ObjectChart.tsx` decides behaviour. The three code reads before the change were the two gates and the fetch key; after it there are none. ## Pins `packages/plugin-charts/src/__tests__/object-chart-compareto-spectype-11530.test.tsx` (new), through the real `SchemaRenderer` and this package's registrations. Every expectation is read off `chartTypeIgnoresCompareTo`; no family list is restated. - **Per object-path shape** (the `properties` bag, which is the card's document; the dashboard producer's flat node; the react-page wrapper's node): - `specType: scatter` with `compareTo` draws one scatter after 1 call, with no refusal; - `specType: pie` makes 1 call; - CONTROL: `specType: bar` makes 2 calls and draws 2 bars (the overlay); - CONTROL: the `chartType` twins answer scatter 1, pie 1, bar 2 with the overlay. - **The flat node with inline rows that already carry the comparison column.** It fetches nothing, so it isolates the overlay gate. `specType: scatter` draws instead of refusing; CONTROL: `bar` on both channels draws the overlay. - **Every spec family (20) on the card's document:** `specType` makes the call count `chartTypeIgnoresCompareTo` predicts, the same as `chartType`, and shows the same form. - **The dataset node** (scatter, pie, bar): both channels make the same calls and show the same form. - **A `specType` family change, bar to pie:** 2 calls, then exactly 1 more, and the pie drawn. - **Premise:** the card's document parses on `safeValidateSchema` and `StrictAnyComponentSchema` with scatter, pie and bar on `specType`. ## Reverse verification and ablation (predicted first, all at committed head `4589e68c0`) The subject resolves to `src` through the vitest alias, so no `dist` leg applies. The three mutations went through objectstack's `scripts/ablation-replace.mjs` (anchor 1 to 0, blob moved; restore proven by blob equal to `HEAD` and an empty `git diff HEAD`). The BASE leg was `git checkout 06634af -- ObjectChart.tsx`, restored with `git checkout HEAD --` and the same two proofs. | leg | prediction | reading | |---|---|---| | **BASE** `ObjectChart.tsx` | red: 3 shapes x (scatter, pie), inline scatter, the 4 ignoring families in the matrix, the re-run row = 12 | **12 failed, 28 passed (40)**, exactly those | | **A1:** the fetch gate back to `schema.chartType` | the 6 shape rows, the 4 matrix rows, and the re-run row (it re-runs, then fetches the comparison) = 11; inline scatter stays green | **11 failed, 29 passed (40)**, exactly those | | **A2:** the overlay gate back to `schema.chartType` | only inline scatter (the object paths never get the column) | **1 failed, 39 passed (40)**, that one | | **A3:** the fetch key back to `schema.chartType` | only the re-run row (calls stay at 2) | **1 failed, 39 passed (40)**, that one | ## Gates (at `4589e68c0`) - `pnpm exec vitest run packages/plugin-charts/` plus every test naming `compareTo` or `chartTypeIgnoresCompareTo` (`git grep -l`; 17 outside plugin-charts, in console, core, data-objectstack, plugin-dashboard, react and types): **106 files, 1889 passed, 9 skipped**. - `pnpm turbo run build --filter='./packages/*'` (39 of 39; plugin-charts, plugin-dashboard, runner and app-shell rebuilt), then `pnpm --filter @object-ui/plugin-charts type-check` (`tsc --noEmit` and `tsc -p tsconfig.test.json`, whose file list includes the new pin): exit 0. - `pnpm --filter @object-ui/console build`, the `Bundle Analysis` program (`tsc`, vite build, SDUI manifest, `tsconfig.plugin.json`): exit 0. - Exit 0 with their own verdict lines: `check:control-bytes`, `check:new-line-citations` (0 new), `check-changeset-presence.mjs`, `changeset:check`, `check:pending-changeset-literals`, `check:self-import`, `check:test-path-roots`, `check:vi-mock-specifiers`, `check:vi-mock-inherit`, `check:vi-mock-override-shape`, `check:spec-symbols`, `check:phantom-deps`, `check:unreferenced-sources`, `check:esm-specifiers` (specifier leg), `check:sdui-registration-pins`, `check:element-data-source-declaration`, `check:installed-pin-claims`, `check:handler-key-reads`, `check:shell-escape-residue` and `check:i18n-keys`. - `check:changeset-claims` (report-only) named 4 pending changesets that cite `ObjectChart.tsx`: `8650-chart-foreign-dialect-retired`, `8885-object-chart-drilldown-title-compareto`, `humanize-label-single-home-5444` and `objectchart-schema-anchor-7946`. Each paragraph was read. None says how the compare gate reads the family, so none goes false. - **Lint, a declared narrowing.** `eslint --no-inline-config --format json` over the changed files read 3 entries: - the 2 TS files, 0 errors. `ObjectChart.tsx` has 41 warnings, the same 41 by rule as BASE (linted through `--stdin`). The pin has 2, both `no-explicit-any` in the `vi.mock('recharts')` block, the sibling pattern; - the changeset, which the config ignores. - The population is the root flat config: plugin-charts' `lint` is `eslint .` and the package has no config of its own. `eslint.config.js` sets no `parserOptions.project` / `projectService`, and no rule in `eslint-rules/` reads the filesystem, so this diff cannot move a verdict on an untouched file. The repo-wide lint belongs to CI. ## Acceptance notes - **What an accepted document does differently:** `specType: scatter` with `compareTo` draws instead of refusing; `specType` set to `pie`, `donut` or `funnel` stops the unused comparison fetch, with the same picture. A family on `chartType`, and every family that keeps `compareTo` on either key, is unchanged. Changeset: `@object-ui/plugin-charts` `patch`. - **Route:** the ruling's effective family is read through `normalizeChartSchema`, which is already exported and already called by this file. Exporting the family expression on its own was the claim's fallback and was not needed. - **`Clause-②: no` holds:** no exported type moves; the change is inside the component body. - **The overlay gate alone** is reachable only when the rows already carry the comparison column (inline or bound rows with an `aggregate`). The pin's inline shape is that case, built to isolate it. - **Noted, not filed:** the dataset-bound path of `ObjectChart` forwards no `compareTo` to `queryDataset` for any family. The pin holds only that both channels agree there. `compareTo` on `object-chart` is declared INTERNAL (relay-composed by `DashboardRenderer`), and no producer of a dataset-bound `object-chart` with `compareTo` was measured. Carrier: none. - **Docs:** nothing under `content/docs`, in the package README or under `skills/` mentions `compareTo`, so no doc moves. --- _Generated by [Claude Code](https://claude.ai/code/session_01YLg8XqWGJ785fwQ5v4pH37)_ --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 8bfc001 commit 6837bfa

3 files changed

Lines changed: 424 additions & 4 deletions

File tree

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
'@object-ui/plugin-charts': patch
3+
---
4+
5+
fix(plugin-charts): an `object-chart` whose family is on `specType` gets `compareTo` exactly as the same family on `chartType` does, so a `specType: scatter` chart with `compareTo` draws instead of refusing, and `specType: pie` makes no comparison fetch (objectui#11530)
6+
7+
`ObjectChart` decides two things with `chartTypeIgnoresCompareTo` from `@object-ui/core`: whether to run the comparison query, and whether to add the `__comparison` overlay series. Both read only `chartType`. A family on `specType` (the react tier's channel, which objectui#11520 routes) was invisible to them. So a family that ignores `compareTo` (`pie`, `donut`, `funnel` and `scatter` at this release) still fetched the comparison window and still got the overlay:
8+
9+
- **`specType: scatter` with `compareTo`** made 2 aggregate calls and rendered the refusal "A scatter plots one measure. Keep exactly one series: amount, amount__comparison" (with the document's own measure). It now makes 1 call and draws the scatter.
10+
- **`specType: pie`, `donut` or `funnel` with `compareTo`** made a comparison call whose rows the chart never drew. It now makes 1 call. The picture is unchanged.
11+
12+
Both decisions now read the family the chart draws, which is the value `normalizeChartSchema` hands `ChartRenderer`: `chartType`, else `specType`. The family list stays the one in `chartTypeIgnoresCompareTo`. The object fetch also re-runs when that family changes, where it used to re-run on a `chartType` change only.
13+
14+
No other document changes: a family on `chartType` and every family that keeps `compareTo` (on either key) fetch and draw as before.

‎packages/plugin-charts/src/ObjectChart.tsx‎

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -554,6 +554,29 @@ export const ObjectChart = (props: ObjectChartProps) => {
554554
// only source of it.
555555
const { t, language } = useObjectTranslation();
556556

557+
/**
558+
* The chart family this block DRAWS, for the two `compareTo` gates below:
559+
* the comparison fetch in `fetchData` and the overlay series
560+
* (`enableComparisonSeries`), objectui#11530.
561+
*
562+
* Read through `normalizeChartSchema`, the translation `ChartRenderer`
563+
* dispatches on, so it is `chartType`, else `specType` (objectui#11520): a
564+
* family on either channel meets `chartTypeIgnoresCompareTo` as the value the
565+
* chart is drawn as. Both gates used to read `schema.chartType` alone, so a
566+
* family on `specType` (the react tier's channel) was invisible to them. A
567+
* `specType: scatter` then fetched the comparison window, got the overlay
568+
* series and refused its own two series; a `specType: pie` paid for a fetch
569+
* it never drew. ⛔ No compare decision in this file reads `schema.chartType`
570+
* or `schema.specType` directly: one family reader here, one family list in
571+
* `chartTypeIgnoresCompareTo`.
572+
*
573+
* `language` is passed although no label is read off the result, so the call
574+
* in `resolveChartCategoryField` stays the package's one call without it. The
575+
* memo is a cost hint only: the answer is a string, so nothing keys on an
576+
* identity (AGENTS.md #10).
577+
*/
578+
const chartFamily = useMemo(() => normalizeChartSchema(schema, language).chartType, [schema, language]);
579+
557580
// Stable JSON keys for aggregate/filter so that callers passing a fresh
558581
// object literal on each render (e.g. DashboardRenderer.getComponentSchema)
559582
// do not trigger infinite refetch loops.
@@ -809,8 +832,10 @@ export const ObjectChart = (props: ObjectChartProps) => {
809832
// #7194's two-or-more-series scatter refusal. WHICH families is
810833
// `chartTypeIgnoresCompareTo` in `@object-ui/core`'s chart-presentation:
811834
// the one declaration the dashboard's DatasetWidget reads too
812-
// (objectui#7495). This file keeps no list of its own.
813-
const wantsComparison = !!compareTo && !chartTypeIgnoresCompareTo(schema.chartType);
835+
// (objectui#7495). This file keeps no list of its own. WHICH family
836+
// this chart is, is `chartFamily`: the one it draws, on either family
837+
// channel (objectui#11530).
838+
const wantsComparison = !!compareTo && !chartTypeIgnoresCompareTo(chartFamily);
814839
// shiftFilterByCompareTo expects the raw filter (with date macros)
815840
// so it can substitute `{current_*}` tokens or re-resolve macros
816841
// against a shifted `now`. It only understands the date vocabulary,
@@ -944,7 +969,7 @@ export const ObjectChart = (props: ObjectChartProps) => {
944969
// this list (`schema.aggregate`, `schema.dataset`, ...), which predate
945970
// this change.
946971
// eslint-disable-next-line react-hooks/exhaustive-deps
947-
}, [schema.objectName, datasetKey, aggregateKey, filterKey, compareToKey, schema.xAxisKey, schema.chartType, runAggregate, filterScope, fieldOptionLabel]);
972+
}, [schema.objectName, datasetKey, aggregateKey, filterKey, compareToKey, schema.xAxisKey, chartFamily, runAggregate, filterScope, fieldOptionLabel]);
948973

949974
// objectui#10035 — the refresh input this chart had none of, so a host could
950975
// show it a write only by remounting it (AGENTS.md #8's corollary: refresh
@@ -1153,14 +1178,16 @@ export const ObjectChart = (props: ObjectChartProps) => {
11531178
// Merge data if not provided in schema. When `compareTo` is configured
11541179
// for a supported chart type, also synthesize a second series so the
11551180
// chart implementation renders the comparison overlay (dashed / muted).
1181+
// "Supported" is asked of the family the chart draws (`chartFamily`, either
1182+
// family channel), exactly as the comparison fetch asks it (objectui#11530).
11561183
const compareToConfig: CompareToConfig | undefined = schema.compareTo;
11571184
// The result column this aggregate projects its value under, and the column
11581185
// the comparison overlay arrives in (framework#3701).
11591186
const valueKey = schema.aggregate ? aggregateValueKey(schema.aggregate) : undefined;
11601187
const comparisonKey = valueKey ? `${valueKey}${COMPARISON_SUFFIX}` : undefined;
11611188
const enableComparisonSeries =
11621189
!!compareToConfig &&
1163-
!chartTypeIgnoresCompareTo(schema.chartType) &&
1190+
!chartTypeIgnoresCompareTo(chartFamily) &&
11641191
!!comparisonKey &&
11651192
finalData.some((row: Record<string, any>) => row[comparisonKey] != null);
11661193

0 commit comments

Comments
 (0)