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(assistant-ui): cover edit composer behaviour in thread
Steven Enamakel41552f691781
diff --git a/app/src/components/assistant-ui/thread.editComposer.test.tsx b/app/src/components/assistant-ui/thread.editComposer.test.tsxnew file mode 100644index 0000000000..3b84b86f03--- /dev/null+++ b/app/src/components/assistant-ui/thread.editComposer.test.tsx@@ -0,0 +1,44 @@+import { AssistantRuntimeProvider, useExternalStoreRuntime } from '@assistant-ui/react';+import { fireEvent, render, screen, waitFor } from '@testing-library/react';+import { describe, expect, it, vi } from 'vitest';++import { Thread } from './thread';++function Harness({ onEdit = vi.fn() }: { onEdit?: ReturnType<typeof vi.fn> }) {+ const runtime = useExternalStoreRuntime({+ messages: [+ { id: 'user-1', role: 'user' as const, content: 'Original question' },+ { id: 'answer-1', role: 'assistant' as const, content: 'Original answer' },+ ],+ onNew: vi.fn(),+ onEdit,+ });+ return <AssistantRuntimeProvider runtime={runtime}><Thread /></AssistantRuntimeProvider>;+}++describe('native message edit composer', () => {+ it('disables sending an empty edit and cancels without changing the transcript', async () => {+ const onEdit = vi.fn();+ render(<Harness onEdit={onEdit} />);+ fireEvent.click(screen.getByRole('button', { name: 'Edit' }));+ const input = screen.getByRole('textbox', { name: 'Edit your message' });+ expect(input).toHaveValue('Original question');+ fireEvent.change(input, { target: { value: '' } });+ expect(screen.getByRole('button', { name: 'Send' })).toBeDisabled();+ fireEvent.click(screen.getByRole('button', { name: 'Cancel' }));+ await waitFor(() => expect(screen.queryByRole('textbox', { name: 'Edit your message' })).toBeNull());+ expect(screen.getByText('Original question')).toBeInTheDocument();+ expect(onEdit).not.toHaveBeenCalled();+ });++ it('sends the edit through the message composer rather than the thread composer', async () => {+ const onEdit = vi.fn();+ render(<Harness onEdit={onEdit} />);+ fireEvent.click(screen.getByRole('button', { name: 'Edit' }));+ fireEvent.change(screen.getByRole('textbox', { name: 'Edit your message' }), { target: { value: 'Updated question' } });+ fireEvent.click(screen.getByRole('button', { name: 'Send' }));+ await waitFor(() => expect(onEdit).toHaveBeenCalledWith(expect.objectContaining({+ content: [{ type: 'text', text: 'Updated question' }],+ })));+ });+});