Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .changeset/27886-flow-clone-notice-one-line.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
'@objectstack/runtime': patch
---

fix(runtime): the flow clone notice is one line in business words

Clause-②: no
Metadata-protocol: none

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.
23 changes: 11 additions & 12 deletions packages/runtime/src/domains/automation-flow-clone.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -442,27 +442,26 @@ describe('#12156 — the source, the notice, and the gate', () => {
expect(spies.registerFlow).not.toHaveBeenCalled();
});

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

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

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

it('is admin copy: it names controls, never an endpoint or a request body', async () => {
Expand Down
60 changes: 30 additions & 30 deletions packages/runtime/src/flow-clone.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,42 +153,42 @@ export const FLOW_CLONE_DROPPED_KEYS: readonly string[] = Object.freeze([
]);

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

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