diff --git a/browser_tests/fixtures/agentConversationFixture.ts b/browser_tests/fixtures/agentConversationFixture.ts index fe878bcae85..39e1b1c655a 100644 --- a/browser_tests/fixtures/agentConversationFixture.ts +++ b/browser_tests/fixtures/agentConversationFixture.ts @@ -16,7 +16,10 @@ import type { AgentWsEvent } from '@/workbench/extensions/agent/schemas/agentApiSchema' import { parseAgentWsEvent } from '@/workbench/extensions/agent/schemas/agentApiSchema' -import { parseServerDocFrame } from '@/workbench/extensions/agent/crdt/docFrameClient' +import { + DOC_PROTOCOL_VERSION, + parseServerDocFrame +} from '@/workbench/extensions/agent/crdt/docFrameClient' import type { GraphOperation } from '@/workbench/extensions/agent/crdt/graphOperations' import type { useAgentWorkflowTabBindingStore } from '@/workbench/extensions/agent/stores/agent/agentWorkflowTabBindingStore' @@ -65,7 +68,7 @@ import { mockSavedWorkflowPersistence } from '@e2e/fixtures/utils/savedWorkflowP import { loadSeedIntoActiveTab } from '@e2e/fixtures/utils/seedActiveTab' import { nextFrame } from '@e2e/fixtures/utils/timing' -const THREAD_ID = 'e9a2f3d1-7c44-4b2e-9a01-5f6d8c7b3a10' +export const THREAD_ID = 'e9a2f3d1-7c44-4b2e-9a01-5f6d8c7b3a10' // One synthetic message id per turn; the recorded ids never reach the page. const turnId = (turn: number): string => `0c5b1e77-2d4a-4f9e-8b63-1a2c3d4e5${turn.toString(16).padStart(3, '0')}` @@ -771,6 +774,67 @@ export class AgentConversationHarness { return this.hostSocket.clientDocFrames() } + async activateEmptyWorkflow(workflowId: string, name: string): Promise { + const seed = structuredClone(this.conversation.workflow.seed) + seed.nodes = [] + seed.links = [] + seed.groups = [] + this.hostSocket.addWorkflow( + workflowId, + new HostDoc(workflowId, seed, this.conversation.workflow.catalog) + ) + const subscribes = this.subscribeCount(workflowId) + this.hostSocket.send({ + type: 'agent_active_tab', + data: { workflow_id: workflowId, name } + }) + await expect(this.topbar.getActiveTab()).toContainText(name) + await expect + .poll(() => this.subscribeCount(workflowId)) + .toBeGreaterThanOrEqual(subscribes + 1) + } + + resumeWorkflowSubscribe(workflowId: string): void { + this.hostSocket.resumeSubscribe(workflowId) + } + + sendDocumentReset(workflowId: string): void { + this.hostSocket.send({ + type: 'doc_reset', + data: { + v: DOC_PROTOCOL_VERSION, + workflow_id: workflowId, + seq: 1, + lineage_seq: 1, + actor: 'system:test-reset' + } + }) + } + + /** Returns to the recorded workflow's tab (the first) and holds its subscribe ack. */ + async activateRecordedWorkflowBeforeSubscribeAck(): Promise { + const { id, name } = this.conversation.workflow + this.hostSocket.pauseSubscribes(id) + const sent = this.clientDocFrames().filter( + (frame) => frame.type === 'doc_subscribe' && frame.workflowId === id + ).length + this.hostSocket.send({ + type: 'agent_active_tab', + data: { workflow_id: id, name } + }) + await expect + .poll( + () => + this.clientDocFrames().filter( + (frame) => frame.type === 'doc_subscribe' && frame.workflowId === id + ).length + ) + .toBeGreaterThanOrEqual(sent + 1) + await expect( + this.topbar.getTab(0).and(this.topbar.getActiveTab()) + ).toBeVisible() + } + /** The applier's verdict on every human op the host has judged so far. */ humanOpOutcomes(): ApplyOutcome[] { return this.hostSocket.humanOpOutcomes() @@ -838,16 +902,68 @@ export class AgentConversationHarness { ]) } + applyOpsOnHostUnsent(operations: RecordedGraphOperation[]): void { + this.host.apply(operations) + for (const id of Object.keys(this.host.graph().nodes)) this.seenIds.add(id) + } + + /** Holds `threadId`'s transcript reads until `release` is called. */ + async holdTranscript( + threadId: string + ): Promise<{ requested: Promise; release: () => void }> { + let release!: () => void + let reached!: () => void + const held = new Promise((resolve) => (release = resolve)) + const requested = new Promise((resolve) => (reached = resolve)) + await this.page.route( + `**/api/agent/threads/${threadId}/messages`, + async (route) => { + if (route.request().method() !== 'GET') return route.fallback() + reached() + await held + return route.fallback() + } + ) + return { requested, release } + } + + /** Serves a second workflow's document beside the recorded one. */ + serveWorkflow(workflowId: string, seed: WorkflowJSON): void { + this.hostSocket.addWorkflow( + workflowId, + new HostDoc(workflowId, seed, this.conversation.workflow.catalog) + ) + } + // Rises once per follower subscribe; a tab return re-subscribes and the // host answers with the catch-up frame this counter has just sent. - subscribeCount(): number { - return this.hostSocket.subscribeCount() + subscribeCount(workflowId?: string): number { + return this.hostSocket.subscribeCount(workflowId) } humanOpFrames(): ClientDocFrame[] { return this.clientDocFrames().filter((frame) => frame.type === 'doc_ops') } + async humanAddNodeBaseVersion( + workflowId: string, + nodeId: string + ): Promise { + const find = () => { + for (const frame of this.humanOpFrames()) { + if (frame.workflowId !== workflowId) continue + const index = frame.ops.indexOf(`add_node:${nodeId}`) + if (index !== -1) return frame.baseVersions[index] + } + return undefined + } + await expect.poll(find).toEqual(expect.any(Number)) + const baseVersion = find() + if (typeof baseVersion !== 'number') + throw new Error(`no numeric base_version for add_node:${nodeId}`) + return baseVersion + } + leaveNextHumanBatchUnanswered(): void { this.hostSocket.leaveHumanBatchesUnanswered(1) } diff --git a/browser_tests/fixtures/agentFollowerHostSocket.test.ts b/browser_tests/fixtures/agentFollowerHostSocket.test.ts index 7117e4acc2d..fe108393d50 100644 --- a/browser_tests/fixtures/agentFollowerHostSocket.test.ts +++ b/browser_tests/fixtures/agentFollowerHostSocket.test.ts @@ -127,6 +127,30 @@ describe('AgentFollowerHostSocket human doc_ops handling', () => { }) }) + it('records each op base_version, null when it is not a number', async () => { + const { hostSocket, emitClientFrame } = await installHost() + + const numbered = validOp('b'.repeat(32), 2) + const missing = validOp('c'.repeat(32), 3) + const malformed = validOp('d'.repeat(32), 4) + delete missing.base_version + malformed.base_version = 'not-a-number' + emitClientFrame({ + type: 'doc_ops', + data: { + workflow_id: WORKFLOW_ID, + tab: 'tab-1', + ops: [numbered, missing, malformed] + } + }) + + expect(hostSocket.clientDocFrames().at(-1)?.baseVersions).toEqual([ + 1, + null, + null + ]) + }) + it('still applies a well-formed doc_ops batch through the real applier', async () => { const { hostSocket, emitClientFrame, sentFrames } = await installHost() @@ -175,6 +199,34 @@ describe('AgentFollowerHostSocket human doc_ops handling', () => { node: { id: nodeId, type: 'TestNode', pos: [10, 20] } }) + it('releases a held batch against the workflow that sent it', async () => { + const { + host: primaryHost, + hostSocket, + emitClientFrame + } = await installHost('hold') + const secondaryWorkflowId = 'wf-2' + const secondaryHost = new HostDoc( + secondaryWorkflowId, + { nodes: [], links: [] }, + { types: {} } + ) + hostSocket.addWorkflow(secondaryWorkflowId, secondaryHost) + + emitClientFrame({ + type: 'doc_ops', + data: { + workflow_id: secondaryWorkflowId, + tab: 'tab-1', + ops: [validOp('c'.repeat(32), 3)] + } + }) + hostSocket.releaseHeldClientOps() + + expect(primaryHost.graph().nodes).toEqual({}) + expect(secondaryHost.graph().nodes).toHaveProperty('3') + }) + it.for([ { label: 'a missing tab', diff --git a/browser_tests/fixtures/agentFollowerHostSocket.ts b/browser_tests/fixtures/agentFollowerHostSocket.ts index c7572dc86e3..b605918595a 100644 --- a/browser_tests/fixtures/agentFollowerHostSocket.ts +++ b/browser_tests/fixtures/agentFollowerHostSocket.ts @@ -68,6 +68,8 @@ export interface ClientDocFrame { /** `op:node_id` per op for a `doc_ops` frame; empty otherwise. */ ops: string[] opIds: string[] + /** Wire `base_version` per op for a `doc_ops` frame; `null` when not a number. */ + baseVersions: Array writers: Array connection: number comfyConnection: number @@ -135,6 +137,9 @@ function parseClientDocFrame( } export class AgentFollowerHostSocket { + private readonly hosts = new Map() + private readonly pausedSubscribes = new Set() + private readonly pendingSubscribes = new Map() private refuseReason: string | null = null private refusalsLeft = 0 private refusedSubscribes = 0 @@ -146,7 +151,7 @@ export class AgentFollowerHostSocket { private comfyConnections = 0 private connections = 0 private unansweredHumanBatches = 0 - private subscribes = 0 + private readonly subscribes = new Map() private subscribeAnswer = (stateVector: string): HostFrame[] => [ this.host.subscribed(), this.host.catchUp(stateVector) @@ -154,6 +159,7 @@ export class AgentFollowerHostSocket { private readonly createdAt = Date.now() private readonly clientFrames: ClientDocFrame[] = [] private readonly heldBatches: Array<{ + workflowId: string tab: string | null ops: WireOpEnvelope[] }> = [] @@ -171,7 +177,27 @@ export class AgentFollowerHostSocket { private readonly host: HostDoc, private readonly humanOpsHost: HumanOpsHost = 'hold', private readonly hostUpdateSink?: HostUpdateSink - ) {} + ) { + this.hosts.set(workflowId, host) + } + + addWorkflow(workflowId: string, host: HostDoc): void { + this.hosts.set(workflowId, host) + } + + /** Holds subscribe answers for `workflowId` until {@link resumeSubscribe}. */ + pauseSubscribes(workflowId: string): void { + this.pausedSubscribes.add(workflowId) + } + + /** Ends the hold and answers the newest subscribe held by {@link pauseSubscribes}. */ + resumeSubscribe(workflowId: string): void { + this.pausedSubscribes.delete(workflowId) + const stateVector = this.pendingSubscribes.get(workflowId) + if (stateVector === undefined) return + this.pendingSubscribes.delete(workflowId) + this.answerSubscribe(workflowId, stateVector) + } /** Pins the `status` sid; `''` models a socket with no id. */ reportSocketSid(sid: string): this { @@ -284,11 +310,11 @@ export class AgentFollowerHostSocket { const frame = parseClientDocFrame(raw) if (!frame) return this.recordClientFrame(frame) - if (frame.workflowId !== this.workflowId) { + if (frame.workflowId === null || !this.hosts.has(frame.workflowId)) { this.rejectForeignOps(frame) return } - this.routeClientDocFrame(frame) + this.routeClientDocFrame(frame, frame.workflowId) } private recordClientFrame(frame: ParsedClientDocFrame): void { @@ -302,31 +328,53 @@ export class AgentFollowerHostSocket { knownLineageSeq: frame.knownLineageSeq, ops: ops.map((op) => opLabel(op)), opIds: ops.map((op) => op.op_id), + baseVersions: ops.map((op) => + 'base_version' in op && typeof op.base_version === 'number' + ? op.base_version + : null + ), writers: ops.map(claimedWriter), connection: this.connections, comfyConnection: this.comfyConnections }) } - private routeClientDocFrame(frame: ParsedClientDocFrame): void { + private routeClientDocFrame( + frame: ParsedClientDocFrame, + workflowId: string + ): void { if (frame.type === 'doc_subscribe' && frame.stateVector !== null) { - this.answerSubscribe(frame.stateVector) + if (this.pausedSubscribes.has(workflowId)) { + this.pendingSubscribes.set(workflowId, frame.stateVector) + return + } + this.answerSubscribe(workflowId, frame.stateVector) return } - if (frame.type === 'doc_ops') this.receiveHumanOps(frame) + if (frame.type === 'doc_ops') this.receiveHumanOps(frame, workflowId) } - private receiveHumanOps(frame: ParsedClientDocFrame): void { - if (this.unansweredHumanBatches > 0 && this.wouldAcceptHumanOps(frame)) { + private receiveHumanOps( + frame: ParsedClientDocFrame, + workflowId: string + ): void { + if ( + this.unansweredHumanBatches > 0 && + this.wouldAcceptHumanOps(frame, workflowId) + ) { this.unansweredHumanBatches -= 1 return } if (this.humanOpsHost === 'apply') { - this.judgeHumanOps(frame.opsResult, frame.tab) + this.judgeHumanOps(workflowId, frame.opsResult, frame.tab) return } if (frame.opsResult.ok) { - this.heldBatches.push({ tab: frame.tab, ops: frame.opsResult.ops }) + this.heldBatches.push({ + workflowId, + tab: frame.tab, + ops: frame.opsResult.ops + }) } } @@ -339,7 +387,11 @@ export class AgentFollowerHostSocket { releaseHeldClientOps(): WireOpEnvelope[] { const batch = this.heldBatches.shift() if (!batch) return [] - this.judgeHumanOps({ ok: true, ops: batch.ops }, batch.tab) + this.judgeHumanOps( + batch.workflowId, + { ok: true, ops: batch.ops }, + batch.tab + ) return batch.ops } @@ -355,11 +407,16 @@ export class AgentFollowerHostSocket { this.subscribeAnswer = answer } - private answerSubscribe(stateVector: string): void { - if (this.refuseReason !== null && this.refusalsLeft > 0) { + private answerSubscribe(workflowId: string, stateVector: string): void { + const host = this.hosts.get(workflowId)! + if ( + workflowId === this.workflowId && + this.refuseReason !== null && + this.refusalsLeft > 0 + ) { this.refusalsLeft -= 1 this.refusedSubscribes += 1 - const refusal = this.host.subscribeRefused(this.refuseReason) + const refusal = host.subscribeRefused(this.refuseReason) this.send({ ...refusal, data: { ...refusal.data, code: this.refuseReason } @@ -367,8 +424,12 @@ export class AgentFollowerHostSocket { this.resolveSubscribed?.() return } - for (const frame of this.subscribeAnswer(stateVector)) this.send(frame) - this.subscribes += 1 + const answer = + workflowId === this.workflowId + ? this.subscribeAnswer(stateVector) + : [host.subscribed(), host.catchUp(stateVector)] + for (const frame of answer) this.send(frame) + this.subscribes.set(workflowId, this.subscribeCount(workflowId) + 1) this.resolveSubscribed?.() } @@ -382,28 +443,37 @@ export class AgentFollowerHostSocket { this.unansweredHumanBatches += count } - private wouldAcceptHumanOps({ opsResult, tab }: ParsedClientDocFrame) { - return 'ops' in this.classifyHumanOps(opsResult, tab) + private wouldAcceptHumanOps( + { opsResult, tab }: ParsedClientDocFrame, + workflowId: string + ) { + return 'ops' in this.classifyHumanOps(workflowId, opsResult, tab) } private classifyHumanOps( + workflowId: string, opsResult: ParsedWireBatch, tab: string | null ): { ops: WireOpEnvelope[] } | { refusal: HostFrame } { if (!opsResult.ok || !tab || !isValidDocOpsBatch(opsResult.ops)) - return { refusal: this.invalidFrameResult() } + return { refusal: this.invalidFrameResult(workflowId) } if (!claimsOneFrameActor(opsResult.ops, tab)) - return { refusal: this.forbiddenResult() } + return { refusal: this.forbiddenResult(workflowId) } return { ops: opsResult.ops } } - private judgeHumanOps(opsResult: ParsedWireBatch, tab: string | null): void { - const verdict = this.classifyHumanOps(opsResult, tab) + private judgeHumanOps( + workflowId: string, + opsResult: ParsedWireBatch, + tab: string | null + ): void { + const verdict = this.classifyHumanOps(workflowId, opsResult, tab) if ('refusal' in verdict) { this.send(verdict.refusal) return } - const { result, update, outcomes } = this.host.applyWire(verdict.ops) + const host = this.hosts.get(workflowId)! + const { result, update, outcomes } = host.applyWire(verdict.ops) this.humanOutcomes.push(...outcomes) this.send(result) if (update) (this.hostUpdateSink ?? ((frame) => this.send(frame)))(update) @@ -423,17 +493,17 @@ export class AgentFollowerHostSocket { applied: [], skipped: [], code: 'unknown_workflow', - message: 'the fake host serves one workflow' + message: 'the fake host does not serve this workflow' } }) } - private invalidFrameResult(): HostFrame { + private invalidFrameResult(workflowId: string): HostFrame { return { type: 'doc_ops_result', data: { v: DOC_PROTOCOL_VERSION, - workflow_id: this.workflowId, + workflow_id: workflowId, ok: false, code: 'invalid_frame', message: 'doc_ops frame was not structurally valid' @@ -441,12 +511,12 @@ export class AgentFollowerHostSocket { } } - private forbiddenResult(): HostFrame { + private forbiddenResult(workflowId: string): HostFrame { return { type: 'doc_ops_result', data: { v: DOC_PROTOCOL_VERSION, - workflow_id: this.workflowId, + workflow_id: workflowId, ok: false, code: 'forbidden', message: 'op actor does not match the authenticated writer' @@ -457,10 +527,11 @@ export class AgentFollowerHostSocket { /** * Rises once per subscribe the host accepted, after its answer was sent. * A custom answer from {@link answerSubscribesWith} may carry no catch-up; - * refused subscribes count only in {@link refusedSubscribeCount}. + * refused subscribes count only in {@link refusedSubscribeCount}. Counts the + * primary workflow unless another served workflow id is passed. */ - subscribeCount(): number { - return this.subscribes + subscribeCount(workflowId = this.workflowId): number { + return this.subscribes.get(workflowId) ?? 0 } connectionCount(): number { diff --git a/browser_tests/fixtures/data/agent/backgroundTabEdits.ts b/browser_tests/fixtures/data/agent/backgroundTabEdits.ts new file mode 100644 index 00000000000..b5659f1f4f5 --- /dev/null +++ b/browser_tests/fixtures/data/agent/backgroundTabEdits.ts @@ -0,0 +1,99 @@ +import type { ComfyWorkflowJSON } from '@/platform/workflow/validation/schemas/workflowSchema' + +import type { RecordedGraphOperation } from '@e2e/fixtures/data/agent/agentConversation' +import { + agentThreadSummary, + agentUserTranscript +} from '@e2e/fixtures/data/agent/agentThreadList' +import type { AgentWorkflowChatsMock } from '@e2e/fixtures/helpers/agentWorkflowChats' + +type WorkflowChats = ConstructorParameters[0] + +interface ChatWorkflow { + id: string + name: string + threadId: string + request: string +} + +export const BACKGROUND_TAB_CASE = 'agent-rec-set-widget-existing' +export const FOREGROUND_NAME = 'Unsaved Workflow' +export const BACKGROUND: ChatWorkflow = { + id: '3c1e5b7a-9d2f-4e8b-a6c4-0f1e2d3c4b5a', + name: 'Other Study', + threadId: '7a2b4c6d-8e0f-4a1b-9c3d-5e7f9a1b3c5d', + request: 'Tidy up the other study' +} +export const BACKGROUND_NODES = [ + { id: 801, title: 'b1', x: 1400 }, + { id: 802, title: 'b2', x: 1700 }, + { id: 803, title: 'b3', x: 2000 } +] + +const EMPTY_GRAPH: ComfyWorkflowJSON = { + last_node_id: 0, + last_link_id: 0, + nodes: [], + links: [], + groups: [], + config: {}, + extra: {}, + version: 0.4 +} + +export function backgroundEdits(): RecordedGraphOperation[] { + const type = 'EmptyLatentImage' + return BACKGROUND_NODES.flatMap(({ id, title, x }) => [ + { + op: 'add_node', + node_id: id, + class_type: type, + pos: [x, 600], + node: { + id, + type, + pos: [x, 600], + size: [240, 134], + flags: {}, + order: 0, + mode: 0, + inputs: [], + outputs: [{ name: 'LATENT', type: 'LATENT', links: [] }], + properties: {}, + widgets_values: [512, 512, 1] + } + }, + { op: 'set_node_field', node_id: id, field: 'title', value: title } + ]) +} + +export function backgroundTabChats( + foreground: Omit +): WorkflowChats { + const chats = [ + { ...foreground, name: FOREGROUND_NAME, at: '2026-11-02T09:00:00Z' }, + { ...BACKGROUND, at: '2026-11-02T10:00:00Z' } + ] + return { + workflows: chats.map(({ id, name }) => ({ + id, + name, + content: EMPTY_GRAPH + })), + threads: chats.map(({ id, name, threadId, request, at }) => + agentThreadSummary(threadId, `${name} chat`, { + preview: request, + workflow_id: id, + last_message_at: at + }) + ), + transcripts: Object.fromEntries( + chats.map(({ id, threadId, request }) => [ + threadId, + agentUserTranscript(threadId, id, request) + ]) + ) + } +} + +export const USER_NOTE_POSITION: [number, number] = [400, 400] diff --git a/browser_tests/tests/agent/agentBackgroundTabEditsLand.spec.ts b/browser_tests/tests/agent/agentBackgroundTabEditsLand.spec.ts new file mode 100644 index 00000000000..2084a0d9028 --- /dev/null +++ b/browser_tests/tests/agent/agentBackgroundTabEditsLand.spec.ts @@ -0,0 +1,146 @@ +import { expect } from '@playwright/test' + +import { + agentConversationTest as test, + THREAD_ID +} from '@e2e/fixtures/agentConversationFixture' +import { AgentPanel } from '@e2e/fixtures/components/AgentPanel' +import { + BACKGROUND, + BACKGROUND_NODES, + BACKGROUND_TAB_CASE, + backgroundEdits, + backgroundTabChats, + FOREGROUND_NAME, + USER_NOTE_POSITION +} from '@e2e/fixtures/data/agent/backgroundTabEdits' +import { AgentWorkflowChatsMock } from '@e2e/fixtures/helpers/agentWorkflowChats' + +test.describe( + 'Agent edits to a background workflow tab', + { tag: ['@cloud', '@agent', '@vue-nodes'] }, + () => { + test.use({ conversationCase: BACKGROUND_TAB_CASE }) + + test.beforeEach(async ({ agentConversation, page }) => { + test.setTimeout(120_000) + const panel = new AgentPanel(page) + const topbar = agentConversation.topbar + const aRequest = agentConversation.conversation.turns[0].request.content + + await test.step('agent edits workflow A', () => + agentConversation.runTurns()) + + await test.step('workflow B has a saved chat of its own', async () => { + agentConversation.serveWorkflow(BACKGROUND.id, { + ...agentConversation.conversation.workflow.seed, + nodes: [], + links: [] + }) + await new AgentWorkflowChatsMock( + backgroundTabChats({ + id: agentConversation.conversation.workflow.id, + threadId: THREAD_ID, + request: aRequest + }) + ).route(page) + }) + + await test.step('user opens workflow B and its chat', async () => { + await panel.historyButton.click() + await panel.root + .getByRole('button', { name: `${BACKGROUND.name} chat`, exact: true }) + .click() + await expect(panel.userMessageBubbles).toHaveText([BACKGROUND.request]) + await expect( + topbar.getWorkflowTab(BACKGROUND.name).and(topbar.getActiveTab()) + ).toBeVisible() + }) + + await test.step('user returns to A by its tab', async () => { + await topbar.getWorkflowTab(FOREGROUND_NAME).click() + await expect(panel.userMessageBubbles).toHaveText([aRequest]) + }) + }) + + test('are on the canvas when the user returns to that tab', async ({ + agentConversation, + page + }) => { + const panel = new AgentPanel(page) + const topbar = agentConversation.topbar + const aRequest = agentConversation.conversation.turns[0].request.content + + await test.step('user switches to B by its tab', async () => { + await topbar.getWorkflowTab(BACKGROUND.name).click() + await expect(panel.userMessageBubbles).toHaveText([BACKGROUND.request]) + await expect( + topbar.getWorkflowTab(BACKGROUND.name).and(topbar.getActiveTab()) + ).toBeVisible() + }) + + await test.step('agent adds three titled nodes to A while B is shown', () => + agentConversation.applyOpsOnHostUnsent(backgroundEdits())) + + await test.step('returning to A shows every background edit', async () => { + await topbar.getWorkflowTab(FOREGROUND_NAME).click() + await expect( + topbar.getWorkflowTab(FOREGROUND_NAME).and(topbar.getActiveTab()) + ).toBeVisible() + await expect(panel.userMessageBubbles).toHaveText([aRequest]) + for (const { id, title } of BACKGROUND_NODES) + await expect( + agentConversation.vueNodes + .getNodeLocator(String(id)) + .getByTestId('node-title') + ).toHaveText(title) + }) + }) + + test('do not rebind a tab the user edited while its chat was loading', async ({ + agentConversation, + page + }) => { + const panel = new AgentPanel(page) + const topbar = agentConversation.topbar + const subscribesBefore = agentConversation.subscribeCount(BACKGROUND.id) + const transcript = await agentConversation.holdTranscript( + BACKGROUND.threadId + ) + + const noteId = + await test.step('user edits B before its chat loads', async () => { + await topbar.getWorkflowTab(BACKGROUND.name).click() + await transcript.requested + const id = await agentConversation.addNoteThroughSearchBox({ + x: USER_NOTE_POSITION[0], + y: USER_NOTE_POSITION[1] + }) + await expect( + agentConversation.vueNodes.getNodeLocator(id) + ).toBeVisible() + return id + }) + + await test.step('B keeps the edit once its chat loads', async () => { + transcript.release() + await expect(panel.userMessageBubbles).toHaveText([BACKGROUND.request]) + await expect( + agentConversation.vueNodes.getNodeLocator(noteId) + ).toBeVisible() + }) + + await test.step('the next subscribe, to A, finds B never re-subscribed', async () => { + const aId = agentConversation.conversation.workflow.id + const aSubscribes = agentConversation.subscribeCount(aId) + await topbar.getWorkflowTab(FOREGROUND_NAME).click() + await expect + .poll(() => agentConversation.subscribeCount(aId)) + .toBeGreaterThan(aSubscribes) + expect(agentConversation.subscribeCount(BACKGROUND.id)).toBe( + subscribesBefore + ) + }) + }) + } +) diff --git a/browser_tests/tests/agent/agentFollowerRestoredBindingReload.spec.ts b/browser_tests/tests/agent/agentFollowerRestoredBindingReload.spec.ts index f68ec563b1c..8b22d23ff29 100644 --- a/browser_tests/tests/agent/agentFollowerRestoredBindingReload.spec.ts +++ b/browser_tests/tests/agent/agentFollowerRestoredBindingReload.spec.ts @@ -123,5 +123,51 @@ test.describe( expect(await posted).toContain('local edit before automatic restore') }) }) + + test('keeps a saved local edit made while restored-target identity is pending', async ({ + agentConversation, + page + }) => { + test.setTimeout(90_000) + const reload = new RestoredBindingReloadDriver(page, agentConversation) + await agentConversation.persistSavedWorkflow() + await agentConversation.runTurns() + const prompt = agentConversation.vueNodes + .getNodeLocator('6') + .getByRole('textbox') + await agentConversation.topbar.saveWorkflowAs('Restored reload') + await reload.persistThreadTranscript() + + let releaseIdentity!: () => void + const identityPending = new Promise((resolve) => { + releaseIdentity = resolve + }) + await page.route('**/api/agent/identity', async (route) => { + await identityPending + await route.fallback() + }) + + await reload.reloadIntoRestoredTarget('Restored reload') + await prompt.fill('local edit while identity is pending') + await agentConversation.topbar.saveWorkflowAs('Restored reload') + + const subscribesBeforeSecondReload = agentConversation.subscribeCount() + await reload.reloadIntoRestoredTarget('Restored reload') + await expect(prompt).toHaveValue('local edit while identity is pending') + + const identityResponse = page.waitForResponse('**/api/agent/identity') + releaseIdentity() + await identityResponse + await page.evaluate( + () => + new Promise((resolve) => + requestAnimationFrame(() => requestAnimationFrame(() => resolve())) + ) + ) + expect(agentConversation.subscribeCount()).toBe( + subscribesBeforeSecondReload + ) + await expect(prompt).toHaveValue('local edit while identity is pending') + }) } ) diff --git a/browser_tests/tests/agent/agentHumanEditAfterOtherWorkflowReset.spec.ts b/browser_tests/tests/agent/agentHumanEditAfterOtherWorkflowReset.spec.ts new file mode 100644 index 00000000000..cd54f8c0baa --- /dev/null +++ b/browser_tests/tests/agent/agentHumanEditAfterOtherWorkflowReset.spec.ts @@ -0,0 +1,74 @@ +import { comfyExpect as expect } from '@e2e/fixtures/ComfyPage' +import { agentConversationTest as test } from '@e2e/fixtures/agentConversationFixture' + +test.describe( + 'Human edit after another workflow resets', + { + tag: ['@cloud', '@agent', '@vue-nodes'], + annotation: { + type: 'issue', + description: 'https://github.com/Comfy-Org/ComfyUI_frontend/pull/19871' + } + }, + () => { + const RESET_WORKFLOW_ID = '93ba31ab-65a2-42fe-bd12-b96bf4ef3591' + test.use({ + conversationCase: 'agent-rec-text-only-answer', + humanOpsHost: 'apply' + }) + + test('keeps the original workflow mint cursor before its resubscribe is acknowledged', async ({ + agentConversation + }) => { + const { recordedWorkflowId, firstBaseVersion } = + await test.step('Edit the original workflow and record its wire version', async () => { + await agentConversation.runTurns() + const recordedWorkflowId = agentConversation.conversation.workflow.id + const firstNodeId = await agentConversation.addNodeOfType( + 'Note', + [400, 400] + ) + await expect( + agentConversation.vueNodes.getNodeLocator(firstNodeId) + ).toBeVisible() + await agentConversation.waitForHumanOps(1) + const firstBaseVersion = + await agentConversation.humanAddNodeBaseVersion( + recordedWorkflowId, + firstNodeId + ) + return { recordedWorkflowId, firstBaseVersion } + }) + + await test.step('Reset the other workflow', async () => { + await agentConversation.activateEmptyWorkflow( + RESET_WORKFLOW_ID, + 'Reset target' + ) + const beforeReset = agentConversation.subscribeCount(RESET_WORKFLOW_ID) + agentConversation.sendDocumentReset(RESET_WORKFLOW_ID) + await expect + .poll(() => agentConversation.subscribeCount(RESET_WORKFLOW_ID)) + .toBeGreaterThanOrEqual(beforeReset + 1) + }) + + await test.step('Edit before the resubscribe acknowledgement', async () => { + await agentConversation.activateRecordedWorkflowBeforeSubscribeAck() + const secondNodeId = await agentConversation.addNodeOfType( + 'Note', + [650, 400] + ) + await expect( + agentConversation.vueNodes.getNodeLocator(secondNodeId) + ).toBeVisible() + expect( + await agentConversation.humanAddNodeBaseVersion( + recordedWorkflowId, + secondNodeId + ) + ).toBeGreaterThan(firstBaseVersion) + agentConversation.resumeWorkflowSubscribe(recordedWorkflowId) + }) + }) + } +) diff --git a/src/workbench/extensions/agent/AgentPanelRoot.test.ts b/src/workbench/extensions/agent/AgentPanelRoot.test.ts index 013d3ac0051..d4296c13cd3 100644 --- a/src/workbench/extensions/agent/AgentPanelRoot.test.ts +++ b/src/workbench/extensions/agent/AgentPanelRoot.test.ts @@ -10662,6 +10662,90 @@ describe('AgentPanelRoot workflow binding', () => { } }) + it('leaves a workflow unbound after a local edit made before its follower subscribe confirms', async () => { + vi.mocked(resolveAgentIdentity).mockReturnValue({ + state: ref({ status: 'pending' }), + reset: vi.fn(), + stop: () => {} + }) + makeTab('wf-42') + const target = addTab('workflows/target.json', { + activeState: fromPartial({ id: 'graph-target' }) + }) + useAgentWorkflowTabBindingStore().bind('wf-target', target.path) + const messagesFor = (threadId: string, text: string): AgentMessages => [ + { + id: `row-${threadId}`, + thread_id: threadId, + seq: 1, + role: 'user', + status: 'complete', + turn_id: 'turn', + workflow_id: 'wf-target', + content: { text } + } + ] + vi.mocked(fetch).mockImplementation(async (input: RequestInfo | URL) => { + const url = String(input) + + if (url.includes('/th-first/messages')) + return json(200, messagesFor('th-first', 'First request')) + if (url.includes('/th-second/messages')) + return json(200, messagesFor('th-second', 'Second request')) + if (url.includes('/workflows')) + return json(200, { + data: [{ id: 'wf-target', name: 'target' }], + pagination: { offset: 0, limit: 100, total: 1, has_more: false } + }) + return json( + 200, + agentThreadList([ + agentThread({ + id: 'th-first', + title: 'First chat', + last_message_at: '2026-09-01T00:00:00Z' + }), + agentThread({ + id: 'th-second', + title: 'Second chat', + last_message_at: '2026-08-01T00:00:00Z' + }) + ]) + ) + }) + renderWithSelectedTarget() + expect(docOpMinterDeps.current?.isDocBound()).toBe(false) + + await userEvent.click( + screen.getByRole('button', { + name: i18n.global.t('agent.showChatHistory') + }) + ) + await userEvent.click(await screen.findByText('First chat')) + await screen.findAllByText('First request') + await vi.waitFor(() => + expect(useAgentChatHistoryStore().activeId).toBe('th-first') + ) + await vi.waitFor(() => + expect(docOpMinterDeps.current?.boundRootGraphId()).not.toBeNull() + ) + expect(docOpMinterDeps.current?.isDocBound()).toBe(false) + docOpMinterDeps.current?.onUnboundLocalIntent?.() + + await userEvent.click( + screen.getByRole('button', { + name: i18n.global.t('agent.showChatHistory') + }) + ) + await userEvent.click(await screen.findByText('Second chat')) + await screen.findAllByText('Second request') + await vi.waitFor(() => + expect(useAgentChatHistoryStore().activeId).toBe('th-second') + ) + expect(docOpMinterDeps.current?.boundRootGraphId()).toBeNull() + expect(docOpMinterDeps.current?.isDocBound()).toBe(false) + }) + it('binds the session to the workflow a history thread restored, not only a reload', async () => { makeTab('wf-42') const old = addTab('workflows/old.json', { diff --git a/src/workbench/extensions/agent/AgentPanelRoot.vue b/src/workbench/extensions/agent/AgentPanelRoot.vue index 36066e59af7..a3ca938cfaa 100644 --- a/src/workbench/extensions/agent/AgentPanelRoot.vue +++ b/src/workbench/extensions/agent/AgentPanelRoot.vue @@ -926,12 +926,23 @@ async function onWorkflowRestoredAndBound( isCurrent ) if (committedWorkflowId === null || !isCurrent()) return ready - if (hasUnsyncedHumanOps(committedWorkflowId)) return ready - if (boundWorkflowId.value !== committedWorkflowId) - bindWorkflow(committedWorkflowId) + bindRestoredWorkflow(committedWorkflowId) return ready } +function bindRestoredWorkflow(workflowId: string): void { + if (hasUnsyncedHumanOps(workflowId)) return + if (boundWorkflowId.value !== workflowId) bindWorkflow(workflowId) +} + +function adoptFollowedWorkflow( + workflow: ComfyWorkflow, + workflowId: string +): void { + adoptWorkflowTarget(workflow, workflowId) + bindRestoredWorkflow(workflowId) +} + function warnWorkflowUnavailable(): void { toast.warning(t('agent.targetNavigationUnavailable'), { duration: 5000 }) } @@ -1083,6 +1094,7 @@ const { status: crdtStatus, debugSnapshot: crdtDebugSnapshot, enqueueHumanOperations, + noteUnboundLocalIntent, retrySubscription, docInputNames, docWidgetValue, @@ -1155,9 +1167,18 @@ function boundRootGraphId(): RootGraphId | null { function followerCanDeliver(): boolean { return isFollowerActive.value && subscriptionSent() } +function noteUnboundVisibleIntent(): void { + const visible = workflowStore.activeWorkflow + const workflowId = visible + ? bindingStore.workflowIdFor(visible.path) + : undefined + if (workflowId !== undefined) noteUnboundLocalIntent(workflowId) +} const docOpMinter = attachDocOpMinter({ isEnabled: () => agentPanelStore.enabled, isDocBound: followerCanDeliver, + onUnboundLocalIntent: noteUnboundLocalIntent, + onUnboundVisibleIntent: noteUnboundVisibleIntent, enqueue: enqueueHumanOperations, getGraph: () => (app.isGraphReady ? app.rootGraph : null), boundRootGraphId, @@ -1769,7 +1790,7 @@ const workflowChatFollow = useAgentWorkflowChatFollow({ trackThreadStarted: () => useTelemetry()?.trackAgentThreadStarted({ source: 'history_select' }), restoreThreadWorkflow, - adoptWorkflowTarget, + adoptWorkflowTarget: adoptFollowedWorkflow, adoptRestoredWorkflowTab }) diff --git a/src/workbench/extensions/agent/crdt/docOpMinter.test.ts b/src/workbench/extensions/agent/crdt/docOpMinter.test.ts index 0663bc74be0..eb020cfbbe0 100644 --- a/src/workbench/extensions/agent/crdt/docOpMinter.test.ts +++ b/src/workbench/extensions/agent/crdt/docOpMinter.test.ts @@ -303,6 +303,8 @@ describe('attachDocOpMinter', () => { let refusals: Array<[string, string]> let seededPromotedDocs: Set> let dynamicComboDocs: Set> + let unboundLocalIntents: number + let unboundVisibleIntents: number function registeredDynamicComboScenario() { const scenario = dynamicComboScenario(graph) @@ -326,9 +328,13 @@ describe('attachDocOpMinter', () => { refusals = [] seededPromotedDocs = new Set() dynamicComboDocs = new Set() + unboundLocalIntents = 0 + unboundVisibleIntents = 0 minter = attachDocOpMinter({ isEnabled: () => enabled, isDocBound: () => bound, + onUnboundLocalIntent: () => unboundLocalIntents++, + onUnboundVisibleIntent: () => unboundVisibleIntents++, enqueue: (operations) => minted.push(...operations), getGraph: () => (graphAvailable ? graph : null), boundRootGraphId: () => (unbound ? null : rootGraphId), @@ -572,6 +578,33 @@ describe('attachDocOpMinter', () => { expect(source.widgets![0].value).toBe(6) expect(minted).toEqual([]) + expect(unboundLocalIntents).toBe(1) + }) + + it('marks only edits to the bound workflow while its document is unconfirmed', async () => { + const { source } = seedGraph(graph) + bound = false + source.widgets![0].value = 5 + unbound = true + source.widgets![0].value = 6 + await afterFlush() + + expect(unboundLocalIntents).toBe(1) + expect(minted).toEqual([]) + }) + + it('marks an unbound edit to the visible workflow while another one is bound', async () => { + const { source } = seedGraph(graph) + bound = false + rootGraphId = toRootGraphId('other-root-graph') + source.widgets![0].value = 5 + unbound = true + source.widgets![0].value = 6 + await afterFlush() + + expect(unboundLocalIntents).toBe(0) + expect(unboundVisibleIntents).toBe(2) + expect(minted).toEqual([]) }) it('snapshots a pasted node after its same-tick configure, folding the widget and field writes into add_node', async () => { diff --git a/src/workbench/extensions/agent/crdt/docOpMinter.ts b/src/workbench/extensions/agent/crdt/docOpMinter.ts index 3ad8c259555..f96834f16c7 100644 --- a/src/workbench/extensions/agent/crdt/docOpMinter.ts +++ b/src/workbench/extensions/agent/crdt/docOpMinter.ts @@ -63,6 +63,10 @@ export interface DocOpMinterDeps { isEnabled(): boolean /** A semantic doc is bound for the active workflow. */ isDocBound(): boolean + /** Records a local edit that cannot yet enter the semantic document. */ + onUnboundLocalIntent?(): void + /** Records a local edit to the visible workflow while another one, or none, is bound. */ + onUnboundVisibleIntent?(): void /** Receives minted semantic operations (the sender's inbox). */ enqueue(operations: GraphOperation[]): void /** The live root graph, or null when no workflow is open. */ @@ -1186,14 +1190,38 @@ export function attachDocOpMinter(deps: DocOpMinterDeps): DocOpMinter { schedule({ kind: 'add_node', graph: event.graph, node: event.node }) } + function discardHeldWrite(event: GraphIntentEvent): void { + if (event.type === 'set_widget') + heldPromotedWrites.delete(heldWriteKey(event)) + } + + function intentRootGraphId( + event: GraphIntentEvent, + graph: LGraph | null + ): string | null { + if ('graph' in event) return event.graph.rootGraph.id + return graph !== null && reachableIntentGraph(graph, event.graphId) !== null + ? graph.id + : null + } + + function noteUnboundLocalIntent(event: GraphIntentEvent): void { + const graph = deps.getGraph() + const eventRootGraphId = intentRootGraphId(event, graph) + if (eventRootGraphId === null) return + if (eventRootGraphId === deps.boundRootGraphId()) + deps.onUnboundLocalIntent?.() + else if (eventRootGraphId === graph?.id) deps.onUnboundVisibleIntent?.() + } + function onIntent(event: GraphIntentEvent): void { if (event.source !== 'local') return - if (!deps.isEnabled() || !deps.isDocBound()) { - if (event.type === 'set_widget') - heldPromotedWrites.delete(heldWriteKey(event)) + if (deps.isEnabled() && deps.isDocBound()) { + mintIntent(event) return } - mintIntent(event) + if (deps.isEnabled()) noteUnboundLocalIntent(event) + discardHeldWrite(event) } function mintIntent(event: GraphIntentEvent): void { diff --git a/src/workbench/extensions/agent/crdt/followerProductGate.test.ts b/src/workbench/extensions/agent/crdt/followerProductGate.test.ts index 81ee362c5f2..41dedc8d002 100644 --- a/src/workbench/extensions/agent/crdt/followerProductGate.test.ts +++ b/src/workbench/extensions/agent/crdt/followerProductGate.test.ts @@ -5,6 +5,7 @@ import { defineComponent, nextTick, ref } from 'vue' import { useAgentPanelStore } from '@/workbench/extensions/agent/stores/agent/agentPanelStore' import { createFakeAgentSocket } from './__fixtures__/agentSocket' +import { hasUnsyncedHumanOps } from './unsyncedHumanOps' import { useAgentCrdtFollower } from './useAgentCrdtFollower' it('gates real document transport and removes reconnect listeners on revocation', async () => { @@ -67,3 +68,40 @@ it('gates real document transport and removes reconnect listeners on revocation' data: { workflow_id: 'wf-2' } }) }) + +it('hands an unconfirmed local edit to the follower created after a gate restart', async () => { + const agentSocket = createFakeAgentSocket() + const store = useAgentPanelStore() + store.enabled = true + const workflowId = ref('wf-gate-restart') + let follower!: ReturnType + const { unmount } = render( + defineComponent({ + setup() { + follower = useAgentCrdtFollower(workflowId, { + transport: agentSocket.transport + }) + return () => null + } + }) + ) + onTestFinished(unmount) + + follower.noteUnboundLocalIntent() + expect(hasUnsyncedHumanOps('wf-gate-restart')).toBe(true) + + store.enabled = false + await nextTick() + expect(hasUnsyncedHumanOps('wf-gate-restart')).toBe(true) + + store.enabled = true + await nextTick() + agentSocket.receive('doc_subscribed', { + v: 1, + workflow_id: 'wf-gate-restart', + ok: true, + seq: 0, + lineage_seq: 0 + }) + expect(hasUnsyncedHumanOps('wf-gate-restart')).toBe(false) +}) diff --git a/src/workbench/extensions/agent/crdt/unsyncedHumanOps.test.ts b/src/workbench/extensions/agent/crdt/unsyncedHumanOps.test.ts index 0a89349015b..62f2327efa0 100644 --- a/src/workbench/extensions/agent/crdt/unsyncedHumanOps.test.ts +++ b/src/workbench/extensions/agent/crdt/unsyncedHumanOps.test.ts @@ -67,4 +67,15 @@ describe('unsyncedHumanOps', () => { expect(page.hasUnsyncedHumanOps('wf-a')).toBe(false) expect((await loadPage()).hasUnsyncedHumanOps('wf-a')).toBe(false) }) + + it("hands a disposed recorder's workflows to its successor", async () => { + const page = await loadPage() + page.recordUnsyncedHumanOps('tab-1', ['wf-a']) + page.releaseUnsyncedHumanOpsRecorder('tab-1') + page.recordUnsyncedHumanOps('tab-1', []) + + expect(page.hasUnsyncedHumanOps('wf-a')).toBe(true) + page.forgetUnsyncedAtLoad('wf-a') + expect(page.hasUnsyncedHumanOps('wf-a')).toBe(false) + }) }) diff --git a/src/workbench/extensions/agent/crdt/unsyncedHumanOps.ts b/src/workbench/extensions/agent/crdt/unsyncedHumanOps.ts index 8273269ec63..2a5c0226151 100644 --- a/src/workbench/extensions/agent/crdt/unsyncedHumanOps.ts +++ b/src/workbench/extensions/agent/crdt/unsyncedHumanOps.ts @@ -48,6 +48,15 @@ export function recordUnsyncedHumanOps( writeStored([...unsyncedNow()]) } +/** Preserves a disposed recorder's warnings for its successor. */ +export function releaseUnsyncedHumanOpsRecorder(recorder: string): void { + const recorded = unsyncedByRecorder.get(recorder) + if (recorded === undefined) return + for (const workflowId of recorded) loadOnce().add(workflowId) + unsyncedByRecorder.delete(recorder) + writeStored([...unsyncedNow()]) +} + /** Whether `workflowId`'s canvas holds edits the shared document may lack. */ export function hasUnsyncedHumanOps(workflowId: string): boolean { return unsyncedNow().has(workflowId) diff --git a/src/workbench/extensions/agent/crdt/useAgentCrdtFollower.ts b/src/workbench/extensions/agent/crdt/useAgentCrdtFollower.ts index 976ea4c3075..b70e92f4dce 100644 --- a/src/workbench/extensions/agent/crdt/useAgentCrdtFollower.ts +++ b/src/workbench/extensions/agent/crdt/useAgentCrdtFollower.ts @@ -59,7 +59,8 @@ import type { BatchOutcome, OpsResultView } from './opSender' import { createRejectedOpNotifier } from './rejectedOpNotice' import { forgetUnsyncedAtLoad, - recordUnsyncedHumanOps + recordUnsyncedHumanOps, + releaseUnsyncedHumanOpsRecorder } from './unsyncedHumanOps' export { STALE_AFTER_MS, SUBSCRIBE_CATCHUP_GRACE_MS } @@ -371,6 +372,8 @@ export function useAgentCrdtFollower( }), enqueueHumanOperations: (operations: GraphOperation[]) => follower.value?.enqueueHumanOperations(operations), + noteUnboundLocalIntent: (target?: string) => + follower.value?.noteUnboundLocalIntent(target), retrySubscription: () => follower.value?.retrySubscription(), docInputNames: (nodeId: NodeId) => follower.value?.docInputNames(nodeId) ?? null, @@ -536,9 +539,9 @@ function startAgentCrdtFollower( } const workflowByUnsettledOpId = new Map() - const workflowsWithLostOps = new Set() + const workflowsWithUnsyncedOps = new Set() const recordUnsynced = (): void => { - const unsynced = new Set(workflowsWithLostOps) + const unsynced = new Set(workflowsWithUnsyncedOps) for (const { workflowId, ops } of sender.pendingOps()) { unsynced.add(workflowId) for (const op of ops) workflowByUnsettledOpId.set(op.op_id, workflowId) @@ -549,7 +552,7 @@ function startAgentCrdtFollower( const workflowId = workflowByUnsettledOpId.get(outcome.ops[0]?.op_id ?? '') for (const op of outcome.ops) workflowByUnsettledOpId.delete(op.op_id) if (workflowId !== undefined && outcome.state !== 'acknowledged') - workflowsWithLostOps.add(workflowId) + workflowsWithUnsyncedOps.add(workflowId) recordUnsynced() } @@ -907,7 +910,7 @@ function startAgentCrdtFollower( projection.replaceOnNextFrame(detail.workflowId) reportPendingFrames(detail.workflowId, 'discarded', NOTHING_APPLIED) sender.abortAll() - workflowsWithLostOps.delete(detail.workflowId) + workflowsWithUnsyncedOps.delete(detail.workflowId) recordUnsynced() events.onReset?.(detail.workflowId) connected.value = false @@ -1214,6 +1217,7 @@ function startAgentCrdtFollower( () => bridge.destroy(), () => client.destroy() ]) + releaseUnsyncedHumanOpsRecorder(tabId) }) const status = computed(() => ({ @@ -1250,6 +1254,11 @@ function startAgentCrdtFollower( projection.noteLocalWrites(operations) coalescer.enqueue(operations) }, + noteUnboundLocalIntent: (target = workflowId.value) => { + if (target === null) return + workflowsWithUnsyncedOps.add(target) + recordUnsynced() + }, docInputNames: (nodeId: NodeId) => readDocSlotNames(bridge.follower.doc, String(nodeId), 'inputs'), docWidgetValue: (nodeId: NodeId, widgetName: string) =>