Skip to content

Commit 95f545e

Browse files
fix(runtime): say the flow clone notice in one business line (#28072)
<!-- claude-projects-attribution: {"github_login":"os-elon-musk"} --> _Requested by **Elon** · [project thread](https://claude.ai/code/project/chan_01WedDzV26nniwxv7jC88B9D?thread=cmsg_01WedDzV26nniwxv7jC88B9DR7SzDBhXQGAHb2Ls1TDmTM)_ Fixes #27886 domain:server#3 card thread · os-elon-musk · session_016WV4cxQRTfRrRf5wo1ZC3U ## What changes `FLOW_CLONE_NOTICE` (`packages/runtime/src/flow-clone.ts`), the notice `POST /api/v1/automation/:name/clone` returns with `{ flow, notice }`, goes from seven sentences of engine prose to one line: > The copy runs alongside the original until you switch one of them off, and it still uses the same subflows, actions and objects as the original. The detail the old paragraph carried (`status: 'draft'` is not an off-switch, references are not re-pointed, the Packaged automation `Switch "…" off` action does not reach the clone, the clone is switched off in Studio with its Enabled switch and a publish) now lives in the constant's TSDoc. The REST recipe stays in the client SDK's `automation.toggle` TSDoc, unchanged. The runtime pin in `domains/automation-flow-clone.test.ts` now asserts both facts by their new wording, exactly one sentence, and no engine words (`draft`, `status`, `off-switch`, `lifecycle`, `Studio`). The existing `toBe(FLOW_CLONE_NOTICE)` and no-endpoint pins stay. ## Why Triage 6515426773: the packaged-flow clone notice is one business line. The console shows it verbatim beside a "Switch the original off" button, so most of the paragraph repeated the screen. Re-measured on `main` at 5aee206: the notice was the seven-sentence string the card quotes. Both facts are kept on purpose. "Runs alongside the original" is the double-fire warning the card asks to keep. "Still uses the same subflows, actions and objects" is the ADR-0126 §9 line ("the clone's references stay pointed at what the original pointed at, and the surface tells the admin so"), said in business words, so the shortening does not drop an ADR requirement. ## Verification - `vitest run src/domains/automation-flow-clone.test.ts src/dispatcher-plugin.automation-clone-mount.integration.test.ts`: 23 passed. - Red control: with `origin/main`'s `flow-clone.ts` restored, the rewritten notice test fails (1 failed, 18 passed); restored to this diff, green. - `dispatch-gates --ran`: 60 derived families accounted for, 58 exit 0, 2 exit 3 in the fresh worktree. Re-run after their prerequisites: `check-plugin-teardown-shape --self-test` exit 0 after fetching its pinned commit; `check:dual-build-cjs-loads` NOT MEASURED (needs every package's dist). - `pnpm lint` exit 0; `pnpm --filter @objectstack/runtime typecheck` exit 0. - The dogfood door test (`qa/dogfood/test/automation-flow-clone-door.dogfood.test.ts`) asserts `toBe(FLOW_CLONE_NOTICE)` by import, so it follows the constant; not run locally. Clause-②: no Metadata-protocol: none Skills-docs: none. `grep -rn "re-pointed\|alongside the original\|lifecycle label and NOT\|does not reach the clone" skills/ docs/ content/` finds no copy of the notice; the one Setup mention (`content/docs/build-without-code.mdx:38`) does not quote it. Out of scope, for the seat: `ui/packages/app-shell/src/views/setup/PackagedAutomationPage.test.tsx` keeps a fixture `CLONE_NOTICE` with the first two old sentences. The page test pins that whatever notice arrives is shown unedited, so it stays green, but the fixture text is now stale (`ui/` is outside this order's surface). ## Human Minimum - [x] 1. Schemas start as Zod; `packages/spec` holds no runtime logic. - [x] 2. Every name I added uses the casing for its kind. - [x] 3. No formatter ran; `pnpm lint` passes. - [x] 4. One issue, one branch off an up-to-date `main`, one pull request. - [x] 5. A change that publishes carries a changeset, and both declaration lines are filled in here and in the changeset. - [x] 6. `packages/spec` touched: its generated artifacts are regenerated and committed. (not touched) - [x] 7. No hand edits to `content/docs/references/`, `packages/*/CHANGELOG.md` or `content/docs/releases/`. - [x] 8. Title, body and comments are in English. - [x] The *Before Submitting* list in CONTRIBUTING.md is done. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_016WV4cxQRTfRrRf5wo1ZC3U Co-authored-by: Claude <noreply@anthropic.com>
1 parent b1b35a3 commit 95f545e

3 files changed

Lines changed: 51 additions & 42 deletions

File tree

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
'@objectstack/runtime': patch
3+
---
4+
5+
fix(runtime): the flow clone notice is one line in business words
6+
7+
Clause-②: no
8+
Metadata-protocol: none
9+
10+
The notice returned by `POST /api/v1/automation/:name/clone` (`FLOW_CLONE_NOTICE`) was seven sentences that named `status draft`, lifecycle labels, the Packaged automation switch and the Studio Enabled switch. The console shows it verbatim beside a "Switch the original off" button, so most of it repeated the screen. It now reads: "The copy runs alongside the original until you switch one of them off, and it still uses the same subflows, actions and objects as the original." The detail (`draft` is not an off-switch, references are not re-pointed, where each switch lives) stays in the constant's TSDoc; the REST recipe stays in the client SDK's `automation.toggle` TSDoc.

‎packages/runtime/src/domains/automation-flow-clone.test.ts‎

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -442,27 +442,26 @@ describe('#12156 — the source, the notice, and the gate', () => {
442442
expect(spies.registerFlow).not.toHaveBeenCalled();
443443
});
444444

445-
it('states plainly that references are NOT re-pointed, and that the clone is armed', async () => {
445+
it('states in one line that the clone runs alongside the original, and that references are NOT re-pointed', async () => {
446446
const source = packagedExemplar();
447447
const { dispatcher } = makeDispatcher([source]);
448448

449449
const result = await dispatcher.handleAutomation(clonePath(source.name as string), 'POST', NEW, CTX);
450450
const notice: string = ((result.response?.body?.data ?? result.response?.body) as any)?.notice ?? '';
451451

452-
// ADR-0126 §9: automatic re-pointing is explicitly not chartered, and
453-
// the ADR requires the surface to TELL the admin so.
454-
expect(notice).toMatch(/not re-pointed/i);
455-
// And the fact an admin is most likely to be caught by: `draft` is a
452+
// The fact an admin is most likely to be caught by: `draft` is a
456453
// lifecycle label, not an off-switch — the engine only disables on
457454
// `obsolete`/`invalid`, so a cloned record-change flow runs beside the
458455
// one it was copied from. Saying so is cheaper than the surprise.
459-
expect(notice).toMatch(/off-switch/i);
460-
// [#20726] And it names the switches an admin has. A clone carries no
461-
// package envelope, so the packaged-flow switch does not reach it; the
462-
// clone is switched off in Studio, the original from its own row.
463-
expect(notice).toContain('Switch "…" off');
464-
expect(notice).toContain('does not reach the clone');
465-
expect(notice).toContain('open it in Studio, set its Enabled switch to Disabled, and publish');
456+
expect(notice).toContain('runs alongside the original until you switch one of them off');
457+
// ADR-0126 §9: automatic re-pointing is explicitly not chartered, and
458+
// the ADR requires the surface to TELL the admin so.
459+
expect(notice).toContain('still uses the same subflows, actions and objects as the original');
460+
// [#27886] One line in business words. The console shows it beside a
461+
// "Switch the original off" button, so the engine words and the switch
462+
// locations stay in `flow-clone.ts`'s TSDoc.
463+
expect(notice.match(/[.!?](\s|$)/g)).toHaveLength(1);
464+
expect(notice).not.toMatch(/\b(draft|status|off-switch|lifecycle|Studio)\b/i);
466465
});
467466

468467
it('is admin copy: it names controls, never an endpoint or a request body', async () => {

‎packages/runtime/src/flow-clone.ts‎

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -153,42 +153,42 @@ export const FLOW_CLONE_DROPPED_KEYS: readonly string[] = Object.freeze([
153153
]);
154154

155155
/**
156-
* What the clone response tells the admin, in the admin's own words.
156+
* What the clone response tells the admin, in one line of the admin's own
157+
* words.
157158
*
158159
* Two facts, both required to be stated rather than discovered:
159160
*
160-
* 1. References are not re-pointed (ADR-0126 §9). A cloned flow's subflow
161-
* nodes, action calls and object references point exactly where the
162-
* original's did.
163-
* 2. The clone is armed. `status: 'draft'` is a lifecycle label, not an
161+
* 1. The clone is armed. `status: 'draft'` is a lifecycle label, not an
164162
* off-switch — see {@link FLOW_CLONE_STATUS}. An admin who clones a
165-
* record-change flow and walks away has two flows running on one trigger,
166-
* and the only thing standing between them and that surprise is this
167-
* sentence.
168-
*
169-
* [#20726, ADR-0126 §7.2] The clone's own off-switch is its `status`
170-
* (`obsolete`), published through `PUT /:name`. A clone carries no package
171-
* envelope (see {@link FLOW_CLONE_DROPPED_KEYS}), so it is a flow authored in
172-
* this deployment, and the activation toggle — which switches packaged flows
173-
* only — refuses it. That holds whatever the clone was copied from: the clone
174-
* door takes any registered flow as its source, packaged or not.
175-
*
176-
* The notice is admin copy — the console shows it verbatim on the clone
177-
* result — so it names the controls the admin uses, never an endpoint or a
178-
* request body: the Packaged automation page's `Switch "…" off` action for a
179-
* packaged original, and Studio's Enabled switch (publish to apply) for the
180-
* clone. The REST recipe is developer copy and lives in the client SDK's
181-
* `automation.toggle` TSDoc.
163+
* record-change or schedule flow and walks away has two flows running on
164+
* one trigger, and the only thing standing between them and that surprise
165+
* is this line.
166+
* 2. References are not re-pointed (ADR-0126 §9 — "the surface tells the
167+
* admin so"). A cloned flow's subflow nodes, action calls and object
168+
* references point exactly where the original's did.
169+
*
170+
* [#27886] The notice is ONE line in business words, because the console
171+
* shows it verbatim beside a "Switch the original off" button: a paragraph
172+
* that named `status`, lifecycle labels and both switches repeated what the
173+
* screen already offers. Engine words (`draft`, `status`, off-switch) and
174+
* the switch locations live here, not in the notice:
175+
*
176+
* - [#20726, ADR-0126 §7.2] The clone's own off-switch is its `status`
177+
* (`obsolete`). In the console that is Studio's Enabled switch set to
178+
* Disabled, then a publish. A clone carries no package envelope (see
179+
* {@link FLOW_CLONE_DROPPED_KEYS}), so it is a flow authored in this
180+
* deployment, and the activation toggle — which switches packaged flows
181+
* only — refuses it. That holds whatever the clone was copied from: the
182+
* clone door takes any registered flow as its source, packaged or not.
183+
* - A packaged original is switched off on the Packaged automation page,
184+
* with its `Switch "…" off` action; that switch does not reach the clone.
185+
*
186+
* The notice names no endpoint or request body. The REST recipe is developer
187+
* copy and lives in the client SDK's `automation.toggle` TSDoc.
182188
*/
183189
export const FLOW_CLONE_NOTICE =
184-
'References are not re-pointed: this clone calls exactly what the original called '
185-
+ '(subflows, actions and objects are unchanged). It is created with status `draft`, '
186-
+ 'which is a lifecycle label and NOT an off-switch — a cloned record-change or schedule '
187-
+ 'flow is bound to its trigger and will run alongside the flow it was copied from. '
188-
+ 'If that is not what you want, switch one of them off. A packaged original is switched '
189-
+ 'off on the Packaged automation page, with its Switch "…" off action; that switch covers '
190-
+ 'packaged flows only and does not reach the clone. To switch the clone itself off, open it '
191-
+ 'in Studio, set its Enabled switch to Disabled, and publish.';
190+
'The copy runs alongside the original until you switch one of them off, '
191+
+ 'and it still uses the same subflows, actions and objects as the original.';
192192

193193
/** ADR-0112 envelope for the same-name refusal: a status AND a code. */
194194
export const FLOW_CLONE_NAME_TAKEN_STATUS = 409;

0 commit comments

Comments
 (0)