You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit e8cba8f
Browse filesBrowse the repository at this point in the historyBrowse files
fix(console): the public form prints a form entry's own label, not the app bundle's object-field translation (#34390)
<!-- claude-projects-attribution: {"github_login":"os-steve"} -->
_Requested by **Steve** · [project
thread](https://claude.ai/code/project/chan_01FdL1XeUyvVNxLreh3F4Qi9?thread=cmsg_01FdL1XeUyvVNxLreh3F4Qi9BtJbyfcjefHVT9XXSMDFVR)_Fixes#34375
Clause-②: no
Metadata-protocol: none
## 维护者速读
- **改了什么**:公开表单页(console `FormPage`)里,表单项自己声明了 `label`
的行,直接显示表单接口返回的标签(已按访客语言本地化);只有标签来自对象字段的行,才继续用应用翻译包的 `fields.对象.字段`
覆盖。必填提示和 `visibleWhen` 故障提示按同一规则点名字段。
- **为什么改**:浏览器里只要加载了应用翻译包(比如访客在同一 console
已登录),对象字段的坐席侧译名就会盖掉表单项的访客侧标签。HotCRM
公开支持表单因此显示「提交人姓名」而不是「您的姓名」,冷启动的匿名访问却显示正确,同一版本两种结果。
- **风险与回滚**:只改 console
一个组件的标签取值;行在构建时记下标签来源(`labelSource`),不比较字符串。没有表单项标签的行行为不变。无服务端、契约或
`@object-ui/i18n` 改动。回滚即 revert 本 PR。
- **先看**:`ui/apps/console/src/components/FormPage.tsx` 的
`rowLabel`(组件内)与 `buildSections` 里新增的 `labelSource` 一行;其次
`FormPage.sectionLabelI18n.test.tsx` 末尾新增的一组测试。
- **两分钟验证**:`pnpm --dir ui exec vitest run
apps/console/src/components/FormPage.sectionLabelI18n.test.tsx`,预期 9
个测试全过(其中 3 个为本卡新增)。
- **需要你做的**:无,席位落地。
## What changes
- **The row records where its label came from.** `RenderableField` gains
`labelSource: 'entry' | 'object'`, set in `buildSections` from the same
`??` that picks the label: `'entry'` when the form entry declared its
own `label`, `'object'` when the row fell back to the object field's
label (or its name). Nothing compares strings.
- **One naming rule for the row.** A component-local `rowLabel(object,
f)` prints an `'entry'` label as served (the form endpoint already
localized it from `_sections.SECTION.fields.FIELD.label`) and keeps
`fieldLabel(object, f.name, f.label)`, the bundle overlay with the
served label as fallback, for an `'object'` row. It replaces all four
call sites: the row label on screen, the `visibleWhen`-fault banner, the
required banner/toast and the per-row required message. So a refusal
names a field by the label the visitor sees.
- **`fieldLabel` in `@object-ui/i18n` is unchanged.** Every other
surface keeps bundle-first resolution for object fields.
## Why
The form endpoint serves the entry label correctly. The page then looked
up `fields.OBJECT.FIELD` first, which translates the object field's
agent-side label, and printed it whenever the browser held the app
bundle. A signed-in visitor (or any visit with the bundle loaded) read
the agent-side label; a cold anonymous visit (no bundle, see
`FormPage.signedOutSectionI18n-12333.test.tsx`) read the entry label.
## Tests
New top-level `describe` in the existing public-form i18n harness
`FormPage.sectionLabelI18n.test.tsx` (the file that already seeds an app
bundle on the unwrapped `/f/:slug` route). The fixture's bundle
translates both object fields (`supplied_name` → 提交人姓名, `supplied_email`
→ 提交人邮箱); the form entry for `supplied_name` declares `label: 您的姓名`, the
entry for `supplied_email` declares none. Every leg asserts both
strings.
- (a) `ENTRY_LABEL_RENDERS_AS_SERVED`: the row reads 您的姓名, 提交人姓名 is
nowhere on the page, and the input is named by 您的姓名.
- (b) `REQUIRED_REFUSAL_NAMES_THE_VISIBLE_LABELS`: an empty submit's
toast/banner message contains 您的姓名 and 提交人邮箱, not 提交人姓名; the per-row
message the name input points at (`aria-describedby`) names 您的姓名.
- (c) CONTROL `OBJECT_LABEL_TAKES_THE_BUNDLE`: the row with no entry
label reads 提交人邮箱, not the object's authored "Submitter email".
The `visibleWhen`-fault message goes through the same `rowLabel` call;
it has no new pin of its own (the card asked for (a)–(c)).
**Forced test edits** (type only, no assertion changed):
`RenderableField.labelSource` is required, so the hand-built row
fixtures gain `labelSource: 'object'`: `FormPage.test.ts` (the
`readPrefill` fields and the `remind_at` row),
`FormPage.omitBlanksRebind.test.ts` (`row()`),
`FormPage.optionDefault-13049.test.tsx` (the `priority` row). Without it
`@object-ui/console` `type-check` reds (28 TS errors measured before the
edit).
## Acceptance notes
- The internal in-app form route (`?form=ID`) renders through the same
`buildSections` and the same `rowLabel`, so it follows the same rule.
Whether that route's form view arrives with its entry labels already
localized was not measured here; an entry label that is a plain string
is printed as authored there, as it was whenever the bundle missed.
- An entry whose `label` happens to equal the object field's label is
still an entry label and is printed as served (no string comparison, by
the card's instruction).
## Verification
Readings taken on head `f29f7093` (base `6cc3f974`).
<details><summary>Ablations (each leg via scripts/ablation-replace.mjs,
restored blob == HEAD, git diff HEAD empty)</summary>
- A1 `rowLabel` ignores provenance (`/* ablated */ fieldLabel(object,
f.name, f.label)`): (a) and (b) red, (c) green. `expected '提交人姓名' to be
'您的姓名'`; `expected '必填项:提交人姓名、提交人邮箱' to contain '您的姓名'`. 2 failed, 7
passed.
- A2 `buildSections` always `labelSource: 'object'`: the same two legs
red with the same messages. 2 failed, 7 passed.
- A3 no overlay at all (`/* ablated */ f.label`): (c) red (`expected
'Submitter email' to be '提交人邮箱'`), (b) red on its 提交人邮箱 half, and the
existing `FIELD_LABEL_IS_TRANSLATED` red. 3 failed, 6 passed.
The console test imports `FormPage` from source, so no dist rebuild sits
between mutation and run.
</details>
<details><summary>Local runs</summary>
- `pnpm --dir ui exec vitest run
apps/console/src/components/FormPage.sectionLabelI18n.test.tsx`: 9/9.
- Every console test file that names `FormPage` or `buildSections` (62
files): `Test Files 62 passed (62)`, `Tests 557 passed (557)`.
- `pnpm --filter @object-ui/console run type-check`: exit 0.
- `pnpm exec eslint` on the five touched files: 0 errors; warning counts
equal to base for `FormPage.tsx` (26) and `FormPage.test.ts` (2).
- `pnpm --dir ui check:new-line-citations`: 0 new citations.
- `node scripts/pm/dispatch-gates.mjs --commands --repo
objectstack-ai/objectstack`: 37 commands, each run on the final head,
all exit 0 (list in the os-dev-report on the card).
</details>
## Human Minimum
- [x] 1. Schemas start as Zod; `packages/spec` holds no runtime logic.
- [x] 2. Every name I added uses the casing for its kind.
- [x] 3. No formatter ran; `pnpm lint` passes.
- [x] 4. One issue, one branch off an up-to-date `main`, one pull
request.
- [x] 5. A change that publishes carries a changeset, and both
declaration lines are filled in here and in the changeset.
- [x] 6. `packages/spec` touched: its generated artifacts are
regenerated and committed. (Not touched.)
- [x] 7. No hand edits to `content/docs/references/`,
`packages/*/CHANGELOG.md` or `content/docs/releases/`.
- [x] 8. Title, body and comments are in English.
- [x] The *Before Submitting* list in CONTRIBUTING.md is done.
---
_Generated by [Claude
Code](https://claude.ai/code/session_01ADHkmTMdcLKvrzHvpYZ3gn)_
---------
Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: objectstack-fleet[bot] <332303061+objectstack-fleet[bot]@users.noreply.github.com>
fix(console): the public form prints a form entry's own label as served, not the app bundle's object-field translation
6
+
7
+
Clause-②: no
8
+
Metadata-protocol: none
9
+
10
+
A form entry that declares its own `label` is the form's visitor-facing copy, and the form endpoint already serves it localized (from `_sections.SECTION.fields.FIELD.label` in the app's translations). The public form page then looked the field up in the app bundle as `fields.OBJECT.FIELD` first and printed that whenever the browser held the bundle, which translates the object field's label, the one agents see. So a visitor who was signed in to the same console, or any visit with the bundle loaded, read the agent-side label (for example "Submitter name" where the form says "Your name"), while a cold anonymous visit read the form's own label.
11
+
12
+
Each row now records where its label came from. A row whose entry declared a `label` prints it as served; only a row whose label came from the object field takes the bundle translation, as before. The required-field and `visibleWhen` refusal messages name each field by the same rule, so they use the label the visitor sees.
0 commit comments