Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
4a1c1bd
fix(agent): require observed canvas confirmation
christian-byrne Oct 20, 2026
e6b564b
fix(agent): make no canvas claim for uncorrelated tool frames
christian-byrne Oct 20, 2026
d55a232
fix(agent): keep denying uncorrelated writes no live frame reached
christian-byrne Oct 20, 2026
2776945
fix(agent): ignore repeated terminal outcomes
christian-byrne Oct 21, 2026
fdca0b0
Merge remote-tracking branch 'origin/main' into oploop-836-refresh
christian-byrne Oct 21, 2026
61b1823
test: name the one-frame two-op confirmation case
christian-byrne Oct 21, 2026
1daf4b7
test: name the non-UUID workflow id case for op matching
christian-byrne Oct 21, 2026
d284d84
test: drop the state assertion the exact equality already pins
christian-byrne Oct 21, 2026
fc48075
test: name the redelivered frame in the canvas-took-it spec
christian-byrne Oct 21, 2026
d8231c1
fix(agent): let a completed clear settle the turn's canvas claim
christian-byrne Oct 21, 2026
e3f202d
Merge remote-tracking branch 'origin/main' into oploop-863d-refresh
christian-byrne Oct 21, 2026
b4c4722
Merge remote-tracking branch 'origin/main' into oploop-866d-refresh
christian-byrne Oct 21, 2026
49849b6
Merge remote-tracking branch 'origin/main' into op613-canvas-claim-in…
christian-byrne Oct 22, 2026
b027218
fix(agent): gate template insertion like any other canvas write (PM-1…
christian-byrne Oct 22, 2026
a7114ab
chore(agent): drop two added comments and name the tool-outcome tuple
christian-byrne Oct 22, 2026
4cdc0fa
Merge remote-tracking branch 'origin/main' into oploop-897a-refresh
christian-byrne Oct 22, 2026
5ad4f4b
Merge branch 'main' into op613-canvas-claim-invariant
DrJKL Oct 22, 2026
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
15 changes: 5 additions & 10 deletions browser_tests/fixtures/agentFollowerHostSocket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -296,15 +296,6 @@ export class AgentFollowerHostSocket {
return batch.ops
}

/**
* Make the host REFUSE subscribes, as it does when `docService` is nil,
* when it is overloaded, or at the per-session document cap. No catch-up
* follows a refusal, so the follower gets no canvas frame at all.
*
* `times` bounds the refusal: a finite count models a transient overload
* that the follower's own subscribe-retry ladder is meant to ride out, and
* the default (unbounded) models a host that never recovers.
*/
refuseSubscribes(
reason = 'overloaded',
times = Number.POSITIVE_INFINITY
Expand All @@ -321,7 +312,11 @@ export class AgentFollowerHostSocket {
if (this.refuseReason !== null && this.refusalsLeft > 0) {
this.refusalsLeft -= 1
this.refusedSubscribes += 1
this.send(this.host.subscribeRefused(this.refuseReason))
const refusal = this.host.subscribeRefused(this.refuseReason)
this.send({
...refusal,
data: { ...refusal.data, code: this.refuseReason }
})
this.resolveSubscribed?.()
return
}
Expand Down
13 changes: 7 additions & 6 deletions browser_tests/fixtures/agentTurnLockFixture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
zAgentPendingAsk,
zAgentPostMessageRequest
} from '@comfyorg/ingest-types/zod'
import { escapeRegExp } from 'es-toolkit'
import { z } from 'zod'

import enMessages from '@/locales/en/main.json' with { type: 'json' }
Expand Down Expand Up @@ -532,14 +533,14 @@ export class AgentTurnLockHarness {
name: enMessages.agent.runApproval.run,
exact: true
})
// WorkSummary.vue renders three labels off the elapsed total: `worked`
// alone, `workedForSeconds`, or `workedForMinutes`. Anchoring on the
// shared `worked` stem matches all three, so the negative assertions on
// this locator cannot go vacuous when a turn is shorter or longer than the
// fixture's tool duration, or when the copy is reworded.
this.workSummary = this.panel.getByRole('button', {
name: new RegExp(
`^${enMessages.agent.worked.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}`
`^(${[
enMessages.agent.worked,
enMessages.agent.workedNotConfirmedOnCanvas
]
.map(escapeRegExp)
.join('|')})$`
)
})
this.workingRow = this.panel.getByText(enMessages.agent.working, {
Expand Down
31 changes: 16 additions & 15 deletions browser_tests/fixtures/helpers/AgentRemoteApplyHarness.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { expect } from '@playwright/test'
import type { Locator, Page } from '@playwright/test'
import { escapeRegExp } from 'es-toolkit'

import enMessages from '@/locales/en/main.json' with { type: 'json' }
import type {
Expand All @@ -11,7 +12,9 @@ import { HostDoc } from '@e2e/fixtures/agentConversationHostDoc'
import type { HostFrame } from '@e2e/fixtures/agentConversationHostDoc'
import { AgentFollowerHostSocket } from '@e2e/fixtures/agentFollowerHostSocket'
import {
BLANK_WORKFLOW,
bootAgentApp,
loadIntoBootWorkflow,
mockAgentTurnApi,
mockWorkflowPersistence
} from '@e2e/fixtures/agentPanelFixture'
Expand Down Expand Up @@ -63,18 +66,18 @@ export class AgentRemoteApplyHarness {
})
this.workSummary = this.panel.getByRole('button', {
name: new RegExp(
`^${enMessages.agent.worked.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}`
`^(${[
enMessages.agent.worked,
enMessages.agent.workedNotConfirmedOnCanvas
]
.map(escapeRegExp)
.join('|')})`
)
})
}

/**
* Makes the host refuse `doc_subscribe`, as an overloaded one does. `times`
* bounds it: a finite count is a transient overload the follower's own
* retry ladder should ride out, and the default never recovers.
*/
refuseDocSubscribes(times?: number): void {
this.hostSocket.refuseSubscribes('overloaded', times)
refuseDocSubscribes(reason = 'overloaded', times?: number): void {
this.hostSocket.refuseSubscribes(reason, times)
}

/**
Expand All @@ -101,6 +104,10 @@ export class AgentRemoteApplyHarness {
return row.locator('[class*="lucide--wrench"]')
}

unconfirmedGlyph(row: Locator): Locator {
return row.locator('[class*="lucide--triangle-alert"]')
}

async openWorkSummary(): Promise<void> {
await this.workSummary.click()
await expect(this.workSummary).toHaveAttribute('aria-expanded', 'true')
Expand All @@ -109,10 +116,6 @@ export class AgentRemoteApplyHarness {
async setUp(): Promise<void> {
const { page } = this

// Registered before `bootAgentApp` (called with `objectInfo: 'server'`)
// so it wins over the empty handler the boot mocks would otherwise
// register for the same route: Playwright runs the most-recently
// registered matching handler first.
await page.route('**/api/object_info', (route) =>
route.fulfill(jsonRoute(agentReplayNodeDefs))
)
Expand All @@ -132,10 +135,8 @@ export class AgentRemoteApplyHarness {
'Comfy.Graph.CanvasInfo': false
}
})
await loadIntoBootWorkflow(page, BLANK_WORKFLOW)

