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 dda5e74
Browse filesBrowse the repository at this point in the historyBrowse files
fix(components): the docs flow embed names the flow and its approval steps in the reader's language (#36335)
<!-- claude-projects-attribution: {"github_login":"zhuangjianguo"} -->
_Requested by **Steedos** · [project
thread](https://claude.ai/code/project/chan_018ETKaNwMZCNRYD7D8Q9Ubb?thread=cmsg_018ETKaNwMZCNRYD7D8Q9UbbUq2j5tRRVo3TVY3wcS1Fdg)_
Part of #35979 (Asked item 1 only. Asked item 2, a translation key for
decision / notify / start / end node labels, was ruled option A on the
card and is built on its own claim and branch, not in this PR; the card
stays open for it)
repo:objectstack#7 · zhuangjianguo · session_01QsR2jV3scu6UYPb42n5okQ
Clause-②: yes (widening)
Metadata-protocol: none
## 维护者速读
-
用户能看到什么变化:非英文读者打开带流程嵌入的使用手册时,流程标题、审批步骤名,以及判断分支指向的审批步骤名,改用读者语言显示(例如「大额商机审批」「销售经理审核」);包里没有译文的地方仍显示原文。
- 为什么做:HotCRM 中文手册里的审批流程图标题和步骤全是英文,而包里已带中文译文;这是此前 Studio
流程设计器同类修复未覆盖的文档查看器。
-
出错会怎样:只影响显示,最坏情况是某个步骤仍显示原文;不改任何数据,可直接撤回。开始、判断、通知、结束这几类步骤的译文位置已裁定要补,由另一项单独完成,本次仍显示原文。
- 要你做什么:无。
## What changes
- **The docs viewer's flow embed reads the package's flow labels.**
`FlowView` in `element:metadata_viewer` now draws the flow title from
`flows.FLOW.label` and each `approval` step from
`flows.FLOW.approvals.NODE_ID.label`, in the reader's language, and
falls back to the authored label (then the name / node id) where the
bundle has no entry. Two label reads changed (`flow.label`, `n.label`),
through one hook call placed before the early returns.
- **Branch targets too.** Since #36327 landed, the business view lists
each decision's branches and names the step each branch leads to. That
name now takes the same translated step label (a `stepLabel` prop on
`Branches`), so an approval step reached from a decision is not named in
English beside its translated row.
- **The flow-label resolution moved to `@object-ui/i18n`.**
`ui/packages/i18n/src/flowLabels.ts` holds `flowLabelTranslations` and
`useFlowLabelTranslations`, moved from the Studio module because
`@object-ui/components` cannot import `@object-ui/app-shell`. It is
built on `activeFlowsBundle`, which #36316 already moved into
`@object-ui/i18n` (`flowsBundle.ts`); this PR adds no second copy of
that reader. The flow label still goes through the spec's
`translateFlow`; the step label is still read for `approval` nodes only.
The Studio module keeps its own parts (the Automations rail reader and
the canvas context) and re-exports the moved ones, so its call sites are
unchanged.
- **Which steps can be translated today.** The spec's `flows.FLOW` group
has a label key only for `approval` steps. A start, decision, notify or
end step keeps its authored label until the Asked item 2 work adds its
key.
- No spec change, no server change. `GET /meta/flow` is unchanged; the
embed reads the bundle the host already loads.
## Read first (by risk)
1. `ui/packages/components/src/renderers/basic/metadata-viewer.tsx`, the
`FlowView` and `Branches` hunks: the hook sits before the early returns,
beside the `business` flag from #36327.
2. `ui/packages/i18n/src/flowLabels.ts`: the moved resolver; compare
with the Studio original removed from `flow-label-translations.tsx`.
3.
`ui/packages/app-shell/src/views/metadata-admin/previews/flow-label-translations.tsx`:
what stays in Studio, and the re-export.
Two-minute check: `pnpm --dir ui exec vitest run
packages/components/src/__tests__/metadata-viewer.test.tsx`; expect 18
passed, including the three tests under "flow embed: package label
translations".
## Tests
<details><summary>Pins (one top-level describe in the existing viewer
harness)</summary>
`metadata-viewer.test.tsx`, describe "element:metadata_viewer flow
embed: package label translations (flows.FLOW.label,
approvals.STEP.label)", with a real `createI18n` instance loaded from a
zh-CN `TranslationData` through `transformSpecTranslations`, inside
`I18nProvider`:
- an `opportunity_approval`-shaped flow draws 大额商机审批, 销售经理审核 and 销售总监签批,
and none of the English approval labels; the start, decision, notify and
end steps keep their authored labels;
- a bundle entry without the flow label and without one step falls back
to the authored text; a bundle that translates only another flow leaves
everything authored;
- a decision branch whose target is an approval step names it 销售总监签批,
and the English label appears nowhere on the card.
The Studio pins in `FlowCanvas.test.tsx` exercise the moved resolver
unchanged.
</details>
<details><summary>Runs</summary>
- At 78faa00, under the verify lock: `vitest run` of
`metadata-viewer.test.tsx` and `FlowCanvas.test.tsx`: `Test Files 2
passed (2)`, `Tests 47 passed (47)`; then `pnpm --filter
@object-ui/components run type-check` (both tsc programs); `VERDICT
command-exit 0`.
- At 10f5352 (first main merge), under the lock: turbo build of the
`@object-ui/app-shell^...` and `@object-ui/components^...` closures (68
tasks successful), the same two files (`Tests 40 passed (40)`), and
`pnpm --filter @object-ui/i18n --filter @object-ui/components --filter
@object-ui/app-shell run type-check`: test exit 0, type-check exit 0.
- Ablation at 78faa00 through `scripts/ablation-replace.mjs
--delete`: anchor `(target && stepLabel?.(target)) ?? ` 1 to 0, blob
e061084 to 1bcbe5a1bdbb. Result: `Tests 1 failed | 17 passed (18)`,
the branch-target pin red. Restored: blob equals HEAD and `git diff
HEAD` is empty. A first attempt with `--replacement ''` was refused by
the tool before any test ran (it cannot count an empty replacement), so
it measured nothing. The test resolves the viewer through `src`, so no
dist preflight applies.
- Earlier ablation of the two label reads (seat 4, at 1ffd047): both
original pins red, restored clean.
</details>
## Acceptance notes
- **Merges.** This branch merged `origin/main` twice. First merge
(c261a7c, #36316, already on main): #36316 moved `activeFlowsBundle`
into `@object-ui/i18n` at the same path this branch had used. Resolution
kept main's `flowsBundle.ts` byte-for-byte, dropped this branch's
duplicate move, and kept `flowLabels.ts` and its export. `git grep` on
the merged tree: one `function activeFlowsBundle`
(`ui/packages/i18n/src/flowsBundle.ts`), no app-shell copy, no
`utils/flowsBundle` import left. Second merge (e605773, #36327): kept
its branches and entry-condition code and its tests, and added the two
label reads plus the branch-target label.
- **Measurement for Asked item 2 (built elsewhere).** hotcrm
`opportunity_approval` (hotcrm 01d3ec4): 13 nodes; 11 drawn at the
default business altitude; 2 have a key (`approval`), 9 do not: 1 start,
3 decision, 4 notify, 1 end.
- The embed's subtitle is the authored `flow.description`. The spec's
`flows` group has no description key, so it stays authored.
- No `content/docs` page documents the viewer (only its ADR, a governed
surface), so no docs page changed.
- Changeset: `@object-ui/components` and `@object-ui/i18n` patch.
`@object-ui/app-shell` is private and its behaviour is unchanged.
## Verification
<details><summary>Gates</summary>
- `node scripts/pm/dispatch-gates.mjs --commands --repo
objectstack-ai/objectstack` at 78faa00: 38 families, the same list as
at 10f5352. At 10f5352 all 37 non-vitest families exited 0, each
exit code captured before any pipe, and `pnpm --dir ui exec vitest run
scripts/` under the lock gave `Test Files 172 passed | 2 skipped (174)`,
`VERDICT command-exit 0`. The re-run at the final head is in the report
on the card.
- `node scripts/pm/overlap-check.mjs` at 5999753: `VERDICT clean exit
0` (origin/main e605773 merges cleanly, no open PR head overlaps).
- CI at 10f5352: all eleven required contexts success.
</details>
---
_Generated by [Claude
Code](https://claude.ai/code/session_01QsR2jV3scu6UYPb42n5okQ)_
<!-- signed: repo:objectstack#7 · zhuangjianguo ·
session_01QsR2jV3scu6UYPb42n5okQ -->
---------
Co-authored-by: Claude <noreply@anthropic.com>
fix(components): a docs `type: flow` metadata embed names the flow and its approval steps in the reader's language
7
+
8
+
Clause-②: yes (widening)
9
+
Metadata-protocol: none
10
+
11
+
A package can translate a flow's label (`flows.<flow>.label`) and an approval step's label (`flows.<flow>.approvals.<node_id>.label`). The flow runner and the Studio flow designer already showed both, but the docs viewer's `type: flow` embed (`element:metadata_viewer`) drew the authored text, so a zh-CN reader of a manual saw the English flow name and step names. The embed now reads the same bundle, through the same resolution, in the reader's language, and falls back to the authored text where the bundle carries no key. A decision's branch list names the approval step a branch leads to by the same translated label.
12
+
13
+
The spec has no key yet for a start, decision, notify or end node's label, so those steps still show the authored text.
14
+
15
+
`@object-ui/i18n` has new public exports for the flow-label resolution (`flowLabelTranslations`, `useFlowLabelTranslations` and the `FlowLabelTranslations` type), moved out of the Studio flow designer and built on the `activeFlowsBundle` reader that package already exports, so the runner, the designer and the docs viewer share one reader of the `flows` group.
0 commit comments