The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
test(chat): cover dropped and pasted files on the assistant composer
Shanuc9eabbfb76d6
diff --git a/app/src/features/conversations/components/AssistantUiChat.slots.test.tsx b/app/src/features/conversations/components/AssistantUiChat.slots.test.tsxindex 6f016ee6e6..a4f787eed8 100644--- a/app/src/features/conversations/components/AssistantUiChat.slots.test.tsx+++ b/app/src/features/conversations/components/AssistantUiChat.slots.test.tsx@@ -13,7 +13,7 @@* slots correct.*/import { combineReducers, configureStore } from '@reduxjs/toolkit';-import { render, screen } from '@testing-library/react';+import { fireEvent, render, screen } from '@testing-library/react';import { Provider } from 'react-redux';import { describe, expect, it, vi } from 'vitest';@@ -83,7 +83,11 @@ function goalController(overrides: Partial<ThreadGoalController> = {}): ThreadGo};}-function chat(threadGoal: ThreadGoalController, onOpenHumanMode?: () => void) {+function chat(+ threadGoal: ThreadGoalController,+ onOpenHumanMode?: () => void,+ overrides: { attachmentsEnabled?: boolean; attachmentInteractionBlocked?: boolean } = {}+) {return (<AssistantUiChatthreadGoal={threadGoal}@@ -95,14 +99,18 @@ function chat(threadGoal: ThreadGoalController, onOpenHumanMode?: () => void) {onAttachFiles={vi.fn()}onRemoveAttachment={vi.fn()}maxAttachments={5}- attachmentsEnabled={false}- attachmentInteractionBlocked={false}+ attachmentsEnabled={overrides.attachmentsEnabled ?? false}+ attachmentInteractionBlocked={overrides.attachmentInteractionBlocked ?? false}onAttachmentOnlySend={vi.fn()}onOpenHumanMode={onOpenHumanMode}/>);}+function composerShell(): HTMLElement {+ return document.querySelector('[data-slot="aui_composer-shell"]') as HTMLElement;+}+describe('assistant-ui composer slots', () => {it('shows the thread-goal editor once the controller expands', async () => {const store = buildStore();@@ -136,4 +144,36 @@ describe('assistant-ui composer slots', () => {expect(screen.getByTestId('composer-human-mode')).toBe(button);});++ it('refuses a file drag while the composer is locked', () => {+ const store = buildStore();+ render(+ <Provider store={store}>+ {chat(goalController(), undefined, {+ attachmentsEnabled: true,+ attachmentInteractionBlocked: true,+ })}+ </Provider>+ );++ const dataTransfer = { types: ['Files'], dropEffect: 'copy' };+ fireEvent.dragOver(composerShell(), { dataTransfer });++ // `preventDefault` still ran — otherwise the webview navigates away to the+ // dropped file — but the drop is refused and no affordance is shown.+ expect(dataTransfer.dropEffect).toBe('none');+ expect(composerShell().getAttribute('data-dragging')).toBeNull();+ });++ it('leaves the assistant-ui dropzone in charge when the host takes no files', () => {+ const store = buildStore();+ render(<Provider store={store}>{chat(goalController())}</Provider>);++ const dataTransfer = { types: ['Files'], dropEffect: 'copy' };+ fireEvent.dragOver(composerShell(), { dataTransfer });++ // `attachmentsEnabled` is false here, so no host file sink is published and+ // the primitive's own (capability-gated) handling is what remains.+ expect(composerShell().getAttribute('data-dragging')).toBeNull();+ });});diff --git a/app/src/pages/__tests__/Conversations.attachments.test.tsx b/app/src/pages/__tests__/Conversations.attachments.test.tsxindex 7869429c22..c1cc9a913c 100644--- a/app/src/pages/__tests__/Conversations.attachments.test.tsx+++ b/app/src/pages/__tests__/Conversations.attachments.test.tsx@@ -377,6 +377,69 @@ describe('Conversations — attachment feature', () => {expect(screen.getByAltText('preview.png')).toBe(image);});+ // Drop and paste had no host path on this surface at all: the only dropzone+ // was assistant-ui's own, which routes files to a runtime attachment adapter+ // this app does not use and refuses the drag outright when the runtime+ // declares no attachment capability.+ it('attaches a file dropped on the composer', async () => {+ await renderWithSelectedThread();++ const shell = document.querySelector('[data-slot="aui_composer-shell"]') as HTMLElement;+ expect(shell).not.toBeNull();++ const file = makeFile('dropped.png', 'image/png', 512);+ await act(async () => {+ fireEvent.drop(shell, { dataTransfer: { files: [file], types: ['Files'] } });+ });++ await waitFor(() => {+ expect(screen.getByText('dropped.png')).toBeInTheDocument();+ });+ });++ it('marks the composer while files are dragged over it, and clears on leave', async () => {+ await renderWithSelectedThread();++ const shell = document.querySelector('[data-slot="aui_composer-shell"]') as HTMLElement;++ await act(async () => {+ fireEvent.dragOver(shell, { dataTransfer: { types: ['Files'], dropEffect: '' } });+ });+ expect(shell.getAttribute('data-dragging')).toBe('true');++ await act(async () => {+ fireEvent.dragLeave(shell, { relatedTarget: document.body });+ });+ expect(shell.getAttribute('data-dragging')).toBeNull();+ });++ it('attaches a pasted screenshot', async () => {+ const { textarea } = await renderWithSelectedThread();++ const file = makeFile('screenshot.png', 'image/png', 512);+ await act(async () => {+ fireEvent.paste(textarea, {+ clipboardData: { items: [{ kind: 'file', type: 'image/png', getAsFile: () => file }] },+ });+ });++ await waitFor(() => {+ expect(screen.getByText('screenshot.png')).toBeInTheDocument();+ });+ });++ it('ignores a plain-text paste so typing still works', async () => {+ const { textarea } = await renderWithSelectedThread();++ await act(async () => {+ fireEvent.paste(textarea, {+ clipboardData: { items: [{ kind: 'string', type: 'text/plain', getAsFile: () => null }] },+ });+ });++ expect(document.querySelector('[data-slot="aui_composer-shell"] img')).toBeNull();+ });+it('shows too-many error when selecting more than 4 images', async () => {await renderWithSelectedThread();