Skip to content

Commit aa0fde3

Browse files
feat(flow designer): the publish checks show before the publish, worded for the builder (#34850)
<!-- claude-projects-attribution: {"github_login":"os-support-ai"} --> _Requested by **Yibo Wang** · [project thread](https://claude.ai/code/project/chan_01BVUyyPie8gHwoPM18iABwB?thread=cmsg_01BVUyyPie8gHwoPM18iABwBLW6dHPW6sSheA32XPKZzPV)_ repo:objectstack#3 · os-support-ai · session_01WGufzgae1jRRi8FRrTxaZL Part of #34818 (slice 1 of 3: items 1 and 2; slice 2 takes items 3 and 4, slice 3 items 5 to 9 and closes the card). Clause-②: yes (widening: optional userTextLocales on GetMetaItemRequestSchema) Metadata-protocol: added Skills-docs: none — `userTextLocales` is a request field the REST door and the runtime dispatcher set from the request's locale; no metadata author writes it, so there is nothing for a skill to teach ## 维护者速读 - 流程草稿的读取现在带上发布检查会报的建议:条件分支没设条件、审批人可能为空这类,保存后就进「问题」页签,点一条能定位到节点。 - 检查文字改为面向搭建者:用流程和节点的显示名,没有规则号、`node_3`、`xin_huiyi_tixing`,11 种语言都有译文。 - 发布抽屉在「全部发布」上方按流程列出这些检查;从抽屉或设计器发布后,提示只留一句标题。 - AI 等未经检查列表的发布路径仍保留完整提示,因为那是作者唯一能看到这些检查的地方。 - 契约面:`GetMetaItemRequestSchema` 新增可选 `userTextLocales`(只放宽,记为 `Metadata-protocol: added`,spec 升 minor);规则、严重级别和发布判定都不变。 - 已知偏差:「了解更多」里的规则号未做,它需要在 `_diagnostics.warnings[]` 上加 `code`,本卡不做这个扩展(席位裁定)。 ## What changes **Server: a flow draft read carries what its publish would still report.** - `draftPublishJudgement` (`protocol-authoring-gate.ts`) returns the publish gate's refusals and its advisories. `draftPublishVerdict` keeps its shape for its callers. - `serveDraft` (`protocol-meta-item-reads.ts`) folds the advisories into the draft's `_diagnostics.warnings` through `withPublishAdvisories` (`metadata-diagnostics.ts`). Each warning has an item-relative path (`nodes.1`) and the finding's `userMessage`, else its `message`. Warnings are deduplicated on path and message, and `valid` is not changed. Only `flow` drafts are folded (`DRAFT_ADVISORY_TYPES`), so other types' draft reads are unchanged. - The locale for the sentence comes from the request: `GetMetaItemRequestSchema.userTextLocales` (new, optional, at most 2), set from `userTextLocalesOf(ctx)` by the REST item read (`meta-item-read-routes.ts`, draft reads only) and the runtime dispatcher (`domains/meta.ts`). Absent means English. **Lint: the two flow findings speak to the builder.** - `flow-decision-unconditional-branch` gets a user-text catalog (`lint-flow-patterns.user-text.ts`) in all 11 platform locales, with two arms: `none` (no path is gated) and `mixed` (some paths are not gated). It names the flow, the branch step and the target steps by label, says what the shape does to a run, and says how to fix it. Its findings now carry `path` (`flows[i].nodes[j]`) and `userTextParams`. - The `approval-approvers-*` sentences take the flow's and the node's labels (`flowDisplayLabel`, `flowNodeLabel`) instead of the flow's machine name and the node id. With no label they fall back to the name or id. - Rules, severities, `message`, `hint` and `where` are unchanged. **Console: the checks before the publish.** - The designer's Problems tab already lists a draft's `_diagnostics.warnings` and maps `nodes.N` to that node. With the server change, the checks appear there after each save, and the tab's count includes them. No designer code changed for this. - The pending-changes drawer (`DraftChangesPanel.tsx`) reads each flow draft through `readDraftChecks` (`preview/flowDraftChecks.ts`). The read sends the console language as `Accept-Language`. The drawer lists the checks above Publish, grouped under the flow's label, and in Studio the label opens that flow. The drawer never disables Publish, and a failed read lists nothing. It uses one new eager pack key, `preview.changes.flowChecksTitle`, in all 11 packs. - After a publish made from the drawer or the designer while the checks were listed, the advisory toast keeps its title line only (`providers/saveAdvisoryToast.ts`, `preview/publishChecksShown.ts`). The mark lasts only while that publish is in flight. Any other publish (an AI surface, or an item the drawer listed nothing for) keeps the full toast. That is pinned by the existing `*AdvisoryReachesAuthor` suites, which stay green. ## Tests - `packages/lint/src/finding-user-text.test.ts`: - the new catalog is pinned and rendered from real findings, both arms, in every locale; - the path is `flows[0].nodes[1]`; - no machine names or rule id appear in any locale; - the fallback to machine names when there are no labels; - approval sentences carry labels while `where` is unchanged. - `packages/metadata-protocol/src/protocol.draft-publish-verdict.test.ts` (#34818 describe): - zh warning at `nodes.1` with `valid: true`; - English with no locale; - the warning equals the judgement advisory's `userMessage`; - a gated decision reads no warning. - `packages/metadata-protocol/src/metadata-diagnostics.publish-advisories.test.ts`: `withPublishAdvisories` unit pins. - `ui/.../preview/flowDraftChecks.test.ts`: projection, flow-only reads, `Accept-Language`, failed reads. - `ui/.../preview/__tests__/DraftChangesPanel.flowChecks-34818.test.tsx`: - the block lists the sentence under the label; - the Publish button stays live; - the block is silent when there are no checks; - the reviewed mark holds only for the flight, with a control. - `ui/.../providers/saveAdvisoryToast.test.ts` (#34818 describe): title-only after a reviewed publish, with three controls (unreviewed publish, save door, another item). Ablations (`scripts/ablation-replace.mjs`, each restored to HEAD and verified): - Replacing the `withPublishAdvisories` call with `const after = refused;` fails 3 of the 4 new protocol tests. The 4th ("gated decision reads no warning") stays green, as expected. - Making `listedBeforePublish` return `false` fails 1 of 22 toast tests (the title-only case). - Stubbing the drawer's `readDraftChecks` call fails 3 of 5 drawer tests. "Says nothing" and the CONTROL stay green, as expected. ## Acceptance notes The card's acceptance lines covered by this slice: - **"发布前「问题」页签列出条件分支没有条件、审批人可能解析为空这两条,点击能定位节点;发布抽屉里也看得到"** - Server half: measured by the protocol tests. - Designer half: the existing mapping in `buildFlowProblems` (`serverTarget`, `nodes.N` to node). - Drawer: the drawer suite. - **"两条的文字里没有 `node_2`、`xin_huiyi_tixing`、规则号和英文段落"**: lint suite, all 11 locales. Bound: once the publish lands, the published read does not run the publish gate. So the Problems tab lists these advisories again only after the next save makes a new draft. Accepted deviation (seat ruling in the thread): no rule id under a "learn more" line. It needs `code` on `_diagnostics.warnings[]`, a spec widening this slice does not make. ## Verification Measured on head `762fafa44` (base `3bbda33b`), under `scripts/pm/os-verify-lock.sh`, on a shared box: - Tests: - `@objectstack/lint`: 7 affected files, 513 passed. - `@objectstack/metadata-protocol`: full suite, 349 files, 23098 passed. - `@objectstack/rest`: full suite, 420 files. - `@objectstack/runtime`: `src/domains/meta`, 45 files, 2616 passed. - `ui/`: `packages/app-shell/src/preview/`, `providers/`, `console/ai/__tests__/`, the advisory sink suites and `packages/i18n/`, 246 files, 2984 passed. All exit 0. - Type-check: exit 0 for spec, lint, metadata-protocol, rest, runtime, `@object-ui/i18n` and `@object-ui/app-shell` (both projects). - Derived gates: `dispatch-gates --ran`, 125 derived, 125 run, 0 NOT-MEASURED, 0 UNRUN. - Two were red and are fixed in this branch: `check:facade-delegation-only` (the protocol facade was 1 line over its ceiling) and `check:test-source-alias` (the new advisory test now loads the lint package during collection). - Three exited 3 until their prerequisites were met, then exited 0: `check-plugin-teardown-shape --self-test` (after fetching its pinned commit), `check:skill-examples` and `check:dual-build-cjs-loads` (after the full build that `check:type-check-debt` runs). - Changeset level: `check-changeset-no-major.mjs`, run locally with this body as the event payload. It refused `Metadata-protocol: none` because `packages/spec/authorable-surface/api.json` gains `api/GetMetaItemRequest:userTextLocales`. The body and the changeset therefore declare `added` with `@objectstack/spec` at `minor`. - Eager locale bundle: console `vite build` with `CI=true`. The before leg is this head with only `locales/en.ts` restored to base. - `i18n-locale-en`: 61,622 to 61,648 bytes gzip (+26), against the 62,000 ceiling, so 352 bytes of headroom. - Eager closure total: 1,941,502 to 1,941,499 bytes gzip. - `check-eager-closure-budget.mjs`: exit 0 on both legs. - Not run locally, left to CI: `test:repo`, the dogfood battery (no `!` and no `(narrowing)` arm), and the full ui suite. No browser check of the running console was taken for this slice. <!-- signed: repo:objectstack#3 · os-support-ai · session_01WGufzgae1jRRi8FRrTxaZL --> --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent ab44198 commit aa0fde3

41 files changed

Lines changed: 1276 additions & 32 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
'@objectstack/spec': minor
3+
'@objectstack/lint': patch
4+
'@objectstack/metadata-protocol': patch
5+
'@objectstack/rest': patch
6+
'@objectstack/runtime': patch
7+
'@object-ui/app-shell': patch
8+
'@object-ui/i18n': patch
9+
---
10+
11+
feat(flow designer): the publish checks show in the Problems tab and the publish drawer before the publish, worded for the builder
12+
13+
Clause-②: yes (widening: optional userTextLocales on GetMetaItemRequestSchema)
14+
Metadata-protocol: added
15+
16+
Before, a flow's publish checks were seen only after the publish, as a toast that listed rule ids, machine names and English prose, and then disappeared.
17+
18+
- **The draft read carries what the publish would still report.** A flow draft read (`state: 'draft'`) now adds the publish gate's advisory findings to `_diagnostics.warnings`, next to the refusals it already carried. Each warning has the finding's user sentence in the reader's language. The REST door and the runtime dispatcher pass the request's locales, through a new optional `userTextLocales` on `GetMetaItemRequestSchema`. With no locales the sentence is English. `valid` does not change, and the drafts of other types read as before.
19+
- **The sentences name what the builder sees.** `flow-decision-unconditional-branch` has user text in all 11 platform locales. It names the flow, the branch step and the paths by their labels, and says what the shape does to a run and how to fix it. The `approval-approvers-*` sentences now name the flow and the approval step by their labels instead of the flow's machine name and the node id. A step or flow with no label falls back to its id or name. The findings' `message`, `where`, rules and severities do not change.
20+
- **The console shows them before the publish.** The designer's Problems tab already lists a draft's warnings, so the checks now appear there after each save, and clicking one selects its step. The pending-changes drawer lists each flow draft's checks under the flow's label, above Publish. A publish from the drawer or the designer, made after the checks were listed, ends with the toast's title line only. A publish the author did not review, such as one an AI surface performs, keeps the full toast.

‎content/docs/deployment/validating-metadata.mdx‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -698,6 +698,14 @@ refusal to a loud log for a migration window, so rows written before the gate
698698
existed stay re-savable; it converts refusals, and never promotes them into
699699
`advisories`.
700700

701+
A flow draft can be read before it is published. That read (`GET /api/v1/meta/flow/:name?state=draft`)
702+
runs the publish's own judgement, so its `_diagnostics` say what the publish would answer. A refusal is
703+
listed in `errors`. Each advisory is listed in `warnings`, at the flow-relative path of the step it is
704+
about (`nodes.1`), as the finding's sentence for the builder in the language the request states
705+
(`Accept-Language`, else the workspace default, else English). `valid` is not changed by an advisory.
706+
The flow designer's Problems tab and the pending-changes drawer read these warnings, so an author sees
707+
the publish checks before pressing Publish. A draft of any other type carries no advisories in its read.
708+
701709
So `os validate` is the fast inner-loop check (no artifact), `os build` is what
702710
you run when you need the deployable artifact, and `os lint` adds its own style
703711
rubric on top. **Any rule that can fail a build runs on all three**, so a green

‎content/docs/references/api/protocol.mdx‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1504,6 +1504,7 @@ This schema accepts one of the following structures:
15041504
| **member** | `string` | optional | Bundle member selector, for a metadata type whose identity is a pair (today only `email_template`, identified by `(name, locale)`): the member this request addresses, spelled as its discriminator value (`zh-CN`). Absent, the canonical member (`en-US` for `email_template`), which is what a bare-name read answers; naming the canonical value is the same request. It is not the response translation locale, which `?locale=` and `Accept-Language` choose. Refused with 400 `VALIDATION_ERROR` on a type that has no members, and for a blank value or one longer than a stored member can be (100 characters). A well-formed member with nothing stored or shipped answers as that door answers an absent item. |
15051505
| **state** | `Enum<'active' \| 'draft'>` | optional | Draft-visibility switch — which lifecycle row to read (strict mode): `'draft'` opens the pending draft buffer (Studio's editor read) and fails when no draft exists; absent or `'active'` reads the live published row. Distinct from `previewDrafts`, which FALLS BACK to the active row when no draft exists. Declaration ≠ authorization: this member only selects which stored row is read — ADR-0106 masking is unaffected, and draft access is gated upstream, not by this schema. |
15061506
| **previewDrafts** | `boolean` | optional | Draft-visibility switch (ADR-0033 draft-overlay preview, non-strict): when true and `state` is not `'draft'`, a pending draft row is preferred if one exists, else the read falls back to the active row — the render path degrades to the published value instead of erroring. A served draft is tagged `_draft: true` so UIs can badge it. Declaration ≠ authorization: this member only switches which row is read, and ADR-0106 masking is unaffected — draft preview is admin-gated upstream, not by this schema. |
1507+
| **userTextLocales** | `string[]` | optional | The locales the user-facing sentences of a served DRAFT's check findings are composed in, in ladder order: the locale the request names, then the workspace default — the save request's member of the same name, read the same way (each value against the platform locale table, whole and then one subtag shorter at a time; a value that names no table language is passed over; `en` is the last rung). Read only by the `state: 'draft'` read, which folds what publishing the draft would say into its `_diagnostics`: an advisory finding that carries a user sentence becomes a `_diagnostics.warnings[]` entry in that sentence. Stated by the door that holds the request (the REST door and the dispatcher state `[ExecutionContext.locale, ExecutionContext.workspaceLocale]`), never read from a query string. ABSENT ⇒ the sentences are composed in `en`. It selects a language only: which row is read, and what the verdict is, do not depend on it. |
15071508

15081509

15091510
---

‎packages/lint/src/authoring-rules.ts‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2059,9 +2059,15 @@ export const AUTHORING_RULES: readonly AuthoringRule[] = [
20592059
severity: f.severity ?? 'warning',
20602060
rule: f.rule,
20612061
where: f.where,
2062-
path: f.where,
2062+
// [#34818] A finding placed on a node carries its document path, so a
2063+
// draft's `_diagnostics` entry resolves onto that node; the rest keep
2064+
// `where` as before.
2065+
path: f.path ?? f.where,
20632066
message: f.message,
20642067
hint: f.hint,
2068+
// The user sentence's names ride through the re-map, so the doors can
2069+
// render this finding in the request's language.
2070+
...(f.userTextParams !== undefined ? { userTextParams: f.userTextParams } : {}),
20652071
})),
20662072
},
20672073
// A credential typed as a LITERAL into a flow position every flow reader is

