From 79b801123eb70c7e58700525e76dee4f37f99ccb Mon Sep 17 00:00:00 2001 From: glary-bot Date: Mon, 5 Oct 2026 00:48:28 +0000 Subject: [PATCH 1/6] fix(agent): say why Send is blocked while attachments upload MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit canSend stays false while any attachment is uploading, and useAttachment uploads at most three at a time, so attaching a batch blocks sending for a window that grows with the batch. onEnter calls preventDefault() before that check, so Enter produced no send, no newline and no message — the composer simply went dead with no indication why. Blocking the send is correct; the refs are not resolved yet. Account for it instead: a status row beside the chips names how many uploads are outstanding, mirroring the existing savingWorkflow row, and clears when the last settles. --- .../fixtures/components/AgentPanel.ts | 2 + .../agent/agentComposerUploadGating.spec.ts | 89 +++++++++++++++++++ src/locales/en/main.json | 1 + .../agent/components/agent/Composer.test.ts | 52 +++++++++++ .../agent/components/agent/Composer.vue | 26 ++++++ 5 files changed, 170 insertions(+) create mode 100644 browser_tests/tests/agent/agentComposerUploadGating.spec.ts diff --git a/browser_tests/fixtures/components/AgentPanel.ts b/browser_tests/fixtures/components/AgentPanel.ts index 1f613987e4e..19ed5a2a35d 100644 --- a/browser_tests/fixtures/components/AgentPanel.ts +++ b/browser_tests/fixtures/components/AgentPanel.ts @@ -21,6 +21,7 @@ export class AgentPanel { public readonly workflowPicker: Locator public readonly fileInput: Locator public readonly composerAssetSection: Locator + public readonly composerUploadStatus: Locator public readonly attachmentChips: Locator public readonly composer: Locator public readonly composerPromptArea: Locator @@ -64,6 +65,7 @@ export class AgentPanel { }) this.fileInput = this.root.getByTestId('agent-file-input') this.composerAssetSection = this.root.getByTestId('composer-asset-section') + this.composerUploadStatus = this.root.getByTestId('composer-upload-status') this.attachmentChips = this.root.getByTestId('agent-attachment-chip') this.composer = this.root.getByRole('textbox', { name: /^Describe ideas/ }) this.composerPromptArea = this.root.getByTestId('composer-inline-input') diff --git a/browser_tests/tests/agent/agentComposerUploadGating.spec.ts b/browser_tests/tests/agent/agentComposerUploadGating.spec.ts new file mode 100644 index 00000000000..8dd303d94a4 --- /dev/null +++ b/browser_tests/tests/agent/agentComposerUploadGating.spec.ts @@ -0,0 +1,89 @@ +import { expect } from '@playwright/test' + +import { jsonRoute } from '@e2e/fixtures/utils/jsonRoute' +import { agentTest as test } from '@e2e/tests/agent/agentPanelMocks' + +// Regression for https://linear.app/comfyorg/issue/PM-1954 +// +// `canSend` is false while any attachment is still uploading, and +// `useAttachment` uploads at most three at a time, so attaching a batch blocks +// sending for a window that grows with the batch. `onEnter` calls +// `preventDefault()` before that check, so during the window Enter produced no +// send, no newline and no message — the composer just went dead, which is what +// the reporter hit after attaching dozens of images. Blocking the send is +// correct (the refs are not resolved yet); doing it without saying so is not. +const ATTACHMENT_COUNT = 3 + +function pngAttachments(count: number) { + return Array.from({ length: count }, (_, index) => ({ + name: `attachment-${index + 1}.png`, + mimeType: 'image/png', + buffer: Buffer.from('image') + })) +} + +test.describe( + 'Agent composer while attachments upload', + { tag: ['@cloud', '@agent', '@ui'] }, + () => { + test('says why sending is blocked, and sends once uploads settle', async ({ + agentPanel, + comfyPage, + postedMessages + }) => { + const page = comfyPage.page + let releaseUploads = () => {} + const uploadsHeld = new Promise((resolve) => { + releaseUploads = resolve + }) + await page.route('**/api/upload/image', async (route) => { + await uploadsHeld + await route.fulfill( + jsonRoute({ name: 'uploaded.png', subfolder: '', type: 'input' }) + ) + }) + + try { + await agentPanel.open() + await agentPanel.selectWorkflow() + await agentPanel.composer.fill('Use these images') + await expect(agentPanel.sendButton).toBeEnabled() + + await agentPanel.fileInput.setInputFiles( + pngAttachments(ATTACHMENT_COUNT) + ) + await expect(agentPanel.attachmentChips).toHaveCount(ATTACHMENT_COUNT) + await expect(agentPanel.sendButton).toBeDisabled() + + // The composer has to account for the dead Send, naming how many + // uploads it is waiting on rather than leaving the user to guess. + await expect(agentPanel.composerUploadStatus).toHaveText( + `Uploading ${ATTACHMENT_COUNT} attachments` + ) + + // Enter stays a no-op by design while refs are unresolved; what changes + // is that the reason is now on screen instead of nowhere. + await agentPanel.composer.press('Enter') + expect(postedMessages).toHaveLength(0) + + releaseUploads() + + // Empty, not absent: the live region stays mounted so the next batch's + // first message lands in a region the screen reader already knows. + await expect(agentPanel.composerUploadStatus).toHaveText('') + await expect(agentPanel.sendButton).toBeEnabled() + + await agentPanel.composer.press('Enter') + await expect.poll(() => postedMessages).toHaveLength(1) + // Asserting the refs, not just the count: a send that leaked past the + // gate would carry the staged empty refs and still be three long. + expect(JSON.parse(postedMessages[0]).attachments).toEqual( + Array.from({ length: ATTACHMENT_COUNT }, () => 'uploaded.png') + ) + } finally { + releaseUploads() + await page.unrouteAll({ behavior: 'wait' }) + } + }) + } +) diff --git a/src/locales/en/main.json b/src/locales/en/main.json index 44f24aceff7..7d6c2cdacfe 100644 --- a/src/locales/en/main.json +++ b/src/locales/en/main.json @@ -5506,6 +5506,7 @@ "focusNodeLabel": "Show {node} on canvas", "removeNodeLabel": "Remove {node} reference", "uploading": "Uploading", + "uploadingAttachments": "Uploading {count} attachment | Uploading {count} attachments", "noNodesToMention": "No nodes in this workflow", "friend": "there", "sendFailed": "Message failed to send", diff --git a/src/workbench/extensions/agent/components/agent/Composer.test.ts b/src/workbench/extensions/agent/components/agent/Composer.test.ts index b37bcafd6f5..4ebb4051e94 100644 --- a/src/workbench/extensions/agent/components/agent/Composer.test.ts +++ b/src/workbench/extensions/agent/components/agent/Composer.test.ts @@ -1559,6 +1559,58 @@ describe('Composer', () => { ) }) + describe('attachment upload status', () => { + function mountUploading(count: number) { + const composer = ref | null>(null) + const Host = defineComponent({ + setup: () => () => h(Composer, { ref: composer }) + }) + render(Host, { global: { plugins: [i18n] } }) + for (let index = 1; index <= count; index += 1) + composer.value?.addAttachment({ + id: `attachment-${index}`, + name: `shot-${index}.png`, + ref: '', + uploading: true + }) + return composer + } + + // Anchored: 'Uploading 1 attachment' is a substring of the plural form, so + // an unanchored singular case passes under either plural branch. + it.for([ + { name: 'one upload', uploads: 1, expected: /^Uploading 1 attachment$/ }, + { + name: 'three uploads', + uploads: 3, + expected: /^Uploading 3 attachments$/ + } + ])('accounts for the blocked Send with $name', async (testCase) => { + mountUploading(testCase.uploads) + await nextTick() + + expect(screen.getByTestId('composer-upload-status')).toHaveTextContent( + testCase.expected + ) + }) + + it('clears the status once the last upload settles', async () => { + const composer = mountUploading(2) + await nextTick() + expect(screen.getByTestId('composer-upload-status')).toBeVisible() + + composer.value?.updateAttachment('attachment-1', { uploading: false }) + await nextTick() + expect(screen.getByTestId('composer-upload-status')).toHaveTextContent( + /^Uploading 1 attachment$/ + ) + + composer.value?.updateAttachment('attachment-2', { uploading: false }) + await nextTick() + expect(screen.getByTestId('composer-upload-status')).toBeEmptyDOMElement() + }) + }) + it('keeps uploaded attachments when navigating from a staged workflow', async () => { useAgentComposerStore().setWorkflowReferences([ { id: 'wf-1', name: 'Water world', textOffset: 0 } diff --git a/src/workbench/extensions/agent/components/agent/Composer.vue b/src/workbench/extensions/agent/components/agent/Composer.vue index 1e3c9472935..a0722cc5828 100644 --- a/src/workbench/extensions/agent/components/agent/Composer.vue +++ b/src/workbench/extensions/agent/components/agent/Composer.vue @@ -245,6 +245,10 @@ function onEnter(event: KeyboardEvent): void { composer.submit() } +const uploadingAttachmentCount = computed( + () => composer.attachments.value.filter((item) => item.uploading).length +) + const primaryActionTooltip = computed(() => running.value ? t('agent.stop') : t('agent.send') ) @@ -512,6 +516,28 @@ defineExpose({ /> + +
+ +
+
Date: Sun, 4 Oct 2026 21:16:32 -0700 Subject: [PATCH 2/6] test(agent): wait before checking blocked Enter Addresses review feedback: https://github.com/Comfy-Org/ComfyUI_frontend/pull/20150#discussion_r4180344828 --- browser_tests/tests/agent/agentComposerUploadGating.spec.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/browser_tests/tests/agent/agentComposerUploadGating.spec.ts b/browser_tests/tests/agent/agentComposerUploadGating.spec.ts index 8dd303d94a4..608ba7138e4 100644 --- a/browser_tests/tests/agent/agentComposerUploadGating.spec.ts +++ b/browser_tests/tests/agent/agentComposerUploadGating.spec.ts @@ -64,7 +64,6 @@ test.describe( // Enter stays a no-op by design while refs are unresolved; what changes // is that the reason is now on screen instead of nowhere. await agentPanel.composer.press('Enter') - expect(postedMessages).toHaveLength(0) releaseUploads() @@ -72,6 +71,9 @@ test.describe( // first message lands in a region the screen reader already knows. await expect(agentPanel.composerUploadStatus).toHaveText('') await expect(agentPanel.sendButton).toBeEnabled() + // Check only after the upload requests and reactive UI have settled, so + // a POST leaked by the first Enter cannot still be in flight. + expect(postedMessages).toHaveLength(0) await agentPanel.composer.press('Enter') await expect.poll(() => postedMessages).toHaveLength(1) From 73075e25035282718efcb1a79166a4e995fa1441 Mon Sep 17 00:00:00 2001 From: Christian Byrne Date: Sun, 4 Oct 2026 21:16:59 -0700 Subject: [PATCH 3/6] test(agent): cover queued attachment uploads Addresses review feedback: https://github.com/Comfy-Org/ComfyUI_frontend/pull/20150#discussion_r4180386584 --- browser_tests/tests/agent/agentComposerUploadGating.spec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/browser_tests/tests/agent/agentComposerUploadGating.spec.ts b/browser_tests/tests/agent/agentComposerUploadGating.spec.ts index 608ba7138e4..70275412f85 100644 --- a/browser_tests/tests/agent/agentComposerUploadGating.spec.ts +++ b/browser_tests/tests/agent/agentComposerUploadGating.spec.ts @@ -12,7 +12,7 @@ import { agentTest as test } from '@e2e/tests/agent/agentPanelMocks' // send, no newline and no message — the composer just went dead, which is what // the reporter hit after attaching dozens of images. Blocking the send is // correct (the refs are not resolved yet); doing it without saying so is not. -const ATTACHMENT_COUNT = 3 +const ATTACHMENT_COUNT = 5 function pngAttachments(count: number) { return Array.from({ length: count }, (_, index) => ({ From 8024cc11c136aed703373a98b6b6a9a894319265 Mon Sep 17 00:00:00 2001 From: Christian Byrne Date: Sun, 4 Oct 2026 21:17:16 -0700 Subject: [PATCH 4/6] test(agent): distinguish uploaded attachment refs Addresses review feedback: https://github.com/Comfy-Org/ComfyUI_frontend/pull/20150#discussion_r4180386591 --- .../tests/agent/agentComposerUploadGating.spec.ts | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/browser_tests/tests/agent/agentComposerUploadGating.spec.ts b/browser_tests/tests/agent/agentComposerUploadGating.spec.ts index 70275412f85..91cb29040d6 100644 --- a/browser_tests/tests/agent/agentComposerUploadGating.spec.ts +++ b/browser_tests/tests/agent/agentComposerUploadGating.spec.ts @@ -36,10 +36,16 @@ test.describe( const uploadsHeld = new Promise((resolve) => { releaseUploads = resolve }) + let uploadNumber = 0 await page.route('**/api/upload/image', async (route) => { + const currentUpload = ++uploadNumber await uploadsHeld await route.fulfill( - jsonRoute({ name: 'uploaded.png', subfolder: '', type: 'input' }) + jsonRoute({ + name: `uploaded-${currentUpload}.png`, + subfolder: '', + type: 'input' + }) ) }) @@ -80,7 +86,10 @@ test.describe( // Asserting the refs, not just the count: a send that leaked past the // gate would carry the staged empty refs and still be three long. expect(JSON.parse(postedMessages[0]).attachments).toEqual( - Array.from({ length: ATTACHMENT_COUNT }, () => 'uploaded.png') + Array.from( + { length: ATTACHMENT_COUNT }, + (_, index) => `uploaded-${index + 1}.png` + ) ) } finally { releaseUploads() From 1205eac8e38fead53c7cd93d8147dbecc7663881 Mon Sep 17 00:00:00 2001 From: Christian Byrne Date: Sun, 4 Oct 2026 21:17:31 -0700 Subject: [PATCH 5/6] test(agent): validate posted composer request Addresses review feedback: https://github.com/Comfy-Org/ComfyUI_frontend/pull/20150#discussion_r4180344833 --- browser_tests/tests/agent/agentComposerUploadGating.spec.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/browser_tests/tests/agent/agentComposerUploadGating.spec.ts b/browser_tests/tests/agent/agentComposerUploadGating.spec.ts index 91cb29040d6..0e6b797c699 100644 --- a/browser_tests/tests/agent/agentComposerUploadGating.spec.ts +++ b/browser_tests/tests/agent/agentComposerUploadGating.spec.ts @@ -1,4 +1,5 @@ import { expect } from '@playwright/test' +import { zAgentPostMessageRequest } from '@comfyorg/ingest-types/zod' import { jsonRoute } from '@e2e/fixtures/utils/jsonRoute' import { agentTest as test } from '@e2e/tests/agent/agentPanelMocks' @@ -85,7 +86,10 @@ test.describe( await expect.poll(() => postedMessages).toHaveLength(1) // Asserting the refs, not just the count: a send that leaked past the // gate would carry the staged empty refs and still be three long. - expect(JSON.parse(postedMessages[0]).attachments).toEqual( + expect( + zAgentPostMessageRequest.parse(JSON.parse(postedMessages[0])) + .attachments + ).toEqual( Array.from( { length: ATTACHMENT_COUNT }, (_, index) => `uploaded-${index + 1}.png` From 78ac1155dba515dfc8dd2aefc4de4219e4bb8dd4 Mon Sep 17 00:00:00 2001 From: Christian Byrne Date: Sun, 4 Oct 2026 21:17:50 -0700 Subject: [PATCH 6/6] test(agent): prove upload status precondition Addresses review feedback: https://github.com/Comfy-Org/ComfyUI_frontend/pull/20150#discussion_r4180386589 --- .../extensions/agent/components/agent/Composer.test.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/workbench/extensions/agent/components/agent/Composer.test.ts b/src/workbench/extensions/agent/components/agent/Composer.test.ts index 4ebb4051e94..5a0024bf3aa 100644 --- a/src/workbench/extensions/agent/components/agent/Composer.test.ts +++ b/src/workbench/extensions/agent/components/agent/Composer.test.ts @@ -1597,7 +1597,9 @@ describe('Composer', () => { it('clears the status once the last upload settles', async () => { const composer = mountUploading(2) await nextTick() - expect(screen.getByTestId('composer-upload-status')).toBeVisible() + expect(screen.getByTestId('composer-upload-status')).toHaveTextContent( + /^Uploading 2 attachments$/ + ) composer.value?.updateAttachment('attachment-1', { uploading: false }) await nextTick()