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): read the clipboard on the keystroke, not after the wait

Ruben Lütkeb0c26df28d74
diff --git a/jarvis/ui/web/frontend/src/components/agentic/terminalPaste.test.ts b/jarvis/ui/web/frontend/src/components/agentic/terminalPaste.test.ts
index 8b68f78819..2be915f9d0 100644
--- a/jarvis/ui/web/frontend/src/components/agentic/terminalPaste.test.ts
+++ b/jarvis/ui/web/frontend/src/components/agentic/terminalPaste.test.ts
@@ -163,6 +163,28 @@ describe("pasting into a terminal pane", () => {
expect(term.pasted).toEqual([]);
});
+ /**
+ * How every dictation tool inserts text: put it on the clipboard, send
+ * Ctrl+V, then put the user's previous clipboard back. Reading the clipboard
+ * only after the wait would sometimes land after that restore and paste the
+ * text the user had copied earlier instead of what they just said.
+ */
+ it("pastes what was dictated, not what the tool restored afterwards", async () => {
+ const term = fakeTerminal();
+ let clipboard = "the dictated sentence";
+ dispose = installPasteBridge(term, container, {
+ readClipboard: async () => clipboard,
+ isMac: false,
+ fallbackDelayMs: DELAY,
+ });
+
+ term.press({ key: "v", ctrlKey: true });
+ clipboard = "whatever the user had copied before"; // the tool puts it back
+ await vi.advanceTimersByTimeAsync(DELAY);
+
+ expect(term.pasted).toEqual(["the dictated sentence"]);
+ });
+
it("says so when no path could read the clipboard", async () => {
const term = fakeTerminal();
const onUnavailable = vi.fn();
diff --git a/jarvis/ui/web/frontend/src/components/agentic/terminalPaste.ts b/jarvis/ui/web/frontend/src/components/agentic/terminalPaste.ts
index 37882f149d..787fa121b9 100644
--- a/jarvis/ui/web/frontend/src/components/agentic/terminalPaste.ts
+++ b/jarvis/ui/web/frontend/src/components/agentic/terminalPaste.ts
@@ -16,6 +16,13 @@
* application, and every terminal people actually use on Windows and macOS
* (Windows Terminal, iTerm, the VS Code terminal) pastes on Ctrl+V / Cmd+V.
*
+ * It also silently disabled a whole category of assistive software. Dictation
+ * tools, text expanders, clipboard managers and password-manager auto-type all
+ * insert text the same way: put it on the clipboard and send Ctrl+V. Their own
+ * logs then report success — they sent the keystroke, and nobody tells them it
+ * was swallowed — so the failure surfaces only as "my dictation does nothing
+ * in that window" (confirmed against a dictation app's insertion log, 2026-07-26).
+ *
* ## How it is fixed, and why not more simply
*
* The browser's own paste is still the best path when it works: it needs no
@@ -136,10 +143,19 @@ export function installPasteBridge(
// own paste — which is the whole point.
disarm();
const mine = generation;
+ // Read the clipboard NOW rather than when the timer fires, and that timing
+ // is load-bearing. Dictation tools (a dictation app and every tool shaped like
+ // it) insert text by putting it on the clipboard, sending Ctrl+V, and then
+ // putting the user's PREVIOUS clipboard back. Asking for the clipboard
+ // after the wait can land on the far side of that restore and paste the
+ // wrong text — intermittently, which is the worst way for it to be wrong.
+ // The wait below is only there to give the browser its chance; it waits on
+ // an answer that is already in flight.
+ const pending = options.readClipboard().catch(() => null);
timer = setTimeout(() => {
timer = undefined;
void (async () => {
- const text = await options.readClipboard();
+ const text = await pending;
// A browser paste landed while the clipboard was being read — it has
// already inserted the text, so inserting it again would double it.
if (generation !== mine) return;