Skip to content

refactor(plugin-charts): ObjectChart consumes the shared analytics label-net helpers (#4405) - #4412

Merged
yinlianghui merged 2 commits into
mainfrom
claude/issue-4405-objectchart-third-copy
Aug 12, 2026
Merged

refactor(plugin-charts): ObjectChart consumes the shared analytics label-net helpers (#4405)#4412
yinlianghui merged 2 commits into
mainfrom
claude/issue-4405-objectchart-third-copy

Conversation

@yinlianghui

Copy link
Copy Markdown
Collaborator

Fixes#4405

objectui#4389 (PR #4404) named two copies of the analytics label-net glue and retired both. There was a THIRD, which that card did not name and its PR deliberately left out of scope: packages/plugin-charts/src/ObjectChart.tsx. This retires it.

Step 1 — the pure-function swap (mandatory, done)

ObjectChart carried three pieces of the glue longhand. All three now call the helpers PR #4404 landed in @object-ui/core:

was, locally in ObjectChart.tsxnow
a translatorFor(path) closure — logically identical to the two deleted copies, down to the comment about binding to the owning objectdimensionOptionTranslator(meta, fieldOptionLabel)
a buildDimensionLabelMap loop accumulating per-dimension mapsderiveDimensionLabelMaps(metaByPath, relabel, fieldOptionLabel)
loadObjectSchema(objectName) then resolveDimensionFieldMeta(...)loadDimensionFieldMeta(loadObjectSchema, objectName, paths)

The third row goes slightly beyond the two swaps the ruling enumerates. It is the same "consume the landed helpers" mandate from the card title, it is strictly mechanical (two statements collapse into the one composition that is those two statements), and the read count is identical because resolveDimensionFieldMeta memoizes per call and seeds the base schema either way. Flagged explicitly here so it is trivial to veto — dropping it changes nothing else in this PR.

@object-ui/core was already a declared dependency of @object-ui/plugin-charts (verified against package.json, per the #4394 phantom-dep lesson — and that gate landed in main mid-task, so it also ran green against this branch after merging).

The two bug-fix properties are untouched and remain stated locally, exactly as the card predicted for a step-1-only landing: apiFetch is still in the effect's deps (objectui#4121) and the locale is still NOT (objectui#4030 / PR #4324). The diff does not touch the effect's dependency array.

Step 2 — the dataset read onto useDatasetDimensionMeta: attempted, DECLINED on measurement

The blocker is not the fieldByDim map to ordered-array translation the card worried about — that part is clean, since the shared hook already takes both a dimension name to field path map and the name list, so the adapter is just Object.keys(fieldByDim).

The blocker is that ObjectChart's colour dimension is not one of the dimensions the surface renders, and the shared hook only resolves dimensions it will also relabel.

Measured, on main as it stands: a dataset chart that declares no dimensions still resolves its colour map, because ObjectChart resolves [fieldName, ...values(fieldByDim)] where fieldName comes from the dataset DEFINITION's first dimension, not from schema.dimensions. I pinned this in a scratch test and it is green today — 2 reads, colours applied:

✓ a dataset chart with NO schema.dimensions still resolves colour meta (2 reads)
categoryColors: { todo: '#f59e0b', 'To do': '#f59e0b', done: '#16a34a', Done: '#16a34a' }
metaCalls: ['/api/v1/meta/dataset/showcase_task_metrics', '/api/v1/meta/object/task']

Routed through useDatasetDimensionMeta, that case passes dimensions: [], and the hook's effect bails before fetching:

// packages/react/src/hooks/useDatasetDimensionLabels.ts:134if(!enabled||!object||dims.length===0){setMeta(null);return;}

So the read count would go 2 to 1 and the colour map would silently stop resolving — a behaviour change, in the exact best-effort-so-it-fails-quietly way this family keeps getting bitten by. Preserving it requires smuggling the colour path through as a synthetic dimension and filtering it back out of the derived maps before relabelDimensions sees it, which is a contorted adapter that changes the hook's meaning rather than adapting a shape.

Two further costs, for completeness:

  • Split effects and a new state. The hook needs object and dimensionFields already resolved, but on the dataset path both come from the /api/v1/meta/dataset/... read that today lives inside the same effect. Using the hook forces that read into its own effect writing a new state that the hook then keys on: one effect and one state become two of each, and the metadata settles in two render commits instead of one.
  • It would not actually remove the local glue. The ruling scopes step 2 to the dataset path, so the aggregate path keeps its own loadObjectSchema plus loadDimensionFieldMeta call regardless. Step 2 therefore splits the local code and leaves half behind while adding a state and a sentinel adapter — net local code grows.

Residual, recorded rather than acted on: the clean version of step 2 would need the shared hook to grow a "resolve these extra paths but emit no relabel entry for them" concept. That is an edit to @object-ui/react, a surface that just landed and whose naming/shape belongs to a fresh card — so per the dispatch constraints I stopped rather than reshaping it here.

Verification

All runs are repo-root vitest, per AGENTS.md.

Pins unchanged (the acceptance evidence):git diff --name-only origin/main...HEAD -- 'packages/plugin-charts/**/*.test.*' is empty. The whole branch touches exactly two files:

.changeset/objectchart-label-net-third-copy-4405.md
packages/plugin-charts/src/ObjectChart.tsx

Note the pin that actually covers this code is packages/plugin-charts/src/ObjectChart.optionColors.test.tsx, which sits outside the src/__tests__/ directory — the sweep above deliberately covers the whole package's test surface rather than that one directory.

Reverse verification

Direction predicted before each run.

  1. Revert ObjectChart.tsx to the local closures, keep the suite. Predicted GREEN, got GREEN (22 files / 170 tests). This is a null result and is reported as such: for a behaviour-preserving swap it is the correct outcome, and it is the argument that the seam-level pins carry the guarantee — the same result and the same reasoning PR refactor(core,react,dashboard,report): the analytics label net's fetch-and-memo glue is written once (#4389) #4404's RV1 recorded.
  2. Because a null result alone cannot distinguish "behaviour preserved" from "pins do not watch this path", break the derivation deliberately — pass null as the relabel argument. Predicted RED, got RED, on exactly the two dataset label pins: expected 'todo' to be 'To do' in resolves a dataset chart through its definition to the underlying object and routes BOTH dataset hops through the host apiFetch. The pins do observe this path, so run 1's green is meaningful.
  3. Unbind the colour translator (dimensionOptionTranslator(undefined, ...)). Predicted GREEN as a blind spot, got GREEN (7/7). Reported honestly rather than dressed up as coverage: these pins mount no I18nProvider, so the resolver returns the authored label and a bound translator is indistinguishable from an unbound one. The colour path's translator binding is therefore not pinned at this seam today — it is pinned one level down in core's own unit tests. Not a regression introduced here (the same gap existed before this PR), and not in scope to fix.

Working tree clean after each; no git stash used at any point.


Generated by Claude Code

…lpers (#4405)
objectui#4389 (PR #4404) retired two copies of the analytics label-net glue
into `@object-ui/core` + `@object-ui/react`. `ObjectChart` was a third copy,
which that card did not name and its PR left out of scope: a local
`translatorFor` closure logically identical to the two deleted ones (down to
the comment), a longhand `buildDimensionLabelMap` loop, and its own
base-object-read-then-walk composition.
It now calls core's `dimensionOptionTranslator`, `deriveDimensionLabelMaps`
and `loadDimensionFieldMeta`. Pure function swap — same reads in the same
order, same best-effort fallback, same locale-applying memo boundary. The
package's 22 test files / 170 assertions pass unchanged and are byte-identical.
The two bug-fix properties stay stated locally and undisturbed: `apiFetch` is
in the effect's deps (objectui#4121), the locale is NOT (objectui#4030 /
PR #4324).
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017Qqyix2QcnpUC9XeYVDzx3
@vercel

vercelBot commented Aug 12, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
ProjectDeploymentActionsUpdated (UTC)
objectuiIgnoredIgnoredAug 12, 2026 4:20am

Request Review

@github-actions

Copy link
Copy Markdown
Contributor

✅ Console Performance Budget

MetricValueBudget
Main entry (gzip)24.7 KB350 KB
Entry fileindex-DBTgxD_P.js
StatusPASS

📦 Bundle Size Report

PackageSizeGzipped
app-shell (index.js)9.56KB3.59KB
app-shell (runtime-config.js)7.42KB2.32KB
app-shell (types.js)0.01KB0.04KB
app-shell (urlParams.js)8.92KB3.41KB
auth (AuthContext.js)0.31KB0.24KB
auth (AuthGuard.js)1.17KB0.53KB
auth (AuthProvider.js)22.10KB4.37KB
auth (AuthShell.js)3.49KB1.40KB
auth (ForgotPasswordForm.js)12.21KB3.45KB
auth (LoginForm.js)18.13KB5.39KB
auth (PreviewBanner.js)0.90KB0.50KB
auth (RegisterForm.js)6.64KB2.21KB
auth (SocialSignInButtons.js)9.60KB3.89KB
auth (UserMenu.js)3.40KB1.22KB
auth (auth-gate-events.js)1.29KB0.66KB
auth (authStyles.js)5.04KB1.72KB
auth (createAuthClient.js)35.76KB9.11KB
auth (createAuthenticatedFetch.js)4.37KB1.69KB
auth (index.js)2.35KB1.07KB
auth (org-roles.js)6.66KB2.78KB
auth (phone-identifier.js)1.11KB0.66KB
auth (types.js)0.59KB0.35KB
auth (useAuth.js)4.91KB0.87KB
auth (useIsWorkspaceAdmin.js)1.61KB0.85KB
collaboration (CommentThread.js)26.07KB7.56KB
collaboration (LiveCursors.js)3.17KB1.27KB
collaboration (PresenceAvatars.js)6.49KB2.64KB
collaboration (PresenceProvider.js)2.79KB1.13KB
collaboration (index.js)1.65KB0.73KB
collaboration (useCollaborationTranslation.js)6.05KB2.52KB
collaboration (useCommentSearch.js)1.98KB0.88KB
collaboration (useConflictResolution.js)7.75KB1.86KB
collaboration (useMentionNotifications.js)1.81KB0.68KB
collaboration (usePresence.js)6.33KB1.84KB
collaboration (useRealtimeSubscription.js)7.91KB2.01KB
components (index.js)489.20KB108.43KB
core (index.js)2.99KB1.14KB
create-plugin (index.js)10.08KB3.26KB
data-objectstack (index.js)153.42KB41.19KB
fields (index.js)228.33KB56.61KB
i18n (LocalizationContext.js)1.76KB0.96KB
i18n (currency.js)1.22KB0.64KB
i18n (i18n.js)4.32KB1.77KB
i18n (index.js)3.35KB1.38KB
i18n (pickLocalized.js)3.69KB1.73KB
i18n (provider.js)23.12KB7.62KB
i18n (useDisplayLocale.js)2.33KB1.20KB
i18n (useObjectLabel.js)27.59KB6.63KB
i18n (useSafeTranslation.js)7.77KB3.13KB
layout (index.js)38.98KB10.85KB
mobile (MobileProvider.js)0.92KB0.49KB
mobile (ResponsiveContainer.js)0.94KB0.38KB
mobile (breakpoints.js)1.51KB0.70KB
mobile (createOfflineDataSource.js)5.61KB1.74KB
mobile (index.js)1.50KB0.62KB
mobile (offlineQueue.js)3.91KB1.35KB
mobile (pwa.js)0.97KB0.49KB
mobile (serviceWorker.js)1.48KB0.62KB
mobile (serviceWorkerSource.js)3.41KB1.48KB
mobile (useBreakpoint.js)1.54KB0.65KB
mobile (useGesture.js)6.96KB1.98KB
mobile (useOfflineSync.js)1.99KB0.72KB
mobile (usePullToRefresh.js)2.53KB0.85KB
mobile (useResponsive.js)0.71KB0.42KB
mobile (useResponsiveConfig.js)1.36KB0.63KB
mobile (useSpecGesture.js)4.32KB1.64KB
mobile (useTouchTarget.js)1.01KB0.54KB
permissions (MePermissionsProvider.js)8.75KB3.06KB
permissions (PermissionContext.js)0.31KB0.25KB
permissions (PermissionGuard.js)0.89KB0.45KB
permissions (PermissionProvider.js)3.67KB1.12KB
permissions (evaluator.js)4.41KB1.44KB
permissions (index.js)0.91KB0.41KB
permissions (store.js)0.91KB0.42KB
permissions (useFieldPermissions.js)1.28KB0.52KB
permissions (usePermissions.js)1.55KB0.71KB
plugin-ai (index.js)15.71KB3.79KB
plugin-calendar (index.js)45.23KB12.45KB
plugin-charts (index.js)62.01KB17.63KB
plugin-chatbot (index.js)180.33KB42.79KB
plugin-dashboard (index.js)120.57KB31.32KB
plugin-designer (index.js)211.16KB42.76KB
plugin-detail (index.js)239.03KB59.77KB
plugin-editor (index.js)2.46KB1.10KB
plugin-form (index.js)114.58KB27.68KB
plugin-gantt (index.js)164.14KB39.98KB
plugin-grid (index.js)187.99KB49.92KB
plugin-kanban (index.js)48.60KB13.41KB
plugin-list (index.js)110.21KB26.79KB
plugin-map (index.js)18.05KB5.80KB
plugin-markdown (index.js)13.72KB4.69KB
plugin-report (index.js)40.99KB10.74KB
plugin-timeline (index.js)26.21KB7.52KB
plugin-tree (index.js)8.50KB2.88KB
plugin-view (index.js)84.03KB20.55KB
providers (DataSourceProvider.js)0.75KB0.39KB
providers (MetadataProvider.js)1.37KB0.59KB
providers (ThemeProvider.js)1.90KB0.85KB
providers (UploadProvider.js)11.71KB3.53KB
providers (index.js)0.44KB0.22KB
providers (types.js)0.01KB0.04KB
react-runtime (index.js)5.67KB2.37KB
react (LazyPluginLoader.js)3.77KB1.33KB
react (SchemaRenderer.js)23.71KB7.96KB
react (data-invalidation.js)5.05KB2.08KB
react (index.js)1.23KB0.66KB
react (spec-input.js)0.20KB0.18KB
sdui-parser (codegen.js)4.09KB1.74KB
sdui-parser (index.js)4.47KB2.03KB
sdui-parser (parse.js)10.04KB2.82KB
sdui-parser (types.js)0.29KB0.24KB
sdui-parser (validate.js)4.69KB1.48KB
types (ai.js)0.20KB0.17KB
types (api-types.js)0.20KB0.18KB
types (app.js)2.87KB0.99KB
types (base.js)0.20KB0.18KB
types (blocks.js)0.20KB0.18KB
types (complex.js)0.20KB0.18KB
types (crud.js)0.20KB0.18KB
types (dashboard-filter-alias.js)6.23KB2.74KB
types (data-display.js)0.20KB0.18KB
types (data-protocol.js)0.20KB0.19KB
types (data.js)0.20KB0.18KB
types (designer.js)1.87KB0.85KB
types (disclosure.js)0.20KB0.18KB
types (error-code.js)1.54KB0.88KB
types (feedback.js)0.20KB0.18KB
types (field-types.js)0.20KB0.18KB
types (form.js)0.20KB0.18KB
types (http-retry.js)4.32KB2.02KB
types (index.js)3.05KB1.52KB
types (layout.js)0.20KB0.18KB
types (managed-by.js)0.19KB0.18KB
types (mobile.js)2.59KB1.31KB
types (navigation.js)0.20KB0.18KB
types (objectql.js)0.20KB0.18KB
types (overlay.js)0.20KB0.18KB
types (permissions.js)0.20KB0.18KB
types (plugin-scope.js)0.20KB0.18KB
types (record-components.js)0.20KB0.19KB
types (record-semantics.js)1.28KB0.67KB
types (registry.js)0.20KB0.18KB
types (reports.js)0.20KB0.18KB
types (spec-report.js)5.05KB1.93KB
types (system-fields.js)3.33KB1.54KB
types (theme.js)0.20KB0.18KB
types (ui-action.js)3.40KB1.71KB
types (views.js)0.20KB0.18KB
types (widget.js)0.20KB0.18KB

Size Limits

  • ✅ Core packages should be < 50KB gzipped
  • ✅ Component packages should be < 100KB gzipped
  • ⚠️ Plugin packages should be < 150KB gzipped

@yinlianghuiClaude

Copy link
Copy Markdown
CollaboratorAuthor

ACCEPT — PM 复核 (session session_017Qqyix2QcnpUC9XeYVDzx3), closes #4405.

  • Step 2's decline is the ruling's criteria applied to a better measurement than the card had: the real blocker (the colour dimension is not a rendered dimension; the shared hook resolves only what it relabels, so the empty-dims bail silently drops the colour map — 2 reads → 1, scratch-pinned) beats the card's fieldByDim worry, which the dev showed is trivial. The contorted-adapter cost plus the hook-edit stop condition make step-1-only the correct landing, Fixes kept per the ruling.
  • The scope+1 (read composition onto loadDimensionFieldMeta) is accepted — mechanical, the third landed helper, read-count-identical.
  • The RV trio is the standard: RV1's null result labelled as null, RV2 proving the pins observe the path (which is what makes RV1 meaningful — the same epistemics as PR refactor(core,react,dashboard,report): the analytics label net's fetch-and-memo glue is written once (#4389) #4404), RV3 reporting a pre-existing blind spot honestly instead of dressing it as coverage.
  • The self-inflicted checkout clobber, detected-redone-recommitted with all verification re-run from the committed state, plus the two-dot/three-dot diff lesson, are process capture worth the deviations section.
  • Step-2 residual disposition: filed as a finding (unassigned, no queue) rather than lost or force-queued — the drift surface is down 3→1 with the properties correctly stated and RV2-observed; growing @object-ui/react's fresh API a "resolve-without-relabel" concept is a design addition that earns its own card when pull exists.

Flipping ready + arming auto-merge.


Generated by Claude Code

@yinlianghui
yinlianghui marked this pull request as ready for review August 12, 2026 04:34
@yinlianghui
yinlianghui added this pull request to the merge queueAug 12, 2026
Merged via the queue into main with commit 0b49d60Aug 12, 2026
21 checks passed
@yinlianghui
yinlianghui deleted the claude/issue-4405-objectchart-third-copy branch August 12, 2026 04:34
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Analytics label net: ObjectChart is a THIRD copy of the derivation glue — it can consume the core helpers #4389 extracted

2 participants

@yinlianghui@claude