Skip to content

fix(plugin-dashboard): a dataset widget labels its comparison from compareTo.kind, not the filter's macro tokens (objectui#11632) - #11647

Merged
objectstack-fleet[bot] merged 2 commits into
mainfrom
claude/issue-11632-dataset-compare-label
Oct 5, 2026
Merged

objectstack-fleet[bot] merged 2 commits into
mainfrom
claude/issue-11632-dataset-compare-label

Conversation

@objectstack-fleet

Copy link
Copy Markdown
Contributor

Fixes #11632

Clause-②: no

What changed

On the ADR-0021 dataset path, DatasetWidget now names a comparison window from compareTo.kind alone. previousPeriod reads "vs previous period" and previousYear reads "vs last year". It no longer calls compareToTrendLabelKey, which guesses the window from the RAW filter's date-macro tokens ({today} gives "vs yesterday", quarter macros give "vs last quarter").

A module-local COMPARE_KIND_TREND_KEY maps each kind to its existing dashboard.trend.* key. It is typed with satisfies against a Record keyed by CompareToConfig['kind'], so a third kind added to that type is a compile error there. TREND_LABEL_DEFAULTS is unchanged: it stays the vocabulary check:i18n-keys reads for the dashboard.trend. family.

compareToTrendLabelKey in @object-ui/core and the inline path that uses it are unchanged, per triage's direction.

Why the guess was wrong here and right inline

On the inline path, shiftFilterByCompareTo really does rewrite the filter ({today} becomes {yesterday}, current_* becomes last_*), so a label read off those tokens names what was queried. On the dataset path no token is rewritten. The widget lowers the resolved window into timeDimensions[].dateRange, and the executor's shiftRange (objectstack service-analytics, dataset-executor.ts, read at objectstack 07bf21ff) moves the whole window. previousPeriod becomes the equal-length window ending the day before, and previousYear the same window a year back. The kind is all there is to know about which window was compared, so the label comes from the kind.

Every surface this label reaches

The fix changes one call. Its result, compareLabel, is the only window label in DatasetWidget, and every comparison surface reads it: the KPI delta (dataset-compare-trend), the flat table's comparison column header and its CSV export header, the cross-tab caption and cell title, and the chart's comparison series label (the line legend in the card). None of them needs a change of its own.

Other callers of compareToTrendLabelKey, none of them changed:

  • ObjectMetricWidget: the inline object metric. It compares through shiftFilterByCompareTo, so its label is faithful there.
  • ObjectChart (plugin-charts): its comparison series is built only for an aggregate chart on the inline path. Its dataset branch forwards no compareTo to queryDataset, so the label call never runs for a dataset-bound chart. See Acceptance notes.

"And the resolved window": what the window would add, and why the kind is enough

The card's Done-when names "the compareTo kind and the resolved window". The kind decides the window: for every window, previousPeriod is "the equal-length window before it". So "vs previous period" is true of a 30-day range, a quarter and a single day alike, and the window adds no correctness to the label. What it could add is specificity, in one of two ways:

  • The length ("vs previous 30 days"). This needs a new interpolated dashboard.trend.* key in ten locales. That is outside this dispatch's Clause-② fence (no new i18n key).
  • A calendar name when the shifted window happens to coincide with one. A 7-day Monday-to-Sunday window shifted back is "last week". Q4 shifted back 92 days is Q3, but Q1 (90 days) shifted back starts on 3 October, so the name holds only sometimes. Deciding when would re-derive the executor's shiftRange arithmetic in the renderer: a second copy of the producer's logic, which can drift from it.

Neither is needed for a faithful label, so this PR takes the kind. The report raises it as an open question so the Done-when reading is confirmed rather than assumed.

Tests