// Registered only now: the boot mocks blanket-match `**/api/userdata**`
// for every method, and the most-recently-registered route wins, so this
// has to come after them to take over the workflow-save round trip.
await mockWorkflowPersistence(page, WORKFLOW_ID)
}

Expand Down
114 changes: 114 additions & 0 deletions browser_tests/tests/agent/agentCanvasClaimNeedsObservation.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
import { expect } from '@playwright/test'

import enMessages from '@/locales/en/main.json' with { type: 'json' }
import { STALE_AFTER_MS } from '@/workbench/extensions/agent/crdt/agentCrdtDocLifecycle'

import { agentTest as test } from '@e2e/fixtures/agentPanelFixture'
import {
AGENT_NODE_IDS,
addLoadImageNode
} from '@e2e/fixtures/data/agent/agentRemoteApply'
import { AgentRemoteApplyHarness } from '@e2e/fixtures/helpers/AgentRemoteApplyHarness'

const COPY = enMessages.agent

test.describe(
'the agent may not claim a canvas it has not been observed to change',
{ tag: ['@cloud', '@agent', '@vue-nodes'] },
() => {
test.describe.configure({ timeout: 60_000 })

test('export and save guidance is contradicted on an empty tab', async ({
page
}) => {
const agent = new AgentRemoteApplyHarness(page)
await agent.setUp()
await agent.openAndTarget()
await agent.sendPrompt('Build me a text-to-image workflow.')
await agent.hostSocket.waitForSubscribe()

agent.reportToolCall('print_workflow', 'call-print')
agent.finishTurn(
'Your nodes are ready. Open the menu to export or save the workflow.'
)

await agent.expectTurnReportedFinished()
await expect(
agent.panel.getByTestId('agent-run-notice-emptyCanvas')
).toContainText(COPY.canvasIsEmptyAfterTurn)
await expect(agent.workSummary).not.toContainText(
COPY.workedNotConfirmedOnCanvas
)
expect(await agent.settledCanvasNodeIds()).toEqual([])
})

test(
'a template the server placed but the canvas never showed is not reported as done',
{
annotation: {
type: 'source',
description:
'https://linear.app/comfyorg/issue/PM-1343/test-agent-completes-an-image-edit-but-leaves-the-canvas-with-zero#comment-1741744b'
}
},
async ({ page }) => {
await page.clock.install()
const agent = new AgentRemoteApplyHarness(page)
await agent.setUp()
await agent.openAndTarget()
await agent.sendPrompt('Turn this forest scene to daytime.')
await agent.hostSocket.waitForSubscribe()

agent.reportToolCall('get_template', 'call-template')
agent.finishTurn('Your workflow is ready to run.')

await agent.expectTurnReportedFinished()
await expect(
agent.panel.getByTestId('agent-run-notice-emptyCanvas')
).toContainText(COPY.canvasIsEmptyAfterTurn)

await page.clock.fastForward(STALE_AFTER_MS + 1)

await expect(agent.workSummary).toContainText(
COPY.workedNotConfirmedOnCanvas
)
expect(await agent.settledCanvasNodeIds()).toEqual([])
}
)

test('a write the canvas took reads as done through a redelivered frame, with no notice', async ({
page
}) => {
await page.clock.install()
const agent = new AgentRemoteApplyHarness(page)
await agent.setUp()
await agent.openAndTarget()
await agent.sendPrompt('Add a Load Image node.')
await agent.hostSocket.waitForSubscribe()

const [nodeId] = AGENT_NODE_IDS
agent.applyAndBroadcast([addLoadImageNode(nodeId, 0)])
await expect(agent.node(nodeId)).toBeVisible()
agent.reportToolCall('add_node', 'call-add-node')
agent.reportToolCall('add_node', 'call-add-node')
agent.finishTurn('Added a Load Image node.')

await agent.expectTurnReportedFinished()
await expect(agent.workSummary).toContainText(COPY.worked)
await expect(agent.workSummary).not.toContainText(
COPY.workedNotConfirmedOnCanvas
)
await expect(
agent.panel.getByTestId('agent-run-notice-emptyCanvas')
).toHaveCount(0)

await page.clock.fastForward(STALE_AFTER_MS + 1)

await expect(agent.workSummary).toContainText(COPY.worked)
await expect(agent.workSummary).not.toContainText(
COPY.workedNotConfirmedOnCanvas
)
await expect(agent.node(nodeId)).toBeVisible()
})
}
)
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,15 @@ async function driveThroughToolCallDone(
})

