Skip to content

feat(components): a type: flow metadata embed shows each decision's branches and their conditions - #36327

Merged
objectstack-fleet[bot] merged 5 commits into
mainfrom
claude/issue-36094-flow-embed-branches
Nov 22, 2026
Merged

objectstack-fleet[bot] merged 5 commits into
mainfrom
claude/issue-36094-flow-embed-branches

Conversation

@objectstack-fleet

@objectstack-fleet objectstack-fleet Bot commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Requested by Steedos · project thread
Fixes #36094

Clause-②: no
Metadata-protocol: none

维护者速读

  • 文档里嵌入的流程图(业务视图)现在在每个判断步骤下列出各分支:条件(如"金额 > 500,000",按读者语言和币种格式化)和去向步骤;流程的触发条件在步骤上方显示一次。
  • 为 HotCRM 销售手册服务:大额审批的金额门槛随管理员在 Studio 中的修改自动更新,手册不用再手抄金额。
  • 读不懂的复杂条件只显示中性的"条件"字样,不会显示原始表达式;出错只影响这张卡片的显示,撤回本 PR 即恢复原样。
  • 无。

What changes

  • ui/packages/components/src/renderers/basic/flow-branches.ts (new, pure): decisionBranches reads a decision's branches in both forms the engine runs (a config.conditions decision through its out-edge labels, default / isDefault as "otherwise"; a gateway decision through its out-edges' condition). readCondition is a small fail-closed reader: comparisons of one field of the flow's object with one literal, joined by && / ||, with parentheses. Presence guards on the compared field (has(x), x != null; !has(x), x == null under ||) are dropped, since the platform's null-guard rule puts one on every ordering comparison. Anything else answers null. A top-level conjunction with some unread terms reads as A and other conditions: each read term is necessary, the rest are named rather than dropped.
  • metadata-viewer.tsx FlowView, business view only: under each decision, its branches (condition or neutral marker, arrow, target step). The start node's condition is shown once above the steps (Runs when …). Field label and options come from the flow's object, useMetadataItem('object', start.config.objectName), which is one extra request per embed. That request lives in FlowConditions, which mounts once the flow is known, so the conditions never draw unread for a render. Amounts use the reader's locale (useDisplayLocale) and, for a currency field, resolveFieldCurrency(field, tenant currency). A whole threshold prints whole ($500,000). The technical view (detail: technical) is unchanged and makes no object request.
  • Six new element.metadataViewer.* strings in all eleven packs (condition, otherwise, conditionAnd, conditionOr, conditionMore, runsWhen).
  • The two label reads Doc metadata embed: a type: flow block draws its title and steps in the authored language — the viewer does not read the package's flows translations, and a decision or notify step has no key #35979 changes (flow.label, n.label) are untouched. A branch's target label reads target.label in Branches; whichever PR lands second routes it through Doc metadata embed: a type: flow block draws its title and steps in the authored language — the viewer does not read the package's flows translations, and a decision or notify step has no key #35979's resolver.
  • The reader's field shape is named FlowConditionField: @object-ui/plugin-list already exports a ConditionField interface, and one-authority-per-exported-name refuses a second declaration of one exported name (it went red in Test UI (10/16) at c3bc920; renamed in c8300e9).
  • Changeset: @object-ui/components and @object-ui/i18n patch.

Read first (riskiest first): flow-branches.ts isGuard and read (what is dropped as a guard, and when a partial reading is allowed), then FlowConditions in metadata-viewer.tsx (the loading gate).

