diff --git a/web/src/lib/attachmentAdapter.test.ts b/web/src/lib/attachmentAdapter.test.ts index 4a0e39b0..df08060b 100644 --- a/web/src/lib/attachmentAdapter.test.ts +++ b/web/src/lib/attachmentAdapter.test.ts @@ -1,6 +1,6 @@ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' -describe('attachmentAdapter restored uploads', () => { +describe('attachmentAdapter', () => { beforeEach(() => { vi.stubGlobal('indexedDB', undefined) vi.resetModules() @@ -10,6 +10,13 @@ describe('attachmentAdapter restored uploads', () => { vi.unstubAllGlobals() }) + it('uses the assistant-ui wildcard sentinel so all files reach the adapter', async () => { + const { createAttachmentAdapter } = await import('./attachmentAdapter') + const adapter = createAttachmentAdapter({} as never, 'session-1') + + expect(adapter.accept).toBe('*') + }) + it('restores an uploaded draft without uploading it again', async () => { const drafts = await import('./composer-attachment-drafts') const { createAttachmentAdapter } = await import('./attachmentAdapter') diff --git a/web/src/lib/attachmentAdapter.ts b/web/src/lib/attachmentAdapter.ts index f98e4d14..06e099b9 100644 --- a/web/src/lib/attachmentAdapter.ts +++ b/web/src/lib/attachmentAdapter.ts @@ -26,7 +26,10 @@ export function createAttachmentAdapter(api: ApiClient, sessionId: string): Atta } return { - accept: '*/*', + // assistant-ui uses the exact "*" sentinel for an allow-all adapter. + // "*/*" is forwarded to MIME matching and rejects every file before + // this adapter's add() method can run. + accept: '*', async *add({ file }): AsyncGenerator { const restored = getRestoredUploadMetadata(file) diff --git a/web/src/lib/scratchlistAttachmentAdapter.test.ts b/web/src/lib/scratchlistAttachmentAdapter.test.ts index 3cc18473..a9899eae 100644 --- a/web/src/lib/scratchlistAttachmentAdapter.test.ts +++ b/web/src/lib/scratchlistAttachmentAdapter.test.ts @@ -24,6 +24,12 @@ describe('hubAttachmentFromRestoredDraft', () => { }) describe('createScratchlistAttachmentAdapter', () => { + it('uses the assistant-ui wildcard sentinel so all files reach the adapter', () => { + const adapter = createScratchlistAttachmentAdapter({} as never, 'session-1') + + expect(adapter.accept).toBe('*') + }) + it('reuses restored hub path without re-uploading', async () => { const drafts = await import('./composer-attachment-drafts') const hubId = 'a1b2c3d4-e5f6-4789-a012-3456789abcde' diff --git a/web/src/lib/scratchlistAttachmentAdapter.ts b/web/src/lib/scratchlistAttachmentAdapter.ts index 1ac16340..1fb1c9d4 100644 --- a/web/src/lib/scratchlistAttachmentAdapter.ts +++ b/web/src/lib/scratchlistAttachmentAdapter.ts @@ -44,7 +44,10 @@ export function createScratchlistAttachmentAdapter(api: ApiClient, sessionId: st const cancelledAttachmentIds = new Set() return { - accept: '*/*', + // assistant-ui uses the exact "*" sentinel for an allow-all adapter. + // "*/*" is forwarded to MIME matching and rejects every file before + // this adapter's add() method can run. + accept: '*', async *add({ file }): AsyncGenerator { const contentType = file.type || 'application/octet-stream'