Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
fix(desktop-ui): show refused and unreadable documents as notices instead of chips
Alfredo Lopez8587977fe470
diff --git a/desktop-app/test/e2e-playwright/qa-recorder-document-upload.spec.ts b/desktop-app/test/e2e-playwright/qa-recorder-document-upload.spec.tsindex 7e129bbe2..b22e5e49e 100644--- a/desktop-app/test/e2e-playwright/qa-recorder-document-upload.spec.ts+++ b/desktop-app/test/e2e-playwright/qa-recorder-document-upload.spec.ts@@ -400,12 +400,13 @@ test('document-upload fixture: an attached text file reaches the model through tawait selectSupportedModel(page, IMAGE_CAPABILITY_FIXTURE_MODELS.supported)})+ const oversized = {+ fileName: `too-big-${randomBytes(3).toString('hex')}.txt`,+ mimeType: 'text/plain',+ buffer: Buffer.alloc(COMPOSER_FILE_LIMIT_BYTES + 1, 0x61),+ }+await test.step('a file one byte over the limit is refused with its reason and leaves no chip', async () => {- const oversized = {- fileName: `too-big-${randomBytes(3).toString('hex')}.txt`,- mimeType: 'text/plain',- buffer: Buffer.alloc(COMPOSER_FILE_LIMIT_BYTES + 1, 0x61),- }await attachDocument(page, oversized)// Liveness witness: the refusal the composer had to produce is on screen.const refusal = page.getByRole('alert').filter({ hasText: oversized.fileName })@@ -424,6 +425,8 @@ test('document-upload fixture: an attached text file reaches the model through tconst chip = fileChips(page).filter({ hasText: throwaway.fileName })await expect(chip).toHaveCount(1, { timeout: 20_000 })await expect(chip).toHaveAttribute('data-file-status', 'ready', { timeout: 20_000 })+ // The next attach replaces the earlier refusal; the ready chip above is the witness.+ await expect(page.getByRole('alert').filter({ hasText: oversized.fileName })).toHaveCount(0)await page.getByRole('button', { name: `Remove ${throwaway.fileName}` }).click()await expect(fileChips(page)).toHaveCount(0, { timeout: 15_000 })})diff --git a/desktop-app/ui/src/App.tsx b/desktop-app/ui/src/App.tsxindex 1e66da88e..c1a285b75 100644--- a/desktop-app/ui/src/App.tsx+++ b/desktop-app/ui/src/App.tsx@@ -2305,6 +2305,7 @@ export function App() {activeChatId: vm.activeChatId,composerImageAttachments: vm.composerImageAttachments,composerFileAttachments: vm.composerFileAttachments,+ composerFileRefusals: vm.composerFileRefusals,composerReferenceAttachments: vm.composerReferenceAttachments,agentSending: vm.agentSending,agentError: vm.agentError,@@ -2316,6 +2317,7 @@ export function App() {vm.activeChatId,vm.composerImageAttachments,vm.composerFileAttachments,+ vm.composerFileRefusals,vm.composerReferenceAttachments,vm.agentSending,vm.agentError,diff --git a/desktop-app/ui/src/components/agents/ComposerPanel.tsx b/desktop-app/ui/src/components/agents/ComposerPanel.tsxindex 39423f71f..dfdd0a2ed 100644--- a/desktop-app/ui/src/components/agents/ComposerPanel.tsx+++ b/desktop-app/ui/src/components/agents/ComposerPanel.tsx@@ -117,7 +117,6 @@ function getComposerReferenceIcon(attachment: ComposerReferenceAttachment) {/** Status line of a document chip: what the user needs to know before sending. */function getComposerFileMeta(file: ComposerFileAttachment): string {- if (file.status === 'failed') return 'Not attached'if (file.status !== 'ready') return 'Reading...'const size = formatFileSize(file.sizeBytes)if (file.classification.reader === 'none') return `${size} · No reader available`@@ -126,7 +125,6 @@ function getComposerFileMeta(file: ComposerFileAttachment): string {/** Notice shown under the chips for a document that needs attention. */function getComposerFileNotice(file: ComposerFileAttachment): string | null {- if (file.status === 'failed') return file.errorif (file.status !== 'ready') return nullif (file.classification.mismatch) {return `${file.filename} looks like a ${file.classification.class} file, not what its name or type says. It is attached as it is.`@@ -142,6 +140,7 @@ export function ComposerPanel({ inline = false, agentSelector }: ComposerPanelPrconst {composerImageAttachments,composerFileAttachments,+ composerFileRefusals,composerReferenceAttachments,agentSending,agentError,@@ -558,11 +557,8 @@ export function ComposerPanel({ inline = false, agentSelector }: ComposerPanelPr}if (!imageCandidates.length) return- const attachedFileCount = composerFileAttachments.filter(- file => file.status !== 'failed'- ).lengthconst availableSlots =- COMPOSER_MAX_ATTACHMENTS - composerImageAttachments.length - attachedFileCount+ COMPOSER_MAX_ATTACHMENTS - composerImageAttachments.length - composerFileAttachments.lengthif (availableSlots <= 0) {setComposerAttachmentError(`A message can carry at most ${COMPOSER_MAX_ATTACHMENTS} attachments.`@@ -839,13 +835,16 @@ export function ComposerPanel({ inline = false, agentSelector }: ComposerPanelPr(a, b) => a.order - b.order || a.fallbackIndex - b.fallbackIndex)}, [composerFileAttachments, composerImageAttachments, composerReferenceAttachments])+ // Refusals come first: they name documents that were not attached at all.const composerFileNotices = useMemo(- () =>- composerFileAttachments.flatMap(file => {+ () => [+ ...composerFileRefusals.map(refusal => ({ ...refusal, refused: true })),+ ...composerFileAttachments.flatMap(file => {const notice = getComposerFileNotice(file)- return notice ? [{ id: file.id, failed: file.status === 'failed', text: notice }] : []+ return notice ? [{ id: file.id, refused: false, text: notice }] : []}),- [composerFileAttachments]+ ],+ [composerFileAttachments, composerFileRefusals])const isDegraded = hostRuntimeStatus?.degraded?.reason === 'llm_key_missing'@@ -1119,15 +1118,7 @@ export function ComposerPanel({ inline = false, agentSelector }: ComposerPanelPr</span><span className="composer-attachment-chip-body"><strong>{attachment.filename}</strong>- <span- className={`composer-attachment-chip-meta${- attachment.status === 'failed'- ? ' composer-attachment-chip-meta--failed'- : ''- }`}- >- {meta}- </span>+ <span className="composer-attachment-chip-meta">{meta}</span></span><IconButtonclassName="composer-attachment-remove"@@ -1238,8 +1229,10 @@ export function ComposerPanel({ inline = false, agentSelector }: ComposerPanelPr{composerFileNotices.map(notice => (<pkey={notice.id}- className={notice.failed ? 'composer-attachment-error' : 'composer-attachment-notice'}- role={notice.failed ? 'alert' : 'status'}+ className={+ notice.refused ? 'composer-attachment-error' : 'composer-attachment-notice'+ }+ role={notice.refused ? 'alert' : 'status'}>{notice.text}</p>diff --git a/desktop-app/ui/src/components/agents/__tests__/ComposerPanel.test.tsx b/desktop-app/ui/src/components/agents/__tests__/ComposerPanel.test.tsxindex 1a1810950..2747f0a31 100644--- a/desktop-app/ui/src/components/agents/__tests__/ComposerPanel.test.tsx+++ b/desktop-app/ui/src/components/agents/__tests__/ComposerPanel.test.tsx@@ -33,6 +33,7 @@ const composerStyles = readFileSync(resolve(__dirname, '../../../styles.css'), 'const composerState: ChatComposerStateContextValue = {composerImageAttachments: [],composerFileAttachments: [],+ composerFileRefusals: [],composerReferenceAttachments: [],agentSending: false,agentError: null,@@ -181,6 +182,7 @@ afterEach(() => {Object.assign(composerState, {composerImageAttachments: [],composerFileAttachments: [],+ composerFileRefusals: [],composerReferenceAttachments: [],agentSending: false,agentError: null,@@ -1096,24 +1098,36 @@ describe('ComposerPanel document attachments (#678)', () => {expect(sendButton().disabled).toBe(true)})- it('keeps a failed document on screen with its reason and blocks the send until it is removed', () => {- composerState.composerFileAttachments = [- {- id: 'file-3',- type: 'file',- filename: 'broken.bin',- sizeBytes: 10,- declaredMediaType: '',- status: 'failed',- error: 'broken.bin could not be read.',- },+ it('shows a refused document as an alert without a chip and does not block the send', () => {+ composerState.composerFileRefusals = [+ { id: 'refusal-1', text: 'broken.bin could not be read: permission denied' },]draftState.value = 'hello'render(<ComposerPanel inline />)- expect(screen.getByTestId('composer-file-chip').getAttribute('data-file-status')).toBe('failed')- expect(screen.getByRole('alert').textContent).toBe('broken.bin could not be read.')- expect(sendButton().disabled).toBe(true)+ // Witness for the two negative checks below: the refusal is on screen.+ expect(screen.getByRole('alert').textContent).toBe(+ 'broken.bin could not be read: permission denied'+ )+ expect(screen.queryAllByTestId('composer-file-chip')).toHaveLength(0)+ expect(sendButton().disabled).toBe(false)+ })++ it('lists refusals before the notices of ready documents', () => {+ composerState.composerFileRefusals = [{ id: 'refusal-2', text: 'huge.bin is too large.' }]+ composerState.composerFileAttachments = [+ readyFile({+ id: 'file-5',+ filename: 'archive.zip',+ classification: { ...readyClassification, class: 'binary_unsupported', reader: 'none' },+ }),+ ]+ render(<ComposerPanel inline />)++ const notices = screen.getByTestId('composer-file-notices')+ const roles = Array.from(notices.children).map(child => child.getAttribute('role'))+ expect(roles).toEqual(['alert', 'status'])+ expect(screen.getByTestId('composer-file-chip').getAttribute('data-file-status')).toBe('ready')})it('says when the agent has no reader for an attached document', () => {diff --git a/desktop-app/ui/src/contexts/ChatComposerStateContext/types.ts b/desktop-app/ui/src/contexts/ChatComposerStateContext/types.tsindex 79d17009f..babb25224 100644--- a/desktop-app/ui/src/contexts/ChatComposerStateContext/types.ts+++ b/desktop-app/ui/src/contexts/ChatComposerStateContext/types.ts@@ -1,6 +1,7 @@import type { ReactNode } from 'react'import type {ComposerFileAttachment,+ ComposerFileRefusal,ComposerImageAttachment,ComposerReferenceAttachment,FailedAgentSend,@@ -16,6 +17,8 @@ export interface ChatComposerStateContextValue {activeChatId: string | nullcomposerImageAttachments: ComposerImageAttachment[]composerFileAttachments: ComposerFileAttachment[]+ /** Why the documents of the last attach were not attached (#678). */+ composerFileRefusals: ComposerFileRefusal[]composerReferenceAttachments: ComposerReferenceAttachment[]agentSending: booleanagentError: string | nulldiff --git a/desktop-app/ui/src/hooks/domain/__tests__/useComposerAttachments.files.test.tsx b/desktop-app/ui/src/hooks/domain/__tests__/useComposerAttachments.files.test.tsxindex ab9400910..aecfa6859 100644--- a/desktop-app/ui/src/hooks/domain/__tests__/useComposerAttachments.files.test.tsx+++ b/desktop-app/ui/src/hooks/domain/__tests__/useComposerAttachments.files.test.tsx@@ -1,8 +1,9 @@// @vitest-environment jsdom/*** Issue #678 — the composer's document state machine: a picked file is- * `reading` at once, then `ready` (or `failed` with a reason); the user can- * remove it at any point, and a removed file never comes back.+ * `reading` at once, then `ready`; the user can remove it at any point, and a+ * removed file never comes back. A refused or unreadable file leaves no chip,+ * only a notice that the next attach, a send or an agent change clears.*/import { afterEach, describe, expect, it, vi } from 'vitest'import { act, renderHook, waitFor } from '@testing-library/react'@@ -106,7 +107,7 @@ describe('useComposerAttachments — documents (#678)', () => {await waitFor(() => expect(statuses(result)).toEqual(['ready', 'ready']))})- it('shows a file over the size limit as failed with the reason and never reads it', () => {+ it('refuses a file over the size limit with a notice, adds no chip and never reads it', () => {const { result } = render()const huge = textFile('huge.bin', 'x')Object.defineProperty(huge, 'size', { configurable: true, value: COMPOSER_MAX_FILE_BYTES + 1 })@@ -116,16 +117,16 @@ describe('useComposerAttachments — documents (#678)', () => {result.current.handleAddComposerFiles([huge], 0)})- const [failed] = result.current.composerFileAttachments- expect(failed?.status).toBe('failed')- expect(failed?.status === 'failed' && failed.error).toMatch(+ // Witness for the two negative checks below: the refusal names this file.+ expect(result.current.composerFileRefusals).toHaveLength(1)+ expect(result.current.composerFileRefusals[0]?.text).toMatch(/^huge\.bin is .* at most 11\.0 MiB/)- // Witness for "never reads it": the chip exists, and the reader was not called.+ expect(result.current.composerFileAttachments).toEqual([])expect(read).not.toHaveBeenCalled()})- it('shows the 21st attachment as failed and keeps the first 20', async () => {+ it('refuses the 21st attachment with a notice and keeps the first 20', async () => {const { result } = render()const files = Array.from({ length: COMPOSER_MAX_ATTACHMENTS + 1 }, (_, index) =>textFile(`f${index}.txt`, `content ${index}`)@@ -140,11 +141,13 @@ describe('useComposerAttachments — documents (#678)', () => {COMPOSER_MAX_ATTACHMENTS))- const last = result.current.composerFileAttachments.at(-1)- expect(last?.status).toBe('failed')- expect(last?.status === 'failed' && last.error).toBe(- `A message can carry at most ${COMPOSER_MAX_ATTACHMENTS} attachments.`+ expect(result.current.composerFileAttachments).toHaveLength(COMPOSER_MAX_ATTACHMENTS)+ expect(result.current.composerFileAttachments.map(file => file.filename)).not.toContain(+ `f${COMPOSER_MAX_ATTACHMENTS}.txt`)+ expect(result.current.composerFileRefusals.map(refusal => refusal.text)).toEqual([+ `A message can carry at most ${COMPOSER_MAX_ATTACHMENTS} attachments.`,+ ])})it('does not bring back a file removed while it was being read', async () => {@@ -176,21 +179,113 @@ describe('useComposerAttachments — documents (#678)', () => {expect(result.current.composerFileAttachments).toEqual([])})- it('removes a failed file so the composer can send again', () => {+ it('replaces the previous refusal when the user attaches again', async () => {const { result } = render()const bad = textFile('bad/name.txt', 'x')act(() => {result.current.handleAddComposerFiles([bad], 0)})- expect(statuses(result)).toEqual(['failed'])+ // Twin: the refusal is on screen before the next attach.+ expect(result.current.composerFileRefusals).toHaveLength(1)+ expect(result.current.composerFileAttachments).toEqual([])act(() => {- result.current.handleRemoveComposerFileAttachment(- result.current.composerFileAttachments[0]!.id- )+ result.current.handleAddComposerFiles([textFile('good.txt', 'good')], 0)})+ await waitFor(() => expect(statuses(result)).toEqual(['ready']))+ expect(result.current.composerFileRefusals).toEqual([])+ })++ it('removes the chip of a file that cannot be read and shows why', async () => {+ const { result } = render()+ const file = textFile('locked.txt', 'locked')+ let fail: (reason: Error) => void = () => {}+ vi.spyOn(file, 'arrayBuffer').mockReturnValue(+ new Promise<ArrayBuffer>((_, reject) => {+ fail = reject+ })+ )+ act(() => {+ result.current.handleAddComposerFiles([file], 0)+ })+ // Witness: the chip existed while the file was being read.+ expect(statuses(result)).toEqual(['reading'])++ await act(async () => {+ fail(new Error('permission denied'))+ })++ await waitFor(() => expect(result.current.composerFileAttachments).toEqual([]))+ expect(result.current.composerFileRefusals.map(refusal => refusal.text)).toEqual([+ 'locked.txt could not be read: permission denied',+ ])+ })++ it('shows no notice for a failed read whose chip was already removed', async () => {+ const { result } = render()+ const file = textFile('gone.txt', 'gone')+ let fail: (reason: Error) => void = () => {}+ vi.spyOn(file, 'arrayBuffer').mockReturnValue(+ new Promise<ArrayBuffer>((_, reject) => {+ fail = reject+ })+ )+ act(() => {+ result.current.handleAddComposerFiles([file], 0)+ })+ const [reading] = result.current.composerFileAttachments+ // Witness: the file was reading when the user removed it.+ expect(reading?.status).toBe('reading')+ act(() => {+ result.current.handleRemoveComposerFileAttachment(reading!.id)+ })++ await act(async () => {+ fail(new Error('permission denied'))+ await new Promise(resolve => setTimeout(resolve, 20))+ })+expect(result.current.composerFileAttachments).toEqual([])+ expect(result.current.composerFileRefusals).toEqual([])+ })++ it.each([+ [+ 'a send',+ (hook: ReturnType<typeof render>) => hook.result.current.clearComposerAfterSend(null),+ ],+ [+ 'an agent change',+ (hook: ReturnType<typeof render>) => hook.rerender({ agent: 'agent-other' }),+ ],+ [+ 'an image attach',+ (hook: ReturnType<typeof render>) =>+ hook.result.current.handleAddComposerImageAttachments([+ {+ id: 'img-1',+ name: 'a.png',+ mimeType: 'image/png',+ dataBase64: 'aGVsbG8=',+ sizeBytes: 5,+ previewDataUrl: 'data:image/png;base64,aGVsbG8=',+ },+ ]),+ ],+ ])('clears the refusal on %s', (_label, clear) => {+ const hook = render()+ act(() => {+ hook.result.current.handleAddComposerFiles([textFile('bad/name.txt', 'x')], 0)+ })+ // Twin: the refusal is on screen before the clearing action.+ expect(hook.result.current.composerFileRefusals).toHaveLength(1)++ act(() => {+ clear(hook)+ })++ expect(hook.result.current.composerFileRefusals).toEqual([])})it('clears the documents when the selected agent changes', async () => {diff --git a/desktop-app/ui/src/hooks/domain/useAgentChatController.ts b/desktop-app/ui/src/hooks/domain/useAgentChatController.tsindex 6a5ce66ce..53bc63e09 100644--- a/desktop-app/ui/src/hooks/domain/useAgentChatController.ts+++ b/desktop-app/ui/src/hooks/domain/useAgentChatController.ts@@ -714,6 +714,7 @@ export function useAgentChatController({const {composerImageAttachments,composerFileAttachments,+ composerFileRefusals,composerAttachmentRevisionRef,composerReferenceAttachments,resetComposerAttachments,@@ -3858,6 +3859,7 @@ export function useAgentChatController({progressByAgentMessage,composerImageAttachments,composerFileAttachments,+ composerFileRefusals,composerReferenceAttachments,agentSending,// A fresh send-time error (a blocked image send, a new POST failure) wins;diff --git a/desktop-app/ui/src/hooks/domain/useComposerAttachments.ts b/desktop-app/ui/src/hooks/domain/useComposerAttachments.tsindex 99c5b7652..550ae63b4 100644--- a/desktop-app/ui/src/hooks/domain/useComposerAttachments.ts+++ b/desktop-app/ui/src/hooks/domain/useComposerAttachments.ts@@ -4,6 +4,7 @@ import { clearComposerDraft, clearComposerDraftAfterSend } from '@lib/composerDrimport { composerFileAdmissionError, readComposerFile } from '@lib/composerFileAdmission'import type {ComposerFileAttachment,+ ComposerFileRefusal,ComposerImageAttachment,ComposerReferenceAttachment,} from '../../uiTypes'@@ -40,6 +41,7 @@ export function useComposerAttachments({const [composerFileAttachments, setComposerFileAttachments] = useState<ComposerFileAttachment[]>([])+ const [composerFileRefusals, setComposerFileRefusals] = useState<ComposerFileRefusal[]>([])const composerAttachmentOrderRef = useRef(0)const composerAttachmentRevisionRef = useRef(0)// Mirrors of the state above. Admission of a file and the completion of its@@ -91,6 +93,7 @@ export function useComposerAttachments({const resetComposerAttachments = useCallback(() => {clearComposerImageAttachments()clearComposerFileAttachments()+ setComposerFileRefusals([])setComposerReferenceAttachments([])}, [clearComposerFileAttachments, clearComposerImageAttachments])@@ -116,14 +119,13 @@ export function useComposerAttachments({(attachments: ComposerImageAttachment[]) => {composerAttachmentRevisionRef.current += 1if (!attachments.length) return+ // A new attach replaces the notice about documents refused earlier.+ setComposerFileRefusals([])setComposerImageAttachments(previous => {const next = [...previous]for (const attachment of attachments) {// Images and files share one per-message count.- const attachedFiles = composerFilesRef.current.filter(- file => file.status !== 'failed'- ).length- if (next.length + attachedFiles >= COMPOSER_MAX_ATTACHMENTS) {+ if (next.length + composerFilesRef.current.length >= COMPOSER_MAX_ATTACHMENTS) {revokeComposerPreviewUrls([attachment])continue}@@ -189,20 +191,21 @@ export function useComposerAttachments({/*** Adds picked documents (#678). Each accepted file appears at once as* `reading` and becomes `ready` when its bytes are read and hashed. A file- * that breaks a limit appears as `failed` with the reason, so a refusal is- * never silent; the user removes it to continue.+ * that breaks a limit, or cannot be read, gets no chip: its reason is shown+ * as a refusal notice instead, so a refusal is never silent. Each attach+ * replaces the refusals of the previous one.*/const handleAddComposerFiles = useCallback((files: File[], textBytes: number) => {composerAttachmentRevisionRef.current += 1if (!files.length) return+ const refusals: ComposerFileRefusal[] = []for (const file of files) {const id = crypto.randomUUID()const current = composerFilesRef.current- const accepted = current.filter(item => item.status !== 'failed')const error = composerFileAdmissionError(file, {- attachedCount: composerImageCountRef.current + accepted.length,- files: accepted,+ attachedCount: composerImageCountRef.current + current.length,+ files: current,textBytes,})composerAttachmentOrderRef.current += 1@@ -215,15 +218,21 @@ export function useComposerAttachments({declaredMediaType: file.type,}if (error) {- commitComposerFiles(previous => [...previous, { ...base, status: 'failed', error }])+ refusals.push({ id, text: error })continue}commitComposerFiles(previous => [...previous, { ...base, status: 'reading' }])void readComposerFile(file, id).then(result => {+ // A file removed while it was read (by the user, a send or an agent+ // change) leaves neither a chip nor a notice.+ if (!composerFilesRef.current.some(item => item.id === id)) return+ if (result.status === 'failed') {+ commitComposerFiles(previous => previous.filter(item => item.id !== id))+ setComposerFileRefusals(previous => [...previous, { id, text: result.error }])+ return+ }commitComposerFiles(previous => {- if (!previous.some(item => item.id === id)) return previousif (- result.status === 'ready' &&previous.some(item =>item.id !== id &&@@ -240,6 +249,7 @@ export function useComposerAttachments({})})}+ setComposerFileRefusals(refusals)clearSendError()},[clearSendError, commitComposerFiles]@@ -299,6 +309,7 @@ export function useComposerAttachments({return {composerImageAttachments,composerFileAttachments,+ composerFileRefusals,composerAttachmentRevisionRef,composerReferenceAttachments,resetComposerAttachments,diff --git a/desktop-app/ui/src/hooks/useAppController.ts b/desktop-app/ui/src/hooks/useAppController.tsindex fb4f861a0..417a170b3 100644--- a/desktop-app/ui/src/hooks/useAppController.ts+++ b/desktop-app/ui/src/hooks/useAppController.ts@@ -1537,6 +1537,7 @@ export function useAppController() {olderMessagesLoading: chat.olderMessagesLoading,composerImageAttachments: chat.composerImageAttachments,composerFileAttachments: chat.composerFileAttachments,+ composerFileRefusals: chat.composerFileRefusals,composerReferenceAttachments: chat.composerReferenceAttachments,agentSending: chat.agentSending,agentError: chat.agentError,diff --git a/desktop-app/ui/src/lib/composerFileAdmission.ts b/desktop-app/ui/src/lib/composerFileAdmission.tsindex 02ba5dc1b..2ff023239 100644--- a/desktop-app/ui/src/lib/composerFileAdmission.ts+++ b/desktop-app/ui/src/lib/composerFileAdmission.ts@@ -7,7 +7,7 @@ import {COMPOSER_MAX_TOTAL_FILE_BASE64_BYTES,COMPOSER_REQUEST_ENVELOPE_BYTES,} from '@constants/attachments'-import type { ComposerFileAttachment } from '../uiTypes'+import type { ComposerFileAttachment, ComposerFileReadResult } from '../uiTypes'const FILE_NAME_MAX_CODE_POINTS = 255const BASE64_CHUNK_BYTES = 0x8000@@ -146,7 +146,7 @@ async function sha256Hex(bytes: Uint8Array<ArrayBuffer>): Promise<string> {* with the reason. The bytes read must match the size the picker reported: a* file that changes on disk while it is read is not sent.*/-export async function readComposerFile(file: File, id: string): Promise<ComposerFileAttachment> {+export async function readComposerFile(file: File, id: string): Promise<ComposerFileReadResult> {const base = {id,type: 'file' as const,diff --git a/desktop-app/ui/src/styles.css b/desktop-app/ui/src/styles.cssindex e4deeb422..cd4df2eb5 100644--- a/desktop-app/ui/src/styles.css+++ b/desktop-app/ui/src/styles.css@@ -8068,10 +8068,6 @@ h3 {text-overflow: ellipsis;}-.composer-attachment-chip-meta--failed {- color: var(--danger);-}-.composer-attachment-remove {border: none;background: transparent;diff --git a/desktop-app/ui/src/uiTypes.ts b/desktop-app/ui/src/uiTypes.tsindex 028d8f32d..9820aefa6 100644--- a/desktop-app/ui/src/uiTypes.ts+++ b/desktop-app/ui/src/uiTypes.ts@@ -275,13 +275,13 @@ type ComposerFileAttachmentBase = {/*** A document picked for the current message (#678). It is read completely in* the renderer (`selected` → `reading`) before it can be sent; only a `ready`- * file travels, as an inline `kind:'file'` attachment. `failed` keeps the- * reason on screen until the user removes the chip.+ * file travels, as an inline `kind:'file'` attachment. A file that is refused+ * or cannot be read never stays in this list: it becomes a+ * `ComposerFileRefusal` instead.*/export type ComposerFileAttachment = ComposerFileAttachmentBase &(| { status: 'selected' | 'reading' }- | { status: 'failed'; error: string }| {status: 'ready'classification: FileClassification@@ -293,6 +293,20 @@ export type ComposerFileAttachment = ComposerFileAttachmentBase &/** A document that is fully read and hashed: the only state that can be sent. */export type ReadyComposerFileAttachment = Extract<ComposerFileAttachment, { status: 'ready' }>+/** The outcome of reading a picked document: ready to send, or the reason it cannot be. */+export type ComposerFileReadResult =+ | ReadyComposerFileAttachment+ | (ComposerFileAttachmentBase & { status: 'failed'; error: string })++/**+ * Why a picked document was not attached (#678). Shown as a notice until the+ * next attach, a send or an agent change.+ */+export type ComposerFileRefusal = {+ id: string+ text: string+}+export type ComposerPluginReference = {id: stringaddedOrder?: numberdiff --git a/tests/e2e/fixtures/package-lock.json b/tests/e2e/fixtures/package-lock.jsonindex 8e11b8b25..be94373d4 100644--- a/tests/e2e/fixtures/package-lock.json+++ b/tests/e2e/fixtures/package-lock.json@@ -1,12 +1,12 @@{"name": "@clerum/e2e-test-fixtures",- "version": "1.0.102",+ "version": "1.0.103","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "@clerum/e2e-test-fixtures",- "version": "1.0.102",+ "version": "1.0.103","dependencies": {"@kubernetes/client-node": "^1.0.0"},diff --git a/tests/e2e/fixtures/package.json b/tests/e2e/fixtures/package.jsonindex 84138e7b7..29e5fe879 100644--- a/tests/e2e/fixtures/package.json+++ b/tests/e2e/fixtures/package.json@@ -1,11 +1,11 @@{"name": "@clerum/e2e-test-fixtures",- "version": "1.0.102",+ "version": "1.0.103","description": "E2E test fixtures and utilities for Clerum testing","type": "module","main": "index.ts","scripts": {- "test": "vitest run --passWithNoTests",+ "test": "vitest run","test:watch": "vitest","lint": "eslint . --ext .ts","typecheck": "tsc --noEmit"