Repository navigation
fix(react): evaluate a ${…} hole inside an inline locale map like a plain string (objectui#12936) - #12940
Conversation
… string on the same key A config-bag value that is an inline locale map (the spec's second I18nLabel form, recognised by @objectstack/spec's InlineLocaleMapSchema) now has every member evaluated with the same evaluator and scope as a plain string on that key: record, current_user / user, page, and data under an API binding. Any other data object keeps the objectui#10288 rule and is handed over as authored. A member's result is spelled as a string, and a map without a hole keeps its identity. The unevaluated-expression diagnostic reads the members through the same recogniser and walker, so a member whose expression throws is reported by its locale, as a plain string with the same hole is. Claude-Session: https://claude.ai/code/session_0188TsgPV8kQXfuRuKmkj2ks Co-authored-by: Claude <noreply@anthropic.com>
✅ Console Performance Budget
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
Size Limits
|
Contract reviewServed-tier: The face owed is the ① Derived judgments
② Semver level
③ Boundary flags
Implemented-by: VERDICT: PASS |
席位核对 — ACCEPT ·
|
Fixes #12936
Clause-②: yes (widening) —
@object-ui/react'sSchemaRenderernow honours a shape it used to hand over raw: each member of an inline locale map in a node's config bag is evaluated like a plain string on the same key. No export is added or removed and no type changes; the set of authored values the renderer evaluates widens by that one shape.Dispatched by the
domain:uiseat 1 PM (claim comment 6246422606), triage route 1 (comment 6246364337). Sessionhttps://claude.ai/code/session_0188TsgPV8kQXfuRuKmkj2ks.What changed
packages/react/src/utils/localeMap.ts(new).isInlineLocaleMapasks@objectstack/spec/ui's ownInlineLocaleMapSchema(every key a locale tag ordefault, neverkey/defaultValue; every value a string), behind a fast reject on a non-string member that can only refuse what the schema refuses.mapLocaleMapMembersmaps each member through a visitor, spells the result as a string, and copies on write, so a map without a hole comes back as the very object that went in.SchemaRenderer.tsx,evaluateConfigValueWith(the one per-value rule): inside the data-object branch, an inline locale map has each member evaluated by the same evaluator, so against the same scope as a plain string on that key. Every other data object keeps the objectui#10288 hand-over, with no walk. This one rule serves the memo's node-levelparams,propertiesandpropsloops andevaluateConfigBagInScope(useConfigBagEvaluator), so every carrier moves together. The docblocks ofisDataObjectValueandevaluateConfigValueWith, and the two memo comments that describe the shallow radius, now name the one-level exception.utils/unevaluatedExpression.ts.scanBagwalks a locale map's members through the same recogniser and walker, so a member whose expression throws (the evaluator keeps its source text) is reported by its locale, for exampleproperties.title.en, as a plain string with the same hole is. Its "Depth" docblock records the second shape. The message text is unchanged.content/docs/guide/expressions.md: a short "Localized Copy" subsection (AGENTS.md Add automated testing infrastructure and CI/CD workflows #2)..changeset/12936-locale-map-holes.md:@object-ui/reactminor.A member's result is always a string: a member that is one whole hole,
'${data.count}', resolves to the number as a plain string does, and a number member would be skipped by everypickLocalizedlimb (each reads string entries only), so the viewer would get another locale's line.String(result ?? '')is the spelling the evaluator already gives an interpolated part of a plain string.The PM's mechanism assumptions, measured
isDataObjectValuehands every non-envelope object on a non-predicate key over as authored. Its only reader isevaluateConfigValueWith, and that is the rule behind node-levelparams, thepropertiesloop, thepropsloop (through the memo'sevaluateConfigValue) andevaluateConfigBagInScope. The diagnostic had to learn the shape too. Its own header says "Depth: exactly the evaluator's own radius, and not one level more". Without the scan change, a member whose hole throws stays raw and says nothing, while the same plain string is reported. Ablation 2 below shows this.@object-ui/i18nhas noisInlineLocaleMap(pickLocalizedaccepts any object), andplugin-dashboard's module-privateisLocaleMapis "any non-array object", which is too wide. The installed@objectstack/spec18.0.0-next.3declaresInlineLocaleMapSchemaat runtime as az.recordof a locale-tag key regex toz.string(). Verdicts measured through it: the card's map true;{ source, campaign }false; a 30-key mixed data object false; an expression envelope false; aDatefalse;{ id, url }true (see Acceptance notes). Cost measured on this box: about 2 microseconds for a map; the member pre-check turns away most data objects before the schema runs.predicateScopeas the ambient scope plusdata: apiDataonce the API binding's status isready, andconfigEvaluationScopeaddscurrent_user,recordandpage. The members go through that same evaluator, pinned once per root:record,page,current_user, anddataunder an API binding.isDataObjectValue, which already excludesPREDICATE_CHAIN_KEYSand spec envelopes. An envelope can never be a locale map, becausedialectandsourcefail the key regex. No locale map on a predicate key was found.hero(readsschema.properties, thenpickLocalized) andelement:text(reads throughreadProps, thenpickLocalized) both draw the evaluated member. No consumer was found re-reading the raw node.Tests (all on head
3d521e22)packages/react/src/__tests__/SchemaRenderer.localeMapHoles-12936.test.tsx:Tests 15 passed (15). It pins member/plain-string parity per root (record, page, current_user, data under an API binding), thepropsalias,evaluateConfigBagInScope, the whole-hole string spelling, four data-object controls (non-string member, nested object member, non-locale key, the retiredkey/defaultValueform) and the no-hole identity control. It also has three diagnostic cases: a throwing member reported by its locale, an evaluated member not reported, and the scan walking a locale map and nothing else.packages/app-shell/src/console/blocks/__tests__/localeMapHole-12936.test.tsx:Tests 6 passed (6). It covers the card's zh / enherotitlewith adata.*hole under the real API binding, the zh / en no-hole control, andelement:textin zh-CN / en.pnpm exec vitest run --maxWorkers=2 packages/react/:Test Files 117 passed (117),Tests 1464 passed (1464), lockVERDICT command-exit 0.packages/components/src/renderers/action/__tests__/,packages/components/src/renderers/basic/__tests__/, five locale/aria suites inpackages/components/src/__tests__/,packages/app-shell/src/console/blocks/__tests__/andDeclaredActionsBar.test.tsx:Test Files 65 passed (65),Tests 984 passed (984),VERDICT command-exit 0.pnpm --filter @object-ui/react type-check(tsc --noEmit && tsc -p tsconfig.test.json): exit 0, afterpnpm --workspace-concurrency=2 --filter "@object-ui/components^..." run build. A--listFilescount shows both new files are read.@object-ui/app-shelltype-check: narrowed to the new test file (a temporary project extendingtsconfig.test.json, deleted afterwards) because the full project needs about 30 package builds. Exit 0, and--listFilesshows it read the test andproductBlocks.tsx. The full project is left to CI's Type Check.Ablations (committed first; mutation and restore through
ablation-replace.mjs, wrap mode, restore proven by blob equals HEAD and an emptygit diff HEAD)mapLocaleMapMembers(value, …)replaced byvalueinevaluateConfigValueWith). Predicted: every parity pin red, the hero andelement:textreads red, the diagnostic's "evaluated member is not reported" control red (direction: more diagnostics, because the members stay raw), and every data-object control green. ObservedTests 12 failed | 9 passed (21), exactly those 12. Restored to blob1d4dc859ba4c, equal to HEAD.isInlineLocaleMaptest inscanBagmade false). Predicted and observed:Tests 2 failed | 13 passed (15), namely the throwing-member report and the scan pin. Restored to blob681dee2e782c, equal to HEAD.Gates (run locally on
3d521e22; exit captured before any pipe)objectui has no
dispatch-gates.mjs, so this list is derived by hand from the rootpackage.jsonagainst this diff.pnpm check:new-line-citations: 0,VERDICT new-cross-file-line-citations: 0 new citation(s)pnpm check:test-path-roots: 0, OKpnpm check:changeset-claims: 0, "No pending changeset names a file this change touches."node scripts/check-changeset-presence.mjs: 0, "5 source file(s) of 2 released package(s) changed, and this change declares 1 changeset(s)"pnpm changeset:check: 0pnpm check:pending-changeset-literals,check:control-bytes,check:unreferenced-sources,check:phantom-deps,check:esm-specifiers,check:spec-symbols,check:element-data-source-declaration: all 0check:doc-json0 ("Every judged JSON node document on the scan surface passes the strict authoring face";content/docs/**is on its surface, so the newelement:textfence was judged),check:doc-types0,check:doc-fences0,check:doc-example-ids0,check:doc-example-readers0.check:doc-snippets,check:doc-examples: NOT MEASURED, exit 2PRECONDITION NOT MET(they need a 34-package scoped build). The new block is a JSON fence, whichcheck:doc-jsonjudged; left to CI.SchemaRenderer.tsx, and this diff adds noany.node scripts/check-governed-queue-guard.mjs --testover all seven paths: "NOT GOVERNED".Acceptance notes
SchemaRenderer.tsx, the tests and one changeset. This diff also addsutils/localeMap.ts, the shared recogniser and walker, followingutils/paramsBag.ts. It also editsutils/unevaluatedExpression.tsfor diagnostic parity (assumption 1) andcontent/docs/guide/expressions.md(AGENTS.md Add automated testing infrastructure and CI/CD workflows #2). Nothing in the claim's not-in-scope list is touched:pickLocalized, block prop reads, the save path and spec keys are all unchanged. The seat may want to amend the claim's file surface.{ id, url }qualifies) and whose values are all strings is an inline locale map toInlineLocaleMapSchema, so it is one here too, and a${…}in its members is now evaluated. A source grep found no authored data object of that shape carrying a hole; the matches were JS template literals. Recorded, not filed. Carrier: none.contentleg and the spec's expression-bindable node keys (statistic/card/button) still evaluate strings only, so a locale map written at node level stays raw. The diagnostic now names such a member, since it scans locale maps on every channel as it scans strings, and its message points the author toproperties.*, which evaluates it. No producer was measured writing that shape. Recorded, not filed. Carrier: none.aria.ariaLabel) stays raw, by the ruling.needs:contract-review. Clause-② is yes; this run's definition does not ask the dev to hang the marker, so no label was written. That is the seat's call before ready.Generated by Claude Code