Repository navigation
refactor(core): dashboard date presets read their bounds from the spec window table - #29320
Merged
Merged
Conversation
…c window table dashboard-filters drops its local PRESET_RANGES copy and lowers every preset through @objectstack/spec's DATE_RANGE_PRESET_MACRO_WINDOWS, with membership decided by isDateRangePresetName. The emitted current-period tokens move to the spec's bare aliases, which resolve to the same days. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QsR2jSgqmN55SMKRe9YTif
Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QsR2jSgqmN55SMKRe9YTif
…t comments Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QsR2jSgqmN55SMKRe9YTif
Contributor
Author
|
domain:ui#5 · zhuangjianguo · session_01QsR2jQjvWkZ7is6GXbC6DB 席位核对 — ACCEPT ·
|
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 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.
Requested by Steedos · project thread
Fixes #29116
Clause-②: no
Metadata-protocol: none
维护者速读
{current_month_start}对{month_start}),迟早会漂移;你已定为低优先级卡。{current_*}换成同义的{month_start}这类别名,解析出的日期逐一相同;回滚就是 revert 本 PR。ui/packages/core/src/utils/dashboard-filters.ts里的presetBounds,然后是新测试dashboard-filters.presetWindows-29116.test.ts。ui/下运行pnpm exec vitest run packages/core/src/utils/__tests__/dashboard-filters.presetWindows-29116.test.ts,应看到 44 个测试全部通过。What changes
ui/packages/core/src/utils/dashboard-filters.ts: the localPRESET_RANGEStable is gone.presetBounds(preset)now returns the spec's window fromDATE_RANGE_PRESET_MACRO_WINDOWS(@objectstack/spec/data), and membership is decided by the spec's exactisDateRangePresetName, both inpresetBoundsand innormalizeDateDefault(which useddefaultValue in PRESET_RANGES). The docblocks that explained the table'ssatisfiespin now say where that guarantee lives: the spec declaration is typedRecord<DateRangePreset, …>, so a preset added without a window fails to compile in the spec, and there is no local table to invent a name in.this_week,this_month,this_quarterandthis_yearemit the bare aliases ({month_start}/{month_end}and so on) instead of{current_month_start}/{current_month_end}. The other nine presets emit byte-identical tokens.DATE_RANGE_PRESETSis still re-exported from@object-ui/coreas before..changeset/29116-dashboard-preset-windows-from-spec.mdfor@object-ui/core.Why
The card: the same 13 presets had two tables, the spec's and this module's, in two spellings of the same days. Both resolve today through
DATE_MACRO_ALIAS_TOKENS, so nothing was wrong on screen; the risk was the tables drifting.Tests
New
ui/packages/core/src/utils/__tests__/dashboard-filters.presetWindows-29116.test.ts(44 tests):DATE_RANGE_PRESETSemits exactly the spec's window (13 cases), and the preset set equals the retired table's 13 keys;resolveDateMacros) to the same two calendar dates under the new spelling and under the retired{current_*}table, copied verbatim into the test, on six reference dates that cross week, month, quarter and year boundaries plus a leap day (13 cases);shiftFilterByCompareTogives the same window forpreviousPeriodandpreviousYear, andcompareToTrendLabelKeygives the same label under both spellings (13 cases);{current_*}spelling still filters: a custom range{ from: '{current_month_start}', to: '{current_month_end}' }passes through and selects the same days as thethis_monthpreset, and a date global filter defaulting to'{current_quarter_start}'is kept as a token, passed through and resolved;Object.prototypemembers (constructor,toString,__proto__), and such a name is not lifted to{ preset }as a date default.Changed pin:
ui/packages/core/src/utils/__tests__/dashboard-filters.test.tsasserted the literal{current_month_start}/{current_month_end}emitted forthis_month(two places). They now assert{month_start}/{month_end}. This is behaviour-neutral: the pin is on the emitted token string, and the parity cases above prove the two tokens resolve to the same day on every preset and reference date.Pins named by the card stay green without edits:
ui/packages/types/src/__tests__/report-chart-query-spec-parity.test.ts, the plugin-dashboardDashboardFilterBar*andDashboardRenderer.filterstests (none of them pins an emitted current-period token).Acceptance notes
'constructor') used to pass the oldincheck, then resolved to no bounds and was dropped with no warning. It is now dropped with the standard unknown-preset warning. Covered by the prototype-member cases above.DATE_RANGE_PRESET_MACRO_WINDOWSsays the console's lowering "stays the executable mapping" and the table is "deliberately NOT a resolver". That still reads true (the lowering stays indashboard-filters, it now reads the table), so the spec is left untouched as the card requires.dashboard-filters(fix(spec)!: a dashboard that declares two global filters under one name is refused #29162, feat(components): the filter panel offers relative dates on date rows #29263, fix(rest)!: GET /meta/_drafts refuses an unknown type or package filter instead of answering an empty list (#29180) #29295, fix(rest)!: refuse unknown keys on the dataset query body (#29156) #29251) do not touchdashboard-filters.ts.Verification
Local runs (ui/, locked; b8bd448, core suite again on 97d4d50)
turbo run build --filter='@object-ui/core^...'plus formula, sdui-parser, lint, client: 38/38 tasks, exit 0.pnpm exec vitest run packages/core/: Test Files 231 passed (231), Tests 4280 passed, 27 skipped.DashboardFilterBar*,DashboardRenderer.filters,DashboardPhoneTouchTargets-29078; typesreport-chart-query-spec-parity; plugin-designerDashboardDesignPage.presetAlias; i18ndashboard-range-preset-labels-4984; app-shellDashboardWidgetInspector): Test Files 16 passed, Tests 142 passed, 6 skipped.turbo run type-check --filter=@object-ui/core: exit 0 (it compiles the test files; the first run caught a typing slip in the new test, fixed in the second commit).Ablations (scripts/ablation-replace.mjs, restored to the HEAD blob each time)
presetBoundsguard swapped topreset in DATE_RANGE_PRESET_MACRO_WINDOWS: "an unknown preset name still misses, prototype member names included" goes red; restored, blob equals HEAD.normalizeDateDefaultguard swapped todefaultValue in DATE_RANGE_PRESET_MACRO_WINDOWS: "a non-preset date default is not lifted to a preset" goes red; restored, blob equals HEAD.Derived gates
Derived with
node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstackat b8bd448 (34 families) and run there;--ranreconciliation: 34 derived, 34 run, 0 NOT-MEASURED, 0 UNRUN. Every family exit 0:node scripts/check-adr-0087-registration.mjs --base origin/mainexit 0node scripts/check-adr-0087-registration.mjs --self-testexit 0node scripts/check-changeset-no-major.mjs --base origin/mainexit 0node scripts/check-closing-keyword-parity.mjsexit 0node scripts/check-closing-keyword-parity.mjs --self-testexit 0node scripts/check-comment-mask-corpus.mjsexit 0node scripts/check-empty-changeset.mjs --base origin/mainexit 0node scripts/check-empty-changeset.mjs --self-testexit 0node scripts/check-sdui-manifest.mjsexit 0node scripts/check-sdui-manifest.mjs --self-testexit 0node scripts/pm/release-rehearsal-clone.mjs --self-testexit 0node scripts/release-pending-publish.mjs --self-testexit 0pnpm --filter @objectstack/spec run check:duration-unit-keysexit 0pnpm check:changeset-gate-self-testsexit 0pnpm check:closed-ceremony-textexit 0pnpm check:cross-package-test-inputsexit 0pnpm check:dispatcher-error-vocabularyexit 0pnpm check:driver-memory-censusexit 0pnpm check:engine-double-contractexit 0pnpm check:gitlink-declaredexit 0pnpm check:nul-bytesexit 0pnpm check:pm-changeset-deadline-censusexit 0pnpm check:published-filesexit 0pnpm check:query-options-erasureexit 0pnpm check:refd-timer-probeexit 0pnpm check:skill-identifier-livenessexit 0pnpm check:test-source-aliasexit 0pnpm check:tier-file-adoptionexit 0pnpm check:type-check-coverageexit 0pnpm check:type-check-debtexit 0pnpm check:undeclared-dep-importsexit 0pnpm check:watch-hint-literalexit 0pnpm check:where-matcherexit 0pnpm --dir ui exec vitest run scripts/exit 0pnpm --dir ui exec vitest run scripts/: Test Files 169 passed, 2 skipped (171). After merging main (head 97d4d50, no change to the touched files or the spec date tables):vitest run packages/core/again 231/231 files,check:nul-bytesandcheck-sdui-manifest.mjsexit 0.Generated by Claude Code