Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

fix(thread): guard file-drop handlers against missing onComposerFiles

Steven Enamakel49c83dee64ee
diff --git a/app/src/components/assistant-ui/thread.tsx b/app/src/components/assistant-ui/thread.tsx
index db8f1204b6..e4e76739aa 100644
--- a/app/src/components/assistant-ui/thread.tsx
+++ b/app/src/components/assistant-ui/thread.tsx
@@ -271,9 +271,9 @@ function useThreadFileDrop() {
const isFileDrag = (event: React.DragEvent) =>
Array.from(event.dataTransfer?.types ?? []).includes('Files');
const onDragOver = (event: React.DragEvent) => {
- if (!onComposerFiles || !isFileDrag(event)) return;
+ if (!isFileDrag(event)) return;
event.preventDefault();
- if (!canAcceptComposerFiles) {
+ if (!onComposerFiles || !canAcceptComposerFiles) {
event.dataTransfer.dropEffect = 'none';
return;
}
@@ -286,10 +286,10 @@ function useThreadFileDrop() {
setIsDraggingFiles(false);
};
const onDrop = (event: React.DragEvent) => {
- if (!onComposerFiles || !isFileDrag(event)) return;
+ if (!isFileDrag(event)) return;
event.preventDefault();
setIsDraggingFiles(false);
- if (!canAcceptComposerFiles) {
+ if (!onComposerFiles || !canAcceptComposerFiles) {
debug('[assistant-composer] drop: refused, ingest not accepting');
return;
}
diff --git a/app/src/features/conversations/components/AssistantUiChat.slots.test.tsx b/app/src/features/conversations/components/AssistantUiChat.slots.test.tsx
index b549b272d3..6543bec56e 100644
--- a/app/src/features/conversations/components/AssistantUiChat.slots.test.tsx
+++ b/app/src/features/conversations/components/AssistantUiChat.slots.test.tsx
@@ -112,9 +112,14 @@ describe('assistant-ui composer slots', () => {
it('refuses a file drag while the composer is locked', () => {
const store = buildStore();
+ const onAttachFiles = vi.fn(() => Promise.resolve());
render(
<Provider store={store}>
- {chat(undefined, { attachmentsEnabled: true, attachmentInteractionBlocked: true })}
+ {chat(undefined, {
+ attachmentsEnabled: true,
+ attachmentInteractionBlocked: true,
+ onAttachFiles,
+ })}
</Provider>
);
@@ -125,6 +130,14 @@ describe('assistant-ui composer slots', () => {
// dropped file — but the drop is refused and no affordance is shown.
expect(dataTransfer.dropEffect).toBe('none');
expect(composerShell().getAttribute('data-dragging')).toBeNull();
+
+ const drop = fireEvent.drop(threadViewport(), {
+ dataTransfer: { types: ['Files'], files: [new File(['blocked'], 'blocked.txt')], items: [] },
+ });
+
+ expect(drop).toBe(false); // default navigation is still cancelled
+ expect(onAttachFiles).not.toHaveBeenCalled();
+ expect(composerShell().getAttribute('data-dragging')).toBeNull();
});
it('leaves the assistant-ui dropzone in charge when the host takes no files', () => {
@@ -137,6 +150,7 @@ describe('assistant-ui composer slots', () => {
// `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();
+ expect(dataTransfer.dropEffect).toBe('none');
});
it('takes a file dropped anywhere over the open thread, not just the composer', () => {