Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
fe0c45a
fix(agent): one accepted file-type list for every composer upload path
Glary-Bot Sep 30, 2026
05a8f85
fix(agent): close the asset-card bypass and split the retain tier
Glary-Bot Sep 30, 2026
ee53407
fix(agent): tighten the asset-card gate, aggregate refusals, correct …
Glary-Bot Sep 30, 2026
92a8aea
fix(agent): make the attachment gate three-valued and plural-correct
Glary-Bot Sep 30, 2026
7774da8
fix(agent): parse extensions strictly and prefer the authoritative ref
Glary-Bot Sep 30, 2026
fc64b88
refactor(agent): extract the dropped-asset verdict and the warn toast
Glary-Bot Sep 30, 2026
52e00d3
fix(agent): report the server's refusal total, not the capped list le…
Glary-Bot Sep 30, 2026
1f8d3ee
fix(agent): separate ref and label extension checks
christian-byrne Sep 30, 2026
22021f8
fix(agent): defer opaque asset refs to server policy
christian-byrne Sep 30, 2026
7a8d443
fix(agent): handle unnamed attachment refusals
christian-byrne Sep 30, 2026
b67c046
fix(agent): make asset verdict authority explicit
christian-byrne Sep 30, 2026
69e141b
fix(agent): narrow attachment rejection parsing
christian-byrne Sep 30, 2026
f5a808f
fix(agent): keep attachment names out of error reports
christian-byrne Sep 30, 2026
73af648
fix(agent): judge fetched assets by resolved filename
christian-byrne Sep 30, 2026
6ed4906
fix(agent): abort timed-out asset fetches
christian-byrne Sep 30, 2026
8e96af7
fix(agent): preserve admitted attachment capability
christian-byrne Sep 30, 2026
ccab11c
refactor(agent): keep review fixes below complexity gate
christian-byrne Sep 30, 2026
6395ec9
refactor(agent): derive the rejection parser from the generated schema
Glary-Bot Sep 30, 2026
603bd3c
chore(agent): refresh ingest types for the hardened attachment contract
Glary-Bot Sep 30, 2026
b72155a
fix(agent): cap staged attachments at the contract's maxItems
Glary-Bot Sep 30, 2026
ae249f8
feat(agent): surface the readable text tier and cover every format pa…
Glary-Bot Sep 30, 2026
6266ae1
fix(agent): stop an unjudgeable asset ref skipping the policy silently
Glary-Bot Sep 30, 2026
0cd7e34
fix(agent): preserve opaque asset refs for server policy
christian-byrne Sep 30, 2026
d0638f1
fix(agent): align the ref allowlist with the server's path semantics
Glary-Bot Sep 30, 2026
bd59bf4
fix(agent): correct the chip's capability source and the dropped-asse…
Glary-Bot Sep 30, 2026
8647d91
fix(agent): judge a card's stored name when its ref cannot be judged
Glary-Bot Sep 30, 2026
42e4a09
fix(agent): regenerate ingest types from the PROJECTED spec
Glary-Bot Sep 30, 2026
c6f4606
fix(agent): stop an oversized file costing a turn slot, and revive th…
Glary-Bot Sep 30, 2026
47bb1c4
merge: resolve attachment policy against main
christian-byrne Sep 30, 2026
cd63fad
merge: incorporate latest attachment review fixes
christian-byrne Sep 30, 2026
e61d592
merge: refresh attachment policy on current main
christian-byrne Sep 30, 2026
4d7cb7a
test(agent): retain send telemetry surface
christian-byrne Sep 30, 2026
6acadd1
fix(agent): keep a dropped asset when its storage path has a bad escape
Glary-Bot Oct 9, 2026
0e2369d
merge: catch up with main (includes #18389)
ryan-di Oct 14, 2026
22d7076
fix(agent): stage refused file types as invalid chips
ryan-di Oct 14, 2026
d0ef26e
chore(ingest-types): regenerate agent attachment schemas from cloud#1…
ryan-di Oct 14, 2026
2d719cc
test(agent): prove accepted files upload and drop the icon-class asse…
ryan-di Oct 14, 2026
ce7ea58
Merge branch 'main' into glary/agent-attachment-composable
ryan-di Oct 14, 2026
35e9fbe
refactor(agent): drop restating comments and name the refusal count
DrJKL Oct 15, 2026
17fb563
refactor(agent): map validation messages exhaustively and keep locale…
DrJKL Oct 15, 2026
d97d941
fix(agent): detect attachment refusals with the generated schema
DrJKL Oct 15, 2026
3872712
test(agent): strengthen weak attachment oracles and drop duplicate cases
DrJKL Oct 15, 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
6 changes: 2 additions & 4 deletions browser_tests/tests/agent/agentAttachFileTypeParity.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@ test.describe(

await expect(agentPanel.fileInput).toHaveAttribute(
'accept',
/(^|,)video\/\*(,|$)/
/(^|,)\.mp4(,|$)/
)
await expect(agentPanel.fileInput).toHaveAttribute(
'accept',
/(^|,)audio\/\*(,|$)/
/(^|,)\.wav(,|$)/
)

await agentPanel.fileInput.setInputFiles([
Expand Down Expand Up @@ -123,8 +123,6 @@ test.describe(
)

expect(dropped).not.toBe('ignored')

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P3: handOverAttachment returns 'attached' whenever a chip with that name becomes visible (AgentPanel.ts:236-238). After this PR an unsupported-type chip is also a visible chip, so this parity check passes when both paths stage an invalid chip, and the helper's 'refused' outcome no longer covers type refusals. Parity still holds for .csv, but 'attached' now reads as "accepted" when it is not. An 'invalid' outcome keyed on the chip's status in the helper, or an assertion here that the CSV chip has no status, keeps the outcome honest. Prose because the helper lives in browser_tests/fixtures.


test.fail()
expect(
dropped,
`the file browser answered "${picked}"; a drop of the same file must answer the same`
Expand Down
289 changes: 289 additions & 0 deletions browser_tests/tests/agent/agentAttachFileTypes.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,289 @@
import { expect } from '@playwright/test'

import type { UploadImageResponse } from '@comfyorg/ingest-types'

import enMessages from '@/locales/en/main.json' with { type: 'json' }
import {
AGENT_ATTACH_ACCEPT,
agentAttachCapability
} from '@/workbench/extensions/agent/utils/attachableFiles'
import type { AgentAttachCapability } from '@/workbench/extensions/agent/utils/attachableFiles'
Comment on lines +6 to +10

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit (P3): Companion to my suggestions on lines 76-93 and 132-136: once both are applied, AGENT_ATTACH_ACCEPT and agentAttachCapability are unused here. Apply together with those two.

Suggested change
import {
AGENT_ATTACH_ACCEPT,
agentAttachCapability
} from '@/workbench/extensions/agent/utils/attachableFiles'
import type { AgentAttachCapability } from '@/workbench/extensions/agent/utils/attachableFiles'
import type { AgentAttachCapability } from '@/workbench/extensions/agent/utils/attachableFiles'


import { agentTest as test } from '@e2e/tests/agent/agentPanelMocks'
import { assetPath } from '@e2e/fixtures/utils/paths'
import { jsonRoute } from '@e2e/fixtures/utils/jsonRoute'

const ACCEPTED: ReadonlyArray<{
tier: AgentAttachCapability
file: string
}> = [
{ tier: 'view', file: 'photo.png' },
{ tier: 'probe', file: 'clip.mp4' },
{ tier: 'read', file: 'notes.md' },
{ tier: 'reference', file: 'mesh.glb' },
{ tier: 'retain', file: 'photo.avif' }
]

const REJECTED = [
'page.html',
'bundle.js',
'style.css',
'doc.pdf',
'clip.wmv',
'clip.flv',
'scene.usdz',
'env.hdr',
'track.aac',
'track.aiff',
'track.wma',
'plate.exr'
] as const

const VIDEO_HEADERS: Partial<Record<string, Buffer>> = {
mp4: Buffer.from('\0\0\0\x18ftypisom', 'latin1')
}

function syntheticFile(name: string) {
const extension = name.slice(name.lastIndexOf('.') + 1)
return {
name,
mimeType: 'application/octet-stream',
buffer: VIDEO_HEADERS[extension] ?? Buffer.from(name)
}
}

function unsupportedTypeMessage(name: string): string {
return enMessages.agent.attachmentUnsupportedType.replace('{name}', name)
}

test.describe(
'Agent composer accepted file types',
{ tag: ['@cloud', '@ui'] },
() => {
test.beforeEach(async ({ comfyPage }) => {
await comfyPage.page.route('**/api/upload/image', (route) => {
const response: UploadImageResponse = {
name: 'uploaded',
subfolder: '',
type: 'input'
}
return route.fulfill(jsonRoute(response))
})
await comfyPage.nodeOps.clearGraph()
await expect.poll(() => comfyPage.nodeOps.getGraphNodesCount()).toBe(0)
})
Comment on lines +63 to +74

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P3: clearGraph and its poll run before all eleven tests, but only the two .json tests (lines 228 and 241) read the graph. Nesting those two in a test.describe with this setup, and keeping only the upload route at file level, saves a command and a poll per test. Prose because it restructures the describe.


test('advertises extensions only, so the OS picker cannot offer a rejected type', async ({
agentPanel
}) => {
await agentPanel.open()

await expect(agentPanel.fileInput).toHaveAttribute(
'accept',
AGENT_ATTACH_ACCEPT
)
expect(AGENT_ATTACH_ACCEPT).not.toContain('/*')
for (const rejected of REJECTED) {
expect(
AGENT_ATTACH_ACCEPT.split(','),
`${rejected} must not be offered by the picker`
).not.toContain(rejected.slice(rejected.lastIndexOf('.')))
}
})

Comment on lines +76 to +93

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P3: Only lines 81-84 touch the browser, and their oracle is the imported production constant; lines 85-91 assert that constant against REJECTED in Node, which the unit tests "carries no MIME wildcard" and "offers exactly what the composer will accept" (attachableFiles.test.ts:162-179) already do. agentAttachFileTypeParity.spec.ts:43-50 already proves the input carries the generated list, so this case costs a page load for no defect of its own.

Suggested change
test('advertises extensions only, so the OS picker cannot offer a rejected type', async ({
agentPanel
}) => {
await agentPanel.open()
await expect(agentPanel.fileInput).toHaveAttribute(
'accept',
AGENT_ATTACH_ACCEPT
)
expect(AGENT_ATTACH_ACCEPT).not.toContain('/*')
for (const rejected of REJECTED) {
expect(
AGENT_ATTACH_ACCEPT.split(','),
`${rejected} must not be offered by the picker`
).not.toContain(rejected.slice(rejected.lastIndexOf('.')))
}
})

for (const { tier, file } of ACCEPTED) {
test(`uploads a ${tier}-tier file (${file}) and leaves no status on its chip`, async ({
agentPanel,
comfyPage
}) => {
await agentPanel.open()
const upload = comfyPage.page.waitForRequest(
(request) =>
request.method() === 'POST' &&
request.url().endsWith('/api/upload/image')
)

await agentPanel.fileInput.setInputFiles(syntheticFile(file))

const chip = agentPanel.attachmentChip(file)
await expect(chip).toBeVisible()
await expect(
chip.getByRole('status'),
`${file} must finish uploading with no validation status`
).toHaveCount(0)
expect((await upload).postDataBuffer()?.toString('latin1')).toContain(
`filename="${file}"`
)
})
}
Comment on lines +94 to +118

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P3: All five generated cases drive the same path (picker, addFiles, upload); the tier never reaches the browser-visible behavior, and the unit table pins it. One accepted case keeps the real multipart filename check. Using the real default.json fixture for that case also keeps the json picker coverage that the deleted agentAttachJsonFile.spec.ts had (see my comment on the "real fixtures" test). Prose because it collapses the ACCEPTED array and the loop.


test('stages every rejected format as an invalid chip that is never uploaded', async ({
agentPanel,
comfyPage
}) => {
const uploads: string[] = []
comfyPage.page.on('request', (request) => {
if (request.url().includes('/api/upload/image'))
uploads.push(request.url())
})
await agentPanel.open()

for (const file of REJECTED) {
expect(
agentAttachCapability(file),
`${file} must not be on any tier`
).toBeUndefined()

Comment on lines +132 to +136

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P3: agentAttachCapability is a unit assertion inside an E2E test, and REJECTED is the same 12 names as the unit rejects %s table. The loop runs the same picker-to-invalid-chip flow twelve times; AgentPanelRoot.test.ts:3299 covers picker, drop and paste at unit level. Dropping these lines and running the remaining body for one file (doc.pdf) keeps the browser signal. The single-file rewrite is prose because it spans the loop; this suggestion removes the in-loop unit assertion.

Suggested change
expect(
agentAttachCapability(file),
`${file} must not be on any tier`
).toBeUndefined()

await agentPanel.fileInput.setInputFiles(syntheticFile(file))

const chip = agentPanel.attachmentChip(file)
await expect(
chip.getByRole('status', { name: unsupportedTypeMessage(file) }),
`${file} must be staged as an invalid chip`
).toBeVisible()
await expect(comfyPage.toast.withText(file)).toHaveCount(0)
await chip.hover()
await chip
.getByRole('button', {
name: enMessages.agent.removeAsset.replace('{name}', file),
exact: true
})
.click()
await expect(chip).toHaveCount(0)
Comment on lines +145 to +152

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit (P3): agentPanel.removeAllAttachments() (AgentPanel.ts:252) does this hover, click and count check, so a timing fix in the helper reaches this test too. The same applies to lines 278-285.

Suggested change
await chip.hover()
await chip
.getByRole('button', {
name: enMessages.agent.removeAsset.replace('{name}', file),
exact: true
})
.click()
await expect(chip).toHaveCount(0)
await agentPanel.removeAllAttachments()

}
expect(uploads).toEqual([])
})

test('blocks Send for refused files from any path until they are removed', async ({
agentPanel,
comfyPage
}) => {
const page = comfyPage.page
await agentPanel.open()
await agentPanel.selectWorkflow()
await agentPanel.composer.fill('Describe these files')
await expect(agentPanel.sendButton).toBeEnabled()

const dataTransfer = await page.evaluateHandle(() => {
const transfer = new DataTransfer()
transfer.items.add(
new File(['%PDF'], 'doc.pdf', { type: 'application/pdf' })
)
return transfer
})
try {
await agentPanel.root.dispatchEvent('drop', { dataTransfer })
} finally {
await dataTransfer.dispose()
}
Comment on lines +167 to +178

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P3: This hand-builds a DataTransfer and dispatches only drop; agentPanel.dropGeneratedFile(comfyPage.dragDrop, { name: 'doc.pdf', type: 'application/pdf', byteLength: 4 }) (AgentPanel.ts:210) drops a generated file with the full drag sequence. Lines 214-225 also repeat agentAttachmentUpload.spec.ts "retains an invalid video across reopening and blocks Send until removal" step for step; the unique signal here is the real pdf drop and the mixed "2 files" tooltip. The test has eight user actions and no test.step, and its title says "from any path" while only drop and picker run. Prose because it trims across the test; I have not run dropGeneratedFile with a pdf.

await expect(
agentPanel
.attachmentChip('doc.pdf')
.getByRole('status', { name: unsupportedTypeMessage('doc.pdf') })
).toBeVisible()
await agentPanel.sendButton.hover()
await expect(
page.getByRole('tooltip', {
name: enMessages.agent.sendBlockedByUnsupportedType.replace(
'{name}',
'doc.pdf'
),
exact: true
})
).toBeVisible()

await agentPanel.fileInput.setInputFiles({
name: 'renamed.mp4',
mimeType: 'video/mp4',
buffer: Buffer.from('plain text')
})
await expect(
agentPanel.attachmentChip('renamed.mp4').getByRole('status')
).toBeVisible()
await page.mouse.move(0, 0)
await agentPanel.sendButton.hover()
await expect(
page.getByRole('tooltip', {
name: enMessages.agent.sendBlockedByInvalidAttachments.replace(
'{count}',
'2'
),
exact: true
})
).toBeVisible()
await agentPanel.composer.press('Enter')
await expect(agentPanel.composer).toHaveText('Describe these files')

await agentPanel.close()
await agentPanel.open()
await expect(agentPanel.attachmentChip('doc.pdf')).toBeVisible()
await expect(agentPanel.composer).toHaveText('Describe these files')
await expect(agentPanel.sendButton).toBeDisabled()
await expect(comfyPage.toast.withText('doc.pdf')).toHaveCount(0)

await agentPanel.removeAllAttachments()
await expect(agentPanel.sendButton).toBeEnabled()
})

test('attaches a .json dropped on the panel instead of opening it as a workflow', async ({
agentPanel,
comfyPage
}) => {
await agentPanel.open()
await expect(agentPanel.composerAssetSection).toHaveCount(0)

await agentPanel.dropFile(comfyPage.dragDrop, 'default.json')

await expect(agentPanel.attachmentChip('default.json')).toBeVisible()
await expect.poll(() => comfyPage.nodeOps.getGraphNodesCount()).toBe(0)
})

test('still opens a .json dropped on the CANVAS as a workflow', async ({
agentPanel,
comfyPage
}) => {
await agentPanel.open()
await expect(agentPanel.composerAssetSection).toHaveCount(0)

await comfyPage.dragDrop.dragAndDropFile('default.json', {
preserveNativePropagation: true
})

await expect.poll(() => comfyPage.nodeOps.getGraphNodesCount()).toBe(7)
expect(
await comfyPage.nodeOps.getNodeRefsByType('KSampler')
).toHaveLength(1)
await expect(
agentPanel.composerAssetSection,
'a canvas drop must not attach to the chat'
).toHaveCount(0)
})

test('attaches the real fixtures that exist on disk through the picker', async ({
agentPanel
}) => {
await agentPanel.open()

for (const file of [
'default.json',
'animated_triangle.glb',
'cube.obj'
]) {
await agentPanel.fileInput.setInputFiles(assetPath(file))
const chip = agentPanel.attachmentChip(file)
await expect(chip, `${file} must attach`).toBeVisible()
await expect(
chip.getByRole('status', { name: enMessages.agent.uploading })
).toHaveCount(0)
await chip.hover()
await chip
.getByRole('button', {
name: enMessages.agent.removeAsset.replace('{name}', file),
exact: true
})
.click()
await expect(chip).toHaveCount(0)
}
})
Comment on lines +261 to +287

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: This test passes when .json, .glb or .obj is refused: an unsupported-type chip is visible, and its status is named with the refusal message, so getByRole('status', { name: 'Uploading' }) still has count 0. It is the pattern fixed for the ACCEPTED cases in 2d719cc, and it is now the only E2E for picking a .json. Deleting it and using default.json as the single accepted case (my comment on lines 94-118, which asserts the upload request) keeps that coverage with a real oracle. Prose because the deletion leaves assetPath unused unless that accepted case adopts default.json.

}
)
Loading
Loading