packages/plugin-dashboard/src/__tests__/DatasetWidget.compareTo.test.tsx:

  • Replaced the pin labels the window from the RAW filter's macros, which resolution erased. It asserted the removed branch: previousPeriod over quarter macros reading "vs last quarter" on the dataset path. That label is wrong there, because the executor compares the equal-length window, not the calendar quarter.
  • Added a block named the comparison label comes from compareTo.kind (objectui#11632), using the card's shape (a dashboard last_30_days range, {30_days_ago} to {today}):
    • previousPeriod reads "vs previous period" and not "yesterday" on the KPI delta. The whole resolved window is lowered for the executor to shift.
    • The chart's comparison series (the line legend) reads the same.
    • previousPeriod over quarter macros reads "vs previous period", with no calendar unit.
    • Each kind @objectstack/spec declares for a widget's compareTo gets its own label. The kinds are read from DashboardWidgetSchema itself, and a coverage test fails if the spec gains a kind this table lacks.
  • The inline path's existing pins stay unchanged and green: compareToTrendLabelKey's {today} gives vsYesterday in packages/core/src/utils/__tests__/compare-to.test.ts, and ObjectMetricWidget.compareTo's "labels vs last quarter".

Reverse verification (one-off, from committed state)

DatasetWidget.tsx was reverted to the base commit 76993f8. The blob hash matched the base blob. COMPARE_KIND_TREND_KEY counted 0, and the old compareToTrendLabelKey(compareTo, rawFilter) call counted 1. A trap then restored HEAD, and the restore was proved by blob hash and an empty git diff HEAD.

  • HEAD 95f2df9: Tests 31 passed (31).
  • Reverted: Tests 4 failed | 27 passed (31), all four in the new block. The failures received "Revenue · vs yesterday", "20%vs yesterday" and "20%vs last quarter".
  • The previousYear case and the spec-coverage case stay green, as expected: previousYear was already labelled by its kind.

Live before/after

The live run used objectstack main 07bf21ff (showcase, objectstack dev --fresh, own port) and the card's probe dashboard: a last_30_days date range on created_at, a previousPeriod metric, a previousYear metric and a previousPeriod line over showcase_task_metrics. Two consoles were served from source and pointed at that one backend.

console previousPeriod KPI previousYear KPI line legend
base 76993f8 800% vs yesterday 100% vs last year Tasks · vs yesterday
this branch 800% vs previous period 100% vs last year Tasks · vs previous period

Both consoles sent identical dataset queries: timeDimensions created_at ["2026-09-05","2026-10-05"] with the compareTo kind, and nothing else. The server answered task_count 9, task_count__compare 1.

A discriminating probe on the same server shows the executor compares the preceding window, not yesterday. The 8-day window 2026-09-28..2026-10-05 with previousPeriod answered task_count 4, task_count__compare 3. Queried alone, 2026-09-20..2026-09-27 counts 3 and yesterday (2026-10-04) counts 1.

Gates (HEAD 95f2df9)

  • pnpm exec vitest run --maxWorkers=2 packages/plugin-dashboard/ packages/core/src/utils/__tests__/compare-to.test.ts: Test Files 171 passed (171), Tests 1699 passed | 6 skipped (1705).
  • pnpm --workspace-concurrency=2 --filter '@object-ui/plugin-dashboard^...' build (the dependency closure, 13 packages): exit 0.
  • pnpm --filter @object-ui/plugin-dashboard type-check (tsc --noEmit && tsc -p tsconfig.test.json): exit 0.
  • pnpm --filter @object-ui/plugin-dashboard lint: exit 0, 0 errors. No warning falls on a line this PR touches.
  • Exit 0 on each of: check:i18n-keys, check:i18n-dead-keys (no dashboard.trend.* key reported), check:spec-symbols, check:new-line-citations (0 new), check:control-bytes, check:changeset-claims, check:pending-changeset-literals, check:test-path-roots, check:vi-mock-specifiers, check:vi-mock-inherit, check:vi-mock-override-shape, check:phantom-deps, check:unused-deps, scripts/check-changeset-presence.mjs and scripts/check-changeset-no-major.mjs.
  • origin/main was still at the base 76993f8 before this PR opened. The origin/main merge was a no-op ("Already up to date"), so the runs above are of the tree that would have resulted.

Changeset: .changeset/11632-dataset-compare-label.md, a patch for @object-ui/plugin-dashboard.

Acceptance notes

These are read-only observations. Neither has been run through a public door, so neither is carded.

  • The inline previousPeriod over a rolling range. shiftFilterByCompareTo rewrites {today} to {yesterday} but leaves {30_days_ago} alone. Over a last_30_days filter, the inline comparison window is therefore 30 days ago to yesterday. That window overlaps the current one almost entirely, and it is labelled "vs yesterday". The label is faithful to the rewrite, but the window is not "the equal-length window before", which is what CompareToConfig's docblock and the spec's DatasetCompareTo describe for previousPeriod. This PR leaves the inline path alone, per triage. No one carries this.
  • A dataset-bound ObjectChart with compareTo. Its dataset branch sends no compareTo to queryDataset, and it builds the comparison series only for an aggregate chart. Read from source, a chart block bound to a dataset with compareTo would draw no comparison and say nothing. No producer of that shape was looked for. No one carries this.

Generated by Claude Code

claude added 2 commits October 5, 2026 06:41
…mpareTo.kind, not the filter's macro tokens (objectui#11632)

On the ADR-0021 dataset path the executor shifts the whole resolved window
(previousPeriod = the equal-length window before it, previousYear = the same
window a year back), so the label is read off the kind. The filter-token
guess in compareToTrendLabelKey stays on the inline path, where it is
faithful.

Claude-Session: https://claude.ai/code/session_015W8GBu6sBiqus2L2xjMsAL
Co-authored-by: Claude <noreply@anthropic.com>
…compareTo.kind; changeset (objectui#11632)

Replaces the pin that held the filter-token guess on the dataset path
("vs last quarter" off quarter macros) with pins that previousPeriod over a
{today} window reads "vs previous period" on the KPI delta and the chart's
comparison series, and that every compareTo kind the spec declares has its
own label.

Claude-Session: https://claude.ai/code/session_015W8GBu6sBiqus2L2xjMsAL
Co-authored-by: Claude <noreply@anthropic.com>
@github-actions

github-actions Bot commented Oct 5, 2026

Copy link
Copy Markdown
Contributor

✅ Console Performance Budget

Metric Value Budget
Eager closure (gzip, 331 chunks) 3317.3 KB 3330.4 KB
Main entry chunk (gzip) 151.6 KB 350 KB
Entry file index-0nC2LZ_R.js —
Status PASS —

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

Package Size Gzipped
app-shell (consoleActionDispatch.js) 0.20KB 0.19KB
app-shell (index.js) 17.22KB 6.37KB
app-shell (runtime-config.js) 22.52KB 7.86KB
app-shell (types.js) 0.01KB 0.04KB
app-shell (urlParams.js) 10.11KB 3.87KB
auth (ActiveOrganizationStorage.js) 27.95KB 10.04KB
auth (AuthContext.js) 0.31KB 0.24KB
auth (AuthGuard.js) 2.07KB 1.00KB
auth (AuthProvider.js) 40.22KB 10.61KB
auth (AuthShell.js) 3.49KB 1.40KB
auth (ForgotPasswordForm.js) 12.21KB 3.45KB
auth (LoginForm.js) 18.17KB 5.40KB
auth (PreviewBanner.js) 0.90KB 0.50KB
auth (RegisterForm.js) 6.72KB 2.24KB
auth (SocialSignInButtons.js) 9.70KB 3.93KB
auth (UserMenu.js) 3.39KB 1.21KB
auth (auth-gate-events.js) 1.29KB 0.66KB
auth (authStyles.js) 5.04KB 1.72KB
auth (createAuthClient.js) 40.70KB 10.94KB
auth (createAuthenticatedFetch.js) 8.54KB 3.46KB
auth (index.js) 3.63KB 1.64KB
auth (invitation-status.js) 1.22KB 0.70KB
auth (org-roles.js) 6.66KB 2.78KB
auth (phone-identifier.js) 1.11KB 0.66KB
auth (types.js) 0.59KB 0.35KB
auth (useAuth.js) 5.30KB 1.02KB
auth (useWorkspaceAdminStatus.js) 11.08KB 4.58KB
collaboration (CommentThread.js) 27.11KB 7.97KB
collaboration (LiveCursors.js) 3.17KB 1.27KB
collaboration (PresenceAvatars.js) 6.28KB 2.60KB
collaboration (PresenceProvider.js) 2.79KB 1.13KB
collaboration (index.js) 1.68KB 0.73KB
collaboration (useCollaborationTranslation.js) 6.50KB 2.52KB
collaboration (useCommentSearch.js) 1.98KB 0.88KB
collaboration (useConflictResolution.js) 7.75KB 1.86KB
collaboration (useMentionNotifications.js) 1.81KB 0.68KB
collaboration (usePresence.js) 6.33KB 1.84KB
collaboration (useRealtimeSubscription.js) 7.91KB 2.01KB
components (index.js) 574.98KB 137.97KB
core (index.js) 10.00KB 3.96KB
create-plugin (index.js) 27.94KB 9.51KB
data-objectstack (index.js) 232.57KB 64.51KB
fields (index.js) 262.75KB 66.62KB
i18n (LocalizationContext.js) 1.76KB 0.96KB
i18n (builtinAggregateLabels.js) 0.86KB 0.49KB
i18n (currency.js) 2.59KB 1.22KB
i18n (fallbackInterpolation.js) 6.25KB 2.77KB
i18n (i18n.js) 8.87KB 3.64KB
i18n (index.js) 5.24KB 2.27KB
i18n (pickLocalized.js) 9.86KB 3.95KB
i18n (provider.js) 39.35KB 12.88KB
i18n (translateFn.js) 0.20KB 0.18KB
i18n (useDisplayLocale.js) 3.52KB 1.76KB
i18n (useObjectLabel.js) 35.66KB 9.49KB
i18n (useSafeTranslation.js) 7.14KB 2.92KB
layout (index.js) 39.47KB 11.25KB
mobile (MobileProvider.js) 0.92KB 0.49KB
mobile (ResponsiveContainer.js) 0.94KB 0.38KB
mobile (breakpoints.js) 1.51KB 0.70KB
mobile (createOfflineDataSource.js) 5.61KB 1.75KB
mobile (index.js) 1.99KB 0.87KB
mobile (offlineQueue.js) 3.91KB 1.35KB
mobile (pwa.js) 0.97KB 0.49KB
mobile (serviceWorker.js) 1.48KB 0.62KB
mobile (serviceWorkerSource.js) 3.41KB 1.48KB
mobile (useBreakpoint.js) 1.54KB 0.65KB
mobile (useGesture.js) 6.96KB 1.98KB
mobile (useOfflineSync.js) 1.99KB 0.72KB
mobile (usePullToRefresh.js) 6.62KB 2.45KB
mobile (useResponsive.js) 0.72KB 0.42KB
mobile (useSpecGesture.js) 5.52KB 2.10KB
mobile (useTouchTarget.js) 1.01KB 0.54KB
permissions (MePermissionsProvider.js) 13.86KB 5.00KB
permissions (PermissionContext.js) 0.31KB 0.25KB
permissions (PermissionGuard.js) 0.89KB 0.45KB
permissions (PermissionProvider.js) 6.52KB 2.26KB
permissions (discardProofCache.js) 1.04KB 0.55KB
permissions (evaluator.js) 8.33KB 3.07KB
permissions (index.js) 0.93KB 0.41KB
permissions (store.js) 0.91KB 0.42KB
permissions (useFieldPermissions.js) 1.28KB 0.53KB
permissions (usePermissions.js) 4.83KB 2.27KB
plugin-ai (index.js) 16.04KB 3.92KB
plugin-calendar (index.js) 53.17KB 15.46KB
plugin-charts (index.js) 84.26KB 23.05KB
plugin-chatbot (index.js) 198.22KB 46.97KB
plugin-dashboard (index.js) 143.58KB 38.81KB
plugin-designer (index.js) 231.41KB 48.84KB
plugin-detail (index.js) 247.21KB 65.03KB
plugin-editor (index.js) 2.23KB 1.05KB
plugin-form (index.js) 177.09KB 45.89KB
plugin-gantt (index.js) 179.16KB 45.06KB
plugin-grid (index.js) 235.92KB 64.87KB
plugin-kanban (index.js) 50.06KB 15.74KB
plugin-list (index.js) 116.72KB 29.10KB
plugin-map (index.js) 25.60KB 8.62KB
plugin-markdown (index.js) 13.88KB 4.80KB
plugin-report (index.js) 44.12KB 12.29KB
plugin-timeline (index.js) 38.80KB 11.71KB
plugin-tree (index.js) 14.51KB 5.15KB
plugin-view (index.js) 90.23KB 22.73KB
providers (DataSourceProvider.js) 0.75KB 0.39KB
providers (MetadataProvider.js) 1.37KB 0.59KB
providers (ThemeProvider.js) 1.90KB 0.85KB
providers (UploadProvider.js) 11.81KB 3.58KB
providers (index.js) 0.45KB 0.23KB
providers (types.js) 0.01KB 0.04KB
react-runtime (index.js) 5.62KB 2.34KB
react (LazyPluginLoader.js) 4.47KB 1.63KB
react (SchemaRenderer.js) 120.63KB 39.56KB
react (data-invalidation.js) 5.05KB 2.08KB
react (index.js) 4.50KB 2.06KB
react (schema-input.js) 4.31KB 2.07KB
react (spec-input.js) 0.20KB 0.18KB
sdui-parser (body-dialect.js) 4.50KB 1.99KB
sdui-parser (codegen.js) 9.45KB 3.76KB
sdui-parser (dashboard-widget-options.js) 3.08KB 1.30KB
sdui-parser (index.js) 7.30KB 3.12KB
sdui-parser (input-type.js) 2.84KB 1.40KB
sdui-parser (parse.js) 25.28KB 7.80KB
sdui-parser (provenance.js) 3.84KB 1.90KB
sdui-parser (types.js) 0.28KB 0.23KB
sdui-parser (validate.js) 23.87KB 7.83KB
types (ai.js) 4.39KB 2.17KB
types (api-types.js) 0.20KB 0.18KB
types (app.js) 4.12KB 1.61KB
types (authoring-nodes.js) 0.20KB 0.19KB
types (base.js) 0.20KB 0.18KB
types (blocks.js) 0.20KB 0.18KB
types (cloud.js) 0.20KB 0.18KB
types (complex.js) 4.44KB 2.07KB
types (crud.js) 0.20KB 0.18KB
types (dashboard-filter-alias.js) 6.23KB 2.74KB
types (dashboard-widget-layout.js) 2.06KB 0.96KB
types (data-display.js) 3.75KB 1.85KB
types (data-protocol.js) 0.20KB 0.19KB
types (data.js) 0.20KB 0.18KB
types (designer.js) 1.85KB 0.85KB
types (disclosure.js) 0.20KB 0.18KB
types (error-code.js) 1.54KB 0.88KB
types (expression.js) 0.20KB 0.18KB
types (feedback.js) 0.20KB 0.18KB
types (field-types.js) 1.13KB 0.65KB
types (form.js) 0.20KB 0.18KB
types (http-inflight.js) 8.87KB 3.73KB
types (http-retry.js) 4.32KB 2.02KB
types (icon-key-migration.js) 4.26KB 1.63KB
types (index.js) 5.78KB 2.70KB
types (layout.js) 0.20KB 0.18KB
types (managed-by.js) 0.19KB 0.18KB
types (mobile.js) 5.00KB 2.39KB
types (navigation.js) 0.20KB 0.18KB
types (node-slots.js) 7.18KB 2.34KB
types (objectql.js) 0.20KB 0.18KB
types (overlay.js) 0.20KB 0.18KB
types (permissions.js) 2.52KB 1.31KB
types (plugin-scope.js) 0.20KB 0.18KB
types (record-components.js) 0.20KB 0.19KB
types (record-semantics.js) 1.28KB 0.67KB
types (registry.js) 0.20KB 0.18KB
types (reports.js) 0.20KB 0.18KB
types (select-option.js) 0.20KB 0.19KB
types (spec-report.js) 4.99KB 1.96KB
types (spec-ui-namespace.js) 0.20KB 0.19KB
types (strict-authoring-face.js) 19.93KB 7.25KB
types (system-fields.js) 3.33KB 1.54KB
types (theme.js) 6.28KB 2.87KB
types (ui-action.js) 8.11KB 3.32KB
types (views.js) 0.20KB 0.18KB
types (widget.js) 0.20KB 0.18KB

Size Limits

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

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

ACCEPT: PR objectui#11647, head 95f2df9. It lands when every check on this head is green

domain:ui execution seat 1 @ objectui · session_015W8GBu6sBiqus2L2xjMsAL (os-steve) · 2026-10-05T07:52Z. Reviewed against GitHub and origin/main, not against the report's prose (report 5990336179).

  • Shape. The PR is a draft against main (base 76993f8), and its assignee is os-steve. Its first line is Fixes #11632, the only line with a closing keyword next to an issue number. Clause-②: no is on its own line. The diff is 3 files, +159/−23, inside the claim's surface: DatasetWidget.tsx, its compareTo pin file and the changeset. No path is governed.
  • The ruling, as written. On the dataset path the label now comes from compareTo.kind through a module-local COMPARE_KIND_TREND_KEY, and compareToTrendLabelKey is no longer imported there. The map is typed satisfies Record<CompareToConfig['kind'], string>, so a third kind becomes a compile error, not an unlabelled comparison. compareToTrendLabelKey itself and the inline path are untouched. rawFilter is still read for resolution and the query signature, so nothing is left dangling. Both keys (vsPreviousPeriod, vsLastYear) already exist, so no i18n key is added.
  • "And the resolved window". Zone 2 item 3 said to take the kind and write up what the window would add. The PR body does that. A length ("vs previous 30 days") needs a new interpolated key, which is outside this card's fence. A calendar name would re-derive the executor's shiftRange in the renderer. The kind alone is true of every window, so the Done-when is met as ruled.
  • Tests. The pin that held the old guess on this path ("vs last quarter" read off {current_quarter_*}) is replaced by its opposite: a quarter's previousPeriod reads "vs previous period". New cases cover a {today} window on the KPI delta and on the chart's comparison series. One more case reads the kinds from @objectstack/spec's DashboardWidgetSchema and fails when the spec declares a kind with no expected label. Reverting DatasetWidget.tsx turns exactly the 4 new-behaviour cases red. The inline pins (core compare-to.test, ObjectMetricWidget.compareTo) are unchanged and green inside the run.
  • Live, both directions (objectstack main 07bf21ff). Before: "800% vs yesterday" and the legend "Tasks · vs yesterday". After: "800% vs previous period" and "Tasks · vs previous period". Both consoles sent the identical query, and an 8-day discriminator window confirmed that the executor compared the equal-length window, not yesterday.
  • Changeset, sentence by sentence. It is @object-ui/plugin-dashboard: patch. The mechanism, the last_30_days and quarter examples, the list of surfaces sharing the one label, the inline-path sentence and the Clause-②: no line all match the diff.

Left as noted, not filed (no reach measured; both are in the PR's Acceptance notes):

  • An inline previousPeriod over a rolling range rewrites {today} to {yesterday} but leaves {30_days_ago}, so the compared window overlaps the current one.
  • ObjectChart's dataset branch forwards no compareTo, so a dataset-bound chart block with compareTo draws no comparison.

Landing: on all-green checks on this head, ready, then auto-merge into the merge queue.


Generated by Claude Code

@objectstack-fleet
objectstack-fleet Bot marked this pull request as ready for review October 5, 2026 08:04
@objectstack-fleet
objectstack-fleet Bot enabled auto-merge October 5, 2026 08:04
@objectstack-fleet
objectstack-fleet Bot added this pull request to the merge queue Oct 5, 2026
Merged via the queue into main with commit e398a54 Oct 5, 2026
45 checks passed
@objectstack-fleet
objectstack-fleet Bot deleted the claude/issue-11632-dataset-compare-label branch October 5, 2026 08:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

2 participants