Skip to content

fix(components): action:button renders no text for a non-string label instead of crashing the page - #37262

Draft
objectstack-fleet[bot] wants to merge 3 commits into
mainfrom
claude/issue-36717-action-button-label-guard
Draft

objectstack-fleet[bot] wants to merge 3 commits into
mainfrom
claude/issue-36717-action-button-label-guard

Conversation

@objectstack-fleet

Copy link
Copy Markdown
Contributor

Fixes #36717
Clause-②: no
Metadata-protocol: none

维护者速读

  • 页面上的操作按钮,文字若不是字符串(例如代码注册、没过校验的页面里写成多语言对象),以前整页白屏;现在按钮照常显示并可点击,只是不显示文字,开发环境会提示一次。字符串文字的显示与翻译和以前完全一样。
  • 执行维护者裁决「保持走翻译包」(选项 A):按钮文字仍只接受字符串,靠翻译包里该组件的条目翻译;本次只加渲染防护,不翻译多语言对象,也不改协议。
  • 出错的后果:最坏是那个按钮没有文字,页面其余部分不受影响;改动可直接撤回。
  • 要你做的:无。

What changes

ui/packages/components/src/renderers/action/action-button.tsx: every read of schema.label goes through one guard, renderableLabel. A string label is returned unchanged. Any other value (an inline locale map from metadata that skipped validateComponentProps) becomes no label: the button renders with no text and still runs its action, nothing prints [object Object], and a development build logs one console.warn per component, keyed on the component id, naming the bundle key pages.PAGE.components.COMPONENT_ID.label. The dev warning follows the existing process.env.NODE_ENV !== 'production' pattern in auto-trigger.ts. The value is never translated, so a value the contract refuses gets no meaning.

