From 3708b1f251a26b458b38e675f5fce287c820a0e1 Mon Sep 17 00:00:00 2001 From: Christian Byrne Date: Thu, 29 Oct 2026 11:01:46 +0000 Subject: [PATCH 1/2] feat(agent): report a warning when a stale canvas draft is withheld (#22224) ## ELI5 When the agent's connection drops, the canvas stops sending its copy of the workflow with the next message so an old copy cannot overwrite newer values. This adds one warning each time that happens, so we can see in Sentry that the safeguard is working for real users. ## Summary - `AgentPanelRoot.targetWorkflowDraft` reports `agent_canvas_draft_withheld_stale` (level `warning`, one fingerprint) when the stale-canvas gate from #21268 withholds the draft. - Tags follow the agent taxonomy: `failure_kind: bad_state`, `feature_area: agent`, `operation: send`, `outcome: withheld`; context carries only the workflow id. - No behaviour change: the draft is withheld exactly as before. Relates to PM-2118 (https://linear.app/comfyorg/issue/PM-2118). A scheduled read-only check compares this warning and the lost-edit errors across releases with and without the fix. ## Testing - Red first: `withholds a bound canvas after its subscribed socket drops` now also expects exactly one warning; it failed before the change. - New: `reports nothing when a connected canvas sends its draft`. - `AgentPanelRoot.test.ts`: 555 passed. `pnpm typecheck` and `oxlint --type-aware` on the changed files are clean.
Full context for agent readers - Volume: one event per send while the canvas is stale. Sends are user-paced, so this is bounded by message count; the shared fingerprint keeps it to one Sentry issue. - Not under `crdt/`, so outside the informal freeze. - Backport labels: core/1.58 and cloud/1.58 so the 1.58.x builds that already carry the gate also report it.
--------- Co-authored-by: Alexander Brown --- .../extensions/agent/AgentPanelRoot.test.ts | 36 +++++++++++++++++++ .../extensions/agent/AgentPanelRoot.vue | 23 +++++++++++- 2 files changed, 58 insertions(+), 1 deletion(-) diff --git a/src/workbench/extensions/agent/AgentPanelRoot.test.ts b/src/workbench/extensions/agent/AgentPanelRoot.test.ts index ca28edbb796..5645b108129 100644 --- a/src/workbench/extensions/agent/AgentPanelRoot.test.ts +++ b/src/workbench/extensions/agent/AgentPanelRoot.test.ts @@ -11425,11 +11425,47 @@ describe('AgentPanelRoot workflow binding', () => { seq: 1 }) + vi.mocked(reportError).mockClear() agentSocket.drop() await sendFromComposer('second message') expect(bodies[1]).toHaveProperty('workflow_id', 'wf-42') expect(bodies[1]).not.toHaveProperty('draft') + expect(reportError).toHaveBeenCalledTimes(1) + expect(reportError).toHaveBeenCalledWith(expect.any(Error), { + surface: 'agent', + errorType: 'agent_canvas_draft_withheld_stale', + level: 'warning', + fingerprint: ['agent_canvas_draft_withheld_stale'], + tags: { + failure_kind: 'bad_state', + feature_area: 'agent', + operation: 'send', + outcome: 'withheld' + }, + context: { workflowId: 'wf-42' } + }) + }) + + it('reports nothing when a connected canvas sends its draft', async () => { + const bodies = await bindAndSettle() + ws.emit('doc_subscribed', { + v: 1, + workflow_id: 'wf-42', + ok: true, + seq: 1 + }) + vi.mocked(reportError).mockClear() + + await sendFromComposer('second message') + + expect(bodies[1]).toHaveProperty('draft') + expect(reportError).not.toHaveBeenCalledWith( + expect.anything(), + expect.objectContaining({ + errorType: 'agent_canvas_draft_withheld_stale' + }) + ) }) it('seeds the draft for a bound document while the agent identity is still pending', async () => { diff --git a/src/workbench/extensions/agent/AgentPanelRoot.vue b/src/workbench/extensions/agent/AgentPanelRoot.vue index 202b2e3106c..b23cb166ae8 100644 --- a/src/workbench/extensions/agent/AgentPanelRoot.vue +++ b/src/workbench/extensions/agent/AgentPanelRoot.vue @@ -801,12 +801,33 @@ function targetWorkflowDraft(origin?: TurnOrigin): DraftSnapshot | undefined { if (workflowDetached.value) return undefined const target = originWorkflow(origin) if (!target) return undefined - if (canvasMissedDocumentFrames(cloudIdFor(target))) return undefined + const documentId = cloudIdFor(target) + if (canvasMissedDocumentFrames(documentId)) { + if (target.activeState) reportWithheldDraft(documentId) + return undefined + } const content = serializedCanvas(target) if (!content) return undefined return { content } } +function reportWithheldDraft(workflowId: string | undefined): void { + const errorType = 'agent_canvas_draft_withheld_stale' + reportError(new Error('agent canvas draft withheld: canvas may be stale'), { + surface: 'agent', + errorType, + level: 'warning', + fingerprint: [errorType], + tags: { + failure_kind: 'bad_state', + feature_area: 'agent', + operation: 'send', + outcome: 'withheld' + }, + context: { workflowId } + }) +} + function canvasMissedDocumentFrames(documentId: string | undefined): boolean { return ( documentId !== undefined && From c72495374b95a8b8550d666c05e2028501925d12 Mon Sep 17 00:00:00 2001 From: bymyself Date: Thu, 29 Oct 2026 11:51:14 +0000 Subject: [PATCH 2/2] fix: drop the fingerprint option, which reportError on 1.58 does not have --- src/workbench/extensions/agent/AgentPanelRoot.test.ts | 1 - src/workbench/extensions/agent/AgentPanelRoot.vue | 1 - 2 files changed, 2 deletions(-) diff --git a/src/workbench/extensions/agent/AgentPanelRoot.test.ts b/src/workbench/extensions/agent/AgentPanelRoot.test.ts index 5645b108129..446d73ddfa1 100644 --- a/src/workbench/extensions/agent/AgentPanelRoot.test.ts +++ b/src/workbench/extensions/agent/AgentPanelRoot.test.ts @@ -11436,7 +11436,6 @@ describe('AgentPanelRoot workflow binding', () => { surface: 'agent', errorType: 'agent_canvas_draft_withheld_stale', level: 'warning', - fingerprint: ['agent_canvas_draft_withheld_stale'], tags: { failure_kind: 'bad_state', feature_area: 'agent', diff --git a/src/workbench/extensions/agent/AgentPanelRoot.vue b/src/workbench/extensions/agent/AgentPanelRoot.vue index b23cb166ae8..47344de345b 100644 --- a/src/workbench/extensions/agent/AgentPanelRoot.vue +++ b/src/workbench/extensions/agent/AgentPanelRoot.vue @@ -817,7 +817,6 @@ function reportWithheldDraft(workflowId: string | undefined): void { surface: 'agent', errorType, level: 'warning', - fingerprint: [errorType], tags: { failure_kind: 'bad_state', feature_area: 'agent',