‎packages/lint/src/finding-user-text.test.ts‎

Lines changed: 96 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ import { FLOW_UPDATE_READONLY_WHEN_FIELD, validateReadonlyFlowWrites } from './v
6767
import { READONLY_FLOW_WRITES_USER_TEXT } from './validate-readonly-flow-writes.user-text.js';
6868
import { FLOW_CREDENTIAL_LITERAL, lintFlowCredentialLiterals } from './lint-flow-credential-literals.js';
6969
import { FLOW_CREDENTIAL_LITERALS_USER_TEXT } from './lint-flow-credential-literals.user-text.js';
70+
import { FLOW_DECISION_UNCONDITIONAL_BRANCH, lintFlowPatterns } from './lint-flow-patterns.js';
71+
import { FLOW_PATTERNS_USER_TEXT } from './lint-flow-patterns.user-text.js';
7072

7173
describe('finding user text · the locale ladder (request locale, then workspace default, then en)', () => {
7274
/** A synthetic entry with two sentences: English and Simplified Chinese. */
@@ -479,12 +481,13 @@ interface AdvisoryCase {
479481
}
480482

481483
/** Params that pick a sentence's arm rather than name something the sentence must show. */
482-
const ARM_PARAMS: ReadonlySet<string> = new Set(['slate', 'locked', 'trigger', 'root', 'position']);
484+
const ARM_PARAMS: ReadonlySet<string> = new Set(['slate', 'locked', 'trigger', 'root', 'position', 'shape']);
483485

486+
/** A list param carries one name per line; each name must show. */
484487
const shownNamesOf = (params: Record<string, string>): string[] =>
485488
Object.entries(params)
486489
.filter(([key, value]) => !ARM_PARAMS.has(key) && value !== '')
487-
.map(([, value]) => value);
490+
.flatMap(([, value]) => value.split('\n'));
488491

489492
/** The catalog holds exactly `ids`, each in exactly the platform locales, and is the one the door renders from. */
490493
function pinCatalog(name: string, catalog: UserTextCatalog, ids: readonly string[]): void {
@@ -1012,3 +1015,94 @@ describe('flow credential literals user text · never the value', () => {
10121015
expect(findingUserMessage(advisory, ['ja-JP'])).toContain('ヘッダー「Authorization」');
10131016
});
10141017
});
1018+
1019+
// ── lint-flow-patterns (#34818) ────────────────────────────────────────────
1020+
//
1021+
// The flow designer's Problems tab shows the draft's check findings before
1022+
// publish, so the sentence names the flow and its steps by the labels the
1023+
// builder sees, never `node_2` or the rule id.
1024+
1025+
/** A labelled decision flow; `edges` are the decision's out-edges. */
1026+
const decisionStack = (edges: Array<Record<string, unknown>>) => ({
1027+
flows: [{
1028+
name: 'meeting_reminder',
1029+
label: 'Meeting reminder',
1030+
nodes: [
1031+
{ id: 'start', type: 'start', label: 'Start', config: {} },
1032+
{ id: 'node_2', type: 'decision', label: 'Check date', config: {} },
1033+
{ id: 'node_3', type: 'end', label: 'Remind owner', config: {} },
1034+
{ id: 'node_4', type: 'end', label: 'Skip', config: {} },
1035+
],
1036+
edges: [{ id: 'e0', source: 'start', target: 'node_2' }, ...edges],
1037+
}],
1038+
});
1039+
1040+
const FLOW_PATTERN_CASES: readonly AdvisoryCase[] = [
1041+
{
1042+
label: 'a decision that gates on nothing',
1043+
rule: FLOW_DECISION_UNCONDITIONAL_BRANCH,
1044+
stack: decisionStack([
1045+
{ id: 'e1', source: 'node_2', target: 'node_3' },
1046+
{ id: 'e2', source: 'node_2', target: 'node_4' },
1047+
]),
1048+
params: { flow: 'Meeting reminder', node: 'Check date', shape: 'none', targets: 'Remind owner\nSkip' },
1049+
},
1050+
{
1051+
label: 'a decision with an ungated path beside a guarded one',
1052+
rule: FLOW_DECISION_UNCONDITIONAL_BRANCH,
1053+
stack: decisionStack([
1054+
{ id: 'e1', source: 'node_2', target: 'node_3', condition: 'record.amount > 10' },
1055+
{ id: 'e2', source: 'node_2', target: 'node_4' },
1056+
]),
1057+
params: { flow: 'Meeting reminder', node: 'Check date', shape: 'mixed', targets: 'Skip' },
1058+
},
1059+
];
1060+
1061+
pinCatalog('flow patterns', FLOW_PATTERNS_USER_TEXT, [FLOW_DECISION_UNCONDITIONAL_BRANCH]);
1062+
// The rule leaves `severity` unset for a warning, as the registry row reads it.
1063+
pinCases('flow patterns', (stack) => lintFlowPatterns(stack).map((f) => ({ ...f, severity: f.severity ?? 'warning' })), FLOW_PATTERN_CASES);
1064+
1065+
describe('flow patterns user text · what the builder reads (#34818)', () => {
1066+
it('places the finding on the decision node by its document path, so the draft verdict resolves onto it', () => {
1067+
for (const c of FLOW_PATTERN_CASES) {
1068+
const [finding] = lintFlowPatterns(c.stack).filter((f) => f.rule === c.rule);
1069+
expect(finding!.path, c.label).toBe('flows[0].nodes[1]');
1070+
const result = runRuntimeAuthoringRules({ type: 'flow', item: (c.stack.flows as unknown[])[0] });
1071+
expect(result.advisories.find((f) => f.rule === c.rule)!.path, c.label).toBe('flows[0].nodes[1]');
1072+
}
1073+
});
1074+
1075+
it('names no machine name and no rule id in any locale', () => {
1076+
for (const c of FLOW_PATTERN_CASES) {
1077+
const [finding] = lintFlowPatterns(c.stack).filter((f) => f.rule === c.rule);
1078+
for (const tag of PLATFORM_LOCALE_TAGS) {
1079+
const text = findingUserMessage(finding!, [tag])!;
1080+
expect(text, `${c.label} · ${tag}`).not.toMatch(/node_\d|meeting_reminder|flow-decision|config\./);
1081+
}
1082+
}
1083+
});
1084+
1085+
it('falls back to the machine names for a flow and nodes that declare no label', () => {
1086+
const stack = decisionStack([
1087+
{ id: 'e1', source: 'node_2', target: 'node_3' },
1088+
{ id: 'e2', source: 'node_2', target: 'node_4' },
1089+
]);
1090+
const flow = (stack.flows as Array<Record<string, unknown>>)[0]!;
1091+
delete flow.label;
1092+
for (const node of flow.nodes as Array<Record<string, unknown>>) delete node.label;
1093+
const [finding] = lintFlowPatterns(stack).filter((f) => f.rule === FLOW_DECISION_UNCONDITIONAL_BRANCH);
1094+
expect(finding!.userTextParams).toEqual({ flow: 'meeting_reminder', node: 'node_2', shape: 'none', targets: 'node_3\nnode_4' });
1095+
});
1096+
1097+
it('names an approval node and its flow by their labels too', () => {
1098+
const stack = approvalStack([{ type: 'position', value: 'finance_manager' }]);
1099+
const flow = (stack.flows as Array<Record<string, unknown>>)[0]!;
1100+
flow.label = 'Expense approval';
1101+
(flow.nodes as Array<Record<string, unknown>>)[1]!.label = 'Manager review';
1102+
const finding = validateApprovalApprovers(stack).find((f) => f.rule === APPROVAL_APPROVERS_MAY_RESOLVE_EMPTY)!;
1103+
expect(finding.userTextParams).toEqual({ flow: 'Expense approval', node: 'Manager review', slate: 'group', locked: 'yes' });
1104+
expect(findingUserMessage(finding, ['zh-CN'])).toContain('流程“Expense approval”的审批节点“Manager review”');
1105+
// `where` keeps the machine names for `os validate` and logs.
1106+
expect(finding.where).toBe('flow "expense_approval" · node "manager_review"');
1107+
});
1108+
});

‎packages/lint/src/finding-user-text.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ import { FLOW_TEMPLATE_PATHS_USER_TEXT } from './validate-flow-template-paths.us
6060
import { FLOW_NODE_WRITES_USER_TEXT } from './validate-flow-node-writes.user-text.js';
6161
import { READONLY_FLOW_WRITES_USER_TEXT } from './validate-readonly-flow-writes.user-text.js';
6262
import { FLOW_CREDENTIAL_LITERALS_USER_TEXT } from './lint-flow-credential-literals.user-text.js';
63+
import { FLOW_PATTERNS_USER_TEXT } from './lint-flow-patterns.user-text.js';
6364
import { WIDGET_BINDINGS_USER_TEXT } from './validate-widget-bindings.user-text.js';
6465
import { CHART_BINDINGS_USER_TEXT } from './validate-chart-bindings.user-text.js';
6566
import { AUTONUMBER_FORMATS_USER_TEXT } from './lint-autonumber-formats.user-text.js';
@@ -180,6 +181,7 @@ export const FINDING_USER_TEXT_CATALOG: UserTextCatalog = mergeUserTextCatalogs(
180181
FLOW_NODE_WRITES_USER_TEXT,
181182
READONLY_FLOW_WRITES_USER_TEXT,
182183
FLOW_CREDENTIAL_LITERALS_USER_TEXT,
184+
FLOW_PATTERNS_USER_TEXT,
183185
// The dashboard writes: widget and chart binding advisories.
184186
WIDGET_BINDINGS_USER_TEXT,
185187
CHART_BINDINGS_USER_TEXT,

‎packages/lint/src/flow-walk.ts‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,16 @@ export function flowNodeLabel(node: AnyRec, index: number): string {
131131
return strName(node.label) ?? strName(node.id) ?? `#${index}`;
132132
}
133133

134+
/**
135+
* A flow's name for a USER sentence (`userTextParams`): its `label`, then its
136+
* machine `name`, then `(flow N)`. A builder reads a flow by the label Studio
137+
* shows them; the machine name is the fallback for a flow that declares none,
138+
* the way {@link flowNodeLabel} falls back to a node's `id`.
139+
*/
140+
export function flowDisplayLabel(flow: AnyRec, index: number): string {
141+
return strName(flow.label) ?? strName(flow.name) ?? `(flow ${index})`;
142+
}
143+
134144
const EMPTY_SLOTS: readonly string[] = [];
135145

136146
/** The region slots a node type owns — empty for every non-container type. */

0 commit comments

Comments
 (0)