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(ide): a click into a coding agent's output selects its pane

rubenluetke10-beepa22224c3f73f
diff --git a/jarvis/ui/web/frontend/src/components/agentic/AgenticTerminal.test.tsx b/jarvis/ui/web/frontend/src/components/agentic/AgenticTerminal.test.tsx
index 6a9730eaac..ae1d29c784 100644
--- a/jarvis/ui/web/frontend/src/components/agentic/AgenticTerminal.test.tsx
+++ b/jarvis/ui/web/frontend/src/components/agentic/AgenticTerminal.test.tsx
@@ -344,6 +344,24 @@ describe("AgenticTerminal layout", () => {
expect(pane.style.borderColor).toBe(resting);
});
+ it("selects the pane on a press into the terminal even when xterm swallows it", () => {
+ const onFocus = vi.fn();
+ render(<AgenticTerminal name="Dana" displayName="Codex" appearance="dark" fontSize={13} headerMode="minimal" onFocus={onFocus} />);
+ const host = screen.getByTestId("agentic-terminal-host-Dana");
+ // xterm's selection service stops a press it turns into a selection.
+ const swallow = (event: Event) => event.stopPropagation();
+ host.addEventListener("mousedown", swallow);
+ fireEvent.mouseDown(host, { button: 0 });
+ expect(onFocus).toHaveBeenCalledTimes(1);
+ host.removeEventListener("mousedown", swallow);
+ // A press that bubbles normally reaches both handlers but counts once.
+ fireEvent.mouseDown(host, { button: 0 });
+ expect(onFocus).toHaveBeenCalledTimes(2);
+ // Only the primary button selects; a right-click is the pane menu's.
+ fireEvent.mouseDown(host, { button: 2 });
+ expect(onFocus).toHaveBeenCalledTimes(2);
+ });
+
it("keeps the wheel on terminal history even while the CLI tracks the mouse", () => {
render(
<AgenticTerminal
diff --git a/jarvis/ui/web/frontend/src/components/agentic/AgenticTerminal.tsx b/jarvis/ui/web/frontend/src/components/agentic/AgenticTerminal.tsx
index 3c20353c93..95a402ae8e 100644
--- a/jarvis/ui/web/frontend/src/components/agentic/AgenticTerminal.tsx
+++ b/jarvis/ui/web/frontend/src/components/agentic/AgenticTerminal.tsx
@@ -2585,6 +2585,25 @@ export function AgenticTerminal({
return () => container.removeEventListener("paste", onPaste, true);
}, [attach, name]);
+ /*
+ * A primary press anywhere on the pane makes it the pane in use.
+ *
+ * The frame's own bubbling handler never saw presses INTO a coding agent's
+ * output: while the CLI tracks the mouse, ./terminalMouseSelection turns a
+ * plain press into a selection press, and xterm's selection service then
+ * stops it from propagating (so the CLI does not get it). The pane stayed
+ * unselected — no highlight, prompts aimed at the previous pane. The
+ * terminal region therefore also listens in the capture phase, which runs
+ * before any of xterm's listeners; the event identity keeps the two
+ * handlers from doing the work twice for one press.
+ */
+ const handledPress = useRef<Event | null>(null);
+ const pressPane = (event: React.MouseEvent) => {
+ if (event.button !== 0 || handledPress.current === event.nativeEvent) return;
+ handledPress.current = event.nativeEvent;
+ onFocus?.();
+ takeOwnershipRef.current?.();
+ };
const chrome = PANE_CHROME[appearance];
const minimal = headerMode === "minimal";
const tile = PANE_TILE[appearance];
@@ -2617,11 +2636,7 @@ export function AgenticTerminal({
return (
<div
- onMouseDown={(event) => {
- if (event.button !== 0) return;
- onFocus?.();
- takeOwnershipRef.current?.();
- }}
+ onMouseDown={pressPane}
{...dragHandlers}
className={cn(
// One quiet border per pane; the focused one carries the workspace's
@@ -2750,6 +2765,7 @@ export function AgenticTerminal({
*/}
<div
ref={terminalRegionRef}
+ onMouseDownCapture={pressPane}
id={terminalRegionId}
className={cn(
"relative min-h-0 flex-1 overflow-hidden px-1.5 pb-0.5 pt-0.5",