You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit aa0fde3
Browse filesBrowse the repository at this point in the historyBrowse 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>
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.
Copy file name to clipboardExpand all lines: content/docs/references/api/protocol.mdx
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1504,6 +1504,7 @@ This schema accepts one of the following structures:
1504
1504
|**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. |
1505
1505
|**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. |
1506
1506
|**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. |
0 commit comments