Repository navigation
fix(agent): say why Send is blocked while attachments upload #20150
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
79b8011
fix(agent): say why Send is blocked while attachments upload
2be2b36
test(agent): wait before checking blocked Enter
christian-byrne 73075e2
test(agent): cover queued attachment uploads
christian-byrne 8024cc1
test(agent): distinguish uploaded attachment refs
christian-byrne 1205eac
test(agent): validate posted composer request
christian-byrne 78ac115
test(agent): prove upload status precondition
christian-byrne File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
104 changes: 104 additions & 0 deletions
104
browser_tests/tests/agent/agentComposerUploadGating.spec.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,104 @@ | ||
| 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' | ||
|
|
||
| // 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 = 5 | ||
|
|
||
| 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<void>((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-${currentUpload}.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') | ||
|
|
||
| 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() | ||
| // 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) | ||
| // 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( | ||
| zAgentPostMessageRequest.parse(JSON.parse(postedMessages[0])) | ||
| .attachments | ||
| ).toEqual( | ||
| Array.from( | ||
| { length: ATTACHMENT_COUNT }, | ||
| (_, index) => `uploaded-${index + 1}.png` | ||
| ) | ||
| ) | ||
| } finally { | ||
| releaseUploads() | ||
| await page.unrouteAll({ behavior: 'wait' }) | ||
| } | ||
| }) | ||
| } | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.