Two-minute check: pnpm --dir ui exec vitest run packages/components/src/__tests__/metadata-viewer.test.tsx. Expect 15 passed, including the six flow branches (objectstack#36094) cases.

Tests

  • ui/packages/components/src/renderers/basic/__tests__/flow-branches-36094.test.ts: the reader (9 readable shapes, 17 refused shapes), both decision forms, the subject and entry-guard resolution.
  • metadata-viewer.test.tsx (the component's shared harness, one new top-level describe), on a hotcrm-shaped opportunity_approval served with { dialect: 'cel', source } envelopes: Amount > 500,000 beside the branch to Sales Director Sign-off and Amount ≤ 500,000 beside the other branch; a 750000 threshold in the served definition draws Amount > 750,000 and no 500,000; $500,000 under a USD tenant; a field-to-field condition draws the neutral marker and no raw CEL; the conditions wait for the object; the technical view draws no branch, no entry line and makes no object request.
Readings at head c8300e9 (the rename)
  • Test UI (10/16) at c3bc920 was red on ui/scripts/__tests__/one-authority-per-exported-name-6273.test.ts: "ConditionField — a NEW colliding name", flow-branches.ts:348 against plugin-list/src/conditions/conditionModel.ts:31. c8300e9 renames the reader's interface to FlowConditionField (3 files, 7 lines, no behaviour change), so no ablation.
  • Under the verify lock at c8300e9: that gate test plus flow-branches-36094.test.ts plus metadata-viewer.test.tsx gave Test Files 3 passed (3), Tests 57 passed (57), VERDICT command-exit 0.
  • pnpm --dir ui exec vitest run --maxWorkers=2 scripts/ (NOT MEASURED at c3bc920) gave Test Files 172 passed | 2 skipped (174), Tests 5122 passed | 2 skipped (5124), VERDICT command-exit 0.
  • pnpm --filter @object-ui/components run type-check exit 0, then pnpm check:type-check-debt exit 0 ("129/132 workspace packages type-checked ... 0 in the DEBT ledger").
  • CI on c8300e9: 45 success, 13 skipped, 0 failed (Test UI and Test UI (10/16) success).
Readings at head c3bc920
  • Green, at c3bc920, run without the lock and declared (the lock queue had not moved for over 40 minutes): pnpm --dir ui exec vitest run --maxWorkers=1 packages/components/src/renderers/basic/__tests__/flow-branches-36094.test.ts packages/components/src/__tests__/metadata-viewer.test.tsx gave Test Files 2 passed (2), Tests 46 passed (46).
  • Earlier, under the lock, at 29ee835: the two files plus packages/i18n/ (key-parity tests included) gave Test Files 107 passed (107), Tests 2007 passed | 13 skipped, VERDICT command-exit 0.
  • pnpm --filter @object-ui/components run type-check exit 0 and pnpm --filter @object-ui/i18n run type-check exit 0. --listFiles counts the new test file and the harness in the test program (2) and the new module in the source program (1).
  • Ablations, one per leg. Each mutation went through scripts/ablation-replace.mjs (anchor 1 to 0, blob moved) and was restored to the HEAD blob with git diff HEAD empty:
    • reader: readComparison returns null. 3 failed | 11 passed (14).
    • neutral marker: unreadable source drawn raw. 1 failed | 13 passed (14).
    • technical view: technical card wrapped in the condition scope. 1 failed | 13 passed (14).
    • loading gate: if (subject.loading) deleted. 3 failed | 12 passed (15) at c3bc920. The same mutation stayed green (14/14) at 29ee835, before the deterministic pin "waits for the flow's object" was added. That pin is why it exists.
  • i18n gates: node ui/scripts/check-i18n-call-site-keys.mjs exit 0, check-i18n-dead-keys.mjs exit 0, check-i18n-en-drift.mjs exit 0 ("No en value changed in this range").

Acceptance notes

  • Served shape, measured at the parse layer only. A hotcrm-shaped fixture through the spec's FlowSchema (spec source at this branch's base): edge and start condition come back as { dialect: 'cel', source } (a bare string normalizes to it), and config.conditions[].expression stays a bare string. The reader takes both spellings of EvaluatedExpressionInputSchema and no other. A live GET /api/v1/meta/flow/… read was NOT MEASURED: no server build was available in the container while the verify lock was saturated.
  • No CEL-to-text helper exists in a package @object-ui/components imports. app-shell's celToRows is a round-trip reader for the edge inspector's own spellings, and app-shell is off-limits to components. @objectstack/formula's parseCelToAst is a real parser, but components does not declare that dependency. Per the dispatch, this PR writes the smallest reader and fails closed. Moving it onto parseCelToAst would need a manifest edit and is noted here, not done.
  • Not read (neutral marker): previous.*, a field compared with a field, function calls, list membership, booleans, dates, percents, and a get_record variable reading another object (it would need a second object request). hotcrm's start condition reads Amount ≥ 100,000 and other conditions.
  • Branch targets that are technical steps (for example Mark Approved, an update_record) are named in the branch line even though the step list hides them.
  • An approval node's approve / reject out-edges are not drawn as branches. The card asks for decisions only.

Verification

Local subset from node scripts/pm/dispatch-gates.mjs --commands (41 families), re-run at c8300e9: 41 exit 0, including pnpm --dir ui exec vitest run scripts/ and pnpm check:type-check-debt (both NOT MEASURED at c3bc920). --ran reconciliation: "41 derived famil(ies) accounted for — 41 run, 0 NOT-MEASURED". node scripts/check-platform-checklist.mjs --changed-from origin/main exit 0 (0 anchored files). overlap-check at c8300e9: VERDICT overlap exit 1, conflicting only with #36335 (the sibling label-translation PR, routed to land after this one and merge main). The full farm is CI's: on c8300e9, 45 check-runs success, 13 skipped, 0 failed.


Generated by Claude Code

… and their conditions

The business view lists each decision's branches with the condition read
from the live definition (field label from the flow's object, amount in the
reader's locale and currency), or a neutral marker when the condition is
outside the reader's grammar. The entry condition is shown once above the
steps.

Claude-Session: https://claude.ai/code/session_01FEkQ5okniknzVVR3KTSVr1
Co-authored-by: Claude <noreply@anthropic.com>
… conditions never draw unread for a render

Claude-Session: https://claude.ai/code/session_01FEkQ5okniknzVVR3KTSVr1
Co-authored-by: Claude <noreply@anthropic.com>
…rawing a condition

Claude-Session: https://claude.ai/code/session_01FEkQ5okniknzVVR3KTSVr1
Co-authored-by: Claude <noreply@anthropic.com>
…d, so no exported name has two authorities

plugin-list already exports a ConditionField interface; one-authority-per-exported-name
counts the flow reader's interface as a second declaration of that name.

Claude-Session: https://claude.ai/code/session_01QsR2jV3scu6UYPb42n5okQ
Co-authored-by: Claude <noreply@anthropic.com>
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#7 · zhuangjianguo · session_01QsR2jV3scu6UYPb42n5okQ

Final head for L1 · area f7-shell · 2026-11-22T08:48Z
Head-sha: c8300e93a5a83184767664da7f45888b14710d05

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#7 · zhuangjianguo · session_01QsR2jS7jCv5PH4ytECQWqf

L1 ACCEPT · head c8300e93a5a83184767664da7f45888b14710d05 · 2026-11-22T08:57Z

维护者速读

席位核对

  • 形态:l1-face --pr 36327 CLEAN(13 项无标记);draft、base main、Fixes #36094,卡的两条完成标准都由用例钉住:一是嵌入 opportunity_approval 时显示金额超过 500,000 走总监签核;二是定义里的门槛改成 750000 后,显示 Amount > 750,000,500,000 不再出现。所以 Fixes 正确。16 个文件 +937 −4;check-governed-merges NOT governed,941 行。
  • 范围:只在 @object-ui/components(新增纯函数模块 flow-branches.ts + FlowView 业务视图)和 i18n 里各 6 个键。只读 flow.label 和 n.label,这两处翻译归 Doc metadata embed: a type: flow block draws its title and steps in the authored language — the viewer does not read the package's flows translations, and a decision or notify step has no key #35979,本 PR 没动,写明了先后顺序。
  • 读法核对:readCondition 失败即关。逐项核过:分词器认不得的字符一律返回 null;!(...)、in、函数调用(has 除外)、字段比字段、previous.*,都走中性标记;字面量在左时用 FLIP 把比较方向翻正;数字只格式化 number/currency 字段;字符串只认 select/radio 的选项标签,以及文本类字段的 ==/!=;顶层 && 里读不懂的项写成「及其他条件」,读不懂的部分不会被删掉。decisionBranches 两种决策写法都读,default/isDefault 读作「否则」。FlowConditions 在对象没读到之前显示 fallback;技术视图不发对象请求。
  • changeset 逐句核:相符。i18n:6 个键在 11 个包里都有。只有 fr 的 condition 和 en 同形,但它本就是法语正确的写法,不算漏译。
  • 测试证据:flow-branches-36094.test.ts 覆盖 9 种读得懂、17 种读不懂的写法;metadata-viewer.test.tsx 用 hotcrm 形状的流程跑了 6 条。四处消融(读法、中性标记、技术视图、加载闸)各自让对应用例变红;加载闸那一处,dev 发现原来的用例测不出来,补了一条确定性的钉后才变红,过程写在正文里。在本 head 上,门禁测试加两个文件共 57 条全过;dispatch-gates --ran 41 族全部跑完,无 NOT-MEASURED。在线 GET /api/v1/meta/flow/… 没实测,正文如实写明,只在 FlowSchema 解析层验证过送达形状。
  • 门禁 check-runs @ c8300e93:47 success · 15 expected skip · 0 failed · 0 pending;Lint & Repo Gates、TypeScript Type Check 均 success。
  • 接受的偏差(nit,不改本 head):① 在 || 里,x == null 和 !has(x) 被当成守卫丢掉。比如 record.amount == null || record.amount <= 500000 会显示成「金额 ≤ 500,000」,但金额为空的记录其实也走这一支,显示漏了这一种情况。dev 在正文里写明了这条规则;业务视图可以接受,但它是读法里唯一会让显示比实际窄的地方。② 文本字段的值固定用中文式弯引号 “…” 包起来,没有按读者语言换引号。③ 字段名读的是对象定义里的原始 label,没有翻译成读者的语言,和 Doc metadata embed: a type: flow block draws its title and steps in the authored language — the viewer does not read the package's flows translations, and a decision or notify step has no key #35979 是同一件事,随 Doc metadata embed: a type: flow block draws its title and steps in the authored language — the viewer does not read the package's flows translations, and a decision or notify step has no key #35979 处理。
  • 范围外去向:改用 @objectstack/formula 的 parseCelToAst 解析需要给 components 加依赖,dev 只记在正文里没有立卡,我照收:当前的小读法失败即关,已经够用。
  • 落地条款:非受管,941 行 ≤ 3000,无 L2 ⇒ 由区 ready + auto-merge;fix(components): the docs flow embed names the flow and its approval steps in the reader's language #36335 随后合并 main。

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#7 · zhuangjianguo · session_01QsR2jV3scu6UYPb42n5okQ

Landing · area f7-shell · 2026-11-22T14:13Z
Head-sha: 3ecf479d103f3cd81d2b856aa0f52ca07d3176a0

Probe Reading
L1 ACCEPT 7076845358 at c8300e9; 3ecf479 is a clean git merge origin/main on top (no conflicts), PR delta unchanged (16 files, +937 / −4), so the ACCEPT holds
Landing K 103 at c8300e9 (≥ 15) ⇒ main merged; 1 at 3ecf479
Checks at head 58 check-runs: 45 success, 13 skipped, 0 failed; mergeable_state clean
Governed check-governed-merges --pr 36327: NOT governed, 941 changed lines; Clause-② no, no L2 owed

State: ready + auto-merge into the merge queue. Fixes #36094 closes the card on merge. #36335 (Part of #35979) merges main after this lands, as routed.

@objectstack-fleet
objectstack-fleet Bot marked this pull request as ready for review November 22, 2026 14:13
@objectstack-fleet
objectstack-fleet Bot added this pull request to the merge queue Nov 22, 2026
Merged via the queue into main with commit e605773 Nov 22, 2026
59 checks passed
@objectstack-fleet
objectstack-fleet Bot deleted the claude/issue-36094-flow-embed-branches branch November 22, 2026 14:35
247257110 pushed a commit to 247257110/objectstack that referenced this pull request Nov 23, 2026
…steps in the reader's language (objectstack-ai#36335)

<!-- claude-projects-attribution: {"github_login":"zhuangjianguo"} -->
_Requested by **Steedos** · [project
thread](https://claude.ai/code/project/chan_018ETKaNwMZCNRYD7D8Q9Ubb?thread=cmsg_018ETKaNwMZCNRYD7D8Q9UbbUq2j5tRRVo3TVY3wcS1Fdg)_

Part of objectstack-ai#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 objectstack-ai#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 objectstack-ai#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 objectstack-ai#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, objectstack-ai#36316, already on main): objectstack-ai#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, objectstack-ai#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>
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/l tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface

Projects

None yet

1 participant