From 372dde4606c4ebac7543f1467f2e25d3d1bbcb1e Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 22 Nov 2026 08:27:32 +0000 Subject: [PATCH 01/10] feat(spec): a flow node's display label gets a translation key under flows.FLOW.nodes Co-authored-by: Claude Claude-Session: https://claude.ai/code/session_01QsR2jTrJZvNaijgX3NxBMc --- packages/spec/src/automation/flow-altitude.ts | 42 +++++++++++++ packages/spec/src/automation/index.ts | 3 + .../src/system/flows-translation-face.test.ts | 9 ++- packages/spec/src/system/translation.zod.ts | 61 ++++++++++++++++++- 4 files changed, 111 insertions(+), 4 deletions(-) create mode 100644 packages/spec/src/automation/flow-altitude.ts diff --git a/packages/spec/src/automation/flow-altitude.ts b/packages/spec/src/automation/flow-altitude.ts new file mode 100644 index 00000000000..cc20906ad2b --- /dev/null +++ b/packages/spec/src/automation/flow-altitude.ts @@ -0,0 +1,42 @@ +// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license. + +/** + * @module automation/flow-altitude + * + * **The flow-node types a business-altitude drawing folds away** (ADR-0051 + * §3.4, the `detail: business` projection of a `type: flow` metadata embed). + * + * A drawing at business altitude shows a reader the process, not the + * plumbing: the infrastructure steps below are counted and hidden, every other + * node is drawn by its label. `detail: technical` draws them all. + * + * ONE table, two readers, so they cannot drift: + * + * - the docs viewer's `FlowView` (`element:metadata_viewer`), which decides + * which steps a manual's reader sees; + * - the i18n walk (`packages/lint`, `i18n/missing-flow`), which demands a + * translated label, `flows..nodes..label`, for exactly the + * steps that viewer draws at its default altitude (ruling 7076440876). + * + * Display only: nothing here changes how a flow runs. + */ + +/** The node types `detail: business` hides. Every other node type is a business step. */ +export const FLOW_TECHNICAL_NODE_TYPES = Object.freeze([ + 'script', + 'http', + 'connector_action', + 'assignment', + 'get_record', + 'create_record', + 'update_record', + 'delete_record', + 'boundary_event', +] as const); + +const TECHNICAL = new Set(FLOW_TECHNICAL_NODE_TYPES); + +/** True when a node of `type` is folded away at business altitude. */ +export function isFlowTechnicalNodeType(type: unknown): boolean { + return typeof type === 'string' && TECHNICAL.has(type); +} diff --git a/packages/spec/src/automation/index.ts b/packages/spec/src/automation/index.ts index d4033e6e477..aa8b9fdf4ea 100644 --- a/packages/spec/src/automation/index.ts +++ b/packages/spec/src/automation/index.ts @@ -6,6 +6,9 @@ export * from './flow.zod'; // registration refusal reads the same table the flow parse refuses with. export { FLOW_RESERVED_NODE_TYPES, reservedFlowNodeTypeRefusal } from './flow-reserved-node-types'; export * from './region-slots'; +// [ADR-0051 §3.4] The node types a business-altitude flow drawing folds away, +// read by the docs viewer and by the i18n walk that demands the drawn labels. +export { FLOW_TECHNICAL_NODE_TYPES, isFlowTechnicalNodeType } from './flow-altitude'; export * from './control-flow.zod'; export * from './io-node-config.zod'; export * from './builtin-node-config.zod'; diff --git a/packages/spec/src/system/flows-translation-face.test.ts b/packages/spec/src/system/flows-translation-face.test.ts index 1c48f0d56f1..39d5c6dfaa8 100644 --- a/packages/spec/src/system/flows-translation-face.test.ts +++ b/packages/spec/src/system/flows-translation-face.test.ts @@ -131,14 +131,17 @@ const RUNNER_SLOTS: Readonly> = { ), // FlowNodeSchema (its `config` is judged per type below) - 'node.id': noReader('the node id — the address of `screens.`, `refusals.` and `approvals.`'), + 'node.id': noReader( + 'the node id — the address of `screens.`, `refusals.`, `approvals.` and `nodes.`', + ), 'node.type': noReader('a node-type token'), 'node.label': keyed( 'screens.NODE.title', "a screen's fallback heading (`config.title ?? node.label`), which the one `title` key covers; an `approval` " + "node's step name, which the approval request it opens shows its submitter and approvers " - + '(`approvals.NODE.label`); on any other node it is designer-canvas text', - ['approvals.NODE.label'], + + '(`approvals.NODE.label`); on any other node the step name a drawing of the flow shows — the docs ' + + "viewer's `type: flow` embed and the Studio canvas (`nodes.NODE.label`, ruling 7076440876)", + ['approvals.NODE.label', 'nodes.NODE.label'], ), 'node.connectorConfig': noReader('connector and action ids, and input values the engine resolves'), 'node.inputSchema': noReader("design-time parameter declarations for the designer's input mapping"), diff --git a/packages/spec/src/system/translation.zod.ts b/packages/spec/src/system/translation.zod.ts index 02e25507a60..315636759d9 100644 --- a/packages/spec/src/system/translation.zod.ts +++ b/packages/spec/src/system/translation.zod.ts @@ -1788,6 +1788,7 @@ const appTranslationDataShape = () => ({ * flows..screens..fields..options. (#22507) * flows..refusals..message (a refused `end` node, #22450) * flows..approvals..label (an `approval` node's step label) + * flows..nodes..label (any other node's display label, ruling 7076440876) * flows..records..fields. (text a record write keeps) * * Every user-read string slot of the flow schemas is either one of these @@ -1913,6 +1914,35 @@ const appTranslationDataShape = () => ({ * spec half of a contract-first split: the reader that renders the step * label in the reader's locale is `plugin-approvals`'s, a downstream change. * + * ## `nodes` — any other node's display label (ruling 7076440876) + * + * flows..nodes..label + * + * A drawing of the flow names each step by its node's `label` + * (`FlowNode.label`): the docs viewer's `type: flow` embed + * (`element:metadata_viewer`, ADR-0051) lists them for a manual's reader, and + * the Studio designer draws them on its canvas. Until this key a decision, a + * notify, a start or an end step had nowhere to put a translation, so a + * manual read in a translated locale named its steps in the authored + * language (the maintainer ruled them translatable on objectstack#35979, + * option A: 「补上翻译位,可以翻译」). + * + * - **Grouped by what it overlays, not by node type.** Every other group + * addresses one node type; this one addresses the node label of every + * node whose label has no key of its own, at any depth (an ADR-0031 region + * included). That excludes two types, each keyed already, so one string + * keeps one key: a `screen` (its `screens..title` covers + * `config.title ?? node.label`) and an `approval` (`approvals..label`). + * `objectstack validate` points a `nodes` key over either at that key. + * - **Start and end nodes included.** Their labels are the author's words + * like any other step's, and often name an outcome or a trigger + * ("Approved", "On Task Created"), so a viewer does not substitute words of + * its own for them. + * - **Plain text, not a template.** `FlowNode.label` is drawn as authored and + * never rendered over a run's variables, so the leaf is a plain string. + * - **Display only.** A reader overlays the label it draws; the flow + * document, the run and the `{{ }}` copy the engine renders are untouched. + * * ## `notices` — a `save_notice` node's message (#28251) * * flows..notices..message @@ -2035,7 +2065,8 @@ const appTranslationDataShape = () => ({ surface: 'this flow translation', history: TRANSLATION_HISTORY, aliases: { - name: 'label', title: 'label', nodes: 'screens', steps: 'screens', screen: 'screens', pages: 'screens', + name: 'label', title: 'label', steps: 'screens', screen: 'screens', pages: 'screens', + node: 'nodes', refusal: 'refusals', ends: 'refusals', approval: 'approvals', notice: 'notices', saveNotices: 'notices', @@ -2149,6 +2180,34 @@ const appTranslationDataShape = () => ({ + 'request shows its submitter and approvers', ), })).optional().describe("Approval-step translations keyed by the node id (`FlowNode.id`) of an `approval` node"), + // [ruling 7076440876] Any other node's display label, the step name a + // drawing of the flow shows (the docs viewer's `type: flow` embed and the + // Studio designer). Grouped by what it overlays, `FlowNode.label`, not by + // node type: a screen's heading and an approval step's label already have + // their own keys, so `objectstack validate` points a key over either at it. + nodes: z.record(z.string(), strictObject({ + surface: 'this flow node translation', + history: TRANSLATION_HISTORY, + // The leaf is the node's own `label`; the spellings a neighbouring group + // uses for the same string are renames onto it. + aliases: { title: 'label', name: 'label', heading: 'label', stepLabel: 'label', text: 'label' }, + guidance: { + message: + 'A node label is a name, not a message. A refused `end` node\'s message is ' + + '`refusals..message`; a `save_notice` node\'s is `notices..message`.', + description: + 'A drawing of the flow shows a node by its label alone. Translate `label`; a screen\'s body text is ' + + '`screens..description`.', + }, + }, { + label: z.string().optional().describe( + "Translated node label — overlays the node's own `label` (`FlowNode.label`), the step name a drawing of the " + + 'flow shows; for any node but a `screen` (keyed `screens..title`) and an `approval` (keyed ' + + '`approvals..label`)', + ), + })).optional().describe( + 'Node-label translations keyed by node id (`FlowNode.id`) — every node other than a `screen` or an `approval`', + ), // [#28251] A `save_notice` node's message, picked by the ENGINE in the // triggering writer's locale before its holes are filled — the `refusals` // posture, one group over, addressed the same way (by `FlowNode.id`). From eabf0e62eb997c0b3164fd9878bc15816994fd15 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 22 Nov 2026 08:32:24 +0000 Subject: [PATCH 02/10] feat(lint): validate and demand flows.FLOW.nodes.NODE.label for the steps a flow embed draws Co-authored-by: Claude Claude-Session: https://claude.ai/code/session_01QsR2jTrJZvNaijgX3NxBMc --- packages/cli/src/utils/i18n-coverage.ts | 6 +- .../cli/test/i18n-flow-node-coverage.test.ts | 146 ++++++++++++++++++ packages/lint/src/i18n-walk.ts | 24 ++- .../validate-translation-references.test.ts | 103 +++++++++++- .../src/validate-translation-references.ts | 44 +++++- 5 files changed, 312 insertions(+), 11 deletions(-) create mode 100644 packages/cli/test/i18n-flow-node-coverage.test.ts diff --git a/packages/cli/src/utils/i18n-coverage.ts b/packages/cli/src/utils/i18n-coverage.ts index 941dc4c17df..c2ecda76774 100644 --- a/packages/cli/src/utils/i18n-coverage.ts +++ b/packages/cli/src/utils/i18n-coverage.ts @@ -364,7 +364,9 @@ const COVERAGE_SOURCE: Record // toasts (`flows..successMessage` / `.errorMessage`, #22507) and a refused // `end` node's message (`flows..refusals..message`, #22450), and an // approval flow's label with each `approval` node's step label - // (`flows..approvals..label`, #24916) — the author's own text, so + // (`flows..approvals..label`, #24916), and every other step a docs + // flow embed draws (`flows..nodes..label`, ruling 7076440876) — the + // author's own text, so // it keeps its own bucket and reports as `i18n/missing-flow` rather than // folding away with `--include-platform`. Until this bucket existed the // family could not report a screen-flow gap at all: HotCRM measured @@ -461,7 +463,7 @@ const SOURCE_SURFACE: Record = { report: 'reports', picklist: 'picklists', page: 'pages', - flow: 'flow screens, approval steps, toasts and refusals', + flow: 'flow screens, steps, approval steps, toasts and refusals', hook: 'hook refusals', position: 'positions', permission: 'permission sets', diff --git a/packages/cli/test/i18n-flow-node-coverage.test.ts b/packages/cli/test/i18n-flow-node-coverage.test.ts new file mode 100644 index 00000000000..6f36f40105e --- /dev/null +++ b/packages/cli/test/i18n-flow-node-coverage.test.ts @@ -0,0 +1,146 @@ +// Copyright (c) 2026 ObjectStack contributors. Apache-2.0 license. +// +// Ruling 7076440876 (objectstack#35979, option A) — every step a docs flow +// embed draws joins the flow bucket. +// +// The docs viewer's `type: flow` embed (`element:metadata_viewer`) lists a +// flow's steps by label for a manual's reader, at `detail: business` by +// default: every top-level node whose type `isFlowTechnicalNodeType` does not +// fold away. A screen's and an approval's label were keyed already; a start, +// decision, notify or end step had no key, so a zh-CN manual named them in +// English under a green coverage run. These pins are the CLI half: the walker +// scaffolds `flows..nodes..label` for exactly the drawn steps +// that have no other key, and the coverage gate demands it. +// +// The ledger mock is `i18n-flow-screen-coverage.test.ts`'s, for its reason: +// these pins measure the bucket itself, whatever the shipped ledger says next. + +import { describe, it, expect, vi } from 'vitest'; + +vi.mock('@objectstack/lint', async (importOriginal) => ({ + ...(await importOriginal()), + authorWarnedProperties: () => new Set(), +})); + +import { collectExpectedEntries } from '../src/utils/i18n-bundle-extract.js'; +import { computeI18nCoverage } from '../src/utils/i18n-coverage.js'; +import { FLOW_TECHNICAL_NODE_TYPES } from '@objectstack/spec/automation'; +import { TranslationDataSchema } from '@objectstack/spec/system'; + +/** + * HotCRM's measured `opportunity_approval` shape, trimmed: a start, a + * decision, two approvals, notifies, a technical record write and an end — + * plus a screen and a loop whose nested notify the embed does not draw. + */ +const opportunityApproval = { + name: 'opportunity_approval', + label: 'Large Deal Approval', + type: 'autolaunched', + nodes: [ + { id: 'start', type: 'start', label: 'Start', config: { objectName: 'crm_opportunity', triggerType: 'record-after-update' } }, + { id: 'manager_review', type: 'approval', label: 'Sales Manager Review', config: { approvers: [{ type: 'manager' }] } }, + { id: 'high_value', type: 'decision', label: 'High Value (> $500K)?' }, + { id: 'director_signoff', type: 'approval', label: 'Sales Director Sign-off', config: { approvers: [{ type: 'manager' }] } }, + { id: 'notify_owner', type: 'notify', label: 'Notify Owner' }, + { id: 'mark_approved', type: 'update_record', label: 'Mark Approved', config: { objectName: 'crm_opportunity', fields: {} } }, + { id: 'confirm', type: 'screen', label: 'Confirm', config: { fields: [{ name: 'ok', label: 'OK' }] } }, + { + id: 'each_line', + type: 'loop', + label: 'Each Line', + config: { collection: '{lines}', body: { nodes: [{ id: 'tell_rep', type: 'notify', label: 'Tell Rep' }] } }, + }, + { id: 'end', type: 'end', label: 'End' }, + ], + edges: [], +}; + +const nodeKeys = (config: any) => + collectExpectedEntries(config) + .filter((e) => e.path[0] === 'flows' && e.path[2] === 'nodes') + .map((e) => e.path.join('.')); + +describe('what the walker harvests for the steps a docs flow embed draws (ruling 7076440876)', () => { + it('emits one label per drawn step with no other key, seeded with the authored text', () => { + const entries = collectExpectedEntries({ flows: [opportunityApproval] }).filter( + (e) => e.path[0] === 'flows' && e.path[2] === 'nodes', + ); + expect(entries.map((e) => e.path.join('.'))).toEqual([ + 'flows.opportunity_approval.nodes.start.label', + 'flows.opportunity_approval.nodes.high_value.label', + 'flows.opportunity_approval.nodes.notify_owner.label', + 'flows.opportunity_approval.nodes.each_line.label', + 'flows.opportunity_approval.nodes.end.label', + ]); + expect(entries[1]).toMatchObject({ + sourceValue: 'High Value (> $500K)?', + inline: 'High Value (> $500K)?', + source: 'flow', + flowName: 'opportunity_approval', + }); + }); + + it('asks nothing for a technical step, whichever type the shared table folds away', () => { + const flow = { + name: 'plumbing', + label: 'Plumbing', + nodes: FLOW_TECHNICAL_NODE_TYPES.map((type) => ({ id: `n_${type}`, type, label: type })), + edges: [], + }; + expect(nodeKeys({ flows: [flow] })).toEqual([]); + }); + + it('skips a step with no id: nothing could address it', () => { + const flow = { ...opportunityApproval, nodes: [{ type: 'decision', label: 'Anonymous' }] }; + expect(nodeKeys({ flows: [flow] })).toEqual([]); + }); + + it('every harvested key parses under the translation schema and is kept', () => { + const nodes = Object.fromEntries( + nodeKeys({ flows: [opportunityApproval] }).map((key) => [key.split('.')[3], { label: '译文' }]), + ); + const parsed = TranslationDataSchema.parse({ flows: { opportunity_approval: { nodes } } }); + expect(Object.keys(parsed.flows?.opportunity_approval?.nodes ?? {})).toEqual(Object.keys(nodes)); + }); +}); + +describe('the coverage gate demands the drawn steps (ruling 7076440876)', () => { + const tree = (flows?: Record) => ({ + i18n: { defaultLocale: 'en', supportedLocales: ['en', 'zh-CN'] }, + flows: [opportunityApproval], + translations: [{ 'zh-CN': { ...(flows ? { flows } : {}) } }], + }); + const zhNodeIssues = (config: any) => + computeI18nCoverage(config) + .issues.filter((i) => i.locale === 'zh-CN' && i.source === 'flow') + .map((i) => i.key) + .filter((k) => k.startsWith('flows.opportunity_approval.nodes.')); + + it('lists every untranslated drawn step in the flow bucket', () => { + expect(zhNodeIssues(tree())).toEqual([ + 'flows.opportunity_approval.nodes.start.label', + 'flows.opportunity_approval.nodes.high_value.label', + 'flows.opportunity_approval.nodes.notify_owner.label', + 'flows.opportunity_approval.nodes.each_line.label', + 'flows.opportunity_approval.nodes.end.label', + ]); + }); + + it('goes quiet once every drawn step is translated', () => { + expect( + zhNodeIssues( + tree({ + opportunity_approval: { + nodes: { + start: { label: '开始' }, + high_value: { label: '大额(> 50 万美元)?' }, + notify_owner: { label: '通知负责人' }, + each_line: { label: '逐行' }, + end: { label: '结束' }, + }, + }, + }), + ), + ).toEqual([]); + }); +}); diff --git a/packages/lint/src/i18n-walk.ts b/packages/lint/src/i18n-walk.ts index 763afc1909c..7902ec43ff6 100644 --- a/packages/lint/src/i18n-walk.ts +++ b/packages/lint/src/i18n-walk.ts @@ -138,6 +138,7 @@ * flows..notices..message (#28251) * flows..records..fields. (ruling 6913660232) * flows..approvals..label (#24916) + * flows..nodes..label (ruling 7076440876) * ^ walked because the ledger's `flows` row is `live` and warns no * author; a group the ledger does warn on is left out of the walk * (see `authorWarnedTranslationGroups`) @@ -185,7 +186,7 @@ import { import { FLOW_REGION_SLOTS_BY_TYPE, flowScreenFieldOptionKey, isFlowTextEnvelopeShaped, templateSlotSource } from '@objectstack/spec/automation'; import { DEFAULT_METADATA_TYPE_REGISTRY } from '@objectstack/spec/kernel'; import { deriveFieldGroupLayout } from '@objectstack/spec/data'; -import { APPROVAL_NODE_TYPE } from '@objectstack/spec/automation'; +import { APPROVAL_NODE_TYPE, isFlowTechnicalNodeType } from '@objectstack/spec/automation'; import { expandViewContainer, InlineLocaleMapSchema } from '@objectstack/spec/ui'; import { authorWarnedProperties } from './lint-liveness-properties.js'; import { walkPageComponents } from './page-walk.js'; @@ -2532,6 +2533,27 @@ function walkScreenFlows(config: any, out: ExpectedEntry[]): void { if (!nodeId) continue; pushOptional(out, ['flows', flowName, 'approvals', nodeId, 'label'], node.label, 'flow', scope); } + + // [ruling 7076440876] `flows..nodes..label` — the label of + // every step the docs viewer's `type: flow` embed draws at its default + // altitude (`detail: business`): a top-level node whose type + // `isFlowTechnicalNodeType` does not fold away, the one table that viewer + // reads. A `screen` and an `approval` are drawn too, but their label is + // keyed already (`screens..title`, `approvals..label`), + // so they are not asked twice. Start and end nodes are asked like any + // other step: the viewer draws the author's words for them, not its own. + // A region's nested nodes (ADR-0031) are not drawn by that embed, so they + // are accepted by `os validate` but not demanded here. + const topLevel: any[] = Array.isArray(flow.nodes) ? flow.nodes : []; + for (const node of topLevel) { + if (!node || typeof node !== 'object') continue; + if (node.type === SCREEN_NODE_TYPE || node.type === APPROVAL_NODE_TYPE) continue; + if (isFlowTechnicalNodeType(node.type)) continue; + const nodeId = typeof node.id === 'string' && node.id.length > 0 ? node.id : undefined; + // No id, no key: nothing could address the step. + if (!nodeId) continue; + pushOptional(out, ['flows', flowName, 'nodes', nodeId, 'label'], node.label, 'flow', scope); + } } } diff --git a/packages/lint/src/validate-translation-references.test.ts b/packages/lint/src/validate-translation-references.test.ts index 0c2ca1addec..53e78e98cd2 100644 --- a/packages/lint/src/validate-translation-references.test.ts +++ b/packages/lint/src/validate-translation-references.test.ts @@ -2373,7 +2373,7 @@ describe('validateTranslationReferences — flow approval steps (`approvals. { + it('a `screens` key over a non-approval, non-screen node keeps its own diagnosis, pointed at `nodes`', () => { const findings = validateTranslationReferences(bundle({ opportunity_approval: { screens: { gate: { title: 'x' } } } })); expect(findings).toHaveLength(1); - expect(findings[0].message).toContain('declares as a `decision` node, not a `screen`'); + expect(findings[0].message).toBe( + 'Translations are keyed to screen "gate", which flow "opportunity_approval" declares as a `decision` node, ' + + 'not a `screen`; its label is keyed `nodes.gate.label`.', + ); + }); +}); + +describe('validateTranslationReferences — flow node labels (`nodes..label`, ruling 7076440876)', () => { + /** + * The same measured HotCRM shape as the approval steps above: a start, a + * decision, a screen, an approval and a refusing end, plus a notify nested + * in a loop body (an ADR-0031 region), so every verdict below is judged + * against the same metadata and differs only in the bundle. + */ + const nodeStack = { + flows: [ + { + name: 'opportunity_approval', + type: 'autolaunched', + nodes: [ + { id: 'start', type: 'start', label: 'Start' }, + { id: 'gate', type: 'decision', label: 'High Value (> $500K)?' }, + { id: 'collect', type: 'screen', label: 'Collect', config: { fields: [{ name: 'note' }] } }, + { + id: 'manager_review', + type: 'approval', + label: 'Sales Manager Review', + config: { approvers: [{ type: 'manager' }] }, + }, + { + id: 'each_line', + type: 'loop', + label: 'Each line', + config: { collection: '{lines}', body: { nodes: [{ id: 'tell_owner', type: 'notify', label: 'Tell owner' }] } }, + }, + { id: 'refuse', type: 'end', label: 'Refused', config: { outcome: 'refused', message: 'Refused.' } }, + ], + }, + ], + }; + const bundle = (flows: unknown) => ({ ...nodeStack, translations: [{ 'zh-CN': { flows } }] }); + + it('reports nothing for the label of a start, decision, end or nested node — and the other groups beside it', () => { + expect( + validateTranslationReferences( + bundle({ + opportunity_approval: { + nodes: { + start: { label: '开始' }, + gate: { label: '大额(> 50 万美元)?' }, + each_line: { label: '逐行' }, + tell_owner: { label: '通知负责人' }, + refuse: { label: '已拒绝' }, + }, + screens: { collect: { title: '收集' } }, + approvals: { manager_review: { label: '销售经理审核' } }, + refusals: { refuse: { message: '已拒绝。' } }, + }, + }), + ), + ).toEqual([]); + }); + + it('points a `nodes` key over an `approval` node at its step label', () => { + const findings = validateTranslationReferences(bundle({ opportunity_approval: { nodes: { manager_review: { label: 'x' } } } })); + expect(findings.map((f) => [f.rule, f.severity, f.path])).toEqual([ + [TRANSLATION_TARGET_UNKNOWN, 'error', 'translations[0]["zh-CN"].flows.opportunity_approval.nodes.manager_review'], + ]); + expect(findings[0].message).toBe( + 'Translations are keyed to node "manager_review", which flow "opportunity_approval" declares as an ' + + '`approval` node; its step label is keyed `approvals.manager_review.label`.', + ); + }); + + it('points a `nodes` key over a `screen` node at its heading', () => { + const findings = validateTranslationReferences(bundle({ opportunity_approval: { nodes: { collect: { label: 'x' } } } })); + expect(findings).toHaveLength(1); + expect(findings[0].message).toBe( + 'Translations are keyed to node "collect", which flow "opportunity_approval" declares as a `screen` node; ' + + 'its heading is keyed `screens.collect.title`.', + ); + }); + + it('refuses a `nodes` key over an UNKNOWN node, with the nearest labelled node offered', () => { + const findings = validateTranslationReferences(bundle({ opportunity_approval: { nodes: { gaet: { label: 'x' } } } })); + expect(findings).toHaveLength(1); + expect(findings[0].rule).toBe(TRANSLATION_TARGET_UNKNOWN); + expect(findings[0].path).toBe('translations[0]["zh-CN"].flows.opportunity_approval.nodes.gaet'); + expect(findings[0].message).toContain( + 'Translations are keyed to node "gaet", which flow "opportunity_approval" does not declare, so its drawn ' + + 'step keeps its authored label.', + ); + expect(findings[0].message).toContain('Did you mean "gate"?'); + expect(findings[0].hint).toBe("Node-label translations are keyed by a node's `id`, not its `label`."); }); }); @@ -4705,6 +4798,10 @@ describe('[#22161] one-line verdicts — translation-target-unknown, translation '`screen` node; its heading is keyed', 'declares no node for, so the step keeps', '`approval` node; its step label is keyed', + '`decision` node, not a `screen`; its label is keyed', + 'not an `approval`; its label is keyed', + 'so its drawn step keeps its authored label', + '`screen` node; its heading is keyed `screens.collect.title`', 'is not a form view, so no title resolves this key', 'Translations are keyed to parameter "', 'does not declare in `outcomeMessages`', diff --git a/packages/lint/src/validate-translation-references.ts b/packages/lint/src/validate-translation-references.ts index bed72caf306..f9ba75c327e 100644 --- a/packages/lint/src/validate-translation-references.ts +++ b/packages/lint/src/validate-translation-references.ts @@ -128,6 +128,14 @@ * node, is pointed at `approvals..label` rather than told only that * the node is not a screen. * + * `flows..nodes..label` (ruling 7076440876) is judged against + * every other node: the id must name a node of the flow, at any depth, that is + * neither a `screen` nor an `approval`. Those two already carry their label + * under their own key, so a `nodes` key over one is pointed at + * `screens..title` or `approvals..label`, and a `screens` or + * `approvals` key written over any other node is pointed at + * `nodes..label`. An id the flow does not declare is an orphan. + * * `hooks..refusals..message` (#26170) is judged against the hook's * refusal catalogue: the hook must be one the stack defines (or a sibling * package's, through the artifact carrier), and the code one its `refusals` @@ -2418,7 +2426,8 @@ export function validateTranslationReferences(stack: AnyRec): TranslationRefFind ? approvalRedirect('screen', nodeId, flowName) : otherType ? `Translations are keyed to screen "${nodeId}", which flow "${flowName}" ` + - `declares as a \`${otherType}\` node, not a \`screen\`, so nothing resolves these keys.` + `declares as a \`${otherType}\` node, not a \`screen\`; its label is keyed ` + + `\`nodes.${nodeId}.label\`.` : `Translations are keyed to screen "${nodeId}", which flow "${flowName}" ` + `declares no screen node for, so the wizard step keeps its source-locale heading.` + suggest(nodeId, flow.screens.keys()), @@ -2556,13 +2565,37 @@ export function validateTranslationReferences(stack: AnyRec): TranslationRefFind `\`screen\` node; its heading is keyed \`screens.${nodeId}.title\`.` : nodeType ? `Translations are keyed to approval step "${nodeId}", which flow "${flowName}" declares as a ` + - `\`${nodeType}\` node, not an \`approval\`, so nothing resolves this key.` + `\`${nodeType}\` node, not an \`approval\`; its label is keyed \`nodes.${nodeId}.label\`.` : `Translations are keyed to approval step "${nodeId}", which flow "${flowName}" declares no ` + `node for, so the step keeps its source-locale label.` + suggest(nodeId, flow.approvals), `Approval-step translations are keyed by the \`id\` of an \`approval\` node.`, ); } + // ── flows..nodes. (ruling 7076440876) ────────────── + // Any node but a `screen` or an `approval`, at any depth: those two + // carry their label under a key of their own, so a `nodes` key over + // one is pointed there rather than accepted as a second key. + for (const nodeId of Object.keys(asRecord(rawFlow.nodes))) { + const nodeType = flow.screens.has(nodeId) ? SCREEN_NODE_TYPE : flow.otherNodes.get(nodeId); + if (nodeType && nodeType !== SCREEN_NODE_TYPE && nodeType !== APPROVAL_NODE_TYPE) continue; + orphan( + `${inLocale} · flow "${flowName}" · node "${nodeId}"`, + `${flowPath}.nodes.${nodeId}`, + nodeType === SCREEN_NODE_TYPE + ? `Translations are keyed to node "${nodeId}", which flow "${flowName}" declares as a ` + + `\`screen\` node; its heading is keyed \`screens.${nodeId}.title\`.` + : nodeType === APPROVAL_NODE_TYPE + ? approvalRedirect('node', nodeId, flowName) + : `Translations are keyed to node "${nodeId}", which flow "${flowName}" does not declare, so ` + + `its drawn step keeps its authored label.` + + suggest( + nodeId, + [...flow.otherNodes].filter(([, type]) => type !== APPROVAL_NODE_TYPE).map(([id]) => id), + ), + `Node-label translations are keyed by a node's \`id\`, not its \`label\`.`, + ); + } } // ── hooks..refusals. (#26170) ─────────────────────────── @@ -2640,10 +2673,11 @@ export function validateTranslationReferences(stack: AnyRec): TranslationRefFind } /** - * The verdict for a `screens` / `refusals` key written over an `approval` - * node: the step's one translatable string is its label, under `approvals`. + * The verdict for a `screens` / `refusals` / `nodes` key written over an + * `approval` node: the step's one translatable string is its label, under + * `approvals`. */ -function approvalRedirect(group: 'screen' | 'refusal', nodeId: string, flowName: string): string { +function approvalRedirect(group: 'screen' | 'refusal' | 'node', nodeId: string, flowName: string): string { return ( `Translations are keyed to ${group} "${nodeId}", which flow "${flowName}" declares as an ` + `\`approval\` node; its step label is keyed \`approvals.${nodeId}.label\`.` From d1969dafdb1e21a7614abc6ab76ffe86189155f5 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 22 Nov 2026 08:42:59 +0000 Subject: [PATCH 03/10] test(cli): pin the drawn-step label demand; older flow-family pins read their own family Co-authored-by: Claude Claude-Session: https://claude.ai/code/session_01QsR2jTrJZvNaijgX3NxBMc --- .changeset/35979-flow-node-label-key.md | 18 ++++++++++++++++++ .../test/i18n-flow-approval-coverage.test.ts | 19 ++++++++++++++----- .../cli/test/i18n-flow-liveness-gate.test.ts | 10 +++++++++- .../test/i18n-flow-screen-coverage.test.ts | 14 +++++++++++--- 4 files changed, 52 insertions(+), 9 deletions(-) create mode 100644 .changeset/35979-flow-node-label-key.md diff --git a/.changeset/35979-flow-node-label-key.md b/.changeset/35979-flow-node-label-key.md new file mode 100644 index 00000000000..495266fc864 --- /dev/null +++ b/.changeset/35979-flow-node-label-key.md @@ -0,0 +1,18 @@ +--- +'@objectstack/spec': minor +'@objectstack/lint': minor +'@objectstack/cli': minor +--- + +feat(spec): every step a flow drawing shows can be translated, under `flows..nodes..label` + +Clause-②: yes (widening: a new translation key `flows..nodes..label`, and the new exports `FLOW_TECHNICAL_NODE_TYPES` and `isFlowTechnicalNodeType` from `@objectstack/spec/automation`) +Metadata-protocol: added +Skills-docs: follow-up owed — skills/objectstack-i18n/SKILL.md + +A package can now translate the label of any flow step, not only a screen's heading and an approval step's label. A manual that embeds a flow (a `type: flow` metadata embed) lists its steps by label, and until now a start, decision, notify or end step had nowhere to put a translation, so a zh-CN reader saw those steps in English beside translated approval steps. + +- **The key.** `flows..nodes..label`, keyed by the node's `id`, at any depth. It overlays the node's own `label` and is plain text. A `screen` keeps its `screens..title` and an `approval` its `approvals..label`, so one string keeps one key: `objectstack validate` points a `nodes` key over either at that key, and points a `screens` or `approvals` key over any other node at `nodes..label`. A key over a node the flow does not declare is refused. `nodes` was an unknown-key hint that suggested `screens`; it is now its own group. +- **Start and end steps are translated like any other.** Their labels are the author's words and often name an outcome or a trigger ("Approved", "On Task Created"), so nothing substitutes words of its own for them. +- **Missing translations are reported.** `os lint` and `os i18n check` (`i18n/missing-flow`) now ask for the label of every top-level step the embed draws at its default `detail: business` altitude, except screens and approvals, which they already asked for. `os i18n extract` scaffolds the keys. An app that ships translated locales gets new findings for its flows until it translates them. +- **One table for what business altitude hides.** `FLOW_TECHNICAL_NODE_TYPES` (and `isFlowTechnicalNodeType`) in `@objectstack/spec/automation` lists the node types `detail: business` folds away (`script`, `http`, `connector_action`, `assignment`, `get_record`, `create_record`, `update_record`, `delete_record`, `boundary_event`). The docs viewer and the coverage check read it, so they agree on which steps a reader sees. diff --git a/packages/cli/test/i18n-flow-approval-coverage.test.ts b/packages/cli/test/i18n-flow-approval-coverage.test.ts index 089f1402995..d255b42299f 100644 --- a/packages/cli/test/i18n-flow-approval-coverage.test.ts +++ b/packages/cli/test/i18n-flow-approval-coverage.test.ts @@ -27,6 +27,13 @@ import { collectExpectedEntries, extractTranslations } from '../src/utils/i18n-b import { computeI18nCoverage } from '../src/utils/i18n-coverage.js'; import { TranslationDataSchema } from '@objectstack/spec/system'; +/** + * The `flows..nodes..label` family (ruling 7076440876) is + * demanded beside this file's own and pinned by `i18n-flow-node-coverage.test.ts`; + * these pins measure their family, so they read every key but that one. + */ +const notNodeLabel = (key: string) => !/^flows\.[^.]+\.nodes\./.test(key); + /** An approval-only flow: record-triggered, two approval steps, no screen. */ const expenseApproval = { name: 'expense_approval', @@ -67,11 +74,13 @@ const nightlyDigest = { }; const flowKeys = (config: any) => - collectExpectedEntries(config).filter((e) => e.path[0] === 'flows').map((e) => e.path.join('.')); + collectExpectedEntries(config).filter((e) => e.path[0] === 'flows').map((e) => e.path.join('.')).filter(notNodeLabel); describe('what the walker harvests from an approval flow (#24916)', () => { it('emits the flow label and each approval step label, seeded with the authored text', () => { - const entries = collectExpectedEntries({ flows: [expenseApproval] }).filter((e) => e.path[0] === 'flows'); + const entries = collectExpectedEntries({ flows: [expenseApproval] }).filter( + (e) => e.path[0] === 'flows' && notNodeLabel(e.path.join('.')), + ); expect(entries.map((e) => e.path.join('.'))).toEqual([ 'flows.expense_approval.label', @@ -99,7 +108,7 @@ describe('the coverage gate demands the approval flow and its steps (#24916)', ( translations: [{ 'zh-CN': { ...(flows ? { flows } : {}) } }], }); const zhFlowIssues = (config: any) => - computeI18nCoverage(config).issues.filter((i) => i.locale === 'zh-CN' && i.source === 'flow'); + computeI18nCoverage(config).issues.filter((i) => i.locale === 'zh-CN' && i.source === 'flow' && notNodeLabel(i.key)); it('lists the untranslated approval flow label and step labels in the flow bucket', () => { const keys = zhFlowIssues(tree()).map((i) => i.key).filter((k) => k.startsWith('flows.expense_approval.')); @@ -154,11 +163,11 @@ describe('the skeleton `os i18n extract` writes for an approval flow (#24916)', const result = extractTranslations({ flows: [expenseApproval] }, { locales: ['en', 'zh-CN'] }); it('writes the authored labels into the default locale and empty slots into the others', () => { - expect((result.bundles.en as any).flows.expense_approval).toEqual({ + expect((result.bundles.en as any).flows.expense_approval).toMatchObject({ label: 'Expense Approval', approvals: { manager_review: { label: 'Manager Review' }, finance_review: { label: 'Finance Review' } }, }); - expect((result.bundles['zh-CN'] as any).flows.expense_approval).toEqual({ + expect((result.bundles['zh-CN'] as any).flows.expense_approval).toMatchObject({ label: '', approvals: { manager_review: { label: '' }, finance_review: { label: '' } }, }); diff --git a/packages/cli/test/i18n-flow-liveness-gate.test.ts b/packages/cli/test/i18n-flow-liveness-gate.test.ts index 581be86bf16..99677591205 100644 --- a/packages/cli/test/i18n-flow-liveness-gate.test.ts +++ b/packages/cli/test/i18n-flow-liveness-gate.test.ts @@ -57,6 +57,13 @@ import { import { computeI18nCoverage } from '../src/utils/i18n-coverage.js'; import { authorWarnedProperties, lintLivenessProperties } from '@objectstack/lint'; +/** + * The `flows..nodes..label` family (ruling 7076440876) is + * demanded beside this file's own and pinned by `i18n-flow-node-coverage.test.ts`; + * these pins measure their family, so they read every key but that one. + */ +const notNodeLabel = (key: string) => !/^flows\.[^.]+\.nodes\./.test(key); + const leadConversion = { name: 'lead_conversion', label: 'Convert Lead', @@ -114,7 +121,7 @@ const app = (withFlowCopy: boolean) => ({ }); const flowDemands = (config: any) => - computeI18nCoverage(config).issues.filter((i) => i.source === 'flow'); + computeI18nCoverage(config).issues.filter((i) => i.source === 'flow' && notNodeLabel(i.key)); const flowWarnings = (config: any) => lintLivenessProperties(config).filter((f) => f.message.includes('`flows`')); @@ -210,6 +217,7 @@ describe('the liveness gate on the i18n coverage walk', () => { const keys = collectExpectedEntries(app(false), UNGATED) .filter((e) => e.path[0] === 'flows') .map((e) => e.path.join('.')) + .filter(notNodeLabel) .sort(); expect(keys).toEqual([ diff --git a/packages/cli/test/i18n-flow-screen-coverage.test.ts b/packages/cli/test/i18n-flow-screen-coverage.test.ts index 9816af272c7..d9c256a317d 100644 --- a/packages/cli/test/i18n-flow-screen-coverage.test.ts +++ b/packages/cli/test/i18n-flow-screen-coverage.test.ts @@ -61,6 +61,13 @@ vi.mock('@objectstack/lint', async (importOriginal) => ({ import { collectExpectedEntries, extractTranslations } from '../src/utils/i18n-bundle-extract.js'; import { computeI18nCoverage, type CoverageIssue, type CoverageReport } from '../src/utils/i18n-coverage.js'; + +/** + * The `flows..nodes..label` family (ruling 7076440876) is + * demanded beside this file's own and pinned by `i18n-flow-node-coverage.test.ts`; + * these pins measure their family, so they read every key but that one. + */ +const notNodeLabel = (key: string) => !/^flows\.[^.]+\.nodes\./.test(key); import { FLOW_SCREEN_COPY_KEYS, FLOW_SCREEN_FIELD_COPY_KEYS, @@ -123,12 +130,13 @@ const hotCrmLike = (flowTranslations?: Record) => ({ /** Only the user's own metadata; `os lint` folds the platform baseline away. */ const userIssues = (report: CoverageReport): CoverageIssue[] => - report.issues.filter((i) => i.source !== 'metadataForm'); + report.issues.filter((i) => i.source !== 'metadataForm' && notNodeLabel(i.key)); const flowKeys = (config: any) => collectExpectedEntries(config) .filter((e) => e.path[0] === 'flows') - .map((e) => e.path.join('.')); + .map((e) => e.path.join('.')) + .filter(notNodeLabel); describe('the screen-flow gap a green i18n gate could not see (#11485)', () => { it('reports every untranslated wizard string on a tree whose objects are done', () => { @@ -153,7 +161,7 @@ describe('the screen-flow gap a green i18n gate could not see (#11485)', () => { it('attributes them to the flow bucket so `os lint` renders `i18n/missing-flow`', () => { const zh = computeI18nCoverage(hotCrmLike()).issues.filter( - (i) => i.locale === 'zh-CN' && i.key.startsWith('flows.'), + (i) => i.locale === 'zh-CN' && i.key.startsWith('flows.') && notNodeLabel(i.key), ); expect(zh.length).toBeGreaterThan(0); From 4200497a50c3218a764d8ab91591dc7c8bb8f418 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 22 Nov 2026 08:47:48 +0000 Subject: [PATCH 04/10] chore(spec): regenerate artifacts for the flows node-label key; ledger row planned until the reader lands Co-authored-by: Claude Claude-Session: https://claude.ai/code/session_01QsR2jTrJZvNaijgX3NxBMc --- content/docs/references/system/translation.mdx | 4 ++++ .../system.md | 2 +- packages/spec/api-surface/automation.json | 2 ++ packages/spec/export-origins/automation.json | 2 ++ packages/spec/liveness/state-counts/translation.md | 2 +- packages/spec/liveness/translation.json | 12 ++++++++++++ 6 files changed, 22 insertions(+), 2 deletions(-) diff --git a/content/docs/references/system/translation.mdx b/content/docs/references/system/translation.mdx index 51ade2bcd9a..e6ae24a7478 100644 --- a/content/docs/references/system/translation.mdx +++ b/content/docs/references/system/translation.mdx @@ -297,6 +297,7 @@ Translation data for a single object | **screens** | `Record }>` | optional | Screen translations keyed by screen node id (`FlowNode.id`, the client's `ScreenSpec.nodeId`) | | **refusals** | `Record` | optional | Refusal translations keyed by the node id (`FlowNode.id`) of an `end` node declaring `outcome: 'refused'` | | **approvals** | `Record` | optional | Approval-step translations keyed by the node id (`FlowNode.id`) of an `approval` node | +| **nodes** | `Record` | optional | Node-label translations keyed by node id (`FlowNode.id`) — every node other than a `screen` or an `approval` | | **notices** | `Record` | optional | Save-notice translations keyed by the node id (`FlowNode.id`) of a `save_notice` node | | **records** | `Record }>` | optional | Record-write text translations keyed by the node id (`FlowNode.id`) of a `create_record` / `update_record` node | @@ -486,6 +487,7 @@ Translation data for a single object | **screens** | `Record }>` | optional | Screen translations keyed by screen node id (`FlowNode.id`, the client's `ScreenSpec.nodeId`) | | **refusals** | `Record` | optional | Refusal translations keyed by the node id (`FlowNode.id`) of an `end` node declaring `outcome: 'refused'` | | **approvals** | `Record` | optional | Approval-step translations keyed by the node id (`FlowNode.id`) of an `approval` node | +| **nodes** | `Record` | optional | Node-label translations keyed by node id (`FlowNode.id`) — every node other than a `screen` or an `approval` | | **notices** | `Record` | optional | Save-notice translations keyed by the node id (`FlowNode.id`) of a `save_notice` node | | **records** | `Record }>` | optional | Record-write text translations keyed by the node id (`FlowNode.id`) of a `create_record` / `update_record` node | @@ -738,6 +740,7 @@ Translation data for a single object | **screens** | `Record }>` | optional | Screen translations keyed by screen node id (`FlowNode.id`, the client's `ScreenSpec.nodeId`) | | **refusals** | `Record` | optional | Refusal translations keyed by the node id (`FlowNode.id`) of an `end` node declaring `outcome: 'refused'` | | **approvals** | `Record` | optional | Approval-step translations keyed by the node id (`FlowNode.id`) of an `approval` node | +| **nodes** | `Record` | optional | Node-label translations keyed by node id (`FlowNode.id`) — every node other than a `screen` or an `approval` | | **notices** | `Record` | optional | Save-notice translations keyed by the node id (`FlowNode.id`) of a `save_notice` node | | **records** | `Record }>` | optional | Record-write text translations keyed by the node id (`FlowNode.id`) of a `create_record` / `update_record` node | @@ -959,6 +962,7 @@ Translation data for a single object | **screens** | `Record }>` | optional | Screen translations keyed by screen node id (`FlowNode.id`, the client's `ScreenSpec.nodeId`) | | **refusals** | `Record` | optional | Refusal translations keyed by the node id (`FlowNode.id`) of an `end` node declaring `outcome: 'refused'` | | **approvals** | `Record` | optional | Approval-step translations keyed by the node id (`FlowNode.id`) of an `approval` node | +| **nodes** | `Record` | optional | Node-label translations keyed by node id (`FlowNode.id`) — every node other than a `screen` or an `approval` | | **notices** | `Record` | optional | Save-notice translations keyed by the node id (`FlowNode.id`) of a `save_notice` node | | **records** | `Record }>` | optional | Record-write text translations keyed by the node id (`FlowNode.id`) of a `create_record` / `update_record` node | diff --git a/docs/audits/2026-07-unknown-key-strictness-ledger.counts/system.md b/docs/audits/2026-07-unknown-key-strictness-ledger.counts/system.md index 6c3fc208fa4..e669c99724b 100644 --- a/docs/audits/2026-07-unknown-key-strictness-ledger.counts/system.md +++ b/docs/audits/2026-07-unknown-key-strictness-ledger.counts/system.md @@ -19,4 +19,4 @@ hand-patch a number here** — fix the code or the verdict and regenerate. | Dir | Sites | |---|---| -| `system/` | 407 | +| `system/` | 408 | diff --git a/packages/spec/api-surface/automation.json b/packages/spec/api-surface/automation.json index fcc0ddd2bbd..dd28344aa1f 100644 --- a/packages/spec/api-surface/automation.json +++ b/packages/spec/api-surface/automation.json @@ -145,6 +145,7 @@ "FLOW_RESERVED_NODE_TYPES (const)", "FLOW_SLOT_REFUSAL_CODES (const)", "FLOW_STRUCTURAL_NODE_TYPES (const)", + "FLOW_TECHNICAL_NODE_TYPES (const)", "FLOW_TEXT_SLOTS (const)", "FLOW_TRIGGER_KINDS (const)", "Flow (type)", @@ -360,6 +361,7 @@ "importBpmnToConstructs (function)", "isExpressionEnvelopeShaped (function)", "isFlowFunctionEffect (function)", + "isFlowTechnicalNodeType (function)", "isFlowTextEnvelopeShaped (function)", "normalizeDecisionOutputs (function)", "normalizeFlowFunctionEntry (function)", diff --git a/packages/spec/export-origins/automation.json b/packages/spec/export-origins/automation.json index cc4e09f0d43..29ed48b3938 100644 --- a/packages/spec/export-origins/automation.json +++ b/packages/spec/export-origins/automation.json @@ -140,6 +140,7 @@ "FLOW_RESERVED_NODE_TYPES": "src/automation/flow-reserved-node-types.ts#FLOW_RESERVED_NODE_TYPES (const)", "FLOW_SLOT_REFUSAL_CODES": "src/automation/flow-node-expression-paths.ts#FLOW_SLOT_REFUSAL_CODES (const)", "FLOW_STRUCTURAL_NODE_TYPES": "src/automation/flow.zod.ts#FLOW_STRUCTURAL_NODE_TYPES (const)", + "FLOW_TECHNICAL_NODE_TYPES": "src/automation/flow-altitude.ts#FLOW_TECHNICAL_NODE_TYPES (const)", "FLOW_TEXT_SLOTS": "src/automation/flow-text-slot-template.ts#FLOW_TEXT_SLOTS (const)", "FLOW_TRIGGER_KINDS": "src/automation/flow-trigger-kind.ts#FLOW_TRIGGER_KINDS (const)", "Flow": "src/automation/flow.zod.ts#Flow (type)", @@ -353,6 +354,7 @@ "importBpmnToConstructs": "src/automation/bpmn-mapping.ts#importBpmnToConstructs (function)", "isExpressionEnvelopeShaped": "src/automation/flow-node-expression-paths.ts#isExpressionEnvelopeShaped (function)", "isFlowFunctionEffect": "src/automation/flow-function.zod.ts#isFlowFunctionEffect (function)", + "isFlowTechnicalNodeType": "src/automation/flow-altitude.ts#isFlowTechnicalNodeType (function)", "isFlowTextEnvelopeShaped": "src/automation/flow-node-expression-paths.ts#isFlowTextEnvelopeShaped (function)", "normalizeDecisionOutputs": "src/automation/approval.zod.ts#normalizeDecisionOutputs (function)", "normalizeFlowFunctionEntry": "src/automation/flow-function.zod.ts#normalizeFlowFunctionEntry (function)", diff --git a/packages/spec/liveness/state-counts/translation.md b/packages/spec/liveness/state-counts/translation.md index 60bf69c6bd3..a79de1a2ddf 100644 --- a/packages/spec/liveness/state-counts/translation.md +++ b/packages/spec/liveness/state-counts/translation.md @@ -12,4 +12,4 @@ committed anywhere: `check:liveness` sums the shards when it reads them. | Type | live | exp | elsewhere | dead | planned | classified | |---|---|---|---|---|---|---| -| `translation` | 47 | 0 | 0 | 0 | 2 | 49 | +| `translation` | 47 | 0 | 0 | 0 | 3 | 50 | diff --git a/packages/spec/liveness/translation.json b/packages/spec/liveness/translation.json index 66e10e7c2fe..3d02ea79774 100644 --- a/packages/spec/liveness/translation.json +++ b/packages/spec/liveness/translation.json @@ -254,6 +254,18 @@ "note": "Overlays the `approval` node's own `FlowNode.label`, the step name an approval request shows. FLIPPED planned → live 2026-10-21 with its container `flows.approvals` (see that row), reader landed in ba69b168be. A read, never a write: the stored `current_step_label` stays the authored snapshot (the audit record, and what the generic data door and list views serve). Nothing is picked when the read carries no locale (a system context, the token-bearing action page), when no `i18n` service is registered, when the pack holds no entry, or when the service throws. Pinned end to end by packages/plugins/plugin-approvals/src/reader-locale-display-labels.integration.test.ts, and the key spelling is held to `TranslationDataSchema` by packages/plugins/plugin-approvals/src/reader-locale-labels.test.ts." } } + }, + "nodes": { + "status": "planned", + "verifiedAt": "2026-11-22", + "note": "PLANNED RECORD (ruling 7076440876 on objectstack#35979, option A): a flow node's display label, `flows..nodes..label`, for every node but a `screen` (keyed `screens..title`) and an `approval` (keyed `approvals..label`). Declared by the face, refused by `objectstack validate` over an unknown node or a screen/approval node (packages/lint/src/validate-translation-references.ts#validateTranslationReferences), and demanded by the i18n walk for every step the docs flow embed draws at `detail: business` (packages/lint/src/i18n-walk.ts#walkScreenFlows). The reader is the docs viewer's `FlowView` (`element:metadata_viewer`) through the shared flow-label resolution in `@object-ui/i18n`, built in the same change once that resolution is on `main`. Flip to `live` on the commit that lands the reader, citing it. DRILLED to its one key, `label`: the entry's face is closed (`.strict()`).", + "children": { + "label": { + "status": "planned", + "verifiedAt": "2026-11-22", + "note": "Planned with its container `flows.nodes` (see that row). Overlays the node's own `FlowNode.label`, plain text, the step name a drawing of the flow shows. Display only: no run, no stored row and no engine-rendered copy reads it." + } + } } }, "note": "[#7646] Contract-first spec half of the screen-flow localization split, and `planned` is the honest status rather than `live` or `dead`: `dead` means declared with no consumer and no plan, while this group was ruled into the vocabulary by the maintainer specifically so the runner half could be built against it (the same ruling fixes the boundary — runner chrome, Cancel/Submit, stays in the console's own message catalog, NOT here). Addressing is measured against what the runner already holds: `flows..screens.` — the node id reaches the client verbatim as `ScreenSpec.nodeId` (packages/spec/src/contracts/automation-service.ts:138), which is also what correlates a resume back to its pause point — and `.fields.` (packages/spec/src/automation/builtin-node-config.zod.ts:382, forwarded as `ScreenFieldSpec.name`). Key face measured against `ScreenFieldConfigSchema`, not mirrored from the report: the per-field keys are `label`, `placeholder` and `inlineHelpText`, each spelled as the screen field spells the string it overlays. The report's `help` was never a key here: when #7646 ruled the face the screen field declared nothing help-shaped, so it would have parsed clean and translated nothing (the ADR-0078 shape #6080 kept out of the page-component face). #17306 gave the screen field `inlineHelpText`, and the face gained it on 2026-10-02 once the console drew the help text; `help` / `helpText` / `hint` / `tooltip` / `description` are aliases onto it on the field surface. `options` stayed out, on `guidance`, because a value-keyed map could not address `ScreenFieldConfig.options[].value`, which is unconstrained (superseded 2026-10-09, see the end of this note). Flip to `live` with an objectui screen-flow-runner evidence pointer when the downstream consumer card lands; the resolver-side helper (a `FLOW_SCREEN_COPY_KEYS` sibling of `PAGE_COMPONENT_COPY_KEYS` in packages/spec/src/system/i18n-resolver.ts) is deliberately NOT in this change — #7634 was in flight on that file. 2026-09-27 (#20296): the `screens` child FLIPPED to `live` (objectui's FlowRunner reads it at the `.objectui-sha` pin f8a9d0fb; see that row), and `authorHint` was rewritten to say so. The container keeps `planned` + `authorWarn` for `label` alone, which nothing reads yet (#20318). The CLI i18n coverage gate keys its whole-group `flows.*` demand off this `authorWarn`, so dropping the bit waits for that reader, and then the whole group flips. 2026-10-05: the `label` child FLIPPED to `live` (objectui's FlowRunner names the flow by `flows..label`, then the served `flowLabel`, then the API name, read at the `.objectui-sha` pin 0abd4f9f8; see that row). Both children are `live`, so the container flips with them, and `authorWarn` and `authorHint` are dropped: a `live` row refuses them, and no half of the group is unread any more. Dropping the bit switches the CLI i18n coverage gate's whole-group `flows.*` demand back on, which is what that gate was built to do on this day. 2026-10-09 (#22507): the closing pass for user-read flow text. The face gains the terminal toasts (`successMessage` / `errorMessage`, child rows `planned`) and, inside `screens`, a screen field's option labels (`fields..options.`, each option keyed by `String(value)`; `ScreenFieldConfigSchema` refuses two options of one field that collide as text). Both are read by `translateFlow` and await the objectui runner change, so neither is drawn translated yet. The container stays `live`: its `label` and `screens` readers are unchanged. The screen `description` stays unkeyed and is recorded as owed in `packages/spec/src/system/flows-translation-face.test.ts`: it is a `{{ }}` template the server renders per run, so its reader is a decision of its own. 2026-10-10 (#22507, maintainer ruling A): that decision is taken. The screen face gains `description`, and the engine picks the translated `title` and `description` templates in the run's locale before it renders them (see the `screens` row). The container stays `live`." From cafc3fdf6e1566ce2b9986ffb6dfa130a559faa4 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 22 Nov 2026 08:58:47 +0000 Subject: [PATCH 05/10] chore(i18n): translate the CRM wizard's drawn steps; freeze the examples' new step-label debt Co-authored-by: Claude Claude-Session: https://claude.ai/code/session_01QsR2jTrJZvNaijgX3NxBMc --- examples/app-crm/src/translations/crm.translation.ts | 6 ++++++ scripts/i18n-coverage-baseline.json | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/examples/app-crm/src/translations/crm.translation.ts b/examples/app-crm/src/translations/crm.translation.ts index 63777e73ada..3b1e901a8ad 100644 --- a/examples/app-crm/src/translations/crm.translation.ts +++ b/examples/app-crm/src/translations/crm.translation.ts @@ -413,6 +413,12 @@ export const CrmTranslationBundle = defineTranslationBundle({ label: '将线索转化为客户和商机', successMessage: '🎉 线索已转化 — 已创建客户和商机。', errorMessage: '线索转化未完成 — 请检查线索后重试。', + // Each step's name where a manual draws the flow. + nodes: { + start: { label: '开始' }, + check_converted: { label: '已转化?' }, + end: { label: '结束' }, + }, screens: { screen_already_converted: { title: '已转化', description: '该线索已转化为商机。' }, screen_account: { diff --git a/scripts/i18n-coverage-baseline.json b/scripts/i18n-coverage-baseline.json index 28610026153..8fdf34782b4 100644 --- a/scripts/i18n-coverage-baseline.json +++ b/scripts/i18n-coverage-baseline.json @@ -1,8 +1,8 @@ { "examples/app-crm/objectstack.config.ts": 0, "examples/app-multi-package/objectstack.config.ts": 0, - "examples/app-showcase/objectstack.config.ts": 317, - "examples/app-todo/objectstack.config.ts": 106, + "examples/app-showcase/objectstack.config.ts": 424, + "examples/app-todo/objectstack.config.ts": 128, "packages/platform-objects/scripts/i18n-extract.config.ts": 0, "packages/plugins/plugin-approvals/scripts/i18n-extract.config.ts": 0, "packages/plugins/plugin-audit/scripts/i18n-extract.config.ts": 0, From 47a645c588630a1eb966097fb62db02a718ae288 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 22 Nov 2026 09:04:27 +0000 Subject: [PATCH 06/10] docs(i18n): list the flow step-name key beside the other flow translation keys Co-authored-by: Claude Claude-Session: https://claude.ai/code/session_01QsR2jTrJZvNaijgX3NxBMc --- content/docs/protocol/kernel/i18n-standard.mdx | 1 + content/docs/ui/translations.mdx | 1 + 2 files changed, 2 insertions(+) diff --git a/content/docs/protocol/kernel/i18n-standard.mdx b/content/docs/protocol/kernel/i18n-standard.mdx index 4d042a8fb50..b2f51518675 100644 --- a/content/docs/protocol/kernel/i18n-standard.mdx +++ b/content/docs/protocol/kernel/i18n-standard.mdx @@ -1169,6 +1169,7 @@ beneath an action entry are judged the same way under either. | `hooks.{hook}.refusals.{code}.reasons.{reason}` | a reason that code declares under `reasons` | | `flows.{flow}.screens.{node}` | the `id` of a `type: 'screen'` node in that flow, nodes nested in loop, parallel and try/catch regions included | | `flows.{flow}.screens.{node}.fields.{field}` | a `config.fields[].name` on that screen — an object-form screen (`config.objectName`) declares none, and its input labels live under `objects.{objectName}.fields` | +| `flows.{flow}.nodes.{node}` | the `id` of a node in that flow that is neither a `screen` nor an `approval` (those two are keyed under `screens` and `approvals`), nodes nested in loop, parallel and try/catch regions included | An unresolvable key is an **error**, not a warning: `os validate`, `os lint` and `os compile` each report it as `translation-target-unknown` and exit non-zero, so diff --git a/content/docs/ui/translations.mdx b/content/docs/ui/translations.mdx index 8813f8fa949..0a8709e0875 100644 --- a/content/docs/ui/translations.mdx +++ b/content/docs/ui/translations.mdx @@ -91,6 +91,7 @@ export default defineStack({ | Page tab labels (`page:tabs` items) | `pages..components..items..label` — keyed by the tabs component's `id` and the item's `value`; an item without a `value` has no key (localize it with an inline locale map), and `page:accordion` panels have none | | A page `object-form`'s thank-you panel | `pages..components..submitBehavior.title` / `.message` — keyed by the `object-form` component's `id` (a form without an `id` has no key), by the same rules as a form view's panel | | Screen-flow wizards (flow label, screen headings and body text, screen field copy) | `flows..label` / `flows..screens..title` / `.description` / `.fields..label` / `.placeholder` / `.inlineHelpText` — a screen field's help text is `inlineHelpText`, the key the field itself declares, not `help`; see the boundary note below | +| Flow step names (each step a drawing of the flow shows, such as a manual's flow embed) | `flows..nodes..label` — keyed by the node's `id`, for a start, decision, notify, end or any other step; an `approval` step's name is `flows..approvals..label` and a screen's is its heading, `flows..screens..title`, so `os validate` points a `nodes` key over either there. `os lint` asks for every step a flow embed draws at its default business altitude | | Text a flow writes into a record (a `create_record` / `update_record` field value marked `{ dialect: 'template', source }`) | `flows..records..fields.` — picked in the organization's language (the Localization setting when set, else the app's `i18n.defaultLocale`), never the run starter's; see [Flows](/docs/automation/flows#text-a-record-keeps--a-field-value-marked-as-text) | | Hook refusal messages | `hooks..refusals..message` — one per entry of the hook's `refusals` catalogue — and `hooks..refusals..reasons..message`, one per reason an entry declares. A hook (a `js` body or a TypeScript `handler`) refuses by code, optionally with a declared reason, and the server answers the refusal with this sentence in the caller's locale, else the declared one. A translation of an entry that declares `params` keeps its `{{ name }}` holes; the server fills them after picking the translation | | Hook texts | `hooks..texts..message` — one per entry of the hook's `texts`. A hook asks for the sentence with `ctx.text(key, params)` when it writes it into a record, and the server answers it in the **organization's** language (the Localization setting somebody set, else the app's `i18n.defaultLocale`), never the caller's, else the declared one. A translation of an entry that declares `params` keeps its `{{ name }}` holes; the server fills them after picking the translation | From c267c2f1617cdf5385f1b7152196021a01cce2c7 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 22 Nov 2026 10:01:45 +0000 Subject: [PATCH 07/10] fix(spec): the steps alias on a flow translation points at nodes Co-authored-by: Claude Claude-Session: https://claude.ai/code/session_01QsR2jTrJZvNaijgX3NxBMc --- packages/spec/src/system/translation.zod.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/spec/src/system/translation.zod.ts b/packages/spec/src/system/translation.zod.ts index 315636759d9..0f7b8b626eb 100644 --- a/packages/spec/src/system/translation.zod.ts +++ b/packages/spec/src/system/translation.zod.ts @@ -2065,8 +2065,9 @@ const appTranslationDataShape = () => ({ surface: 'this flow translation', history: TRANSLATION_HISTORY, aliases: { - name: 'label', title: 'label', steps: 'screens', screen: 'screens', pages: 'screens', - node: 'nodes', + name: 'label', title: 'label', screen: 'screens', pages: 'screens', + // A step's name is a node label: `steps..label` means `nodes`. + node: 'nodes', steps: 'nodes', step: 'nodes', refusal: 'refusals', ends: 'refusals', approval: 'approvals', notice: 'notices', saveNotices: 'notices', From bc0171d889865edd7c67d80ec52c392ac6d68590 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 22 Nov 2026 16:18:07 +0000 Subject: [PATCH 08/10] feat(components): a flow drawing names every step by its translation The shared step-label resolution in @object-ui/i18n now reads the one key each step's name has: approvals..label for an approval, screens..title for a screen with no config.title, and nodes..label for any other node. The docs viewer's flow embed and the Studio canvas (nested region nodes included) read it through stepLabel. The docs embed names a titled screen by its heading, translated where the bundle carries it, unless the heading holds a {{ }} hole, and folds technical steps by the spec's FLOW_TECHNICAL_NODE_TYPES. The flows.nodes ledger row flips to live, citing the readers. Co-authored-by: Claude Claude-Session: https://claude.ai/code/session_01QsR2jTrJZvNaijgX3NxBMc --- .changeset/35979-flow-node-label-key.md | 8 +- .../spec/liveness/state-counts/translation.md | 2 +- packages/spec/liveness/translation.json | 13 +- .../previews/FlowCanvas.test.tsx | 58 +++++++-- .../src/__tests__/metadata-viewer.test.tsx | 121 +++++++++++++++++- .../src/renderers/basic/metadata-viewer.tsx | 59 +++++---- ui/packages/i18n/src/flowLabels.ts | 60 ++++++--- 7 files changed, 256 insertions(+), 65 deletions(-) diff --git a/.changeset/35979-flow-node-label-key.md b/.changeset/35979-flow-node-label-key.md index 495266fc864..1e354c34693 100644 --- a/.changeset/35979-flow-node-label-key.md +++ b/.changeset/35979-flow-node-label-key.md @@ -2,17 +2,21 @@ '@objectstack/spec': minor '@objectstack/lint': minor '@objectstack/cli': minor +'@object-ui/i18n': minor +'@object-ui/components': patch --- feat(spec): every step a flow drawing shows can be translated, under `flows..nodes..label` Clause-②: yes (widening: a new translation key `flows..nodes..label`, and the new exports `FLOW_TECHNICAL_NODE_TYPES` and `isFlowTechnicalNodeType` from `@objectstack/spec/automation`) Metadata-protocol: added -Skills-docs: follow-up owed — skills/objectstack-i18n/SKILL.md +Skills-docs: follow-up owed — skills/objectstack-i18n/SKILL.md (#36401) A package can now translate the label of any flow step, not only a screen's heading and an approval step's label. A manual that embeds a flow (a `type: flow` metadata embed) lists its steps by label, and until now a start, decision, notify or end step had nowhere to put a translation, so a zh-CN reader saw those steps in English beside translated approval steps. - **The key.** `flows..nodes..label`, keyed by the node's `id`, at any depth. It overlays the node's own `label` and is plain text. A `screen` keeps its `screens..title` and an `approval` its `approvals..label`, so one string keeps one key: `objectstack validate` points a `nodes` key over either at that key, and points a `screens` or `approvals` key over any other node at `nodes..label`. A key over a node the flow does not declare is refused. `nodes` was an unknown-key hint that suggested `screens`; it is now its own group. - **Start and end steps are translated like any other.** Their labels are the author's words and often name an outcome or a trigger ("Approved", "On Task Created"), so nothing substitutes words of its own for them. - **Missing translations are reported.** `os lint` and `os i18n check` (`i18n/missing-flow`) now ask for the label of every top-level step the embed draws at its default `detail: business` altitude, except screens and approvals, which they already asked for. `os i18n extract` scaffolds the keys. An app that ships translated locales gets new findings for its flows until it translates them. -- **One table for what business altitude hides.** `FLOW_TECHNICAL_NODE_TYPES` (and `isFlowTechnicalNodeType`) in `@objectstack/spec/automation` lists the node types `detail: business` folds away (`script`, `http`, `connector_action`, `assignment`, `get_record`, `create_record`, `update_record`, `delete_record`, `boundary_event`). The docs viewer and the coverage check read it, so they agree on which steps a reader sees. +- **The drawings read it.** The docs viewer's `type: flow` embed (`element:metadata_viewer`) and the Studio flow designer's canvas, nested region nodes included, now name each step by its translation in the reader's language, through the one resolution in `@object-ui/i18n`: `stepLabel` reads `approvals..label` for an approval, `screens..title` for a screen with no `config.title`, and `nodes..label` for any other node. A step the package leaves untranslated keeps its authored label. A decision's branch list names the step a branch leads to the same way. +- **A titled screen is named by its heading in the docs embed.** A screen that authors its own `config.title` shows that heading at run time, translated under `screens..title`, so the embed names it by the heading (translated where the bundle carries it) instead of its canvas label, which has no key. A heading with a `{{ }}` hole cannot be filled in a drawing, so such a screen keeps its authored label. `FlowLabelTranslations` gains `screenTitle` for this read. The Studio canvas keeps a titled screen's authored label. +- **One table for what business altitude hides.** `FLOW_TECHNICAL_NODE_TYPES` (and `isFlowTechnicalNodeType`) in `@objectstack/spec/automation` lists the node types `detail: business` folds away (`script`, `http`, `connector_action`, `assignment`, `get_record`, `create_record`, `update_record`, `delete_record`, `boundary_event`). The docs viewer folds steps by it and the coverage check asks for translations by it, so they agree on which steps a reader sees. diff --git a/packages/spec/liveness/state-counts/translation.md b/packages/spec/liveness/state-counts/translation.md index a79de1a2ddf..88dbc018bff 100644 --- a/packages/spec/liveness/state-counts/translation.md +++ b/packages/spec/liveness/state-counts/translation.md @@ -12,4 +12,4 @@ committed anywhere: `check:liveness` sums the shards when it reads them. | Type | live | exp | elsewhere | dead | planned | classified | |---|---|---|---|---|---|---| -| `translation` | 47 | 0 | 0 | 0 | 3 | 50 | +| `translation` | 48 | 0 | 0 | 0 | 2 | 50 | diff --git a/packages/spec/liveness/translation.json b/packages/spec/liveness/translation.json index 3d02ea79774..3e10f9a5d30 100644 --- a/packages/spec/liveness/translation.json +++ b/packages/spec/liveness/translation.json @@ -256,14 +256,19 @@ } }, "nodes": { - "status": "planned", + "status": "live", "verifiedAt": "2026-11-22", - "note": "PLANNED RECORD (ruling 7076440876 on objectstack#35979, option A): a flow node's display label, `flows..nodes..label`, for every node but a `screen` (keyed `screens..title`) and an `approval` (keyed `approvals..label`). Declared by the face, refused by `objectstack validate` over an unknown node or a screen/approval node (packages/lint/src/validate-translation-references.ts#validateTranslationReferences), and demanded by the i18n walk for every step the docs flow embed draws at `detail: business` (packages/lint/src/i18n-walk.ts#walkScreenFlows). The reader is the docs viewer's `FlowView` (`element:metadata_viewer`) through the shared flow-label resolution in `@object-ui/i18n`, built in the same change once that resolution is on `main`. Flip to `live` on the commit that lands the reader, citing it. DRILLED to its one key, `label`: the entry's face is closed (`.strict()`).", + "evidenceScope": "in-repo", + "evidence": "ui/packages/i18n/src/flowLabels.ts#flowLabelTranslations (the one resolution of a flow drawing's step names: `stepLabel` reads each `nodes.` entry for its `label`, the drilled child below)", + "note": "FLIPPED planned → live 2026-11-22 on the commit that lands the reader, as this row's planned note prescribed (ruling 7076440876 on objectstack#35979, option A). A flow node's display label, `flows..nodes..label`, for every node but a `screen` (keyed `screens..title`) and an `approval` (keyed `approvals..label`). Refused by `objectstack validate` over an unknown node or a screen/approval node (packages/lint/src/validate-translation-references.ts#validateTranslationReferences), and demanded by the i18n walk for every step the docs flow embed draws at `detail: business` (packages/lint/src/i18n-walk.ts#walkScreenFlows). DRILLED to its one key, `label`: the entry's face is closed (`.strict()`).", "children": { "label": { - "status": "planned", + "status": "live", "verifiedAt": "2026-11-22", - "note": "Planned with its container `flows.nodes` (see that row). Overlays the node's own `FlowNode.label`, plain text, the step name a drawing of the flow shows. Display only: no run, no stored row and no engine-rendered copy reads it." + "evidenceScope": "in-repo", + "evidence": "ui/packages/i18n/src/flowLabels.ts#flowLabelTranslations (`stepLabel` spells `flows..nodes..label` for any node that is not an `approval` or a `screen`, out of the reader's language in the loaded resource tree); ui/packages/components/src/renderers/basic/metadata-viewer.tsx#flowStepName (the docs viewer's `type: flow` embed names each drawn step, and each step a decision branch leads to, by it, else the authored label); ui/packages/app-shell/src/views/metadata-admin/previews/FlowCanvas.tsx#FlowCanvas and ui/packages/app-shell/src/views/metadata-admin/previews/flow-region-view.tsx#RegionNode (the Studio flow designer's canvas, nested region nodes included, by the same `stepLabel`)", + "producer": "ui/packages/i18n/src/flowsBundle.ts#activeFlowsBundle (the app's `flows` group in the reader's language, out of the bundle the host loaded)", + "note": "Overlays the node's own `FlowNode.label`, plain text, the step name a drawing of the flow shows. FLIPPED planned → live 2026-11-22 with its container `flows.nodes` (see that row). Display only: no run, no stored row and no engine-rendered copy reads it. Pinned by ui/packages/components/src/__tests__/metadata-viewer.test.tsx (the docs embed) and ui/packages/app-shell/src/views/metadata-admin/previews/FlowCanvas.test.tsx (the designer); the key spelling is held to `TranslationDataSchema` by packages/cli/test/i18n-flow-node-coverage.test.ts." } } } diff --git a/ui/packages/app-shell/src/views/metadata-admin/previews/FlowCanvas.test.tsx b/ui/packages/app-shell/src/views/metadata-admin/previews/FlowCanvas.test.tsx index 26193c3f6c8..eb3067b97cd 100644 --- a/ui/packages/app-shell/src/views/metadata-admin/previews/FlowCanvas.test.tsx +++ b/ui/packages/app-shell/src/views/metadata-admin/previews/FlowCanvas.test.tsx @@ -612,17 +612,21 @@ describe('FlowCanvas — a node press on a read-only design canvas selects, and /** * The flow designer reads a package's `flows` translations: the flow's label - * (`flows..label`) and an approval node's step label - * (`flows..approvals..label`), in the viewer's language, from - * the bundle `FlowRunner` reads. A decision node and an edge have no key, so - * they stay authored; with no translation everything is authored, as before. + * (`flows..label`) and each step's label by the one key the spec gives + * it — `approvals..label` for an approval, `screens..title` + * for an untitled screen, `nodes..label` for any other node (ruling + * 7076440876), nested nodes included — in the viewer's language, from the + * bundle `FlowRunner` reads. An edge has no key, so it stays authored; with no + * translation everything is authored, as before. */ -describe('Flow designer — package label translations (flows..label, approvals..label)', () => { +describe('Flow designer — package label translations (flows..label, approvals / screens / nodes)', () => { const ZH_CN: TranslationData = { flows: { opportunity_approval: { label: '大额商机审批', approvals: { manager_review: { label: '经理审核' }, director_signoff: { label: '总监签批' } }, + nodes: { big: { label: '超过一百万?' }, tell_signer: { label: '通知签署人' } }, + screens: { confirm: { title: '确认' }, review_deal: { title: '审阅交易' } }, }, }, }; @@ -634,7 +638,15 @@ describe('Flow designer — package label translations (flows..label, appr id: 'each', type: 'loop', label: 'For each signer', - config: { body: { nodes: [{ id: 'director_signoff', type: 'approval', label: 'Director sign-off' }], edges: [] } }, + config: { + body: { + nodes: [ + { id: 'director_signoff', type: 'approval', label: 'Director sign-off' }, + { id: 'tell_signer', type: 'notify', label: 'Tell signer' }, + ], + edges: [{ source: 'director_signoff', target: 'tell_signer' }], + }, + }, }, ]; const EDGES = [ @@ -655,14 +667,25 @@ describe('Flow designer — package label translations (flows..label, appr return t!; }; - it('resolves the flow label and approval-step labels out of the loaded resource tree, and nothing else', () => { + it('resolves the flow label and each step label by its node type out of the loaded resource tree', () => { const t = zh(); expect(t.flowLabel).toBe('大额商机审批'); expect(t.stepLabel({ id: 'manager_review', type: 'approval' })).toBe('经理审核'); expect(t.stepLabel({ id: 'director_signoff', type: 'approval' })).toBe('总监签批'); - // No key for any other node type, even under an approval's id. + // Any other node by `nodes..label`, nested ones included. + expect(t.stepLabel({ id: 'big', type: 'decision' })).toBe('超过一百万?'); + expect(t.stepLabel({ id: 'tell_signer', type: 'notify' })).toBe('通知签署人'); + // An untitled screen by `screens..title`, the key its run-time title already uses. + expect(t.stepLabel({ id: 'confirm', type: 'screen' })).toBe('确认'); + // A titled screen's label has no key: its `screens` title overlays the heading, read apart. + expect(t.stepLabel({ id: 'review_deal', type: 'screen', config: { title: 'Review the deal' } })).toBeUndefined(); + expect(t.screenTitle({ id: 'review_deal', type: 'screen' })).toBe('审阅交易'); + // One string, one key: a type reads its own group only, whatever the id. expect(t.stepLabel({ id: 'manager_review', type: 'decision' })).toBeUndefined(); + expect(t.stepLabel({ id: 'big', type: 'approval' })).toBeUndefined(); + expect(t.stepLabel({ id: 'big', type: 'screen' })).toBeUndefined(); expect(t.stepLabel({ id: 'unknown_step', type: 'approval' })).toBeUndefined(); + expect(t.stepLabel({ type: 'decision' })).toBeUndefined(); // No bundle for the flow: nothing to translate with. expect(flowLabelTranslations(activeFlowsBundle(zhInstance(), 'zh-CN', 'other_flow'), 'other_flow', 'zh-CN')).toBeUndefined(); }); @@ -682,7 +705,7 @@ describe('Flow designer — package label translations (flows..label, appr expect(seen?.stepLabel({ id: 'manager_review', type: 'approval' })).toBe('经理审核'); }); - it('draws the translated approval-step labels on the canvas, nested ones included; decision and branch-edge labels stay authored', () => { + it('draws every translated step label on the canvas, nested ones included; branch-edge labels stay authored', () => { const { container } = render( {}} /> @@ -691,13 +714,18 @@ describe('Flow designer — package label translations (flows..label, appr const card = (id: string) => container.querySelector(`[data-node-id="${id}"]`) as HTMLElement; expect(card('manager_review').textContent).toContain('经理审核'); expect(card('manager_review').textContent).not.toContain('Manager review'); - expect(card('big').textContent).toContain('Over 1M?'); + expect(card('big').textContent).toContain('超过一百万?'); + expect(card('big').textContent).not.toContain('Over 1M?'); + // A node with no translation keeps its authored label. + expect(card('start').textContent).toContain('Start'); // A decision branch's authored edge label has no package key, so it stays as written. (An approval's // `approve` / `reject` outcome pills are the designer's own vocabulary, not the package bundle's.) expect(screen.getByText('Yes, over 1M')).toBeInTheDocument(); fireEvent.click(screen.getByRole('button', { name: 'Expand nested regions' })); expect(card('each').textContent).toContain('总监签批'); expect(card('each').textContent).not.toContain('Director sign-off'); + expect(card('each').textContent).toContain('通知签署人'); + expect(card('each').textContent).not.toContain('Tell signer'); }); it('with no translation the canvas draws the authored labels, as before', () => { @@ -724,10 +752,12 @@ describe('Flow designer — package label translations (flows..label, appr render(); expect(screen.getByText('经理审核')).toBeInTheDocument(); expect(screen.getByTestId('flow-selection-source').textContent).toContain('Manager review'); - // A decision node has no key: authored title, no source line. - const decision = flowSelectionHeading(DRAFT, { kind: 'node', id: 'big' }, undefined, t); - expect(decision.title).toBe('Over 1M?'); - expect(decision).not.toHaveProperty('source'); + // A decision step by its `nodes` key, the same way. + expect(flowSelectionHeading(DRAFT, { kind: 'node', id: 'big' }, undefined, t)).toMatchObject({ title: '超过一百万?', source: 'Over 1M?' }); + // A step the bundle does not translate: authored title, no source line. + const start = flowSelectionHeading(DRAFT, { kind: 'node', id: 'start' }, undefined, t); + expect(start.title).toBe('Start'); + expect(start).not.toHaveProperty('source'); // No translations: exactly as before. expect(flowSelectionHeading(DRAFT, { kind: 'node', id: 'manager_review' })).not.toHaveProperty('source'); expect(flowSelectionHeading(DRAFT, { kind: 'node', id: 'manager_review' }).title).toBe('Manager review'); diff --git a/ui/packages/components/src/__tests__/metadata-viewer.test.tsx b/ui/packages/components/src/__tests__/metadata-viewer.test.tsx index f372841a62a..5ad06a151a1 100644 --- a/ui/packages/components/src/__tests__/metadata-viewer.test.tsx +++ b/ui/packages/components/src/__tests__/metadata-viewer.test.tsx @@ -13,6 +13,7 @@ import { ComponentRegistry } from '@object-ui/core'; import { MetadataCtx } from '@object-ui/react'; import { createI18n, I18nProvider, LocalizationProvider, transformSpecTranslations } from '@object-ui/i18n'; import type { TranslationData } from '@objectstack/spec/system'; +import { FLOW_TECHNICAL_NODE_TYPES } from '@objectstack/spec/automation'; import '../renderers/basic/metadata-viewer'; function metaCtx(getItem: (type: string, name: string) => Promise) { @@ -203,9 +204,9 @@ describe('element:metadata_viewer', () => { * A `type: flow` embed names the flow and each step the spec lets a package * translate in the reader's language: `flows..label` and an `approval` * node's `flows..approvals..label`, read from the package bundle - * the host loaded, through the resolution the Studio flow designer uses. A step - * with no key (start, decision, notify, end) and a key the bundle does not - * carry fall back to the authored text. + * the host loaded, through the resolution the Studio flow designer uses. A key + * the bundle does not carry falls back to the authored text. (Every other + * drawn step's `nodes..label` is pinned in the describe after this.) */ describe('element:metadata_viewer flow embed: package label translations (flows.FLOW.label, approvals.STEP.label)', () => { const OPPORTUNITY_APPROVAL = { @@ -252,7 +253,7 @@ describe('element:metadata_viewer flow embed: package label translations (flows. expect(screen.getByText('销售总监签批')).toBeTruthy(); expect(screen.queryByText('Sales Manager Review')).toBeNull(); expect(screen.queryByText('Sales Director Sign-off')).toBeNull(); - // start, decision, notify and end have no key in the spec's flows group. + // The bundle carries no `nodes` key for start, decision, notify or end, so they keep their authored labels. for (const authored of ['Start', 'High Value (> $500K)?', 'Email Owner — Approved', 'End']) { expect(screen.getByText(authored)).toBeTruthy(); } @@ -312,6 +313,118 @@ describe('element:metadata_viewer flow embed: package label translations (flows. }); }); +/** + * Ruling 7076440876 (objectstack#35979, option A): every step the business + * view draws has a key. A start, decision, notify or end step is named by + * `flows..nodes..label`; an untitled screen by + * `screens..title`; a titled screen by its heading, translated under + * that same key, unless the heading holds a `{{ }}` hole a drawing cannot fill. + * The steps folded away are the spec's `FLOW_TECHNICAL_NODE_TYPES`, the table + * the i18n coverage check reads to ask for exactly these translations. + */ +describe('element:metadata_viewer flow embed: every drawn step by its key (flows.FLOW.nodes.NODE.label)', () => { + function zhCN(data: TranslationData) { + const instance = createI18n({ defaultLanguage: 'zh-CN', detectBrowserLanguage: false }); + instance.addResourceBundle('zh-CN', 'translation', transformSpecTranslations(data as Record), true, true); + return instance; + } + // Each render gets its own instance, so "no bundle" (`{}`) never sees an earlier test's resources. + function renderIn(data: TranslationData, flow: any, getObject?: () => Promise) { + const getItem = vi.fn(async (type: string) => (type === 'object' && getObject ? getObject() : flow)); + return render( + + + , + ); + } + + const ONBOARDING = { + name: 'onboarding', + label: 'Onboarding', + nodes: [ + { id: 'start', type: 'start', label: 'On Hire' }, + { id: 'pick_path', type: 'decision', label: 'Remote?' }, + { id: 'tell_it', type: 'notify', label: 'Tell IT' }, + { id: 'save', type: 'update_record', label: 'Save Hire' }, + { id: 'confirm', type: 'screen', label: 'Confirm' }, + { id: 'welcome', type: 'screen', label: 'Welcome screen', config: { title: 'Welcome aboard' } }, + { id: 'greet', type: 'screen', label: 'Greeting screen', config: { title: 'Hello {{vars.name}}' } }, + { id: 'end', type: 'end', label: 'Onboarded' }, + ], + }; + const ZH: TranslationData = { + flows: { + onboarding: { + nodes: { start: { label: '入职时' }, pick_path: { label: '远程?' }, tell_it: { label: '通知 IT' }, end: { label: '已入职' } }, + screens: { confirm: { title: '确认' }, welcome: { title: '欢迎加入' }, greet: { title: '你好 {{vars.name}}' } }, + }, + }, + }; + + it('names start, decision, notify and end steps by their nodes key, and an untitled screen by its screens title', async () => { + renderIn(ZH, ONBOARDING); + await waitFor(() => expect(screen.getByText('入职时')).toBeTruthy()); + for (const zh of ['远程?', '通知 IT', '已入职', '确认']) expect(screen.getByText(zh)).toBeTruthy(); + for (const en of ['On Hire', 'Remote?', 'Tell IT', 'Onboarded', 'Confirm']) expect(screen.queryByText(en)).toBeNull(); + // The technical record write stays folded away, translated or not. + expect(screen.queryByText('Save Hire')).toBeNull(); + }); + + it('names a titled screen by its heading, translated where the bundle carries it, and keeps the label for a heading with a hole', async () => { + renderIn(ZH, ONBOARDING); + await waitFor(() => expect(screen.getByText('欢迎加入')).toBeTruthy()); + expect(screen.queryByText('Welcome screen')).toBeNull(); + // `Hello {{vars.name}}` cannot be filled in a drawing: the authored label, which has no key, stands. + expect(screen.getByText('Greeting screen')).toBeTruthy(); + expect(screen.queryByText(/你好/)).toBeNull(); + cleanup(); + + // No bundle: the heading itself, untranslated. + renderIn({}, ONBOARDING); + await waitFor(() => expect(screen.getByText('Welcome aboard')).toBeTruthy()); + expect(screen.getByText('On Hire')).toBeTruthy(); + expect(screen.getByText('Greeting screen')).toBeTruthy(); + }); + + it('names the step a decision branch leads to by its nodes key too', async () => { + const flow = { + name: 'onboarding', + label: 'Onboarding', + nodes: [ + { id: 'start', type: 'start', label: 'On Hire', config: { objectName: 'hr_hire' } }, + { id: 'pick_path', type: 'decision', label: 'Remote?' }, + { id: 'tell_it', type: 'notify', label: 'Tell IT' }, + { id: 'end', type: 'end', label: 'Onboarded' }, + ], + edges: [ + { id: 'e1', source: 'start', target: 'pick_path' }, + { id: 'e2', source: 'pick_path', target: 'tell_it', type: 'conditional', condition: { dialect: 'cel', source: 'record.remote == true' } }, + { id: 'e3', source: 'pick_path', target: 'end', isDefault: true }, + ], + }; + const hire = { name: 'hr_hire', fields: { remote: { type: 'boolean', label: 'Remote' } } }; + const { container } = renderIn(ZH, flow, async () => hire); + await waitFor(() => expect(container.querySelector('[data-flow-branches="pick_path"] [data-branch-target="end"]')).toBeTruthy()); + expect(container.querySelector('[data-flow-branches="pick_path"] [data-branch-target="tell_it"]')!.textContent).toContain('通知 IT'); + expect(container.querySelector('[data-flow-branches="pick_path"] [data-branch-target="end"]')!.textContent).toContain('已入职'); + }); + + it('folds away exactly the spec table at business altitude', async () => { + const flow = { + name: 'plumbing', + label: 'Plumbing', + nodes: [ + { id: 'start', type: 'start', label: 'Begin' }, + ...FLOW_TECHNICAL_NODE_TYPES.map((type) => ({ id: `n_${type}`, type, label: `step ${type}` })), + ], + }; + const { container } = renderIn({}, flow); + await waitFor(() => expect(screen.getByText('Begin')).toBeTruthy()); + for (const type of FLOW_TECHNICAL_NODE_TYPES) expect(screen.queryByText(`step ${type}`)).toBeNull(); + expect(container.querySelectorAll('ol > li')).toHaveLength(1); + }); +}); + // objectstack#36094 — the business view draws each decision's branches with // its condition read from the LIVE definition: the served flow, the edges' // `{ dialect: 'cel', source }` envelopes, and the label and currency of the diff --git a/ui/packages/components/src/renderers/basic/metadata-viewer.tsx b/ui/packages/components/src/renderers/basic/metadata-viewer.tsx index e0610844af5..d225e006ed8 100644 --- a/ui/packages/components/src/renderers/basic/metadata-viewer.tsx +++ b/ui/packages/components/src/renderers/basic/metadata-viewer.tsx @@ -28,6 +28,7 @@ import { useDisplayLocale, useFlowLabelTranslations, useLocalization, + type FlowLabelTranslations, useObjectTranslation, } from '@object-ui/i18n'; import type { AriaProps } from '@object-ui/types'; @@ -43,6 +44,7 @@ import { AlertTriangle, } from 'lucide-react'; import type { SelectOption as SpecSelectOption } from '@objectstack/spec/data'; +import { isFlowTechnicalNodeType } from '@objectstack/spec/automation'; import { cn } from '../../lib/utils'; import { readProps } from './readProps'; import { @@ -388,17 +390,31 @@ function StateMachineView({ object, name }: ViewerProps) { // Node-action families that are infrastructure, not business steps. With // `detail: business` (the default), these are folded away so a non-technical // reader sees the process, not the plumbing (ADR-0051 §3.4 altitude projection). -const TECHNICAL_NODE_TYPES = new Set([ - 'script', - 'http', - 'connector_action', - 'assignment', - 'get_record', - 'create_record', - 'update_record', - 'delete_record', - 'boundary_event', -]); +// The table is the spec's (`FLOW_TECHNICAL_NODE_TYPES`), the one the i18n +// coverage check reads to ask a translation for exactly the steps drawn here. + +/** + * What the embed names a step by, in the reader's language where the package + * translates it. + * + * Every step by its label's one key (`approvals` / untitled `screens` / + * `nodes`, `useFlowLabelTranslations`), else the authored label. A screen that + * authors its own `config.title` is named by that heading — the words its + * reader meets at run time, translated under `screens..title` — + * unless the heading holds a `{{ }}` hole a drawing cannot fill; it then keeps + * its authored label, which has no key. + */ +function flowStepName(node: any, translated: FlowLabelTranslations | undefined): string | undefined { + if (!node) return undefined; + const own = translated?.stepLabel(node); + if (own) return own; + const title = node.type === 'screen' ? node.config?.title : undefined; + if (typeof title === 'string' && title) { + const heading = translated?.screenTitle(node) ?? title; + if (!heading.includes('{{')) return heading; + } + return typeof node.label === 'string' && node.label ? node.label : node.id; +} /** * How the business view reads a condition (`flow-branches.ts`): field labels @@ -503,13 +519,13 @@ function Branches({ flow, node, nodes, - stepLabel, + translated, }: { flow: unknown; node: any; nodes: any[]; - /** The step's translated label (`flows..approvals..label`), or `undefined`. */ - stepLabel?: (node: any) => string | undefined; + /** The package's step-label translations ({@link flowStepName}), or `undefined`. */ + translated?: FlowLabelTranslations; }) { const ctx = React.useContext(ConditionScope); const branches = decisionBranches(flow, node); @@ -522,7 +538,7 @@ function Branches({
  • - {(target && stepLabel?.(target)) ?? target?.label ?? b.target} + {flowStepName(target, translated) ?? b.target}
  • ); })} @@ -534,8 +550,9 @@ function FlowView({ name, detail }: ViewerProps) { const { item: flow, loading, error } = useMetadataItem('flow', name ?? null); const { t, ...view } = useViewStates(); // The package's `flows` translations in the reader's language: the flow label - // and each `approval` step's label, the resolution the Studio designer and - // the runner share. Any other step has no key and keeps its authored label. + // and each step's label (`flowStepName`), the resolution the Studio designer + // and the runner share. A step the package leaves untranslated keeps its + // authored label. const translated = useFlowLabelTranslations(name ?? ''); const business = (detail ?? 'business') === 'business'; @@ -545,7 +562,7 @@ function FlowView({ name, detail }: ViewerProps) { if (!flow) return view.notFound(name); const allNodes: any[] = Array.isArray(flow.nodes) ? flow.nodes : []; - const nodes = business ? allNodes.filter((n) => !TECHNICAL_NODE_TYPES.has(n?.type)) : allNodes; + const nodes = business ? allNodes.filter((n) => !isFlowTechnicalNodeType(n?.type)) : allNodes; const hiddenCount = allNodes.length - nodes.length; const card = ( @@ -569,9 +586,7 @@ function FlowView({ name, detail }: ViewerProps) { {i + 1} - {(n && translated?.stepLabel(n)) ?? - n?.label ?? - n?.id ?? + {flowStepName(n, translated) ?? t('element.metadataViewer.untitledStep', { defaultValue: '(step)' })} {n?.type && ( @@ -579,7 +594,7 @@ function FlowView({ name, detail }: ViewerProps) { {n.type} )} - {business && } + {business && } ))} diff --git a/ui/packages/i18n/src/flowLabels.ts b/ui/packages/i18n/src/flowLabels.ts index 5f1bac2999e..03f9f0298bd 100644 --- a/ui/packages/i18n/src/flowLabels.ts +++ b/ui/packages/i18n/src/flowLabels.ts @@ -7,19 +7,24 @@ */ /** - * The two flow labels a surface that DRAWS a flow resolves from the app's - * `flows` translation group (`activeFlowsBundle`, `flowsBundle.ts`): the - * flow's own label (`flows..label`) and an `approval` node's step label - * (`flows..approvals..label`). + * The flow labels a surface that DRAWS a flow resolves from the app's `flows` + * translation group (`activeFlowsBundle`, `flowsBundle.ts`): the flow's own + * label (`flows..label`) and each step's label, from the one key the + * spec gives that step's name: + * + * - an `approval` node: `flows..approvals..label`; + * - a `screen` node with no `config.title`: `flows..screens..title` + * (the executor titles such a screen by its label, so one key covers both); + * - any other node: `flows..nodes..label` (ruling 7076440876). + * + * A screen that authors its own `config.title` is titled apart from its label, + * and its label has no key, so `stepLabel` answers nothing for it. * * The Studio flow designer and the docs viewer's `type: flow` embed * (`element:metadata_viewer`) both read them here, and the flow label goes * through the spec's `translateFlow`, the runner's resolution path, so no two - * surfaces can disagree about what a flow or a step is called. - * - * Only those two keys exist in the spec's `flows` group for a label a flow - * drawing shows. A start, decision, notify or end node's label and an edge - * label have no key, so they stay the authored text. + * surfaces can disagree about what a flow or a step is called. An edge label + * has no key and stays the authored text. * * Display only: nothing here rewrites the flow, so an editor keeps working on * the authored label. @@ -33,8 +38,18 @@ import { activeFlowsBundle } from './flowsBundle.js'; export interface FlowLabelTranslations { /** `flows..label`. */ flowLabel?: string; - /** `flows..approvals..label`, for an `approval` node only. */ - stepLabel: (node: { id?: unknown; type?: unknown }) => string | undefined; + /** + * The step's translated label: `approvals..label` for an `approval`, + * `screens..title` for an untitled `screen`, `nodes..label` + * for any other node. `undefined` for a titled screen and an id-less node. + */ + stepLabel: (node: { id?: unknown; type?: unknown; config?: unknown }) => string | undefined; + /** + * `flows..screens..title` for a `screen` node, titled or not: + * the translated heading the screen shows at run time. A drawing that names + * a titled screen by its heading reads it here. + */ + screenTitle: (node: { id?: unknown; type?: unknown }) => string | undefined; } /** @@ -42,8 +57,8 @@ export interface FlowLabelTranslations { * `undefined` when there is no bundle (nothing to translate with). * * The flow label goes through the spec's `translateFlow`, the runner's - * resolution path; the step label is the spec-typed address - * `flows..approvals..label`, read for `approval` nodes only. + * resolution path; the step label is the spec-typed address of the node's + * name (see the module note), read by node type. */ export function flowLabelTranslations( bundle: TranslationBundle | undefined, @@ -52,14 +67,23 @@ export function flowLabelTranslations( ): FlowLabelTranslations | undefined { if (!bundle || !flowName) return undefined; const flowLabel = translateFlow<{ name: string; label?: string }>({ name: flowName }, bundle, { locale: language }).label; - const approvals = bundle[language]?.flows?.[flowName]?.approvals; + const flow = bundle[language]?.flows?.[flowName]; + const text = (value: unknown) => (typeof value === 'string' && value ? value : undefined); return { - flowLabel: typeof flowLabel === 'string' && flowLabel ? flowLabel : undefined, + flowLabel: text(flowLabel), stepLabel: (node) => { - if (node.type !== 'approval' || typeof node.id !== 'string' || !node.id) return undefined; - const label = approvals?.[node.id]?.label; - return typeof label === 'string' && label ? label : undefined; + if (typeof node.id !== 'string' || !node.id) return undefined; + if (node.type === 'approval') return text(flow?.approvals?.[node.id]?.label); + if (node.type === 'screen') { + const config = node.config && typeof node.config === 'object' ? (node.config as { title?: unknown }) : {}; + return config.title === undefined || config.title === null || config.title === '' + ? text(flow?.screens?.[node.id]?.title) + : undefined; + } + return text(flow?.nodes?.[node.id]?.label); }, + screenTitle: (node) => + node.type === 'screen' && typeof node.id === 'string' && node.id ? text(flow?.screens?.[node.id]?.title) : undefined, }; } From 6f670766b44c02b5ac129ccf86f0fd20373ff314 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 22 Nov 2026 17:51:02 +0000 Subject: [PATCH 09/10] chore(changeset): name every widening on the clause line, and the skills follow-up by its number Co-authored-by: Claude Claude-Session: https://claude.ai/code/session_01QsR2jTrJZvNaijgX3NxBMc --- .changeset/35979-flow-node-label-key.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.changeset/35979-flow-node-label-key.md b/.changeset/35979-flow-node-label-key.md index 1e354c34693..c16d1adc75f 100644 --- a/.changeset/35979-flow-node-label-key.md +++ b/.changeset/35979-flow-node-label-key.md @@ -8,9 +8,9 @@ feat(spec): every step a flow drawing shows can be translated, under `flows..nodes..label` -Clause-②: yes (widening: a new translation key `flows..nodes..label`, and the new exports `FLOW_TECHNICAL_NODE_TYPES` and `isFlowTechnicalNodeType` from `@objectstack/spec/automation`) +Clause-②: yes (widening: a new translation key `flows..nodes..label`; the new exports `FLOW_TECHNICAL_NODE_TYPES` and `isFlowTechnicalNodeType` from `@objectstack/spec/automation`; and `@object-ui/i18n`'s exported `FlowLabelTranslations` type gains the member `screenTitle`, and its `stepLabel` parameter accepts a `config`) Metadata-protocol: added -Skills-docs: follow-up owed — skills/objectstack-i18n/SKILL.md (#36401) +Skills-docs: follow-up #36401 A package can now translate the label of any flow step, not only a screen's heading and an approval step's label. A manual that embeds a flow (a `type: flow` metadata embed) lists its steps by label, and until now a start, decision, notify or end step had nowhere to put a translation, so a zh-CN reader saw those steps in English beside translated approval steps. From 04d28e04f9310fed7f4c981e5f12771d8df2f861 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 22 Nov 2026 18:06:04 +0000 Subject: [PATCH 10/10] fix(lint): ask for a folded step's label where a decision's branch names it The docs flow embed lists each drawn decision's branches and names the step a branch leads to by its label, a folded technical step included (app-todo's check_recurring branches to the compute_next_due_date script). The walk now asks for nodes..label for those targets too, mirroring which out-edges the viewer lists, so the steps the embed names and the steps the coverage check asks for are the same set. The examples' new debt is frozen (showcase +1, todo +2). The nodes docblock says a titled screen's canvas label has no key, and two designer comments name every key stepLabel reads. Co-authored-by: Claude Claude-Session: https://claude.ai/code/session_01QsR2jTrJZvNaijgX3NxBMc --- .changeset/35979-flow-node-label-key.md | 2 +- .../cli/test/i18n-flow-node-coverage.test.ts | 52 +++++++++++++++++-- packages/lint/src/i18n-walk.ts | 52 +++++++++++++++++++ packages/spec/src/automation/flow-altitude.ts | 4 +- packages/spec/src/system/translation.zod.ts | 11 ++-- scripts/i18n-coverage-baseline.json | 4 +- .../previews/flow-label-translations.tsx | 6 ++- .../previews/flow-region-view.tsx | 2 +- 8 files changed, 119 insertions(+), 14 deletions(-) diff --git a/.changeset/35979-flow-node-label-key.md b/.changeset/35979-flow-node-label-key.md index c16d1adc75f..dc6f75efaf3 100644 --- a/.changeset/35979-flow-node-label-key.md +++ b/.changeset/35979-flow-node-label-key.md @@ -16,7 +16,7 @@ A package can now translate the label of any flow step, not only a screen's head - **The key.** `flows..nodes..label`, keyed by the node's `id`, at any depth. It overlays the node's own `label` and is plain text. A `screen` keeps its `screens..title` and an `approval` its `approvals..label`, so one string keeps one key: `objectstack validate` points a `nodes` key over either at that key, and points a `screens` or `approvals` key over any other node at `nodes..label`. A key over a node the flow does not declare is refused. `nodes` was an unknown-key hint that suggested `screens`; it is now its own group. - **Start and end steps are translated like any other.** Their labels are the author's words and often name an outcome or a trigger ("Approved", "On Task Created"), so nothing substitutes words of its own for them. -- **Missing translations are reported.** `os lint` and `os i18n check` (`i18n/missing-flow`) now ask for the label of every top-level step the embed draws at its default `detail: business` altitude, except screens and approvals, which they already asked for. `os i18n extract` scaffolds the keys. An app that ships translated locales gets new findings for its flows until it translates them. +- **Missing translations are reported.** `os lint` and `os i18n check` (`i18n/missing-flow`) now ask for the label of every top-level step the embed draws at its default `detail: business` altitude, except screens and approvals, which they already asked for, and of a folded technical step where a drawn decision's branch list names it as the step the branch leads to (a decision whose branch runs a `script` first). `os i18n extract` scaffolds the keys. An app that ships translated locales gets new findings for its flows until it translates them. - **The drawings read it.** The docs viewer's `type: flow` embed (`element:metadata_viewer`) and the Studio flow designer's canvas, nested region nodes included, now name each step by its translation in the reader's language, through the one resolution in `@object-ui/i18n`: `stepLabel` reads `approvals..label` for an approval, `screens..title` for a screen with no `config.title`, and `nodes..label` for any other node. A step the package leaves untranslated keeps its authored label. A decision's branch list names the step a branch leads to the same way. - **A titled screen is named by its heading in the docs embed.** A screen that authors its own `config.title` shows that heading at run time, translated under `screens..title`, so the embed names it by the heading (translated where the bundle carries it) instead of its canvas label, which has no key. A heading with a `{{ }}` hole cannot be filled in a drawing, so such a screen keeps its authored label. `FlowLabelTranslations` gains `screenTitle` for this read. The Studio canvas keeps a titled screen's authored label. - **One table for what business altitude hides.** `FLOW_TECHNICAL_NODE_TYPES` (and `isFlowTechnicalNodeType`) in `@objectstack/spec/automation` lists the node types `detail: business` folds away (`script`, `http`, `connector_action`, `assignment`, `get_record`, `create_record`, `update_record`, `delete_record`, `boundary_event`). The docs viewer folds steps by it and the coverage check asks for translations by it, so they agree on which steps a reader sees. diff --git a/packages/cli/test/i18n-flow-node-coverage.test.ts b/packages/cli/test/i18n-flow-node-coverage.test.ts index 6f36f40105e..d698b4dfd6f 100644 --- a/packages/cli/test/i18n-flow-node-coverage.test.ts +++ b/packages/cli/test/i18n-flow-node-coverage.test.ts @@ -6,10 +6,11 @@ // The docs viewer's `type: flow` embed (`element:metadata_viewer`) lists a // flow's steps by label for a manual's reader, at `detail: business` by // default: every top-level node whose type `isFlowTechnicalNodeType` does not -// fold away. A screen's and an approval's label were keyed already; a start, +// fold away, and, in a decision's branch list, the step each branch leads to, +// a folded one included. A screen's and an approval's label were keyed already; a start, // decision, notify or end step had no key, so a zh-CN manual named them in // English under a green coverage run. These pins are the CLI half: the walker -// scaffolds `flows..nodes..label` for exactly the drawn steps +// scaffolds `flows..nodes..label` for exactly the named steps // that have no other key, and the coverage gate demands it. // // The ledger mock is `i18n-flow-screen-coverage.test.ts`'s, for its reason: @@ -80,7 +81,7 @@ describe('what the walker harvests for the steps a docs flow embed draws (ruling }); }); - it('asks nothing for a technical step, whichever type the shared table folds away', () => { + it('asks nothing for a technical step no branch names, whichever type the shared table folds away', () => { const flow = { name: 'plumbing', label: 'Plumbing', @@ -90,6 +91,51 @@ describe('what the walker harvests for the steps a docs flow embed draws (ruling expect(nodeKeys({ flows: [flow] })).toEqual([]); }); + it("asks for a folded technical step where a drawn decision's branch list names it, once, and for no other", () => { + // Shaped on app-todo's `task.flow.ts`: `check_recurring` branches to the `compute_next_due_date` script. + const flow = { + name: 'recurring', + label: 'Recurring', + nodes: [ + { id: 'check', type: 'decision', label: 'Recurring?' }, + { id: 'compute', type: 'script', label: 'Compute Next Due Date' }, + { id: 'save', type: 'update_record', label: 'Save' }, + { + id: 'gate', + type: 'decision', + label: 'Gate', + config: { conditions: [{ label: 'Yes', expression: 'vars.ok' }] }, + }, + { id: 'call', type: 'http', label: 'Call Out' }, + { id: 'stray', type: 'assignment', label: 'Stray' }, + { id: 'end', type: 'end', label: 'End' }, + ], + edges: [ + // A decision with no `config.conditions` lists every out-edge. + { id: 'e1', source: 'check', target: 'compute', condition: 'vars.recurring == true', label: 'Yes' }, + { id: 'e2', source: 'check', target: 'end', label: 'No' }, + // The same folded step named by a second branch is asked once. + { id: 'e3', source: 'gate', target: 'compute', label: 'Yes' }, + // A default branch of a `conditions` decision is listed. + { id: 'e4', source: 'gate', target: 'call', isDefault: true }, + // A labelled edge no condition claims is never a branch, so it names nothing. + { id: 'e5', source: 'gate', target: 'stray', label: 'Maybe' }, + // A folded step that only a non-decision leads to is not named. + { id: 'e6', source: 'compute', target: 'save' }, + ], + }; + expect(nodeKeys({ flows: [flow] })).toEqual([ + 'flows.recurring.nodes.check.label', + 'flows.recurring.nodes.gate.label', + 'flows.recurring.nodes.end.label', + 'flows.recurring.nodes.compute.label', + 'flows.recurring.nodes.call.label', + ]); + expect( + collectExpectedEntries({ flows: [flow] }).find((e) => e.path.join('.') === 'flows.recurring.nodes.compute.label'), + ).toMatchObject({ sourceValue: 'Compute Next Due Date', source: 'flow' }); + }); + it('skips a step with no id: nothing could address it', () => { const flow = { ...opportunityApproval, nodes: [{ type: 'decision', label: 'Anonymous' }] }; expect(nodeKeys({ flows: [flow] })).toEqual([]); diff --git a/packages/lint/src/i18n-walk.ts b/packages/lint/src/i18n-walk.ts index 7902ec43ff6..f25862a2074 100644 --- a/packages/lint/src/i18n-walk.ts +++ b/packages/lint/src/i18n-walk.ts @@ -2291,6 +2291,51 @@ function collectFlowNodesDeep(nodes: unknown): any[] { return out; } + +/** The label a decision's fall-through branch carries (`DEFAULT_BRANCH_LABEL` in the engine). */ +const DECISION_DEFAULT_BRANCH = 'default'; + +/** + * The folded technical steps a business-altitude flow drawing still names: the + * top-level `FLOW_TECHNICAL_NODE_TYPES` node a top-level decision's branch + * leads to, in edge order, each once. + * + * Mirrors which out-edges the docs viewer lists as branches + * (`decisionBranches`, `ui/packages/components/src/renderers/basic/flow-branches.ts`): + * every out-edge of a decision with no `config.conditions`; otherwise a + * default edge (`isDefault`, or the `default` label) and an edge whose label a + * condition claims. The viewer finds the target among the top-level nodes + * only, so a region's nested node is not one. + */ +function decisionBranchTechnicalTargets(flow: any, topLevel: any[]): { id: string; label: unknown }[] { + const edges: any[] = Array.isArray(flow?.edges) ? flow.edges : []; + const byId = new Map(); + for (const node of topLevel) { + if (node && typeof node === 'object' && typeof node.id === 'string' && node.id) byId.set(node.id, node); + } + const seen = new Set(); + const targets: { id: string; label: unknown }[] = []; + for (const node of topLevel) { + if (!node || typeof node !== 'object' || node.type !== 'decision' || typeof node.id !== 'string') continue; + const conditions: any[] = Array.isArray(node.config?.conditions) + ? node.config.conditions.filter((c: unknown) => c !== null && typeof c === 'object' && !Array.isArray(c)) + : []; + for (const edge of edges) { + if (!edge || typeof edge !== 'object' || edge.source !== node.id || typeof edge.target !== 'string') continue; + const listed = + conditions.length === 0 || + edge.isDefault === true || + edge.label === DECISION_DEFAULT_BRANCH || + conditions.some((c) => typeof edge.label === 'string' && c.label === edge.label); + if (!listed) continue; + const target = byId.get(edge.target); + if (!target || !isFlowTechnicalNodeType(target.type) || seen.has(target.id)) continue; + seen.add(target.id); + targets.push({ id: target.id, label: target.label }); + } + } + return targets; +} /** * Emit the screen-flow copy surface (#7646, resolver landed in #11287). * @@ -2554,6 +2599,13 @@ function walkScreenFlows(config: any, out: ExpectedEntry[]): void { if (!nodeId) continue; pushOptional(out, ['flows', flowName, 'nodes', nodeId, 'label'], node.label, 'flow', scope); } + // The same embed lists each drawn decision's branches and names the step a + // branch leads to by its label, folded technical steps included (a + // decision whose branch runs a `script` first). Those folded targets are + // drawn words too, so they are asked once each, after the drawn steps. + for (const target of decisionBranchTechnicalTargets(flow, topLevel)) { + pushOptional(out, ['flows', flowName, 'nodes', target.id, 'label'], target.label, 'flow', scope); + } } } diff --git a/packages/spec/src/automation/flow-altitude.ts b/packages/spec/src/automation/flow-altitude.ts index cc20906ad2b..4713f1bead2 100644 --- a/packages/spec/src/automation/flow-altitude.ts +++ b/packages/spec/src/automation/flow-altitude.ts @@ -16,7 +16,9 @@ * which steps a manual's reader sees; * - the i18n walk (`packages/lint`, `i18n/missing-flow`), which demands a * translated label, `flows..nodes..label`, for exactly the - * steps that viewer draws at its default altitude (ruling 7076440876). + * steps that viewer names at its default altitude (ruling 7076440876): + * every step it draws, and a folded step only where a drawn decision's + * branch list names it as the step the branch leads to. * * Display only: nothing here changes how a flow runs. */ diff --git a/packages/spec/src/system/translation.zod.ts b/packages/spec/src/system/translation.zod.ts index 0f7b8b626eb..b91b7d2c59d 100644 --- a/packages/spec/src/system/translation.zod.ts +++ b/packages/spec/src/system/translation.zod.ts @@ -1930,10 +1930,13 @@ const appTranslationDataShape = () => ({ * - **Grouped by what it overlays, not by node type.** Every other group * addresses one node type; this one addresses the node label of every * node whose label has no key of its own, at any depth (an ADR-0031 region - * included). That excludes two types, each keyed already, so one string - * keeps one key: a `screen` (its `screens..title` covers - * `config.title ?? node.label`) and an `approval` (`approvals..label`). - * `objectstack validate` points a `nodes` key over either at that key. + * included). That excludes two types, each of which has a key of its + * own, so one string keeps one key: an `approval` (`approvals..label`) + * and a `screen`, whose `screens..title` covers + * `config.title ?? node.label`. A screen that authors its own `config.title` + * is titled apart from its label, so its canvas label has no key; a drawing + * names such a screen by its heading instead. `objectstack validate` + * points a `nodes` key over either type at its own key. * - **Start and end nodes included.** Their labels are the author's words * like any other step's, and often name an outcome or a trigger * ("Approved", "On Task Created"), so a viewer does not substitute words of diff --git a/scripts/i18n-coverage-baseline.json b/scripts/i18n-coverage-baseline.json index 8fdf34782b4..7b79224de47 100644 --- a/scripts/i18n-coverage-baseline.json +++ b/scripts/i18n-coverage-baseline.json @@ -1,8 +1,8 @@ { "examples/app-crm/objectstack.config.ts": 0, "examples/app-multi-package/objectstack.config.ts": 0, - "examples/app-showcase/objectstack.config.ts": 424, - "examples/app-todo/objectstack.config.ts": 128, + "examples/app-showcase/objectstack.config.ts": 425, + "examples/app-todo/objectstack.config.ts": 130, "packages/platform-objects/scripts/i18n-extract.config.ts": 0, "packages/plugins/plugin-approvals/scripts/i18n-extract.config.ts": 0, "packages/plugins/plugin-audit/scripts/i18n-extract.config.ts": 0, diff --git a/ui/packages/app-shell/src/views/metadata-admin/previews/flow-label-translations.tsx b/ui/packages/app-shell/src/views/metadata-admin/previews/flow-label-translations.tsx index 9840ce7ea6b..91456cd2703 100644 --- a/ui/packages/app-shell/src/views/metadata-admin/previews/flow-label-translations.tsx +++ b/ui/packages/app-shell/src/views/metadata-admin/previews/flow-label-translations.tsx @@ -2,8 +2,10 @@ /** * The flow designer's reading of a package's `flows` translations: the flow's - * own label (`flows..label`) and an `approval` node's step label - * (`flows..approvals..label`), in the viewer's language. + * own label (`flows..label`) and each step's label by the one key its + * node type has (`approvals..label`, an untitled screen's + * `screens..title`, any other node's `nodes..label`), in the + * viewer's language. * * The resolution itself is `@object-ui/i18n`'s (`flowLabelTranslations` over * `activeFlowsBundle`), the one the runner and the docs viewer's flow embed diff --git a/ui/packages/app-shell/src/views/metadata-admin/previews/flow-region-view.tsx b/ui/packages/app-shell/src/views/metadata-admin/previews/flow-region-view.tsx index e02f27bffc8..da2f261b510 100644 --- a/ui/packages/app-shell/src/views/metadata-admin/previews/flow-region-view.tsx +++ b/ui/packages/app-shell/src/views/metadata-admin/previews/flow-region-view.tsx @@ -61,7 +61,7 @@ function RegionNode({ }) { const tone = nodeTone(node.type); const interactive = !!onSelect; - // An approval step's label in the viewer's language, where the package translates it. + // The step's label in the viewer's language, where the package translates it (`stepLabel`, any node type). const labelTranslations = useFlowLabelTranslationsContext(); return (