This repository was archived by the owner on Nov 4, 2026. It is now read-only.
Repository navigation
docs(plugin-view): ObjectView.dataSource has no context fallback — delete the promise, pin the behaviour - #8039
Merged
Conversation
…ete the promise `ObjectViewProps.dataSource` carried "If not provided, falls back to SchemaRendererProvider context" one line above a declaration that has always been required. Measured: the type is right. `ObjectView` holds no context read at all — no `useContext`, no `SchemaRendererContext`, not `useElementDataSource` — and every read site guards on the prop rather than resolving one. The sentence was misfiled, not invented: `ObjectViewRenderer` (index.tsx), the renderer registered for the `object-view` and `view` schema tags, is what really resolves `ctx?.dataSource` and hands it to this prop. The JSDoc now states that, states what happens when the prop is absent anyway, and records that making it optional would widen a published accept set. New pin holds both halves behind a live control. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QnpvbdoRisQdRAczkLwnf5
Contributor
✅ 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
|
This was referenced Sep 6, 2026
os-steve
marked this pull request as ready for review
September 6, 2026 12:43
os-steve
deleted the
claude/issue-7842-objectview-datasource-contract
branch
September 6, 2026 12:58
baozhoutao
pushed a commit
that referenced
this pull request
Sep 6, 2026
Brings in #8046, #8042, #8039. Neither of this branch's two paths is touched by that range; plugin-view source moved, so the forced build and every gate are re-run on the merged head. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FhBNJcLRZLe8M87VcUgpKr
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 free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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 #7842
The measurement, which is the whole card
ObjectViewProps.dataSourcecarried this one line above its own declaration:on a prop declared
dataSource: DataSource— required, no question mark. One of the two had been wrong for the prop's entire life. The type is right; the prose was stale.packages/plugin-view/src/ObjectView.tsxholds no context read at all:useContext, and noSchemaRendererContextimport. Before this change, the only occurrence of the stringSchemaRendererProvideranywhere in the file was the sentence itself.useElementDataSourceeither — the hook@object-ui/reactpublishes for exactly this fallback, and whichplugin-formandElementDataSourceGatereally do use.packages/plugin-view/src/has zero references to it.useSettledSchema(schemaKey, dataSource)at:653, and that shared hook has no context read either: given no source it settles withready: true, def: null.Every consumption site guards on the prop instead of resolving one —
:668if (!dataSource?.onMutation …) return;,:786if (!dataSource || !schema.objectName) return;, and the singledataSource.find()call sits behind that second guard.There is no export-versus-internal split to report:
index.tsxre-exports./ObjectViewdirectly (:12,:18), so the published symbol and the component that renders are the same one.What the component actually does when
dataSourceis absenttsc refuses the omission at the call site, so this state is only reachable from an untyped JS host, or through the registered renderer described below. When it is reached: nothing throws and nothing is fetched.
useSettledSchemasettles with a null definition; the mutation-subscription effect and the non-grid fetch effect both return early; the value is forwarded verbatim to ObjectGrid / SchemaRenderer, and ObjectGrid's owndataSourceis declared OPTIONAL (packages/plugin-grid/src/ObjectGrid.tsx:411). The view renders its chrome and stays empty.That is a description of behaviour, not of the comment: the prop guards by doing nothing, which is what makes "required" the honest declaration.
The sentence was misfiled, not invented
It describes something real in this package, one file over.
ObjectViewRenderer(packages/plugin-view/src/index.tsx:58-64) — the renderer registered for theobject-viewtag and itsviewalias — is what does it: it callsuseContextonSchemaRendererContext, takesctx?.dataSource ?? null, and hands the result to this prop.So a schema-driven host mounted under a provider does get the provider's adapter; a host writing an ObjectView element in TSX does not. That distinction is why the pin below holds both halves. A reader told only "there is no fallback" would be entitled to re-add the sentence the next time they read the registered renderer.
Scope: no accept set moves here
Comment text and a new test. The declaration is untouched, so the published accept set of
@object-ui/plugin-viewis byte-identical.Branch B of the card — making the prop optional, so the JSDoc becomes true — is deliberately NOT taken here: it widens a published accept set and belongs to a maintainer. It is also not the one-character change it looks like. Measured, by flipping the declaration to optional and re-running the package's type-check:
:1870is thedataSourcekey handed to the host'srenderListViewcallback, whose parameter type (:314) declares it required. Anyone taking Branch B has to decide what that host callback receives too.The pin
packages/plugin-view/src/__tests__/ObjectView.dataSourceContextFallback-7842.test.tsx, six tests:SchemaRendererProvidersupplying an adapter, an ObjectView with nodataSourcenever touches that adapter.dataSourceunder ats-expect-errordirective. If the prop ever goes optional the literal compiles, the directive suppresses nothing, andtscfails with TS2578 naming that line.object-viewrenderer still resolvesdataSourcefrom context, and hands downnullwhen no provider is mounted.⭐ This file deliberately does not stub
SchemaRendererContext, unlike every siblingObjectView.*.test.tsx(they replace it with a freshcreateContext(null)). A future fallback would be written against the real context, directly or throughuseElementDataSource; a provider built on a look-alike context object could not be seen by it, and test 2 would be a false green. OnlySchemaRendereris stubbed.Verification
Repo root, canonical invocation, on
fef4b95:pnpm exec vitest run packages/plugin-view/— 35 files, 303 tests, all passed (66.84s). Baseline was 34 files; this PR adds the 35th.pnpm exec vitest run packages/plugin-view/src/__tests__/ObjectView.dataSourceContextFallback-7842.test.tsx --reporter=verbose— 6/6 named and passed, so the new file provably executed.pnpm --filter @object-ui/plugin-view type-check, afterturbo run build --filter=@object-ui/plugin-view(15 tasks, all successful):tsc --noEmitexit 0 andtsc -p tsconfig.test.jsonexit 0.--listFilesconfirms the new test file is one of the 47plugin-view/srcfiles in that program — the pin is measured, not merely present.eslint .in the package: exit 0, 49 files, 0 errors, 308 pre-existing warnings; the new file contributes 0 of them.node scripts/check-changeset-presence.mjsexit 0 (the empty-frontmatter declaration is the explicit exemption for a comment-and-test change), pluschangeset:check,check:control-bytes,check:vi-mock-specifiers,check:vi-mock-inherit— all exit 0.Ablations, both with an on-disk proof that the mutation landed and a restore verified by hash against the HEAD blob:
SchemaRendererContext, resolve the prop throughuseContext): exactly one test turns red — test 2, with its own named message — while the live control and the other four stay green. That is the predicted direction, and it is what makes the negative assertion mean something.tsc -p tsconfig.test.jsonexits 2 withTS2578 Unused 'ts-expect-error' directiveat the pin's line, plus the TS2322 quoted above.Neither ablation needs a
distpreflight: the vitest alias map resolves every@object-ui/*specifier tosrc, and the pin imports../ObjectViewrelatively, so nothing under test is read from a built bundle.Out of scope, deliberately
packages/app-shell's own ObjectView (props typed as ANY) is objectui#7483 — a different component and a different defect. Untouched.ObjectViewRendererhandsnullto a prop declared non-nullable, and nothing complains because the context it reads is typed ANY. That is a downstream instance of objectui#7912 (SchemaRendererProvider'sdataSourceandSchemaRendererContextTypeboth typed ANY), which is already open, already carriesneeds-user-decision, and states that narrowing the seam is a public-contract change with its own blast radius. Filed nowhere new on purpose — a second card would be a duplicate of that one. Test 6 pins thenullas an observation, explicitly not as an endorsement.Session:
https://claude.ai/code/session_01QnpvbdoRisQdRAczkLwnf5Generated by Claude Code