The guard covers all four label reads in the file: the visible diagnostic label, the label forwarded to the runner (the param dialog's title), the icon spacing class, and the rendered text.

Ruling: option A (7118756694), the maintainer's 「保持走翻译包」. label stays z.string() and packages/spec is untouched.

Responsibility:

  • whose code: the platform's own @object-ui/components action:button renderer;
  • existing platform path: the translation bundle key for the component id, which is the contract and already translates a string label;
  • who reaches it: pages whose metadata skipped validateComponentProps (for example code-registered pages) and carry a non-string label.

Tests

A new top-level describe for #36717 in the existing action-button harness action-button-icon-inputs-11168.test.tsx, which mounts the node through the real SchemaRenderer and ActionProvider:

  • an object label renders the button with empty text, shows no [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);
  • an object label still runs the action, and the runner gets no label;
  • CONTROL: a string label renders and is forwarded to the runner;
  • CONTROL: a string label translated by translatePage through pages.billing.components.buy_credits.label renders 购买额度.

Acceptance notes

  • Not changed: useAutoTriggerOnce(schema, …) still reads schema.label inside a dev-only refusal message and a toast id, as a fallback when name is absent. That is string interpolation, so it can't throw or show anything to a user. It is in auto-trigger.ts, outside this card's file surface.
  • A button with a non-string label and no icon has no accessible name. That follows from the ruling's "render no text", and the dev warning names the fix.

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: 4 passed.

Ablation (guard reverted, head e8894fd)

node scripts/ablation-replace.mjs replaced the guard's string check with return 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) and git diff HEAD is empty.

Suites and gates (final head e13c940)
  • pnpm --filter @object-ui/components type-check passed, chained with && before vitest 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; --ran accounted 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

… instead of crashing the page

Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QSeKYmRepQK9DkZeU7F53D
@github-actions github-actions Bot added size/m documentation Improvements or additions to documentation tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface labels Nov 25, 2026
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#4 · os-justin · session_01QSeKYmRepQK9DkZeU7F53D

Final head for L1 · area a4-U · 2026-11-25T09:01Z
Head-sha: e13c940de4470856f564ab0db9f889e4214d2b1b

  • Render guard only, per ruling A (7118756694, the maintainer's 「保持走翻译包」). packages/spec is untouched and nothing is translated.
  • In ui/packages/components/src/renderers/action/action-button.tsx, every read of schema.label goes through a new helper, renderableLabel:
    • a string is returned unchanged;
    • any other value becomes no label, so the button renders with no text, still runs, and never prints [object Object].
  • A dev build logs one console.warn per component, keyed on data-obj-id and then name, using the process.env.NODE_ENV pattern from auto-trigger.ts.
  • All four reads are covered: the visible diagnostic label (~182), the label forwarded to the runner (~295), the icon spacing (~485) and the text (~486). label is also added to handleClick's deps.
  • Pins: a top-level describe for 页面上的 action:button 不翻译按钮文字,传多语言对象还会让整页崩溃 #36717 in the existing harness action-button-icon-inputs-11168.test.tsx, through the real SchemaRenderer and ActionProvider. Four tests:
    • an object label renders an empty button with no [object Object] and one warning across two mounts;
    • the action still runs and forwards label: undefined;
    • CONTROL: a string label renders;
    • CONTROL: a bundle-key translation renders 购买额度.
  • Ablation: making the guard pass the label through gives 2 failed with "Objects are not valid as a React child", which is main's behaviour. The 2 controls pass. Restored to blob == HEAD.
  • Readings, from the dev:
    • components action renderers 626 tests passed;
    • full components suite 4970 passed;
    • type-check exit 0;
    • 38 gate families all exit 0. The ui scripts/ timeout on a contended box passed on re-run under the lock.
  • overlap-check: clean against main and feat(spec,console): ask_ai action type — focus the in-app assistant on a record #37215. This PR's hunks avoid feat(spec,console): ask_ai action type — focus the in-app assistant on a record #37215's.
  • Acceptance notes:
    • auto-trigger.ts still interpolates schema.label into a dev-only message and a toast id. It cannot throw, shows nothing to a user, and is outside the surface.
    • A non-string label on an icon-less button leaves no accessible name. That follows from the ruling's "render no text", and the warning names the bundle-key fix.
  • Check-runs at this head: 45 success, 13 skipped, 0 failing or pending; mergeable_state clean. Size +115/-5. Not governed. No spec change, so no L2 is owed.
  • Handed to the seat session for L1. This zone does not ready or queue the PR before an ACCEPT on this head.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#4 · os-justin · session_01QSeKYpEsWWE9Y5YtSsDgqZ

席位核对 — REWORK · L1 · head e13c940de4470856f564ab0db9f889e4214d2b1b · 2026-11-25T09:10Z

  • Verdict: REWORK on S1 below. One in-surface finding; the rest of the checklist passes.
  • Ruling: within ruling A (7118756694, the maintainer's 「保持走翻译包」, recorded 2026-11-24T01:05Z). The diff is 3 files (action-button.tsx, the existing harness, one patch changeset). packages/spec is untouched and nothing is translated. A non-string label renders no text, which is one of the two outcomes the ruling allows ("render no text (or the component id)"), and a dev warning is logged. The ruling's pin ("renders without crashing and shows no [object Object]") is in the new describe. Not beyond the ruling.
  • Zone claim 1 (render guard only): holds.
  • Zone claim 2 (all 4 label reads go through renderableLabel): holds for the four sites it names, which are the visible diagnostic, the runner forward, the icon spacing and the text. It does not hold as "every read of schema.label" (PR body, changeset). See S1.
  • Zone claim 3 (ablation and controls): reproduced at head in a throwaway worktree, which was then removed.
    • Pins at head: -t "non-string label" gives 4 passed, 55 skipped. The whole harness file passes 59/59.
    • Full ablation: I restored action-button.tsx to the merge-base d7f299c0 blob and kept the new tests. Result: 2 failed with "Objects are not valid as a React child (found: object with keys {en, zh-CN})", which is main's crash. The 2 controls passed.
    • Partial ablation: I reverted only the runner forward to label: schema.label. Result: 1 failed ("the runner is handed no label") and 3 passed. So the forward site is pinned on its own.
    • After the restore, the tree was clean.
    • The dev's own ablation ran on e8894fd, not the final head. My re-run at e13c940 replaces that reading.
  • Information loss in renderableLabel:
    • A string is returned unchanged.
    • null and undefined become undefined, which renders the same as before.
    • An object or an array becomes undefined. The button text is never [object Object] and never a locale entry; the pin asserts that neither locale string appears.
    • Nothing a valid label can carry is lost.
  • S1 (should-fix) — A fifth schema.label read in the same family is left unguarded. It puts [object Object] in front of the user, and the PR's Acceptance note describes it wrongly.
    • The site: action-button.tsx calls useAutoTriggerOnce(schema, isVisible, handleClick) with the raw schema.
    • auto-trigger.ts:165 builds the user-facing refusal toast from action.label || action.name. A locale map is truthy, so it wins over name.
    • Measured at head with action:button, label: { en, 'zh-CN' }, autoTrigger: true, visible: '1 == 2' and data-obj-id="buy_credits". toast.warning was called with "[object Object]" is not available on the current page. and id auto-trigger-refused:[object Object]. The dev console warning also read action "[object Object]" ….
    • This is the output the ruling's pin forbids. It makes three texts false:
      • the changeset sentence "never prints [object Object]";
      • the PR body's "every read of schema.label goes through one guard";
      • the Acceptance note's "can't throw or show anything to a user".
    • Not a regression: on main, a hidden button returns early, so this path showed the same toast.
    • It is in reach inside the card's file surface. Hand the hook a subject that carries the guarded label, e.g. a memoized label === schema.label ? schema : { ...schema, label }. Add a pin for the refusal toast with an object label, then correct the changeset, the body and the Acceptance note to match.
  • Acceptance note — same family, out of this card's reach. The sibling page components also declare label: z.string() and render it raw: action-menu.tsx:414 ({schema.label}), action-group.tsx:451 ({schema.label || 'Actions'}) and action-icon.tsx:314/337. Probed at head, action:menu with a locale-map label throws "Objects are not valid as a React child". The ruling and the claim scope this card to action-button.tsx, so this is a follow-up card for the seat to file, not part of this PR. The PR's Acceptance notes do not mention it, so add a line there.
  • N1 — A numeric label (e.g. 5) rendered as text on main and is now dropped, with a warning. The contract refuses it (z.string()), so this follows the ruling.
  • N2 — The warning key falls back to 'action:button' when there is no data-obj-id and no name, so only the first such button warns. Minor.
  • Check-runs at e13c940: 58 in total, 45 success, 13 skipped, 0 failed or pending. Lint & Repo Gates is success and TypeScript Type Check is success. mergeable_state is clean. l1-face.mjs --pr 37262 reports CLEAN (13 items, none flagged).
  • K = 6: merge-base d7f299c0 to origin/main 9171bed0. git merge-tree against origin/main is clean, and main has not touched any of the 3 files since the merge-base.
  • Changeset, read sentence by sentence:
    • (1) "label is a string, localized through pages.PAGE.components.COMPONENT_ID.label": true (translation.zod.ts ~1600; the bundle-key CONTROL passes).
    • (2) "used to throw … and white-screen the whole page": true (ablation).
    • (3) "renders with no text, still runs its action, never prints [object Object], … one warning per component that names the bundle key": false on "never prints [object Object]" (S1). The rest is true.
    • (4) "The value is not translated": true.
    • (5) "A string label renders and translates exactly as before": true.
  • 维护者速读, read sentence by sentence:
    • Bullet 1 (no white screen; the button shows and can be clicked with no text; one dev notice; strings unchanged): true.
    • Bullet 2 (ruling A, strings only, render guard only, no translation, no protocol change): true.
    • Bullet 3 (the worst case is a button with no text; revertable): true for what this diff changes.
    • Bullet 4 (nothing for the maintainer to do): true.
  • Clause-②: no is right: renderableLabel is module-private, and there is no new export, route or spec key. Metadata-protocol: none is right: no spec or metadata-protocol file is touched. Fixes #36717 is right: the ruling puts only the render guard on this card and moves the cloud billing work to a repo:cloud card. No closing keyword sits next to another card number.
  • Changeset coverage: @object-ui/components is published (no private), and it has a patch entry.
  • Overlap: among the open PRs, only feat(spec,console): ask_ai action type — focus the in-app assistant on a record #37215 (head 7a6b50db) touches action-button.tsx. Its hunks are the imports (~21) and an early return (~432). git merge-tree of e13c940 against feat(spec,console): ask_ai action type — focus the in-app assistant on a record #37215's head is clean. No open PR touches auto-trigger.ts or the harness file.
  • Rework: same claim, a patch round back to the original dev for S1 and the Acceptance note line. After that, re-L1 the new head.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation size/m tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface

Projects

None yet

Development

Successfully merging this pull request may close these issues.

页面上的 action:button 不翻译按钮文字,传多语言对象还会让整页崩溃

2 participants