Uh oh!
There was an error while loading. Please reload this page.
fix(plugin-charts): route ObjectChart's option-color probe through the host apiFetch - #4122
Merged
Merged
Conversation
…e host apiFetch (#4114) ObjectChart's category option-color / dimension-label effect made both of its metadata reads — GET /api/v1/meta/dataset/<dataset> (:344) and GET /api/v1/meta/object/<object> (:352) — on the bare global fetch, so a hosted console's authenticated channel (SchemaRendererContext.apiFetch, supplied at ConsoleShell.tsx:245) was bypassed: no Authorization/tenant headers, no base-URL rewrite, no draft-preview params. The effect is best-effort and swallows every failure, so the symptom was silent — semantic option colors and dataset dimension labels never applied and the chart fell back to the positional theme palette and raw stored values. Both reads now go through `apiFetch ?? fetch`, the documented convention (useRecordEditable.ts:32, ObjectGantt.tsx:461-468, useViewData.ts:100-107). Standalone embeds keep working: no provider, or a provider that supplies no apiFetch, still uses the global fetch. Claude-Session: https://claude.ai/code/session_017Qqyix2QcnpUC9XeYVDzx3 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…routing pins `SchemaRendererProvider.dataSource` is already typed `any`, and the recorder's fake Response can be cast once inside the helper as `ApiFetch` — so the four new tests add zero `no-explicit-any` warnings. Claude-Session: https://claude.ai/code/session_017Qqyix2QcnpUC9XeYVDzx3 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The latest updates on your projects. Learn more about Vercel for GitHub. |
Contributor
✅ Console Performance Budget
📦 Bundle Size Report
Size Limits
|
yinlianghui
marked this pull request as ready for review
August 10, 2026 11:26
Uh oh!
There was an error while loading. Please reload this page.
This was referenced Aug 10, 2026
github-merge-queueBot
pushed a commit
that referenced
this pull request
Aug 10, 2026
…gh the host apiFetch (#4134) The widget's `GET /api/v1/meta/object/{object}` read — which feeds `buildOptionColorMap` (per-category colors for the first dimension) and `buildDimensionLabelMap` (the value -> label maps for the axis/series) — went out on the bare global `fetch`, bypassing whatever the host supplies on `SchemaRendererContext.apiFetch`. The effect is best-effort and swallows every failure, so a hosted console got no error at all: semantic colors and option labels simply never applied. DatasetWidget takes its `dataSource` as a prop and read no context, so the channel is added here as a direct `useContext(SchemaRendererContext)` read (not `useSchemaContext()`, which throws with no provider mounted) and used as `apiFetch ?? fetch`, keeping the global fallback for standalone embeds. The plugin-dashboard twin of #4114 / PR #4122. Claude-Session: https://claude.ai/code/session_017Qqyix2QcnpUC9XeYVDzx3 Co-authored-by: Claude <noreply@anthropic.com>
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 freeto join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes#4114
Branched off
origin/main@ce4b9e8af— PR #4115 (issue #4106) had already merged when this started, so this is not stacked; its four test files and their recording doubles are on main.Premise: verified, still valid
Both bare reads are exactly where the issue said, at the unchanged line numbers on
ce4b9e8af:and the injection point is genuinely in scope —
const context = useContext(SchemaRendererContext);at line 253, already used one line later fordataSource. Nothing had drifted.The fix
const doFetch = apiFetch ?? fetch;at the top of the effect, both call sites through it — the idiomuseRecordEditable.ts:74implements anduseRecordEditable.ts:32documents ("the same channelprovider: 'api'view sources use, not the bare global one"), matchingObjectGantt.tsx:461-468anduseViewData.ts:100-107.Two details taken from the references rather than invented:
useSchemaContext()— that hook throws with no provider mounted, and a standalone chart embed has to keep rendering. Same reasonuseRecordEditablegives at its own context read.apiFetchjoins the effect's dependency array, as it does inuseRecordEditable's. This does not re-open the refetch-loop hazard the surrounding code guards against:ObjectChart's ownsetStatecannot re-render the provider, so the context value — and with it theapiFetchidentity — is stable across the effect's own updates.The sole in-repo host holds it at module scope (
ConsoleShell.tsx:187→:245), so the identity is stable there too.Behavior boundary — the fallback half is pinned, not assumed
Standalone embeds keep working on the global
fetch, and there are two distinct no-channel shapes, both now pinned:dataSourcebut noapiFetch— the shape every existing suite mounts, e.g.ObjectChart.elementDataSource.test.tsx. Presence of a host is not presence of a channel.Tests
Four pins added to
ObjectChart.optionColors.test.tsx(the file #4115 created for this effect), in a newobjectui#4114block. The routing is read off two separate recorders — the global-fetchstub #4115 already had, plus a standalone recorder handed in as the provider'sapiFetch:accept: application/json), and the routed answer reaches the renderer ascategoryColors;:344then:352, in order) are in the host recorder, global empty, and the dimension labels resolved over the host channel reach the rows;apiFetch→ global recorder holds the probe.Both recorders answer the same documents, so the data path stays green either way and the only thing these pins can go red on is the routing itself.
No existing test was changed in meaning. The
plugin-chartsdiff is additive apart from one import line; the four #4115 files are untouched. That follows from the behavior boundary above — every existing mount is a no-apiFetchshape, so the routing change genuinely moves nothing for them. (The second commit only deletes threeas anycasts from the new pins:SchemaRendererProvider.dataSourceis already typedany, and the recorder's fake Response is cast once inside its helper.)Verification
Repo root, both packages, per AGENTS.md:
stderr stays entirely empty — #4115's no-escape guarantee survives the routing change.
Reverse verification, direction predicted before running: revert only the product routing (
git checkout origin/main -- ObjectChart.tsx, new tests held), and the two host-mounted pins go red while the two fallback pins and all three #4106 pins stay green — because with no channel supplied, pre-fix and post-fix code do the identical thing.Exactly as predicted, 2 red / 5 green, and both failures name the host recorder holding nothing — the escape landing in the global recorder instead. Restored afterwards;
git diffclean.Gates:
pnpm --filter @object-ui/plugin-charts type-checkgreen (afterpnpm --filter '@object-ui/plugin-charts^...' build, the fresh-worktree dependency closure).eslinton both changed files 0 errors; the test file is at 2 warnings, both pre-existing #4115 lines — the new tests add zero.check-changeset-presence/check-changeset-no-major/check-control-bytesgreen, plus a control-byte self-scan over the three changed files.Changeset
@object-ui/plugin-chartspatch — a real behavior fix on a released package, not internal-only, so an empty-frontmatter declaration would be wrong here.Out of scope, filed
#4121 —
plugin-dashboard'sDatasetWidget.tsx:589reads the same/api/v1/meta/object/…document off the globalfetch, for the same colors and labels, with the same silent symptom. #4114's body anticipated this twin. Not folded in: different package, different component, and it needs its own decision about where the context read goes (DatasetWidgetdoes not consultSchemaRendererContextat all today).Generated by Claude Code