await expect(panel.getByRole('button', { name: SEND_LABEL })).toBeVisible()
await expect(panel.getByRole('button', { name: /^Worked/ })).toBeVisible()
await expect(
panel.getByRole('button', {
name:
order === 'docUpdateBeforeToolCall'
? enMessages.agent.worked
: enMessages.agent.workedNotConfirmedOnCanvas,
exact: true
})
).toBeVisible()

return {
vueNodes,
Expand Down Expand Up @@ -350,7 +358,10 @@ test.describe(
// the fix under test lives one level down, on the tool call's OWN
// displayed state inside that summary: expand it to look.
const panel = page.locator('#agent-panel-root')
const workSummary = panel.getByRole('button', { name: /^Worked/ })
const workSummary = panel.getByRole('button', {
name: enMessages.agent.workedNotConfirmedOnCanvas,
exact: true
})
await workSummary.click()
await expect(workSummary).toHaveAttribute('aria-expanded', 'true')

Expand Down Expand Up @@ -378,6 +389,12 @@ test.describe(
0
)
await expect(vueNodes.getNodeLocator(String(ADDED_NODE_ID))).toBeVisible()
await expect(
panel.getByRole('button', {
name: enMessages.agent.worked,
exact: true
})
).toBeVisible()
})

test('an unrelated doc_update does not settle the correlated tool call', async ({
Expand All @@ -387,7 +404,10 @@ test.describe(
await driveThroughToolCallDone(page, 'toolCallBeforeDocUpdate', true)

const panel = page.locator('#agent-panel-root')
const workSummary = panel.getByRole('button', { name: /^Worked/ })
const workSummary = panel.getByRole('button', {
name: enMessages.agent.workedNotConfirmedOnCanvas,
exact: true
})
await workSummary.click()
await expect(workSummary).toHaveAttribute('aria-expanded', 'true')

Expand Down Expand Up @@ -424,7 +444,10 @@ test.describe(
)

const panel = page.locator('#agent-panel-root')
const workSummary = panel.getByRole('button', { name: /^Worked/ })
const workSummary = panel.getByRole('button', {
name: enMessages.agent.workedNotConfirmedOnCanvas,
exact: true
})
await workSummary.click()
await expect(workSummary).toHaveAttribute('aria-expanded', 'true')

Expand Down Expand Up @@ -481,7 +504,10 @@ test.describe(
)

const panel = page.locator('#agent-panel-root')
const workSummary = panel.getByRole('button', { name: /^Worked/ })
const workSummary = panel.getByRole('button', {
name: enMessages.agent.worked,
exact: true
})
await workSummary.click()
await expect(workSummary).toHaveAttribute('aria-expanded', 'true')

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,12 @@ test.describe(
await expect(panel.getByRole('button', { name: STOP_LABEL })).toHaveCount(
0
)
await expect(panel.getByRole('button', { name: /^Worked/ })).toBeVisible()
await expect(
panel.getByRole('button', {
name: enMessages.agent.workedNotConfirmedOnCanvas,
exact: true
})
).toBeVisible()

await expect(vueNodes.getNodeLocator(String(ADDED_NODE_ID))).toBeVisible({
timeout: SUBSCRIBE_ACK_TIMEOUT_MS + 10_000
Expand Down
Loading
Loading