You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 4391c50
Browse filesBrowse the repository at this point in the historyBrowse files
fix(plugin-dashboard): a compareTo KPI tile shows its number when the reader picks All time (#26027)
<!-- claude-projects-attribution: {"github_login":"os-steve"} -->
_Requested by **Steve** · [project
thread](https://claude.ai/code/project/chan_01FdL1XeUyvVNxLreh3F4Qi9?thread=cmsg_01FdL1XeUyvVNxLreh3F4Qi9KA65exXwidHdYJ3vG9pE5U)_Fixes#25970
Clause-②: no
Metadata-protocol: none
## What changes
A dataset-bound widget with `compareTo` now asks for a comparison only
when its resolved filter carries a date condition on the compared field
(on any field when `compareTo.dimension` is omitted). When the filter
dates nothing, which is what the reader's **All time** on the dashboard
date filter produces, the widget sends the same query a widget without
`compareTo` sends and the tile shows its number with no comparison
badge.
- `ui/packages/plugin-dashboard/src/DatasetWidget.tsx`: new exported
`filterDatesField(filter, dimension?)`. The widget's declared comparison
becomes `declaredCompareTo`; the `compareTo` the query, the signature
and the overlay read is that value only when `filterDatesField` holds.
No window is lowered either, so `runtimeFilter` is untouched in that
case.
- `ui/packages/plugin-dashboard/SKILL.md`: the "When NOT to use
`compareTo`" line now separates a date condition that is not a closed
window (still an error) from a filter that dates nothing (no comparison,
no error).
## Mechanism, measured
Picking All time calls `onChange(undefined)` (`DashboardFilterBar.tsx`,
the ALL sentinel). `buildWidgetScopedFilter` skips an empty value, so
`DashboardRenderer` merges no condition and the widget's own `filter`
reaches `DatasetWidget` unchanged: the date key is ABSENT, not an open
range. For the HotCRM "Selected Period" tile that means a runtime filter
with no date at all, the case this PR omits the comparison for.
## The ruling this PR implements (the seat's delegated call)
- An author-declared one-bound window (`$gte` only, e.g. a YTD tile)
**stays an error**. The executor and the spec define `compareTo` only on
a two-bound window, so the widget still sends `compareTo`, and the
executor's refusal names the fix. HotCRM's YTD / QTD / 12M tiles written
as one bound keep erroring until they are written as a closed pair.
- Two dated fields with no `compareTo.dimension` stay the executor's
ambiguity error.
- The omission applies only when the filter carries no date condition on
the compared field at all. "A date condition" is any ISO-date operand
under the field, at any depth and in any position (`$or` / `$not`
included), deliberately wider than the windows `extractDateWindows`
lowers. A custom range with only a start date picked in the filter bar
(`{ $gte }`) therefore also keeps erroring.
## Tests
At head `b256ae44`:
- `ui/packages/plugin-dashboard` whole package, `vitest run
--maxWorkers=2 packages/plugin-dashboard/` under the verify lock: Test
Files 188 passed (188), Tests 1842 passed, 6 skipped.
- New in `DatasetWidget.compareTo.test.tsx`: `filterDatesField` unit
cases, and four widget cases against a source that answers the way the
executor does: no filter, a non-date filter, a named dimension left
undated (all three send no `compareTo` and render the number with no
badge), and a one-bound `$gte` window (still sends `compareTo` and shows
the refusal).
- New `DashboardRenderer.compareToAllTime-25970.test.tsx` drives the
real Radix select: under the default `this_quarter` range the tile
compares, then after picking All time the last selection is exactly the
no-comparison query, the number shows, and no badge appears. A YTD tile
(`$gte` only, opted out of the dashboard filter) keeps the refusal.
- Four existing fixtures declared `compareTo` with no dated filter and
had the mock answer a `__compare` column the real executor would have
refused (`DatasetWidget.test.tsx` forwarding case, `colorVariant`,
`comboPresentation`, `dimensionlessMeasures-11261`). Each now states a
closed window. The objectui#7495 control (bar vs pie with no window) now
uses a one-bound filter so its refusal still has something to refuse.
- `pnpm --filter @object-ui/plugin-dashboard type-check`: exit 0; `tsc
-p tsconfig.test.json --listFiles` includes both changed compareTo test
files.
- Ablation, once: the omission condition replaced with the bare declared
value through `scripts/ablation-replace.mjs` (anchor x1 to x0, marker x0
to x1, restored blob equal to HEAD). The three omission cases and the
All-time dashboard case went red (4 failed, 36 passed); the one-bound
and YTD cases stayed green, as they pin unchanged behaviour.
## Gates
`node scripts/pm/dispatch-gates.mjs --commands --repo
objectstack-ai/objectstack` at `b256ae44`: 46 derived commands, each
run, every one exit 0. `--ran` with exit codes: "46 derived famil(ies)
accounted for — 46 run, 0 NOT-MEASURED (a DERIVED zero)". `node
scripts/check-sdui-manifest.mjs` is among them after the re-record;
`node scripts/check-changeset-fixed.mjs` (roster under `.changeset`)
also exit 0. Type-check lanes, Test Core and the wide-population
families are CI's.
## Acceptance notes
- A widget whose author wrote `compareTo` with no date anywhere and no
dashboard date filter bound to it now shows no comparison silently,
where it used to show the refusal. At runtime that case cannot be told
apart from the reader's All time, and the ruling puts the reader's case
first. Catching it would belong at authoring time (a lint on `compareTo`
over a widget that no date filter can reach); not filed here.
- The dataset-bound path of `ObjectChart` (`ui/packages/plugin-charts`)
does not forward `compareTo` to `queryDataset` at all, so it never hit
this refusal. Observation only.
---
_Generated by [Claude
Code](https://claude.ai/code/session_01RJW3o457EFFwmLN1429vn9)_
---------
Co-authored-by: Claude <noreply@anthropic.com>
fix(plugin-dashboard): a `compareTo` KPI tile shows its number when the reader picks All time, instead of the executor's "compareTo needs a dated window to shift" error
6
+
7
+
Clause-②: no
8
+
Metadata-protocol: none
9
+
10
+
-**Before.** A dataset-bound widget with `compareTo` always sent `compareTo` to the dataset executor, but lowered a `timeDimensions` window only when its resolved filter held a closed `{ $gte, $lte }` date pair. Picking **All time** on the dashboard's date-range filter removes that pair, so the executor refused the query and the tile showed a 400 error where its number belonged. The same tile without `compareTo` showed its number.
11
+
-**Now.** When the resolved filter carries no date condition at all on the compared field (on any field when `compareTo.dimension` is omitted), the widget asks for no comparison: the query is the one a widget without `compareTo` sends, and the tile shows its number with no comparison badge.
12
+
-**Unchanged: an author-written window that is not closed stays an error.** A one-bound window (`{ $gte: '{current_year_start}' }`, a YTD tile), an exclusive bound or a single day is still sent with `compareTo`, and the executor still refuses it and names the fix. The executor and the spec define a comparison only against a two-bound window. Two dated fields with no `compareTo.dimension` stay the executor's ambiguity error.
0 commit comments