Repository navigation
fix(components): action:button renders no text for a non-string label instead of crashing the page - #37262
Conversation
… instead of crashing the page Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QSeKYmRepQK9DkZeU7F53D
Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QSeKYmRepQK9DkZeU7F53D
…erer hands down Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QSeKYmRepQK9DkZeU7F53D
|
repo:objectstack#4 · os-justin · session_01QSeKYmRepQK9DkZeU7F53D Final head for L1 · area a4-U · 2026-11-25T09:01Z
|
|
repo:objectstack#4 · os-justin · session_01QSeKYpEsWWE9Y5YtSsDgqZ 席位核对 — REWORK · L1 · head
|
Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QSeKYmRepQK9DkZeU7F53D
…'s own visible gate Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QSeKYmRepQK9DkZeU7F53D
|
repo:objectstack#4 · os-justin · session_01QSeKYmRepQK9DkZeU7F53D Final head for the delta read (rework round 1) · area a4-U · 2026-11-25T12:57Z Against REWORK 7157997155. Dev report: 7162989235.
Handed to the seat session for the delta read. |
|
repo:objectstack#4 · os-justin · session_01QSeKYpEsWWE9Y5YtSsDgqZ 席位核对 — ACCEPT · L1 · head
|
|
repo:objectstack#4 · os-justin · session_01QSeKYmRepQK9DkZeU7F53D Landing · area a4-U · 2026-11-25T13:29Z · head
The seat's optional N1 (a dev-console-only raw label read in State change: ready for review, and auto-merge is armed. The queue lands it. On MERGED, #36717 closes through |
…text for a non-string label instead of crashing (objectstack-ai#37323) Fixes objectstack-ai#37266 Clause-②: no Metadata-protocol: none ## 维护者速读 - 用户能看到什么变化:页面上的菜单、按钮组、图标按钮三种操作控件,名称若被写成多语言对象,以前菜单和按钮组会整块报错、图标按钮会崩溃或显示乱码;现在控件照常显示、照常可点,只是不显示那段名称(菜单仍叫“更多操作”,按钮组下拉仍叫“Actions”,图标按钮显示问号)。字符串名称和翻译与以前完全一样。 - 为什么做:沿用上一张卡给普通操作按钮加的同一层显示保护,补齐它的三个兄弟控件,属于“操作按钮名称必须是字符串”这一修复的收尾,按维护者「保持走翻译包」的裁决执行,不改协议、不翻译多语言对象。 - 出错会怎样:最坏是这三种控件上某个名称不显示,页面其余部分不受影响;改动可以直接撤回。 - 要你做的:无。 ## What changes `ui/packages/components/src/renderers/action/`: - New `renderable-label.ts`: the `renderableLabel` guard moved out of `action-button.tsx` unchanged in behaviour. It gains a `componentType` parameter (default `action:button`, so the button's warning text is byte-identical) and keys its warn-once memo on `componentType:componentKey`. `withRenderableLabel(subject, key, type)` returns the same object when the label is a string or absent, otherwise a copy with `label: undefined`. It is one guard, reused, not forked. - `action-button.tsx`: imports the guard; no other change. - `action-menu.tsx`, `action-group.tsx`, `action-icon.tsx`: each renderer guards its own `schema` once at entry (`withRenderableLabel`, keyed on the component id `data-obj-id`), and `action:menu` / `action:group` guard each member where `actions` is built (keyed on the member `name`, else `COMPONENT_ID#INDEX`). Every later read then sees a guarded label. The value is never translated (ruling A, 7118756694). - `static-params.ts`: the node-level-params warning names a nameless action through `renderableLabel` (scope note 7163349912). Ruling: option A on objectstack-ai#36717 (7118756694), inherited, verbatim: "The renderer must never throw on a non-string label: render no text (or the component id) and log a development warning; it must NOT translate the map (that would accept a value the contract refuses)." `packages/spec` is untouched. ### Every label read and its disposition The seat's re-check, `git grep -n "schema.label\|action.label" -- ui/packages/components/src/renderers/action/`, on `origin/main` d88c41e: 26 non-test hits. | File | Read | Disposition | |:--|:--|:--| | action-button.tsx | `renderableLabel(schema.label, …)`, `label === schema.label` | already guarded (PR objectstack-ai#37262); now imports the shared guard | | action-group.tsx | `useMemberVisible` diagnostic `action.label` | guarded: members built through `withRenderableLabel` | | action-group.tsx | inline leaf icon spacing `action.label && 'mr-2'` | guarded (member) | | action-group.tsx | inline leaf text `{action.label}` | guarded (member); renders no text | | action-group.tsx | dropdown leaf `action.label \|\| action.name` | guarded (member); shows `name` | | action-group.tsx | group `visible` diagnostic `schema.label` | guarded: group schema through `withRenderableLabel` | | action-group.tsx | runner `label: action.label` | guarded (member); runner gets none | | action-group.tsx | dropdown trigger `schema.label \|\| 'Actions'` | guarded (group); shows `Actions` | | action-icon.tsx | `visible` diagnostic `schema.label` | guarded: icon schema through `withRenderableLabel` | | action-icon.tsx | runner `label: schema.label` | guarded; runner gets none | | action-icon.tsx | `aria-label={schema.label \|\| schema.name}` | guarded; named by `name` | | action-icon.tsx | `schema.label?.charAt(0) \|\| '?'` | guarded; shows `?` (threw on main) | | action-icon.tsx | disabled-reason heading `schema.label \|\| schema.description` | guarded | | action-icon.tsx | tooltip gate and text `schema.label \|\| schema.description` (two hits) | guarded | | action-icon.tsx | `useAutoTriggerOnce(schema, …)`, `readStaticParamValues(schema, …)` (not grep hits) | read the guarded schema | | action-menu.tsx | `useMenuActionVisible` diagnostic `action.label` | guarded: members built through `withRenderableLabel` | | action-menu.tsx | item `action.label \|\| action.name` | guarded (member); shows `name` (threw on main) | | action-menu.tsx | menu `visible` diagnostic `schema.label` | guarded: menu schema through `withRenderableLabel` | | action-menu.tsx | runner `label: action.label` | guarded (member); runner gets none | | action-menu.tsx | trigger `aria-label={schema.label \|\| moreActionsLabel}` | guarded (menu); keeps `More actions` | | action-menu.tsx | trigger icon spacing and `{schema.label && ...}` (two hits) | guarded (menu); renders no text (threw on main) | | action-menu.tsx | `ActionAutoTrigger` → `useAutoTriggerOnce(action, …)` (not a grep hit) | reads the guarded member | | auto-trigger.ts | refusal notice and toast id `action.name ?? action.label`, `action.label \|\| action.name` (three hits) | not edited: it reads the subject its caller hands it, and all four callers now hand a guarded one | | static-params.ts | `String(subject.name ?? subject.label ?? '(unnamed)')` (not a grep hit) | guarded (scope note 7163349912) | ## Tests The pins live in the existing harness files, each as its own top-level `describe` naming objectstack#37266 (AGENTS.md, ruling record 6583487846). Each mounts the node through the real `SchemaRenderer` and `ActionProvider`: - `__tests__/action-group-menu-inputs-11168.test.tsx`, `describe('action:group — a non-string label renders no text and never throws (objectstack#37266)')`: inline (member button has no text and runs with no label, one warning) and dropdown (trigger shows `Actions`, member shows `approve`). CONTROL: string labels in both modes. - same file, `describe('action:menu — a non-string label renders no text and never throws (objectstack#37266)')`: a locale-map label on the menu and on a member. No throw, the trigger keeps `More actions` and has no text, the item shows `approve`, no `[object Object]` and neither locale string in the text, the runner gets no label, and there is one warning per component (menu and member). CONTROL: string labels render and reach the runner. - `__tests__/action-icon-autotrigger.test.tsx`, `describe('action:icon — a non-string label renders no text and never throws (objectstack#37266)')`: no `icon` (shows `?`, named `approve`, runs with no label, one warning), with `icon` (`aria-label` is `approve`), and a nameless action with node-level object `params` (the static-params warning names `(unnamed)` and no warning carries `[object Object]`). CONTROL: a string label is the initial, the accessible name and the runner label. Fitting the harnesses: the group and menu pins use that file's own `mount` (which adds `SchemaRendererProvider` and `PredicateScopeProvider` around the node), `openMenu` and `run`; their `console.warn` spy is set up inside each `describe`. The icon file drives `action:icon` as an `action:bar` member with an `api` handler, so the icon `describe` keeps its own `run` handler, `SchemaRenderer` mount, `console.warn` spy and static-params reset inside the `describe`. The file gained the imports for those. No assertion changed (50 `expect(` calls before and after). ## Acceptance notes - The menu and group pins assert text and accessible names, not `innerHTML`. Both renderers spread the host's undeclared node keys onto the DOM, so `actions="[object Object]"` is an attribute on any menu or inline group on main, and a raw `label` attribute rides along. That is an attribute leak, not a label read, and it is not user-visible text. It is out of this guard's reach and not filed. - A nameless action with a locale-map label and node-level object `params` now gets two development warnings: the non-string-label warning (keyed `(unnamed)` for that renderer type) and the existing params warning. Both are dev-only. - An `action:icon` with a non-string label and no `icon` shows `?`, the renderer's existing no-label fallback. - As on `action:button`, a numeric label is now dropped with the same warning; the contract (`z.string()`) already refuses it. ## Verification Two-minute check: `pnpm --dir ui exec vitest run packages/components/src/renderers/action/__tests__/action-group-menu-inputs-11168.test.tsx packages/components/src/renderers/action/__tests__/action-icon-autotrigger.test.tsx -t "objectstack#37266"`. Expected: 9 tests passed, the rest skipped. <details><summary>Ablation (shared guard reverted, head 97ac493)</summary> `node scripts/ablation-replace.mjs` replaced the guard's string check in `renderable-label.ts` (`if (label == null || typeof label === 'string') return label ?? undefined;`) with `return label as string | undefined;`, then ran the two harness files. The anchor went from 1 hit to 0 and the blob from 0e97935 to fa737ebae282. Result: 2 files failed, 6 tests failed and 37 passed. The 6 failures are the six non-CONTROL label pins; the 37 that passed are the three CONTROLs and every existing test in the two files. The menu test rendered the error boundary's `Retry` instead of the menu (the throw). Three icon tests failed with `TypeError: schema.label?.charAt is not a function`. The group tests failed on text content and the runner call. After the restore, the blob equals HEAD (0e97935) and `git diff HEAD` is empty. </details> <details><summary>Suites and gates (head 97ac493)</summary> - `pnpm --filter @object-ui/components type-check && pnpm --dir ui exec vitest run packages/components/src/renderers/action/`: type-check clean, 37 files and 628 tests passed (VERDICT command-exit 0). - After the pin move: `pnpm check:test-source-alias`, `pnpm check:cross-package-test-inputs` and `pnpm check:nul-bytes` each exited 0. - Round 1 (heads 49122c0 to 546ca7d): `dispatch-gates --commands` derived 38 families, all 38 were run and each exit code was captured before any pipe. `--ran` reconciliation gave 38 derived, 38 run, 0 NOT-MEASURED, and every recorded exit was 0. `pnpm check:type-check-debt` first exited 3, a prerequisite refusal whose cause the loop did not keep, and exited 0 on a standalone re-run. `pnpm --dir ui exec vitest run scripts/`: 172 files passed and 2 skipped; 5130 tests passed. - NOT MEASURED locally: the full `packages/components` suite and the CI-only lanes (Lint UI, Test UI shards, Build & E2E UI); CI runs them. </details> --- _Generated by [Claude Code](https://claude.ai/code/session_012MmDsSBHy5paNUz6zke9Re)_ 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_012MmDsSBHy5paNUz6zke9Re <!-- signed: repo:objectstack#6 · os-lizheng · session_012MmDsSBHy5paNUz6zke9Re --> --------- Co-authored-by: Claude <noreply@anthropic.com>
Fixes #36717
Clause-②: no
Metadata-protocol: none
维护者速读
What changes
ui/packages/components/src/renderers/action/action-button.tsx: every read ofschema.labelgoes through one guard,renderableLabel. A string label is returned unchanged. Any other value (an inline locale map from metadata that skippedvalidateComponentProps) becomes no label: the button renders with no text and still runs its action, nothing prints[object Object], and a development build logs oneconsole.warnper component, keyed on the component id, naming the bundle keypages.PAGE.components.COMPONENT_ID.label. The dev warning follows the existingprocess.env.NODE_ENV !== 'production'pattern inauto-trigger.ts. The value is never translated, so a value the contract refuses gets no meaning.The guard covers all five label reads in the file: the
visiblediagnostic label, thelabelforwarded to the runner (the param dialog's title), the icon spacing class, the rendered text, and the subject handed touseAutoTriggerOnce. That hook builds its user-facing refusal toast and toast id from the label, so it now gets the guarded label ({ ...schema, label }when they differ).Ruling: option A (7118756694), the maintainer's 「保持走翻译包」.
labelstaysz.string()andpackages/specis untouched.Responsibility:
@object-ui/componentsaction:buttonrenderer;validateComponentProps(for example code-registered pages) and carry a non-string label.Tests
A new top-level
describefor #36717 in the existing action-button harnessaction-button-icon-inputs-11168.test.tsx, which mounts the node through the realSchemaRendererandActionProvider:[object Object]and neither locale string, and a second mount of the same component does not warn again (exactly one warning, which names the component id);autoTriggerbutton gives a refusal toast whose message and id carry no[object Object](it names the action byname), and no console warning carries it either;translatePagethroughpages.billing.components.buy_credits.labelrenders购买额度.Acceptance notes
5) rendered as text before this PR. It is now dropped like any other non-string label, with the same dev warning. The contract (z.string()) already refuses it, so this follows ruling A.action:menu,action:groupandaction:iconalso render a non-string label raw, andaction:menuthrows on a locale map. The follow-up is action:menu / action:group / action:icon render a non-string label raw (action:menu throws on a locale map) #37266.name. A button with neither shares the fallback keyaction:button, so only the first such button warns.Verification
Two-minute check:
pnpm --dir ui exec vitest run packages/components/src/renderers/action/__tests__/action-button-icon-inputs-11168.test.tsx -t "non-string label". Expected: 5 passed.Ablation of the auto-trigger hand-off (head fce37f7)
node scripts/ablation-replace.mjsput backuseAutoTriggerOnce(schema, isVisible, handleClick)(anchor 1 to 0, blob 60bb1f196925 to 426c38142ef3). Result: 1 failed, 4 passed. The failure:expected '"[object Object]" is not available on…' not to contain '[object Object]'. After the restore, the blob equals HEAD (60bb1f196925) andgit diff HEADis empty.The first version of this pin (da40a35) mounted the node through
SchemaRenderer. Its node gate hides avisible: falsenode before the renderer mounts, so the hook never ran and the toast was never called; that failed the same way locally and in CI. It was a mounting error, not timing. The pin now mounts the registered renderer directly, which is the pathaction:bartakes.Ablation (guard reverted, head e8894fd)
node scripts/ablation-replace.mjsreplaced the guard's string check withreturn label as string | undefined;. The anchor went from 1 to 0 hits and the blob from 212e6892b2cc to 4aa3e1708bd4. Result: 2 failed, 2 passed. Both object-label tests threw "Objects are not valid as a React child (found: object with keys {en, zh-CN})", which is the defect as it is on main. Both controls stayed green. After the restore, the blob equals HEAD (212e6892b2cc) andgit diff HEADis empty.Suites and gates (round 1 head e13c940; round 2 head fce37f7 below)
Round 2 at fce37f7:
pnpm --filter @object-ui/components type-check && vitest run packages/components/src/renderers/action/gave 37 files and 619 tests passed (VERDICT command-exit 0). The harness file gave 60/60.pnpm --filter @object-ui/components type-checkpassed, chained with&&beforevitest run packages/components/src/renderers/action/(38 files, 626 tests passed). VERDICT command-exit 0.Full
packages/components/suite on e8894fd: 510 files passed, 1 skipped; 4970 tests passed. The only later code change is the warning key (dataObjId), and the action-renderer directory was re-run on the final head.dispatch-gates --commands: 38 families derived and run;--ranaccounted for all 38. 37 exited 0 on e13c940.vitest run scripts/had one 15 s timeout under box contention (js-comment-mask-returns-interpolation-9424). That file passed on re-run under the lock on the final head.NOT MEASURED locally: the CI type-check lanes the derivation lists as CI-only, the CI-measured-only families, and Test UI shards beyond
packages/components.Generated by Claude Code
🤖 Generated with Claude Code
https://claude.ai/code/session_01QSeKYmRepQK9DkZeU7F53D