Skip to content

Dodaios is an open-source agent OS for your desktop: it runs your coding agents, browser and apps by voice or chat, on your own machine. Formerly Personal Jarvis.

fix(agentic-ide): stop a pane offering itself to a drag that carries no file

Ruben Lütke7714d2ed7345
diff --git a/docs/BUGS.md b/docs/BUGS.md
index e929565c32..19a5c0ffa1 100644
--- a/docs/BUGS.md
+++ b/docs/BUGS.md
@@ -7590,3 +7590,58 @@ normal-privilege client can see in the Jarvis window went from **1 to 22**.
**Meta-lesson.** A fail-open diagnostic can perfectly disguise its own breakage.
Any probe whose "I don't know" path is silent needs a cross-check against an
independent implementation, or it will report "nothing to see here" forever.
+
+## BUG-110: a terminal pane in the Agentic IDE offers "Drop to put it in front of Dana" to a user holding nothing (LOW, FIXED 2026-07-27)
+
+**Symptom (desktop field report, screenshot).** In the Agentic IDE, one pane
+suddenly dimmed behind a blurred overlay reading "Drop to put it in front of
+**Dana**" with a paperclip icon — while the user was dragging no file, and had
+no file anywhere in hand. The overlay cleared on its own moments later. Nothing
+was lost and no agent was disturbed; it read as the UI hallucinating a
+drag-and-drop that was not happening.
+
+**Root cause — two independent halves, both in the pane's drop arming**
+(`jarvis/ui/web/frontend/src/components/agentic/AgenticTerminal.tsx`):
+
+1. **The pane armed on ANY drag, never asking what it carried.** `onDragEnter`
+ set `dragging = true` unconditionally and `onDragOver` reported
+ `dropEffect = "copy"` to match. A browser fires `dragenter` for every drag
+ that crosses an element, and the cheapest way to start one by accident is a
+ TEXT selection: brush across terminal output or a header label with the
+ mouse held down and the browser lifts the selection into a native drag. An
+ internal Outputs mission card tossed across the grid did the same. Every one
+ of them lit the file overlay of whichever pane it flew over.
+2. **Disarming depended on a `dragleave` that is not owed.** The enter/leave
+ counter (`dragDepth`) is the correct answer to child-element flicker, but it
+ only balances when every enter gets its leave. A drag released over another
+ element, dropped outside the window, or cancelled with Escape sends this pane
+ nothing at all — the overlay then sits over a live agent until some later
+ drag happens to balance the count.
+
+Half 1 explains what the user saw; half 2 is the same defect's worse outcome —
+an overlay that never clears — and was fixed with it.
+
+**Fix.** The arming logic moved into
+`jarvis/ui/web/frontend/src/components/agentic/paneFileDrag.ts`:
+
+- `dragCarriesFiles()` (`paneDrop.ts`) gates the overlay on the drag's TYPES —
+ the only thing a browser exposes mid-flight, by design. `Files` (Explorer,
+ Finder) and `text/uri-list` (some Linux file managers) arm the pane;
+ `text/plain` alone does not, and neither does the internal mission MIME.
+- `dropEffect` follows the same gate, so the cursor stops promising a copy
+ where a drop would do nothing.
+- `dragenter`/`dragover` still call `preventDefault()` for payloads the pane
+ refuses — otherwise a dropped link would NAVIGATE the window and take every
+ agent in the grid with it.
+- A window-level backstop (`drop`, `dragend`, and a viewport-edge `dragleave`
+ with `relatedTarget === null`) disarms the pane whenever the drag ends
+ anywhere else — the same pattern `JarvisDock` already uses.
+
+**Guards.** `paneDrop.test.ts` (types gate: files vs. dragged text vs. mission
+card) and `paneFileDrag.test.ts` (arming, child-element flicker, copy-cursor
+honesty, and all three disarm paths).
+
+**Class rule.** A drop target may only announce itself for a payload it can
+actually accept, and must never rely on a matching `dragleave` to take that
+announcement down. `dragenter` is a "something is moving over you" signal, not
+a "the user is offering you a file" signal.
diff --git a/jarvis/ui/web/frontend/src/components/agentic/AgenticTerminal.tsx b/jarvis/ui/web/frontend/src/components/agentic/AgenticTerminal.tsx
index cdae7b0eb7..548815a34e 100644
--- a/jarvis/ui/web/frontend/src/components/agentic/AgenticTerminal.tsx
+++ b/jarvis/ui/web/frontend/src/components/agentic/AgenticTerminal.tsx
@@ -70,6 +70,7 @@ import {
nameClipboardFile,
type PaneDropPayload,
} from "./paneDrop";
+import { usePaneFileDrag } from "./paneFileDrag";
import { attachToTerminal } from "@/lib/agenticIdeApi";
import { attachTerminalBridge } from "@/lib/editActions";
import { robustPaste } from "@/lib/clipboard";
@@ -449,10 +450,12 @@ export function AgenticTerminal({
*
* Deliberately typed and NOT submitted: someone dropping a screenshot wants to
* say what to do with it. The reference appears, the cursor sits after it.
+ *
+ * WHEN the pane arms for a drop — and when it must stay quiet — lives in
+ * ./paneFileDrag, because getting that wrong is what made a pane offer itself
+ * to a user who was holding nothing at all (BUG-110).
*/
- const [dragging, setDragging] = useState(false);
const [attaching, setAttaching] = useState(false);
- const dragDepth = useRef(0);
const attach = useCallback(
async (payload: PaneDropPayload) => {
@@ -473,6 +476,17 @@ export function AgenticTerminal({
[name, onAttachError],
);
+ const { dragging, handlers: dragHandlers } = usePaneFileDrag(
+ useCallback(
+ (dt: DataTransfer) => {
+ onFocus?.();
+ // Read BEFORE any await — the DataTransfer is gone after this returns.
+ void attach(extractPaneDrop(dt));
+ },
+ [attach, onFocus],
+ ),
+ );
+
// Clipboard images only — pasted TEXT belongs to xterm, which turns it into a
// proper bracketed paste the agent's prompt box understands.
//
@@ -501,29 +515,7 @@ export function AgenticTerminal({
return (
<div
onMouseDown={onFocus}
- onDragEnter={(e) => {
- e.preventDefault();
- // Counted, not a boolean: dragging across the xterm canvas fires
- // enter/leave for every child element, and a boolean flickers.
- dragDepth.current += 1;
- setDragging(true);
- }}
- onDragOver={(e) => {
- e.preventDefault();
- e.dataTransfer.dropEffect = "copy";
- }}
- onDragLeave={() => {
- dragDepth.current = Math.max(0, dragDepth.current - 1);
- if (dragDepth.current === 0) setDragging(false);
- }}
- onDrop={(e) => {
- e.preventDefault();
- dragDepth.current = 0;
- setDragging(false);
- onFocus?.();
- // Read BEFORE any await — the DataTransfer is gone after this returns.
- void attach(extractPaneDrop(e.dataTransfer));
- }}
+ {...dragHandlers}
className={cn(
"relative flex h-full w-full flex-col overflow-hidden rounded-xl border transition-shadow",
focused
diff --git a/jarvis/ui/web/frontend/src/components/agentic/paneDrop.test.ts b/jarvis/ui/web/frontend/src/components/agentic/paneDrop.test.ts
index 8beb1cc689..dbc5f7a32f 100644
--- a/jarvis/ui/web/frontend/src/components/agentic/paneDrop.test.ts
+++ b/jarvis/ui/web/frontend/src/components/agentic/paneDrop.test.ts
@@ -1,5 +1,6 @@
import { describe, expect, it } from "vitest";
import {
+ dragCarriesFiles,
extractPaneDrop,
extractPasteFiles,
isEmptyPayload,
@@ -86,6 +87,39 @@ describe("reading a drop onto a terminal pane", () => {
});
});
+describe("deciding whether a drag in flight is worth offering a pane for", () => {
+ /** A drag mid-flight exposes only its TYPES — never the data. */
+ const inFlight = (types: string[]) =>
+ ({ types }) as unknown as DataTransfer;
+
+ it("recognises a file drag out of Explorer or Finder", () => {
+ expect(dragCarriesFiles(inFlight(["Files"]))).toBe(true);
+ expect(dragCarriesFiles(inFlight(["Files", "text/plain"]))).toBe(true);
+ });
+
+ it("recognises the uri-list some Linux file managers send instead", () => {
+ expect(dragCarriesFiles(inFlight(["text/uri-list"]))).toBe(true);
+ });
+
+ it("ignores dragged TEXT — nobody holding a selection is offering a file", () => {
+ // BUG-110: brushing over terminal output with the mouse down lifts the
+ // selection into a drag, and the pane announced "drop your file here" to a
+ // user holding nothing.
+ expect(dragCarriesFiles(inFlight(["text/plain"]))).toBe(false);
+ });
+
+ it("ignores an internal mission card tossed across the grid", () => {
+ expect(dragCarriesFiles(inFlight(["application/x-jarvis-mission"]))).toBe(
+ false,
+ );
+ });
+
+ it("survives a drag with no DataTransfer at all", () => {
+ expect(dragCarriesFiles(null)).toBe(false);
+ expect(dragCarriesFiles({} as DataTransfer)).toBe(false);
+ });
+});
+
describe("reading a paste", () => {
it("picks up a clipboard image", () => {
expect(extractPasteFiles(dt({ files: [file("image.png")] })).length).toBe(1);
diff --git a/jarvis/ui/web/frontend/src/components/agentic/paneDrop.ts b/jarvis/ui/web/frontend/src/components/agentic/paneDrop.ts
index c256a84c54..5963e82a9d 100644
--- a/jarvis/ui/web/frontend/src/components/agentic/paneDrop.ts
+++ b/jarvis/ui/web/frontend/src/components/agentic/paneDrop.ts
@@ -34,6 +34,33 @@ export function isEmptyPayload(payload: PaneDropPayload): boolean {
return payload.paths.length === 0 && payload.files.length === 0;
}
+/**
+ * Is there a FILE in this drag — the only question a pane may ask while a drag
+ * is still in flight?
+ *
+ * A browser deliberately seals a drag's contents until it is dropped: during
+ * `dragenter`/`dragover` only `DataTransfer.types` is readable, never the data
+ * itself. So this is a type check, and it has to be, but it is enough to tell
+ * the two cases apart that matter:
+ *
+ * * `Files` — a real drag out of Explorer, Finder, or a file manager.
+ * * `text/uri-list` — the one shape some Linux file managers send instead, so
+ * dropping a file there keeps working.
+ * * **`text/plain` ALONE is not a file.** That is what selected TEXT looks
+ * like, and text is what a user drags by accident: brush over terminal
+ * output with the mouse held down and the browser lifts the selection into a
+ * drag nobody asked for. A pane that arms on this announces "drop your file
+ * here" at someone holding nothing (BUG-110).
+ *
+ * An internal mission card carries neither type, so tossing one across the grid
+ * stays invisible to the panes it flies over.
+ */
+export function dragCarriesFiles(dt: DataTransfer | null): boolean {
+ if (!dt) return false;
+ const types = Array.from(dt.types ?? []);
+ return types.includes("Files") || types.includes("text/uri-list");
+}
+
/**
* A `file://` URI as a native path; anything else unchanged.
*
diff --git a/jarvis/ui/web/frontend/src/components/agentic/paneFileDrag.test.ts b/jarvis/ui/web/frontend/src/components/agentic/paneFileDrag.test.ts
new file mode 100644
index 0000000000..5b5906e674
--- /dev/null
+++ b/jarvis/ui/web/frontend/src/components/agentic/paneFileDrag.test.ts
@@ -0,0 +1,154 @@
+import { act, renderHook } from "@testing-library/react";
+import { describe, expect, it, vi } from "vitest";
+import type { DragEvent as ReactDragEvent } from "react";
+import { usePaneFileDrag } from "./paneFileDrag";
+
+/** A drag event as React hands it to a handler. */
+function dragEvent(types: string[]) {
+ const dataTransfer = { types, dropEffect: "" } as unknown as DataTransfer;
+ return {
+ dataTransfer,
+ preventDefault: vi.fn(),
+ } as unknown as ReactDragEvent & {
+ dataTransfer: DataTransfer;
+ preventDefault: ReturnType<typeof vi.fn>;
+ };
+}
+
+describe("arming a terminal pane for a file drop", () => {
+ it("arms for a file drag", () => {
+ const { result } = renderHook(() => usePaneFileDrag(vi.fn()));
+
+ act(() => result.current.handlers.onDragEnter(dragEvent(["Files"])));
+
+ expect(result.current.dragging).toBe(true);
+ });
+
+ it("stays quiet for dragged text — the user is holding no file", () => {
+ // BUG-110: the pane offered itself to a stray text selection drag.
+ const { result } = renderHook(() => usePaneFileDrag(vi.fn()));
+
+ act(() => result.current.handlers.onDragEnter(dragEvent(["text/plain"])));
+
+ expect(result.current.dragging).toBe(false);
+ });
+
+ it("claims even a text drag so a dropped link cannot navigate the IDE away", () => {
+ const { result } = renderHook(() => usePaneFileDrag(vi.fn()));
+ const e = dragEvent(["text/plain"]);
+
+ act(() => result.current.handlers.onDragEnter(e));
+
+ expect(e.preventDefault).toHaveBeenCalled();
+ });
+
+ it("shows a copy cursor only where a drop would do something", () => {
+ const { result } = renderHook(() => usePaneFileDrag(vi.fn()));
+ const withFile = dragEvent(["Files"]);
+ const withText = dragEvent(["text/plain"]);
+
+ act(() => {
+ result.current.handlers.onDragOver(withFile);
+ result.current.handlers.onDragOver(withText);
+ });
+
+ expect(withFile.dataTransfer.dropEffect).toBe("copy");
+ expect(withText.dataTransfer.dropEffect).toBe("none");
+ });
+
+ it("stays armed while the drag crosses child elements", () => {
+ const { result } = renderHook(() => usePaneFileDrag(vi.fn()));
+
+ act(() => {
+ result.current.handlers.onDragEnter(dragEvent(["Files"]));
+ result.current.handlers.onDragEnter(dragEvent(["Files"])); // onto a child
+ result.current.handlers.onDragLeave(dragEvent(["Files"])); // off the parent
+ });
+
+ expect(result.current.dragging).toBe(true);
+
+ act(() => result.current.handlers.onDragLeave(dragEvent(["Files"])));
+
+ expect(result.current.dragging).toBe(false);
+ });
+
+ it("hands a real drop to the pane", () => {
+ const onFiles = vi.fn();
+ const { result } = renderHook(() => usePaneFileDrag(onFiles));
+ const e = dragEvent(["Files"]);
+
+ act(() => {
+ result.current.handlers.onDragEnter(dragEvent(["Files"]));
+ result.current.handlers.onDrop(e);
+ });
+
+ expect(onFiles).toHaveBeenCalledWith(e.dataTransfer);
+ expect(result.current.dragging).toBe(false);
+ });
+
+ it("does not treat a dropped text selection as an attach", () => {
+ const onFiles = vi.fn();
+ const { result } = renderHook(() => usePaneFileDrag(onFiles));
+
+ act(() => result.current.handlers.onDrop(dragEvent(["text/plain"])));
+
+ expect(onFiles).not.toHaveBeenCalled();
+ });
+
+ it("disarms when the drag ends somewhere else in the window", () => {
+ // No `dragleave` is owed to this pane when the drop lands elsewhere, so
+ // without the window backstop the overlay would sit over a live agent.
+ const { result } = renderHook(() => usePaneFileDrag(vi.fn()));
+ act(() => result.current.handlers.onDragEnter(dragEvent(["Files"])));
+
+ act(() => {
+ window.dispatchEvent(new Event("drop"));
+ });
+
+ expect(result.current.dragging).toBe(false);
+ });
+
+ it("disarms when the drag is cancelled", () => {
+ const { result } = renderHook(() => usePaneFileDrag(vi.fn()));
+ act(() => result.current.handlers.onDragEnter(dragEvent(["Files"])));
+
+ act(() => {
+ window.dispatchEvent(new Event("dragend"));
+ });
+
+ expect(result.current.dragging).toBe(false);
+ });
+
+ it("disarms when the drag leaves the window entirely", () => {
+ const { result } = renderHook(() => usePaneFileDrag(vi.fn()));
+ act(() => result.current.handlers.onDragEnter(dragEvent(["Files"])));
+
+ act(() => {
+ // relatedTarget null + a cursor at the viewport edge = gone from the window.
+ const leave = new MouseEvent("dragleave", {
+ clientX: 0,
+ clientY: 12,
+ relatedTarget: null,
+ });
+ window.dispatchEvent(leave);
+ });
+
+ expect(result.current.dragging).toBe(false);
+ });
+
+ it("keeps the overlay up while the drag merely moves inside the window", () => {
+ const { result } = renderHook(() => usePaneFileDrag(vi.fn()));
+ act(() => result.current.handlers.onDragEnter(dragEvent(["Files"])));
+
+ act(() => {
+ const leave = new MouseEvent("dragleave", {
+ clientX: 200,
+ clientY: 200,
+ relatedTarget: document.body,
+ });
+ window.dispatchEvent(leave);
+ });
+
+ expect(result.current.dragging).toBe(true);
+ });
+});
diff --git a/jarvis/ui/web/frontend/src/components/agentic/paneFileDrag.ts b/jarvis/ui/web/frontend/src/components/agentic/paneFileDrag.ts
new file mode 100644
index 0000000000..3c3c406158
--- /dev/null
+++ b/jarvis/ui/web/frontend/src/components/agentic/paneFileDrag.ts
@@ -0,0 +1,119 @@
+/**
+ * When a terminal pane offers itself as a file target — and, the harder half,
+ * when it stops.
+ *
+ * Arming a drop zone looks like three lines of `dragenter`/`dragleave` until it
+ * meets a real desktop, where both halves lie:
+ *
+ * * **`dragenter` fires for drags that carry nothing droppable.** Selected text
+ * lifted by a stray mouse-drag is still a drag, and a pane that arms on it
+ * tells a user holding nothing to "drop the file here" (BUG-110).
+ * * **`dragleave` is not guaranteed to arrive.** Release the drag over another
+ * element, drop it outside the window, or cancel with Escape and the pane
+ * that armed never hears the end of it — the overlay then sits over a live
+ * agent until the next drag happens to balance the books.
+ *
+ * So the arming is gated on the payload, and the disarming has a window-level
+ * backstop that does not depend on a matching leave ever being delivered.
+ */
+import {
+ useCallback,
+ useEffect,
+ useRef,
+ useState,
+ type DragEvent as ReactDragEvent,
+} from "react";
+import { dragCarriesFiles } from "./paneDrop";
+
+export interface PaneFileDragHandlers {
+ onDragEnter: (e: ReactDragEvent) => void;
+ onDragOver: (e: ReactDragEvent) => void;
+ onDragLeave: (e: ReactDragEvent) => void;
+ onDrop: (e: ReactDragEvent) => void;
+}
+
+export interface PaneFileDrag {
+ /** True while a file drag is over this pane — drives the drop overlay. */
+ dragging: boolean;
+ /** Spread onto the pane's root element. */
+ handlers: PaneFileDragHandlers;
+}
+
+/**
+ * Track a file drag over one pane.
+ *
+ * `onFiles` runs on a drop that actually carried files; it is handed the live
+ * `DataTransfer` and must read it SYNCHRONOUSLY (see ./paneDrop).
+ */
+export function usePaneFileDrag(
+ onFiles: (dt: DataTransfer) => void,
+): PaneFileDrag {
+ const [dragging, setDragging] = useState(false);
+ // Counted, not a boolean: a drag moving across the pane fires enter/leave for
+ // every child element it crosses, and a boolean flickers.
+ const depth = useRef(0);
+
+ const disarm = useCallback(() => {
+ depth.current = 0;
+ setDragging(false);
+ }, []);
+
+ // The backstop. A drag that ends anywhere other than on this pane owes it no
+ // `dragleave`, so the end of the drag is watched globally instead — and only
+ // while armed, which is the only time there is anything to take down.
+ useEffect(() => {
+ if (!dragging) return;
+ const onWindowDragLeave = (e: DragEvent) => {
+ // `relatedTarget === null` plus a cursor at the viewport edge means the
+ // drag left the WINDOW, not merely moved between elements inside it.
+ if (
+ e.relatedTarget === null &&
+ (e.clientX <= 0 ||
+ e.clientY <= 0 ||
+ e.clientX >= window.innerWidth ||
+ e.clientY >= window.innerHeight)
+ ) {
+ disarm();
+ }
+ };
+ window.addEventListener("drop", disarm);
+ window.addEventListener("dragend", disarm);
+ window.addEventListener("dragleave", onWindowDragLeave);
+ return () => {
+ window.removeEventListener("drop", disarm);
+ window.removeEventListener("dragend", disarm);
+ window.removeEventListener("dragleave", onWindowDragLeave);
+ };
+ }, [dragging, disarm]);
+
+ const handlers: PaneFileDragHandlers = {
+ onDragEnter: (e) => {
+ // Claimed even for payloads this pane will not take: the default action
+ // for a dropped link or text is to NAVIGATE, which would replace the
+ // whole IDE — every agent in the grid with it.
+ e.preventDefault();
+ if (!dragCarriesFiles(e.dataTransfer)) return;
+ depth.current += 1;
+ setDragging(true);
+ },
+ onDragOver: (e) => {
+ e.preventDefault();
+ // An honest cursor: "copy" only where a drop will actually do something.
+ e.dataTransfer.dropEffect = dragCarriesFiles(e.dataTransfer)
+ ? "copy"
+ : "none";
+ },
+ onDragLeave: () => {
+ depth.current = Math.max(0, depth.current - 1);
+ if (depth.current === 0) setDragging(false);
+ },
+ onDrop: (e) => {
+ e.preventDefault();
+ disarm();
+ if (!dragCarriesFiles(e.dataTransfer)) return;
+ onFiles(e.dataTransfer);
+ },
+ };
+
+ return { dragging, handlers };
+}