From c5ed959dd26c56ce9dbf33272aaa4f5fd24ba44f Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 17 Nov 2026 16:43:37 +0000 Subject: [PATCH 1/6] fix(app-shell): flow designer reads the package's flow and approval-step label translations Claude-Session: https://claude.ai/code/session_01WGufzi3ezPzTysQPDEjmVz Co-authored-by: Claude --- .../metadata-admin/previews/FlowCanvas.tsx | 5 +- .../metadata-admin/previews/FlowPreview.tsx | 37 ++++++++- .../previews/flow-label-translations.tsx | 77 +++++++++++++++++++ .../previews/flow-region-view.tsx | 7 +- .../studio-design/StudioDesignSurface.tsx | 10 ++- ui/packages/i18n/src/namespaces/studio/en.ts | 1 + ui/packages/i18n/src/namespaces/studio/zh.ts | 1 + 7 files changed, 129 insertions(+), 9 deletions(-) create mode 100644 ui/packages/app-shell/src/views/metadata-admin/previews/flow-label-translations.tsx diff --git a/ui/packages/app-shell/src/views/metadata-admin/previews/FlowCanvas.tsx b/ui/packages/app-shell/src/views/metadata-admin/previews/FlowCanvas.tsx index 776392e9d92..b019c763660 100644 --- a/ui/packages/app-shell/src/views/metadata-admin/previews/FlowCanvas.tsx +++ b/ui/packages/app-shell/src/views/metadata-admin/previews/FlowCanvas.tsx @@ -38,6 +38,7 @@ import { AlertCircle, AlertTriangle, Maximize2, Plus, ZoomIn, ZoomOut } from 'lu import { cn } from '@object-ui/components'; import { uniqueId, appendArray, spliceArray } from '../inspectors/_shared.js'; import { t as tr, tFormat } from '../i18n.js'; +import { useFlowLabelTranslationsContext } from './flow-label-translations.js'; import { computeLayoutWithGeometry, NODE_W, @@ -216,6 +217,8 @@ export function FlowCanvas({ // has an index signature). Same reference when nothing needed migrating, so // the memos keyed on `nodes` are unaffected. const nodes = React.useMemo(() => withCanonicalGeometry(storedNodes), [storedNodes]); + // An approval step's label in the viewer's language, where the package translates it. + const labelTranslations = useFlowLabelTranslationsContext(); const viewportRef = React.useRef(null); // objectui#11795 — the viewport width the diagram was last framed at (the @@ -1269,7 +1272,7 @@ export function FlowCanvas({ id={node.id} locale={locale} type={node.type} - label={node.label || node.id} + label={labelTranslations?.stepLabel(node) ?? (node.label || node.id)} summary={nodeSummary(node, locale, objectLabels)} position={pos} selected={selectedId === node.id} diff --git a/ui/packages/app-shell/src/views/metadata-admin/previews/FlowPreview.tsx b/ui/packages/app-shell/src/views/metadata-admin/previews/FlowPreview.tsx index 70659175020..55dd918a8ca 100644 --- a/ui/packages/app-shell/src/views/metadata-admin/previews/FlowPreview.tsx +++ b/ui/packages/app-shell/src/views/metadata-admin/previews/FlowPreview.tsx @@ -39,8 +39,9 @@ import type { MetadataPreviewProps, MetadataSelection } from '../preview-registr import { PreviewShell, PreviewMessage, PreviewErrorBoundary } from './PreviewShell.js'; import { appendArray } from '../inspectors/_shared.js'; import { useObjectCatalog, type ObjectCatalogEntry } from '../inspectors/ObjectPicker.js'; -import { t as tr, translateFlowMeta } from '../i18n.js'; +import { t as tr, tFormat, translateFlowMeta } from '../i18n.js'; import { FlowCanvas } from './FlowCanvas.js'; +import { FlowLabelTranslationsProvider, useFlowLabelTranslations, type FlowLabelTranslations } from './flow-label-translations.js'; import { defaultNodeLabel, flowEdgeDisplayName, flowNodeDisplayName } from './flow-canvas-parts.js'; import { edgeKey, type FlowDesignerEdge, type FlowDesignerNode } from './flow-canvas-layout.js'; import { NESTED_NODE_KIND, parseNestedNodeId, encodeNestedNodeId, locateFlowNode } from '../inspectors/flow-nested-selection.js'; @@ -125,12 +126,18 @@ export function FlowPreviewChromeProvider({ value, children }: { value: FlowPrev * node with its type's display name ("Node · Decision"), or a connection — and * the title is the one the inspector's own header would show (the node's label * or id; the connection's `source → target`, each end by its node's name). + * + * An `approval` node's title is its step label in the viewer's language when + * the package bundle carries one (`translations`, see + * `flow-label-translations.tsx`); `source` is then the authored label, which + * the header shows beside it, since Studio is where that label is authored. */ export function flowSelectionHeading( draft: Record, selection: MetadataSelection, locale?: string, -): { eyebrow: string; title: string } { + translations?: FlowLabelTranslations, +): { eyebrow: string; title: string; source?: string } { if (selection.kind === 'edge') { const edges = Array.isArray(draft.edges) ? (draft.edges as FlowDesignerEdge[]) : []; const edge = edges.find((e, i) => edgeKey(e, i) === selection.id); @@ -150,12 +157,32 @@ export function flowSelectionHeading( return { eyebrow: kind, title: selection.label ?? nested?.nodeId ?? selection.id }; } const type = typeof node.type === 'string' ? node.type : ''; + const authored = (typeof node.label === 'string' && node.label) || node.id; + const translated = translations?.stepLabel(node); return { eyebrow: type ? `${kind} · ${defaultNodeLabel(type, locale)}` : kind, - title: (typeof node.label === 'string' && node.label) || node.id, + title: translated ?? authored, + ...(translated !== undefined && translated !== authored ? { source: authored } : {}), }; } +/** + * A {@link flowSelectionHeading}'s title as a host's inspector header draws + * it: the title, and under it the authored label when a translation stands in + * for it. + */ +export function FlowSelectionTitle({ heading, locale }: { heading: { title: string; source?: string }; locale?: string }) { + if (heading.source === undefined) return <>{heading.title}; + return ( + <> + {heading.title} + + {tFormat('engine.inspector.flowNode.sourceLabel', locale, { label: heading.source })} + + + ); +} + /** * The header's Trigger pill (objectui#11779): the trigger the engine arms this * flow on, read from its Start node by the spec's own resolver @@ -460,6 +487,7 @@ export function FlowPreview({ draft, editing, selection, onSelectionChange, onPa // Run history needs the published flow name (the engine keys runs by it). const flowName = typeof d.name === 'string' && d.name ? d.name : ''; + const labelTranslations = useFlowLabelTranslations(flowName); const empty = canEdit ? (
@@ -485,6 +513,8 @@ export function FlowPreview({ draft, editing, selection, onSelectionChange, onPa const canvasEl = nodes.length === 0 ? (
{empty}
) : ( + // The approval steps' labels in the viewer's language (flow-label-translations.tsx). + + ); // The bar's four panel toggles, as the designer has them: one panel at a time beside the canvas. 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 new file mode 100644 index 00000000000..a0d456de62e --- /dev/null +++ b/ui/packages/app-shell/src/views/metadata-admin/previews/flow-label-translations.tsx @@ -0,0 +1,77 @@ +// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license. + +/** + * 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. + * + * The bundle is the one `FlowRunner` reads, `activeFlowsBundle` over the + * i18next resource tree the console already loaded, and the flow label goes + * through the spec's `translateFlow`, the runner's resolution path. So the + * designer and the runner cannot disagree about a flow's name, and there is no + * second loader. + * + * Only those two keys exist in the spec's `flows` group for a label the + * designer draws. A decision or other node's label and an edge label have no + * key, so they stay the authored text. + * + * Display only: the draft is never rewritten with a translation, so an edit, + * a rename or a save keeps working on the authored label. Studio is the + * authoring surface, so the inspector also shows the authored label beside a + * translation (`flowSelectionHeading`'s `source`). + */ + +import * as React from 'react'; +import { useObjectTranslation } from '@object-ui/react'; +import { translateFlow, type TranslationBundle } from '@objectstack/spec/system'; +import { activeFlowsBundle } from '../../../utils/flowsBundle.js'; + +/** A flow's translated labels in one language. Every member answers `undefined` where the bundle carries nothing. */ +export interface FlowLabelTranslations { + /** `flows..label`. */ + flowLabel?: string; + /** `flows..approvals..label`, for an `approval` node only. */ + stepLabel: (node: { id?: unknown; type?: unknown }) => string | undefined; +} + +/** + * The translated labels for `flowName` out of `bundle` in `language`, or + * `undefined` when there is no bundle (nothing to translate with). + */ +export function flowLabelTranslations( + bundle: TranslationBundle | undefined, + flowName: string, + language: string, +): FlowLabelTranslations | undefined { + if (!bundle || !flowName) return undefined; + const flowLabel = translateFlow({ name: flowName }, bundle, { locale: language }).label; + const approvals = bundle[language]?.flows?.[flowName]?.approvals; + return { + flowLabel: typeof flowLabel === 'string' && flowLabel ? flowLabel : undefined, + 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; + }, + }; +} + +/** + * {@link flowLabelTranslations} for `flowName` in the console's active + * language. Recomputed on every render: a handful of property reads that + * follow the live resource tree and a language switch. + */ +export function useFlowLabelTranslations(flowName: string): FlowLabelTranslations | undefined { + const { i18n, language } = useObjectTranslation(); + return flowLabelTranslations(activeFlowsBundle(i18n, language, flowName), flowName, language); +} + +const FlowLabelTranslationsContext = React.createContext(undefined); + +/** Hands {@link FlowLabelTranslations} to the canvas below it. */ +export const FlowLabelTranslationsProvider = FlowLabelTranslationsContext.Provider; + +/** The translations the nearest provider hands in, or `undefined` outside one. */ +export function useFlowLabelTranslationsContext(): FlowLabelTranslations | undefined { + return React.useContext(FlowLabelTranslationsContext); +} 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 97125b785af..348dd59fff3 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 @@ -37,6 +37,7 @@ import { REGION_BLOCK_PAD, REGION_GAP, REGION_LABEL_H } from './flow-region-metr // stable region `key`. It lives in its own module so the nested-node inspector // breadcrumb reads the same rows (objectui#10696). import { displayRegionLabel } from './flow-region-label.js'; +import { useFlowLabelTranslationsContext } from './flow-label-translations.js'; /** * Node box inside a region — a compact echo of `NodeCard`. Read-only by default @@ -60,6 +61,8 @@ 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. + const label = useFlowLabelTranslationsContext()?.stepLabel(node) ?? (node.label || node.id); return (
-
- {node.label || node.id} +
+ {label}
{node.type}
diff --git a/ui/packages/app-shell/src/views/studio-design/StudioDesignSurface.tsx b/ui/packages/app-shell/src/views/studio-design/StudioDesignSurface.tsx index dbae4173e7c..96999be8856 100644 --- a/ui/packages/app-shell/src/views/studio-design/StudioDesignSurface.tsx +++ b/ui/packages/app-shell/src/views/studio-design/StudioDesignSurface.tsx @@ -385,11 +385,13 @@ import { import { FlowMetaPills, FlowPreviewChromeProvider, + FlowSelectionTitle, flowSelectionHeading, type FlowPreviewSection, type FlowProblemTally, } from '../metadata-admin/previews/FlowPreview.js'; import { InspectorShellHostProvider } from '../metadata-admin/inspectors/_shared.js'; +import { useFlowLabelTranslations } from '../metadata-admin/previews/flow-label-translations.js'; import type { FlowRegistration } from '@objectstack/spec/api'; import { navEntryLabelText, @@ -8229,6 +8231,8 @@ export function AutomationsPillar({ dialog: flowConflictDialog, } = useDraftSaveGuard(client, reloadFlowDraft); const [selection, setSelection] = React.useState(null); + // The package's translations of the flow label and its approval-step labels (flow-label-translations.tsx). + const flowLabels = useFlowLabelTranslations(current?.name ?? ''); const [loading, setLoading] = React.useState(false); const [saving, setSaving] = React.useState(false); const [hasDraft, setHasDraft] = React.useState(false); @@ -9425,7 +9429,7 @@ export function AutomationsPillar({ } icon={current ? Workflow : undefined} - title={current ? current.label || current.name : t('engine.studio.auto.heading', locale)} + title={current ? flowLabels?.flowLabel || current.label || current.name : t('engine.studio.auto.heading', locale)} titleProps={ current ? { 'data-testid': 'auto-canvas-caption', title: `${t('designer.field.apiName', locale)}: ${current.name}` } @@ -9721,13 +9725,13 @@ export function AutomationsPillar({ // draws none of its own (`InspectorShellHostProvider`). With nothing // selected the aside keeps its "Configuration" eyebrow. const heading = - selection && inspector && current && flowLoaded ? flowSelectionHeading(draft, selection, locale) : null; + selection && inspector && current && flowLoaded ? flowSelectionHeading(draft, selection, locale, flowLabels) : null; const aside = ( } onClose={selection ? () => setSelection(null) : undefined} closeLabel={t('engine.studio.deselect', locale)} // objectui#12453 — a read-only package saves no draft: no footer. diff --git a/ui/packages/i18n/src/namespaces/studio/en.ts b/ui/packages/i18n/src/namespaces/studio/en.ts index a4047ddf404..435a9bc37c5 100644 --- a/ui/packages/i18n/src/namespaces/studio/en.ts +++ b/ui/packages/i18n/src/namespaces/studio/en.ts @@ -676,6 +676,7 @@ const STUDIO_EN: Record = { // Flow node inspector 'engine.inspector.flowNode.kind': 'Node', 'engine.inspector.flowNode.close': 'Close node', + 'engine.inspector.flowNode.sourceLabel': 'Authored label: “{label}”', 'engine.inspector.flowNode.id': 'ID', // objectui#11827 — the ID field's inline refusal of a rename that cannot land; // the field shows the stored id again, so each says nothing was renamed. diff --git a/ui/packages/i18n/src/namespaces/studio/zh.ts b/ui/packages/i18n/src/namespaces/studio/zh.ts index 099ce4c6078..fde5e2b91a9 100644 --- a/ui/packages/i18n/src/namespaces/studio/zh.ts +++ b/ui/packages/i18n/src/namespaces/studio/zh.ts @@ -582,6 +582,7 @@ const STUDIO_ZH: Record = { // Flow node inspector 'engine.inspector.flowNode.kind': '节点', 'engine.inspector.flowNode.close': '关闭节点', + 'engine.inspector.flowNode.sourceLabel': '原文标签:“{label}”', 'engine.inspector.flowNode.id': 'ID', 'engine.inspector.flowNode.idRequired': '未重命名:节点必须有 ID。', 'engine.inspector.flowNode.idTaken': '未重命名:此流程中已有另一个节点的 ID 是“{id}”。', From 024c9272ca94430af20efa4ef03e264ec405dc7b Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 17 Nov 2026 16:45:52 +0000 Subject: [PATCH 2/6] test(app-shell): pin the flow designer's package label translations; changeset Claude-Session: https://claude.ai/code/session_01WGufzi3ezPzTysQPDEjmVz Co-authored-by: Claude --- .../34903-flow-designer-label-translations.md | 15 ++ .../previews/FlowCanvas.test.tsx | 133 ++++++++++++++++++ 2 files changed, 148 insertions(+) create mode 100644 .changeset/34903-flow-designer-label-translations.md diff --git a/.changeset/34903-flow-designer-label-translations.md b/.changeset/34903-flow-designer-label-translations.md new file mode 100644 index 00000000000..5cf99c2a020 --- /dev/null +++ b/.changeset/34903-flow-designer-label-translations.md @@ -0,0 +1,15 @@ +--- +'@object-ui/app-shell': patch +'@object-ui/i18n': patch +--- + +fix(app-shell): the Studio flow designer shows a package's translated flow label and approval-step labels + +Clause-②: yes +Metadata-protocol: none + +A package can translate a flow's label (`flows..label`) and an approval step's label (`flows..approvals..label`). The flow runner already used both. The Studio flow designer ignored them, so a zh-CN admin saw the authored English flow name and step names. The designer now reads the same bundle the runner reads, through the spec's `translateFlow`, in the viewer's language. The automation header names the flow by its translation. Approval nodes show their translated step label on the canvas (nested ones included) and in the inspector header. The inspector also shows the authored label on a second line ("Authored label: …"), because Studio is where that label is edited. With no translation, every label shows as authored, as before. The draft is never rewritten with a translation. + +The spec has no key for a decision or other node's label, or for an edge label, so those still show the authored text. + +`@object-ui/i18n` gains one lazy `studio`-namespace key, `engine.inspector.flowNode.sourceLabel` (en and zh). The eager `locales/en.ts` pack is unchanged. 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 364e815a31f..16aa9a5c036 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 @@ -8,6 +8,16 @@ import { extractRegions, NODE_H } from './flow-canvas-layout'; import { predictExpandedNodeHeight } from './flow-region-metrics'; import type { FlowProblem } from './flow-problems'; import { browserClick, browserDrag } from './__tests__/browserClick'; +import { createI18n, I18nProvider, transformSpecTranslations } from '@object-ui/i18n'; +import type { TranslationData } from '@objectstack/spec/system'; +import { FlowPreview, FlowSelectionTitle, flowSelectionHeading } from './FlowPreview'; +import { + FlowLabelTranslationsProvider, + flowLabelTranslations, + useFlowLabelTranslations, + type FlowLabelTranslations, +} from './flow-label-translations'; +import { activeFlowsBundle } from '../../../utils/flowsBundle'; afterEach(cleanup); @@ -596,3 +606,126 @@ describe('FlowCanvas — a node press on a read-only design canvas selects, and expect(onPatch).not.toHaveBeenCalled(); }); }); + + +/** + * 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. + */ +describe('Flow designer — package label translations (flows..label, approvals..label)', () => { + const ZH_CN: TranslationData = { + flows: { + opportunity_approval: { + label: '大额商机审批', + approvals: { manager_review: { label: '经理审核' }, director_signoff: { label: '总监签批' } }, + }, + }, + }; + const NODES = [ + { id: 'start', type: 'start', label: 'Start' }, + { id: 'manager_review', type: 'approval', label: 'Manager review' }, + { id: 'big', type: 'decision', label: 'Over 1M?' }, + { + id: 'each', + type: 'loop', + label: 'For each signer', + config: { body: { nodes: [{ id: 'director_signoff', type: 'approval', label: 'Director sign-off' }], edges: [] } }, + }, + ]; + const EDGES = [ + { source: 'start', target: 'manager_review' }, + { source: 'manager_review', target: 'big', label: 'approve' }, + { source: 'big', target: 'each' }, + ]; + const DRAFT = { name: 'opportunity_approval', label: 'Large Deal Approval', nodes: NODES, edges: EDGES }; + + function zhInstance() { + const instance = createI18n({ defaultLanguage: 'zh-CN', detectBrowserLanguage: false }); + instance.addResourceBundle('zh-CN', 'translation', transformSpecTranslations(ZH_CN as Record), true, true); + return instance; + } + const zh = (): FlowLabelTranslations => { + const t = flowLabelTranslations(activeFlowsBundle(zhInstance(), 'zh-CN', 'opportunity_approval'), 'opportunity_approval', 'zh-CN'); + expect(t).toBeDefined(); + return t!; + }; + + it('resolves the flow label and approval-step labels out of the loaded resource tree, and nothing else', () => { + 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. + expect(t.stepLabel({ id: 'manager_review', type: 'decision' })).toBeUndefined(); + expect(t.stepLabel({ id: 'unknown_step', type: 'approval' })).toBeUndefined(); + // No bundle for the flow: nothing to translate with. + expect(flowLabelTranslations(activeFlowsBundle(zhInstance(), 'zh-CN', 'other_flow'), 'other_flow', 'zh-CN')).toBeUndefined(); + }); + + it('useFlowLabelTranslations reads the console provider’s active language', () => { + let seen: FlowLabelTranslations | undefined; + function Probe() { + seen = useFlowLabelTranslations('opportunity_approval'); + return null; + } + render( + + + , + ); + expect(seen?.flowLabel).toBe('大额商机审批'); + expect(seen?.stepLabel({ id: 'manager_review', type: 'approval' })).toBe('经理审核'); + }); + + it('draws the translated approval-step labels on the canvas, nested ones included; decision and edge labels stay authored', () => { + const { container } = render( + + {}} /> + , + ); + 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(screen.getByText('approve')).toBeInTheDocument(); + fireEvent.click(screen.getByRole('button', { name: 'Expand nested regions' })); + expect(card('each').textContent).toContain('总监签批'); + expect(card('each').textContent).not.toContain('Director sign-off'); + }); + + it('with no translation the canvas draws the authored labels, as before', () => { + const { container } = render( + {}} />, + ); + expect((container.querySelector('[data-node-id="manager_review"]') as HTMLElement).textContent).toContain('Manager review'); + }); + + it('FlowPreview hands the bundle in from the console provider', () => { + vi.stubGlobal('fetch', vi.fn(async () => new Response('not found', { status: 404 }))); + const { container } = render( + + {}} /> + , + ); + expect((container.querySelector('[data-node-id="manager_review"]') as HTMLElement).textContent).toContain('经理审核'); + }); + + it('the inspector header titles an approval step by its translation and shows the authored label beside it', () => { + const t = zh(); + const top = flowSelectionHeading(DRAFT, { kind: 'node', id: 'manager_review' }, undefined, t); + expect(top).toMatchObject({ title: '经理审核', source: 'Manager review' }); + 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. + expect(flowSelectionHeading(DRAFT, { kind: 'node', id: 'big' }, undefined, t)).toEqual( + expect.objectContaining({ title: 'Over 1M?', source: undefined }), + ); + // 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'); + }); +}); From d3f81b31fc52803afdf29fd4fa4090e420141a43 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 17 Nov 2026 17:05:02 +0000 Subject: [PATCH 3/6] test(app-shell): assert the decision heading carries no source line Claude-Session: https://claude.ai/code/session_01WGufzi3ezPzTysQPDEjmVz Co-authored-by: Claude --- .../src/views/metadata-admin/previews/FlowCanvas.test.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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 16aa9a5c036..ba4cb0e169c 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 @@ -721,9 +721,9 @@ describe('Flow designer — package label translations (flows..label, appr 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. - expect(flowSelectionHeading(DRAFT, { kind: 'node', id: 'big' }, undefined, t)).toEqual( - expect.objectContaining({ title: 'Over 1M?', source: undefined }), - ); + const decision = flowSelectionHeading(DRAFT, { kind: 'node', id: 'big' }, undefined, t); + expect(decision.title).toBe('Over 1M?'); + expect(decision).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'); From ba47b53c7f1ebc7e33f2970479dea1aa52325f5a Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 17 Nov 2026 17:23:12 +0000 Subject: [PATCH 4/6] test(app-shell): keep the region-view sites distinct in the 13200 ledger; pay the lint load at collection Claude-Session: https://claude.ai/code/session_01WGufzi3ezPzTysQPDEjmVz Co-authored-by: Claude --- .../src/views/metadata-admin/previews/FlowCanvas.test.tsx | 2 ++ .../views/metadata-admin/previews/flow-region-view.tsx | 6 +++--- .../previews/flowNodeLabels.sites-13200.test.ts | 8 ++++---- 3 files changed, 9 insertions(+), 7 deletions(-) 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 ba4cb0e169c..946e3c8cf83 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 @@ -8,6 +8,8 @@ import { extractRegions, NODE_H } from './flow-canvas-layout'; import { predictExpandedNodeHeight } from './flow-region-metrics'; import type { FlowProblem } from './flow-problems'; import { browserClick, browserDrag } from './__tests__/browserClick'; +// FlowPreview reaches a dynamic `import('@objectstack/lint')`; pay its load at collection, not in a test's clock. +import '@objectstack/lint'; import { createI18n, I18nProvider, transformSpecTranslations } from '@object-ui/i18n'; import type { TranslationData } from '@objectstack/spec/system'; import { FlowPreview, FlowSelectionTitle, flowSelectionHeading } from './FlowPreview'; 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 348dd59fff3..e02f27bffc8 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 @@ -62,7 +62,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. - const label = useFlowLabelTranslationsContext()?.stepLabel(node) ?? (node.label || node.id); + const labelTranslations = useFlowLabelTranslationsContext(); return (
-
- {label} +
+ {labelTranslations?.stepLabel(node) ?? (node.label || node.id)}
{node.type}
diff --git a/ui/packages/app-shell/src/views/metadata-admin/previews/flowNodeLabels.sites-13200.test.ts b/ui/packages/app-shell/src/views/metadata-admin/previews/flowNodeLabels.sites-13200.test.ts index 4c8b63b046f..e40c3b2a8d5 100644 --- a/ui/packages/app-shell/src/views/metadata-admin/previews/flowNodeLabels.sites-13200.test.ts +++ b/ui/packages/app-shell/src/views/metadata-admin/previews/flowNodeLabels.sites-13200.test.ts @@ -276,10 +276,10 @@ const ID_SITES: Record = { 'inspectors/FlowEdgeInspector.tsx · label-or-id · title={selection.label ?? selection.id}': 'selection-label', "inspectors/FlowNodeInspector.tsx · label-or-id · ": 'selection-label', // ── own-title: own title beside the type eyebrow; resolver would repeat the type (ruled B on objectui#13200) ── - 'previews/FlowCanvas.tsx · label-or-id · label={node.label || node.id}': 'own-title', - "previews/FlowPreview.tsx · label-or-id · title: (typeof node.label === 'string' && node.label) || node.id,": 'own-title', - 'previews/flow-region-view.tsx · label-or-id ·
': 'own-title', - 'previews/flow-region-view.tsx · label-or-id · {node.label || node.id}': 'own-title', + 'previews/FlowCanvas.tsx · label-or-id · label={labelTranslations?.stepLabel(node) ?? (node.label || node.id)}': 'own-title', + "previews/FlowPreview.tsx · label-or-id · const authored = (typeof node.label === 'string' && node.label) || node.id;": 'own-title', + 'previews/flow-region-view.tsx · label-or-id ·
': 'own-title', + 'previews/flow-region-view.tsx · label-or-id · {labelTranslations?.stepLabel(node) ?? (node.label || node.id)}': 'own-title', 'inspectors/FlowNodeInspector.tsx · label-or-id · title={node.label || node.id}': 'own-title', "previews/flow-node-refs.ts · edge-ends · const where = site.holder.kind === 'node' ? site.holder.id : `${site.holder.source} → ${site.holder.target}`;": 'id-path', }; From 4972af64236e4cce44360bd0ffb5450fa716891d Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 17 Nov 2026 17:29:29 +0000 Subject: [PATCH 5/6] fix(app-shell): type the flow-label read; FlowPreview test passes the required preview props Claude-Session: https://claude.ai/code/session_01WGufzi3ezPzTysQPDEjmVz Co-authored-by: Claude --- .../src/views/metadata-admin/previews/FlowCanvas.test.tsx | 2 +- .../views/metadata-admin/previews/flow-label-translations.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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 946e3c8cf83..71ea584eea5 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 @@ -709,7 +709,7 @@ describe('Flow designer — package label translations (flows..label, appr vi.stubGlobal('fetch', vi.fn(async () => new Response('not found', { status: 404 }))); const { container } = render( - {}} /> + {}} /> , ); expect((container.querySelector('[data-node-id="manager_review"]') as HTMLElement).textContent).toContain('经理审核'); 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 a0d456de62e..d65b0a22fb0 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 @@ -44,7 +44,7 @@ export function flowLabelTranslations( language: string, ): FlowLabelTranslations | undefined { if (!bundle || !flowName) return undefined; - const flowLabel = translateFlow({ name: flowName }, bundle, { locale: language }).label; + const flowLabel = translateFlow<{ name: string; label?: string }>({ name: flowName }, bundle, { locale: language }).label; const approvals = bundle[language]?.flows?.[flowName]?.approvals; return { flowLabel: typeof flowLabel === 'string' && flowLabel ? flowLabel : undefined, From f5c62bde20c373fc42029196969dc4e9a070b8be Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 17 Nov 2026 18:35:29 +0000 Subject: [PATCH 6/6] test(app-shell): pin authored edge text on a branch edge, not an approval outcome After the merge of #34932 an approval's approve/reject out-edges render the designer's localized outcome pill, so the label-translation pin asserts the authored text on a decision branch edge instead. Claude-Session: https://claude.ai/code/session_01WGufzi3ezPzTysQPDEjmVz Co-authored-by: Claude --- .../src/views/metadata-admin/previews/FlowCanvas.test.tsx | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) 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 71ea584eea5..9bfdf5792a1 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 @@ -640,7 +640,7 @@ describe('Flow designer — package label translations (flows..label, appr const EDGES = [ { source: 'start', target: 'manager_review' }, { source: 'manager_review', target: 'big', label: 'approve' }, - { source: 'big', target: 'each' }, + { source: 'big', target: 'each', label: 'Yes, over 1M' }, ]; const DRAFT = { name: 'opportunity_approval', label: 'Large Deal Approval', nodes: NODES, edges: EDGES }; @@ -682,7 +682,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 edge labels stay authored', () => { + it('draws the translated approval-step labels on the canvas, nested ones included; decision and branch-edge labels stay authored', () => { const { container } = render( {}} /> @@ -692,7 +692,9 @@ describe('Flow designer — package label translations (flows..label, appr expect(card('manager_review').textContent).toContain('经理审核'); expect(card('manager_review').textContent).not.toContain('Manager review'); expect(card('big').textContent).toContain('Over 1M?'); - expect(screen.getByText('approve')).toBeInTheDocument(); + // 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');