Repository navigation
fix(core): a date macro inside a longer string is a literal on the client too - #36068
Conversation
…ient too resolveDateMacros resolves only a value that is entirely one placeholder, the reading the spec declares and the server resolver applies; a value that merely contains a macro is returned as written. The previous-period token rename in compare-to follows the same reading so the comparison query keeps the current query's literal. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L9qibxWPiQYXSf1jxGbN3W
Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L9qibxWPiQYXSf1jxGbN3W
Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L9qibxWPiQYXSf1jxGbN3W
|
repo:objectstack#7 · os-tesla · session_01L9qibxWPiQYXSf1jxGbN3W Final green head for L1 · 2026-11-21T12:38Z: |
|
repo:objectstack#7 · os-tesla · session_01L9qibwRAQZtb2syxNdJ6zT L1 · PR #36068 · head
|
|
repo:objectstack#7 · os-tesla · session_01L9qibxWPiQYXSf1jxGbN3W Landing · 2026-11-21T12:42Z · head
L1 ACCEPT by L1-b (7062744205) on this head; all checks green, mergeable clean. Ready + auto-merge now. |
Requested by Tesla · project thread
Fixes #35754
Clause-②: no
Metadata-protocol: none
维护者速读
What changes
The spec reads a filter value as a placeholder only when the value is ENTIRELY one wrapped token (
FILTER_TOKEN_WRAPPED_REin@objectstack/spec/data: "a value that merely CONTAINS braces ('acme {x} deal') is untouched, as are{a}{b}and{{x}}"), and the server resolverresolveFilterTokensin@objectstack/coreapplies that reading. The client resolver did not: after its whole-value match,resolveDateMacrosin@object-ui/coreran a second, global replace over the string, so'from {today} on'became'from 2026-05-25 on'in the console and stayed literal on the server. The card's question (which side is the contract) is answered by the spec text above, so the client aligns with it.resolveDateMacros(ui/packages/core/src/utils/date-macros.ts): the global pass is removed. A string resolves only when it is one whole{token}/${token}; anything else is returned as written. The header says so and names the spec reading.substituteTokensinui/packages/core/src/utils/compare-to.ts(the previous-period token rename behindshiftFilterByCompareTo) had the same embedded pass. With the resolver fixed alone,'from {today} on'would have been renamed to'from {yesterday} on'and then kept literal, so the comparison query would have filtered on a different literal from the current one. It now renames only whole-value tokens, through the file's existingwholeTokenhelper. Same defect class, mechanical, no other claim on the file, same test family: fixed here under the bounded in-place rule and declared in the report.Caller census (every non-test caller of
resolveDateMacrosat base8145424b; none relies on the embedded form):resolveFilterPlaceholders(corefilter-tokens.ts), and through it every list, grid, chart, dashboard and detail surfaceshiftFilterByCompareTo/lastPeriodBefore(corecompare-to.ts)lastPeriodBeforebuilds a whole{last_UNIT_start}lastPeriodBeforeunchangedisUsableDateString(coredashboard-filters.ts)resolveInitialDateMacro(plugin-calendarinitialDate.ts)calendar.initialDate, which the spec defines as a wrapped tokenutils.tsThe card's "page/URL params" hypothesis does not hold:
resolveParaminsideresolveDateMacrosis the parameterised date-macro grammar ({N_days_ago}and friends), which the server also resolves (parseDateMacroParam), not page or URL parameters. No dashboard title or URL template calls this resolver.Tests
ui/packages/core/src/utils/__tests__/date-macros.embeddedLiteral-35754.test.ts: an embedded fixed macro, an embedded parameterised macro, an embedded macro beside a whole one in a filter tree (throughresolveFilterPlaceholders), a previous-period comparison, and{{today}}all stay literal. CONTROLS: a whole{today},${today}and{7_days_ago}still resolve;'acme {x} deal'and{a}{b}are untouched.date-macros.test.tspinned the embedded behaviour in two assertions: "leaves unknown tokens untouched and ignores non-strings" expected'hello {today} world'to become'hello 2026-05-25 world', and "accepts both {token} and ${token} forms" expected'range: ${last_week_start}..${today}'to become'range: 2026-05-18..2026-05-25'. Both now expect the value as written; the whole-value'${today}'assertion beside them is unchanged.All runs on head
372f6c1f.@object-ui/core suite, type-check, consumers
Ablation, one leg per fixed file (base file restored, pin run, HEAD restored and hash-verified)
Both CONTROL cases stay green under both ablations, as controls should.
Acceptance notes
scripts/analytics-reconcile/macros.ts); read at hotcrme7fe77f, it has no global replace pass, so nothing there disagrees.[a-zA-Z0-9_]+), narrower than the server's recognition grammar. That is a separate question (what an unknown wrapped value does on the client) and is not touched here.Verification
Derived gates (dispatch-gates --commands, head 372f6c1)
Read first:
ui/packages/core/src/utils/date-macros.ts, thewalkstring branch insideresolveDateMacros: the whole cut.ui/packages/core/src/utils/compare-to.ts,substituteTokens: the comparison-query twin.ui/packages/core/src/utils/__tests__/date-macros.test.ts: the two flipped assertions.Two-minute check:
pnpm --dir ui exec vitest run packages/core/src/utils/__tests__/date-macros.embeddedLiteral-35754.test.tsfrom the repo root shows 7 passed.Seat:
repo:objectstack#7 · os-tesla · session_01L9qibxWPiQYXSf1jxGbN3WGenerated by Claude Code