Uh oh!
There was an error while loading. Please reload this page.
fix(plugin-dashboard): route DatasetWidget's option-color probe through the host apiFetch - #4134
Merged
Merged
Conversation
…gh the host apiFetch
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.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017Qqyix2QcnpUC9XeYVDzx3The 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 12:12
This was referenced Aug 10, 2026
Uh oh!
There was an error while loading. Please reload this page.
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#4121
Branched off
origin/main@bcd3e0219— that tip is PR #4122's merge commit, so the ObjectChart sibling is already on main and this is not stacked. Different package, no shared code; the two fixes only share a pattern.Premise: verified, still valid
The bare read is exactly where the issue said, at the unchanged line number on
bcd3e0219:Both halves of the claim hold:
try { … } catch { … setCategoryColors(null); setDimensionLabels(null); setCategoryOrder(null); }. Every failure, including a 401, is swallowed into "no colors, no labels", never an error state. Note it also nullscategoryOrder, so a third product of this one document (the declared category order, framework#3588) was silently lost too.fetchacross the whole file, and then across all ofpackages/plugin-dashboard/src(non-test), returns exactly this one call site. The card said to measure rather than trust the cited line; measured, one is the true count.The card's one real decision: where the channel comes from
The filing dev flagged that unlike
ObjectChart,DatasetWidgetconsults no context today — it takesdataSourceas a prop (DatasetWidget({ widget, dataSource }), andDashboardRendererpasses it down). So there was nothing to hangapiFetchoff.The component's structure does not prevent the family convention — the fetch happens inside a normal
useEffectin a normal function component — so the default applies and no second channel was invented:Two details taken from the references rather than invented:
useSchemaContext()— that hook throws with no provider mounted. This matters more here than it did for ObjectChart: every existing suite in this package mounts the widget bare, so the throwing hook would have turned a routing fix into a package-wide red.apiFetchjoins the effect's dependency array, as it does inuseRecordEditable's.The effect-deps question, checked against THIS file
This file does carry a documented refetch concern, but it is on the other effect and it does not transfer. The query effect is keyed on a hand-built
signaturestring precisely because the resolved filter carries a render-timenow; that is a value the component recomputes every render, which is what would loop.apiFetchis not that kind of value: it arrives fromSchemaRendererProvider'suseMemo'd context value (SchemaRendererContext.tsx:42-43), and this widget's ownsetStatecannot re-render the provider — so the identity is stable across the effect's own updates. The sole in-repo host settles it outright by holding the function at module scope:ConsoleShell.tsx:187→:245. No restructuring was needed.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 pinned:dataSourcebut noapiFetch. Presence of a host is not presence of a channel.Tests
Three pins added to
DatasetWidget.relabel.test.tsx— the file the card named, which already answers this exact endpoint from a double — in a newobjectui#4121block. Extended, not duplicated: no new test file, and the existing double is untouched. Routing is read off two separate recorders, the global stub plus a standalone recorder handed in as the provider'sapiFetch:accept: application/json), and the routed answer is consumed — both products of the document reach the renderer (the value→label relabeling and the first dimension's semanticcategoryColors);apiFetch→ global recorder holds the probe.Both recorders answer the same document, 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 changed in meaning. The two cloud#667 relabeling tests are untouched — which follows from the behavior boundary above: they mount no provider, so the routing change genuinely moves nothing for them.
Verification
Repo root, both packages, per AGENTS.md:
stderr stays entirely empty — the #4115/#4106 no-live-request guarantee survives the routing change.
Reverse verification, direction predicted before running: revert only the product routing (
git checkout origin/main -- DatasetWidget.tsx, new tests held) and exactly one pin goes red — the host-mounted one — while the two fallback pins and both cloud#667 tests stay green, because with no channel supplied pre-fix and post-fix code do the identical thing.Exactly as predicted, 1 red / 4 green, and the failure names the host recorder holding nothing — the escape landing in the global recorder instead. Restored afterwards;
git diffmatches the pre-revert diffstat.Gates:
pnpm --filter @object-ui/plugin-dashboard type-checkgreen (afterpnpm --filter '@object-ui/plugin-dashboard^...' build, the fresh-worktree dependency closure).eslinton both changed files 0 errors; warning counts measured againstorigin/mainfile-by-file —DatasetWidget.tsxis 11 before and 11 after, the test file 6 before and 6 after, so the new pins add zero.check:control-bytesgreen, plus a control-byte self-scan over the three changed files.Changeset
@object-ui/plugin-dashboardpatch — a real behavior fix on a released package.Generated by Claude Code