Skip to content
This repository was archived by the owner on Nov 4, 2026. It is now read-only.

Commit 36e27db

Browse files
fix(app-shell): the designer's unknown-value flags read in the designer's locale (objectui#9652) (#10445)
Fixes #9652 Clause-②: no ## What was wrong A designer picker that holds a stored value its roster does not offer still shows that value, flagged with the reason. The flag was an English template literal at each site, so a zh-CN author read `(not found)`, `(not in object)` or `(deprecated)` on an otherwise Chinese inspector. The designer catalogue (`packages/app-shell/src/views/metadata-admin/i18n.ts`) already carried `engine.form.notInObject` in en and zh, and `widgets.tsx` already used it. ## Sites (re-derived by grep on `origin/main` at the base `3335767b4`) | site | flag | now | |:--|:--|:--| | `ViewColumnInspector` field picker | `(not in object)` | `engine.form.notInObject` (existing row, unchanged) | | `ViewVariantInspector` view type | `(not found)` | `engine.form.notFound` (new) | | `FlowNodeConfigField` select branch | `(deprecated)` | `engine.form.deprecated` (new) | | `FlowObjectListField` select cells | `(deprecated)` | `engine.form.deprecated` | | `InspectorSelectField` default (`_shared.tsx`) | `(not found)` | `engine.form.notFound` | `ActionDefaultInspector` only mentions `VALUE (not found)` in a comment. Its `ActionTargetField` passes no `unknownValueLabel`, so it shows the `_shared.tsx` default, which is now translated. Two sites of the same class that the seat's list did not name. Both are outside this claim's file surface, so they are **not** touched here. They are listed in the report for the seat: - `FlowReferenceField.tsx`, org-membership-level select: `label: \`${current} (invalid)\`` - `HookDefaultInspector.tsx`, object picker: `label: \`${n} (not published)\`` ## Decisions, each measured - **Keys.** `(not in object)` now uses the existing `engine.form.notInObject`. Its value is unchanged, so the bare-suffix readers in `widgets.tsx` (which draw it in a muted span of its own) keep working. The catalogue had no row meaning "not found" or "deprecated" (grep of both tables for `not found`, `deprecated`, `未找到` and `弃用`). One key was added for each, as bare suffixes shaped like `notInObject`: `engine.form.notFound` = `(not found)` / `(未找到)` and `engine.form.deprecated` = `(deprecated)` / `(已弃用)`. `未找到` is the zh pack's own word for "not found" (`未找到选项`, `未找到记录`). The catalogue carries en and zh only, and every new key has a value in both. - **Word order.** The catalogue's `tFormat` interpolates single-brace `{token}` holes. `engine.form.notInObject` is a bare suffix, and its value cannot take a `{value}` hole without changing `widgets.tsx`. So the value and its flag are joined by one template, `engine.form.flaggedValue`: en `{value} {flag}`, zh `{value}{flag}`. The zh template drops the space because every zh flag opens with a full-width bracket. That is the catalogue's own zh convention (`component_id(此页面暂无组件)`), and a `${v} (flag)` literal at the call site could not express it. This adds three keys, one more than "one key each": the template is the word-order key that the open point asked for. The helper is `flagUnknownValue(value, flag, locale)` in `_shared.tsx`, a one-line `tFormat` call. - **How the locale is obtained. No new plumbing.** The three sites that already had a `locale` prop (`ViewColumnInspector`, `ViewVariantInspector`, `FlowNodeConfigField`) translate with that prop. Two places have no `locale` prop: `InspectorSelectField`'s default and `FlowObjectListField`. They read `useMetadataLocale()`, the hook that the designer's shared editors already read when no prop reaches them (`widgets.tsx`, `SchemaForm.tsx`, and `ConditionBuilder.tsx` in this same directory). Every production host (`ResourceEditPage`, `StudioDesignSurface`, `ObjectActionsPanel`) derives the `locale` prop it hands to inspectors from that same hook. - **The `_shared.tsx` default.** It is translated. The other route would have been a `locale` prop on `InspectorSelectField`, but that needs a `locale` argument at each of the call sites that pass no `unknownValueLabel`, which are in other inspector files outside this claim. The hook covers them with no call-site edit. ## Pins The new file is `inspectors/unknownValueFlag.i18n-9652.test.tsx`, with 14 cases. For each site it has one render-level zh case and one en case, and it reads the rendered trigger or option text: - zh expectations are the value followed directly by the catalogue's zh flag. A guard proves each flag row is a real zh value: not the key echoed back, not the English value, and opening with a full-width bracket. - en expectations are the pre-fix literals byte for byte (`amount (not in object)`, `legacy_board (not found)`, `sms (deprecated)`, `role (deprecated)`, `retired_group (not found)`). - The prop-channel sites pass `locale` with no provider. The hook-channel sites mount `I18nProvider` in the language under test. No existing test was rewritten or deleted. None of them asserted an English flag under a zh locale: every existing literal assertion (`ReportDefaultInspector.test.tsx`, `FlowNodeInspector.declaredDefault.test.tsx`, `FlowNodeConfigField.test.tsx`, `FlowObjectListField.select.test.tsx`, the `_shared.*` and `ViewColumnInspector.*` suites) renders en. ## Reverse proof (run at `ff58a68b1`, which has the same code as the head; the next commit adds only the changeset) Mutations were made through `ablation-replace.mjs`. Each anchor hit exactly once, the blob changed, the file was restored to its HEAD blob afterwards, and `git diff HEAD` was empty: - **A.** `ViewColumnInspector` back to `` `${v} (not in object)` ``: `Tests 1 failed | 1 passed | 12 skipped`. The zh case failed with `Expected: "amount(不在对象中)" Received: "amount (not in object)"`, and the en case stayed green. - **B.** The `_shared.tsx` default back to `` `${v} (not found)` ``: `Tests 1 failed | 2 passed | 11 skipped`. The zh default case failed with `expected 'retired_group (not found)' to be 'retired_group(未找到)'`, and the en and caller-override cases stayed green. ## Verification (head `f96ee760a`) - `vitest run` on `metadata-admin/inspectors/` (all of it) plus `check-i18n-{designer-table-parity,dead-keys,call-site-keys,en-drift}.test.ts`, `perm-home-namespace-3546`, `objectView-config-keys-retired-4730`, `block-config-i18n`, `block-config`, `studio-locale.i18n` and the console `preview-samples-designer-options`: `Test Files 100 passed (100)`, `Tests 1570 passed | 1 skipped`. - `vitest run` on tests that render these inspectors from outside the directory: `studio-design/` (all of it), both `ViewConfigPanel` suites, `ResourceEditPage.defaultGate`, `ConditionalFormattingEditor.celGate`, `FieldsListEditor.retiredAliases`, `view-column-io.retiredAliases`, `page-schema`, `ViewRefWidget` and four designer i18n tests: `Test Files 73 passed (73)`, `Tests 401 passed`. - `turbo run build --filter=@object-ui/app-shell^... --concurrency=2` built 28 of 28 tasks. Then `pnpm --filter @object-ui/app-shell type-check` (`tsc --noEmit && tsc -p tsconfig.test.json`) exited 0. `--listFilesOnly` confirms the test tsconfig includes the new test file. - These gates exited 0: `check:i18n-designer-parity` ("Every en row has a zh row, and every shared row carries the same placeholders."), `check:i18n-drift` (designer table: 3 keys added, 0 en values changed), `check:i18n-keys`, `check-changeset-presence`, `check-changeset-no-major`, `check:new-line-citations` (0 new), `check:control-bytes`, `check:changeset-claims`, `check:pending-changeset-literals`, `check:vi-mock-specifiers`, `check:vi-mock-inherit`, `check:vi-mock-override-shape` and `check:test-path-roots`. - `check:changeset-claims` reported three pending changesets that name `i18n.ts`: `6310-designer-formula-key-retired`, `7125-dashboard-empty-state-keys-retired` and `8632-malformed-picklist-option-loud`. I read each paragraph, and all stay true: the keys they name are untouched and still present. - Lint was a proven narrowing, not a repo-wide run. `eslint --no-inline-config --format json` on the 7 touched `.ts`/`.tsx` files gave 7 files, 0 errors and 12 warnings. The population comes from eslint's own config: `calculateConfigForFile` does not ignore these files, and `languageOptions.parserOptions.project` is null. Invariance: type-aware linting is off, and no rule in `eslint-rules/` reads other files, so this diff cannot move a verdict on an untouched file. ## Acceptance notes - One new lint warning: `react-refresh/only-export-components` on the exported `flagUnknownValue`. `_shared.tsx` already exports non-component helpers such as `rosterFrom` and `uniqueId` under the same warning, and `lint.yml` sets no `--max-warnings` on purpose. - The console preview gallery's `?locale=zh-CN` forces the `locale` prop without switching the i18n language. There, the two hook-read flags follow the i18n language, as `SchemaForm` and `widgets.tsx` already do on that page. Production hosts get both from the same hook. - `defaultRosterFailureLabel` stays raw English. Every current `roster` caller passes `t('engine.form.optionsLoadFailedTitle', …)`, so nothing renders it. Its comment is reworded because the old one called the module locale-free. --- _Generated by [Claude Code](https://claude.ai/code/session_01BP8CMtACxTdLjqR6rhd33C)_ --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent cc4366d commit 36e27db

8 files changed

Lines changed: 376 additions & 18 deletions

File tree

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
---
2+
'@object-ui/app-shell': patch
3+
---
4+
5+
fix(app-shell): the designer's unknown-value flags read in the designer's locale
6+
7+
When a designer picker holds a stored value its option list does not offer, it
8+
still shows that value, flagged with the reason: `(not found)`, `(not in object)`
9+
or `(deprecated)`. Those flags were English template literals written at each call
10+
site, so a zh-CN author read untranslated English on an otherwise Chinese
11+
inspector, on the one marker whose job is to explain why a value looks wrong.
12+
13+
Every flag now comes from the designer's own string catalogue. `(not in object)`
14+
uses the existing `engine.form.notInObject` row, and two new rows sit beside it,
15+
`engine.form.notFound` and `engine.form.deprecated`, each in en and zh. The value
16+
and its flag are joined by one new `engine.form.flaggedValue` template, so the
17+
locale decides their order and the gap between them: zh sets no space before the
18+
full-width bracket its flags open with. The en-US text is unchanged.
19+
20+
The sites covered are the view-column field picker, the view-type picker, the
21+
flow-node select field, the select cells of a flow node's object-list editor, and
22+
the default flag `InspectorSelectField` shows at every call site that words none
23+
of its own. That default has no `locale` prop to read, so it follows the
24+
designer's active language through `useMetadataLocale()`, as the designer's other
25+
shared editors already do.

‎packages/app-shell/src/views/metadata-admin/i18n.ts‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1004,6 +1004,16 @@ const ENGINE_STRINGS_EN: Record<string, string> = {
10041004
'This list did not load, so it is not a statement that no options exist. Reload the editor to ask again.',
10051005
'engine.form.none': '— None —',
10061006
'engine.form.notInObject': '(not in object)',
1007+
// The flags a designer picker puts on a STORED value its roster does not
1008+
// offer (objectui#9652). Each is a bare suffix, like `notInObject` above,
1009+
// which `widgets.tsx` draws in a muted span of its own. A picker that shows
1010+
// the value and its flag as ONE option label joins them through
1011+
// `flaggedValue`, so the order of the two and the gap between them belong to
1012+
// the locale rather than to the call site: zh sets no space before the
1013+
// full-width bracket its flags open with.
1014+
'engine.form.notFound': '(not found)',
1015+
'engine.form.deprecated': '(deprecated)',
1016+
'engine.form.flaggedValue': '{value} {flag}',
10071017
'engine.form.searchIcons': 'Search icons…',
10081018
'engine.form.chooseIcon': 'Choose an icon',
10091019
'engine.form.iconsTruncated': 'Showing the first {shown} of {total} — type to narrow.',
@@ -2980,6 +2990,11 @@ const ENGINE_STRINGS_ZH: Record<string, string> = {
29802990
'这个列表没有加载成功,因此它并不表示不存在可选项。请重新加载编辑器后再试。',
29812991
'engine.form.none': '— 无 —',
29822992
'engine.form.notInObject': '(不在对象中)',
2993+
// The zh half of the unknown-value flags (objectui#9652). No space in
2994+
// `flaggedValue`: every flag opens with a full-width bracket.
2995+
'engine.form.notFound': '(未找到)',
2996+
'engine.form.deprecated': '(已弃用)',
2997+
'engine.form.flaggedValue': '{value}{flag}',
29832998
'engine.form.searchIcons': '搜索图标…',
29842999
'engine.form.chooseIcon': '选择图标',
29853000
'engine.form.iconsTruncated': '显示前 {shown} 个,共 {total} 个 —— 继续输入以缩小范围。',

‎packages/app-shell/src/views/metadata-admin/inspectors/FlowNodeConfigField.tsx‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import {
1414
InspectorNumberField,
1515
InspectorSelectField,
1616
InspectorCheckboxField,
17+
flagUnknownValue,
1718
} from './_shared.js';
1819
import { Button, Label } from '@object-ui/components';
1920
import { FlowKeyValueField } from './FlowKeyValueField.js';
@@ -304,7 +305,9 @@ export function FlowNodeConfigField({ field, value, onCommit, disabled, locale,
304305
value={current}
305306
options={opts}
306307
placeholder={declaredDefault}
307-
unknownValueLabel={(v) => `${v} (deprecated)`}
308+
unknownValueLabel={(v) =>
309+
flagUnknownValue(v, t('engine.form.deprecated', locale), locale)
310+
}
308311
onCommit={(v) => onCommit(v)}
309312
disabled={disabled}
310313
/>

‎packages/app-shell/src/views/metadata-admin/inspectors/FlowObjectListField.tsx‎

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,9 @@ import {
2222
Button, Input, Label, Checkbox,
2323
Select, SelectContent, SelectItem, SelectTrigger, SelectValue,
2424
} from '@object-ui/components';
25-
import { uniqueId } from './_shared.js';
25+
import { flagUnknownValue, uniqueId } from './_shared.js';
2626
import type { FlowConfigColumn } from './flow-node-config.js';
27+
import { t, useMetadataLocale } from '../i18n.js';
2728
import { ReferenceCombobox, resolveRefKind, type FlowReferenceContext } from './FlowReferenceField.js';
2829
import { FlowStringListField } from './FlowStringListField.js';
2930
import { VariableTextInput } from './VariableTextInput.js';
@@ -126,6 +127,11 @@ export function FlowObjectListField({
126127
scopeGroups,
127128
approvalScopeGroups,
128129
}: FlowObjectListFieldProps) {
130+
// The add/remove/empty/item labels arrive translated from the caller; the
131+
// flag on a stored select value is composed in this file, so it reads the
132+
// designer's locale itself, as the sibling `ConditionBuilder` does
133+
// (objectui#9652).
134+
const locale = useMetadataLocale();
129135
const external = React.useMemo(
130136
() =>
131137
Array.isArray(value)
@@ -358,7 +364,13 @@ export function FlowObjectListField({
358364
// flag it — it is not offered to fresh rows.
359365
const shown =
360366
current && !opts.some((o) => o.value === current)
361-
? [...opts, { value: current, label: `${current} (deprecated)` }]
367+
? [
368+
...opts,
369+
{
370+
value: current,
371+
label: flagUnknownValue(current, t('engine.form.deprecated', locale), locale),
372+
},
373+
]
362374
: opts;
363375
return (
364376
<div className="flex-1">

‎packages/app-shell/src/views/metadata-admin/inspectors/ViewColumnInspector.tsx‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import {
3333
InspectorSelectField,
3434
InspectorRemoveButton,
3535
InspectorEmptyState,
36+
flagUnknownValue,
3637
rosterFrom,
3738
spliceArray,
3839
moveArray,
@@ -281,7 +282,9 @@ export function ViewColumnInspector({
281282
label={t('engine.inspector.viewColumn.accessorKey', locale)}
282283
value={colFieldKey(col)}
283284
options={fieldOptions}
284-
unknownValueLabel={(v) => `${v} (not in object)`}
285+
unknownValueLabel={(v) =>
286+
flagUnknownValue(v, t('engine.form.notInObject', locale), locale)
287+
}
285288
// objectui#8862 — `useObjectFields` answers over the network, and
286289
// until it does `fieldOptions` is `[]`. Without this the marker
287290
// above told the author, for the length of that round trip, that a

‎packages/app-shell/src/views/metadata-admin/inspectors/ViewVariantInspector.tsx‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import {
3131
InspectorShell,
3232
InspectorTextField,
3333
InspectorSelectField,
34+
flagUnknownValue,
3435
} from './_shared.js';
3536
import { InspectorComboField } from './InspectorComboField.js';
3637
import { useObjectOptions } from './useDatasetFields.js';
@@ -407,7 +408,9 @@ export function ViewVariantInspector({
407408
label={t('engine.inspector.view.type', locale)}
408409
value={viewType}
409410
options={typeOptions}
410-
unknownValueLabel={(v) => `${typeLabel(v, locale)} (not found)`}
411+
unknownValueLabel={(v) =>
412+
flagUnknownValue(typeLabel(v, locale), t('engine.form.notFound', locale), locale)
413+
}
411414
onCommit={(v) => writeVariant({ type: v })}
412415
disabled={readOnly}
413416
/>

‎packages/app-shell/src/views/metadata-admin/inspectors/_shared.tsx‎

Lines changed: 42 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,22 @@
1515
* record, inspectors call `onCommit(value)` which trips an immutable
1616
* splice + `onPatch({...})`. Locale-aware via the `useT` hook the
1717
* caller already has in scope — the shared shell takes raw strings.
18+
*
19+
* One exception, and it is a DEFAULT rather than a label a caller hands in:
20+
* the flag {@link InspectorSelectField} puts on a stored value its roster does
21+
* not offer. Wherever a call site passes none, the default is what a zh-CN
22+
* author reads, so it resolves through `useMetadataLocale()` — the hook the
23+
* designer's other shared editors (`widgets.tsx`, `SchemaForm`,
24+
* `ConditionBuilder`) already read when no `locale` prop reaches them
25+
* (objectui#9652).
1826
*/
1927

2028
import * as React from 'react';
2129
import { ArrowDown, ArrowUp, Trash2, X } from 'lucide-react';
2230
import { cn } from '@object-ui/components';
2331
import { Badge, Button, Input, Label, Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@object-ui/components';
2432
import { type LoadState } from '../loadState.js';
33+
import { t, tFormat, useMetadataLocale, type SupportedLocale } from '../i18n.js';
2534

2635
/* ─────────────── Layout shell ─────────────── */
2736

@@ -300,29 +309,39 @@ export function rosterFrom(source: {
300309

301310
/**
302311
* Default wording for the notice {@link InspectorSelectField} renders when its
303-
* roster failed to load. Raw English, like {@link defaultUnknownValueLabel}:
304-
* this module has no locale in scope (see the file header). Call sites pass
305-
* their own — the repo already has this exact copy localized, as the shared
306-
* picker-failure title objectui#5170 landed for the widget family.
312+
* roster failed to load. Raw English, like `placeholder`'s `'—'` default. A
313+
* call site that passes a `roster` passes its own `rosterFailureLabel` too —
314+
* the repo already has this exact copy localized, as the shared picker-failure
315+
* title objectui#5170 landed for the widget family.
307316
*/
308317
const defaultRosterFailureLabel = 'Options could not be loaded';
309318

310319
/**
311-
* Default wording for the row {@link InspectorSelectField} synthesises when the
312-
* stored value is not in the roster. Raw English, like `placeholder`'s `'—'`
313-
* default: this module takes raw strings and has no locale in scope (see the
314-
* file header). Call sites with a better word for their own domain pass
315-
* `unknownValueLabel` — that is the prop's whole reason to exist.
320+
* The label of the row {@link InspectorSelectField} synthesises for a stored
321+
* value its roster does not offer: the value, then a FLAG saying why it is not
322+
* offered (`t('engine.form.notFound', locale)`, `…notInObject`, `…deprecated`).
323+
*
324+
* The two are joined by the `engine.form.flaggedValue` template, not by a
325+
* template literal at the call site, because the order of the two and the gap
326+
* between them are the locale's to decide — zh sets no space before the
327+
* full-width bracket its flags open with (objectui#9652). Every call site that
328+
* words its own flag goes through here, and so does the primitive's default.
316329
*/
317-
const defaultUnknownValueLabel = (v: string) => `${v} (not found)`;
330+
export function flagUnknownValue(
331+
value: string,
332+
flag: string,
333+
locale: SupportedLocale | string | undefined,
334+
): string {
335+
return tFormat('engine.form.flaggedValue', locale, { value, flag });
336+
}
318337

319338
export function InspectorSelectField({
320339
label,
321340
value,
322341
options,
323342
onCommit,
324343
placeholder = '—',
325-
unknownValueLabel = defaultUnknownValueLabel,
344+
unknownValueLabel: unknownValueLabelProp,
326345
roster,
327346
rosterFailureLabel = defaultRosterFailureLabel,
328347
disabled,
@@ -334,7 +353,9 @@ export function InspectorSelectField({
334353
placeholder?: string;
335354
/**
336355
* Wording for the synthesised row that carries a stored value the roster does
337-
* not offer. Receives the raw stored value; defaults to `VALUE (not found)`.
356+
* not offer. Receives the raw stored value; defaults to the value flagged
357+
* `engine.form.notFound` in the designer's active locale — `VALUE (not found)`
358+
* in en-US. Build an override with {@link flagUnknownValue}.
338359
* Override it, never the RULE — the rule is the one this primitive owns.
339360
*/
340361
unknownValueLabel?: (value: string) => string;
@@ -360,7 +381,7 @@ export function InspectorSelectField({
360381
/**
361382
* Wording for the notice shown when `roster` reports a failure. The CAUSE is
362383
* rendered from the state's own message; this is the sentence in front of it.
363-
* Defaults to raw English, same contract as `unknownValueLabel`.
384+
* Defaults to raw English — pass `t('engine.form.optionsLoadFailedTitle', locale)`.
364385
*/
365386
rosterFailureLabel?: string;
366387
disabled?: boolean;
@@ -378,6 +399,14 @@ export function InspectorSelectField({
378399
// renders the real `button[role=combobox]`, which is a labelable element, so
379400
// one `for`/`id` pair names it (no second `aria-labelledby` channel needed).
380401
const id = React.useId();
402+
// objectui#9652 — the default flag used to be a raw English template literal,
403+
// so every call site that passes no `unknownValueLabel` showed a zh-CN author
404+
// `VALUE (not found)` on an otherwise Chinese inspector. It resolves through
405+
// the designer's own catalogue now, in the locale the designer is showing.
406+
const locale = useMetadataLocale();
407+
const unknownValueLabel =
408+
unknownValueLabelProp ??
409+
((v: string) => flagUnknownValue(v, t('engine.form.notFound', locale), locale));
381410
// `SelectValue`'s own `placeholder` is unreachable here, and was at all 45
382411
// call sites (objectui#8450). Radix shows it only when its value is `''` or
383412
// `undefined`, and the sentinel bridge above guarantees the value is never

0 commit comments

Comments
 (0)