Skip to content

Self-improving AI Employees for everyone

fix(control): let the server's paused-is-editable grant win over the legacy deployment lock

trohitg89fab1ba535c
diff --git a/client/src/lib/__tests__/canvasLock.test.ts b/client/src/lib/__tests__/canvasLock.test.ts
index 53905d47..85009a2e 100644
--- a/client/src/lib/__tests__/canvasLock.test.ts
+++ b/client/src/lib/__tests__/canvasLock.test.ts
@@ -53,7 +53,27 @@ describe('deriveCanvasLock', () => {
expect(running.reason).toContain('pause it to edit');
});
- it('falls back to the legacy broadcaster lock for the same workflow only', () => {
+ it('lets the server grant editing while paused even though the deployment lock is held', () => {
+ // Regression: pause keeps the deployment armed, so the legacy
+ // broadcaster lock stays held for the workflow's whole armed
+ // lifetime. The server's paused-is-editable grant must win — the
+ // legacy lock is a fallback for ungoverned workflows, never an
+ // override of the control plane's capability.
+ const legacyLocked = { locked: true, workflow_id: 'wf-1' };
+ expect(
+ deriveCanvasLock({
+ control: { state: 'paused', can_edit: true },
+ legacyLock: legacyLocked,
+ workflowId: 'wf-1',
+ }),
+ ).toEqual({ locked: false, reason: null });
+ });
+
+ it('falls back to the legacy broadcaster lock only when no generation governs the workflow', () => {
+ // `never_started` is the control plane's explicit "no generation
+ // exists" answer (serialize_control(None) and the FE placeholder
+ // both use it) — legacy deployments never create a control row, so
+ // the broadcaster lock decides for them.
const legacyLocked = { locked: true, workflow_id: 'wf-1' };
expect(
deriveCanvasLock({
@@ -63,6 +83,14 @@ describe('deriveCanvasLock', () => {
}).locked,
).toBe(true);
+ expect(
+ deriveCanvasLock({
+ control: null,
+ legacyLock: legacyLocked,
+ workflowId: 'wf-1',
+ }).locked,
+ ).toBe(true);
+
// A lock held by ANOTHER workflow never locks this canvas.
expect(
deriveCanvasLock({
diff --git a/client/src/lib/canvasLock.ts b/client/src/lib/canvasLock.ts
index f5d705c5..573cdbcb 100644
--- a/client/src/lib/canvasLock.ts
+++ b/client/src/lib/canvasLock.ts
@@ -37,16 +37,31 @@ export function deriveCanvasLock({
legacyLock,
workflowId,
}: CanvasLockInput): CanvasLockResult {
- if (control && control.can_edit === false) {
- const state = control.state ?? null;
- return {
- locked: true,
- reason:
- state && TRANSITION_STATES.has(state) && state !== 'running'
- ? 'Workflow is changing state — wait for the transition to finish'
- : 'Workflow is running — pause it to edit the canvas',
- };
+ // Once the control plane governs the workflow (a generation exists),
+ // its `can_edit` capability is rendered verbatim — granted or denied —
+ // and the legacy broadcaster lock is not consulted. Control-plane
+ // deployments hold the broadcaster lock for their whole armed lifetime
+ // (paused included), so letting it override would deny the server's
+ // paused-is-editable grant. `never_started` is the control plane's
+ // explicit "no generation governs this workflow" answer, so it falls
+ // through to the legacy fallback below.
+ const governed =
+ !!control && control.state != null && control.state !== 'never_started';
+ if (governed) {
+ if (control.can_edit === false) {
+ const state = control.state ?? null;
+ return {
+ locked: true,
+ reason:
+ state && TRANSITION_STATES.has(state) && state !== 'running'
+ ? 'Workflow is changing state — wait for the transition to finish'
+ : 'Workflow is running — pause it to edit the canvas',
+ };
+ }
+ return { locked: false, reason: null };
}
+ // Legacy fallback: deployments driven outside the control plane never
+ // create a control row, so the broadcaster lock decides for them.
if (
legacyLock?.locked &&
!!workflowId &&
diff --git a/docs-internal/temporal-workflow-control.md b/docs-internal/temporal-workflow-control.md
index 91ae3af9..0b918799 100644
--- a/docs-internal/temporal-workflow-control.md
+++ b/docs-internal/temporal-workflow-control.md
@@ -225,8 +225,13 @@ snapshot, so edits cannot corrupt in-flight runs — paused is exactly the
"fix it, then resume" posture the recovery policies produce); locked while
`starting` / `running` / transitional. On the client,
[`lib/canvasLock.ts`](../client/src/lib/canvasLock.ts) maps the capability
-(plus the legacy broadcaster lock for deployments driven outside the
-control plane) to a boolean + reason; `Dashboard` feeds it to the React
+to a boolean + reason. Precedence is strict: once a generation governs the
+workflow (any state other than `never_started`), `can_edit` is rendered
+verbatim and the legacy broadcaster lock is **not** consulted — control-plane
+deployments hold that lock for their whole armed lifetime (paused included),
+so letting it override would deny the server's paused-is-editable grant. The
+legacy lock decides only for ungoverned workflows (deployments driven outside
+the control plane, which never create a control row); `Dashboard` feeds it to the React
Flow interaction props AND a shared `guardCanvasEdit` toast-guard covering
the paths those props cannot reach (palette drop, paste, context-menu
delete/rename, node disable, parameter saves); `TopToolbar` shows a