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): let a parked pane notice for itself that it is on screen

Ruben Lütkee08673f45973
diff --git a/jarvis/ui/web/frontend/src/components/agentic/AgenticTerminal.offscreen.test.tsx b/jarvis/ui/web/frontend/src/components/agentic/AgenticTerminal.offscreen.test.tsx
index 81d093ac27..aaa97898e6 100644
--- a/jarvis/ui/web/frontend/src/components/agentic/AgenticTerminal.offscreen.test.tsx
+++ b/jarvis/ui/web/frontend/src/components/agentic/AgenticTerminal.offscreen.test.tsx
@@ -238,6 +238,40 @@ describe("AgenticTerminal off-screen output", () => {
expect(harness.writes).toEqual(["held while away"]);
});
+ it("un-parks itself when output arrives and the pane is on screen", () => {
+ // The backstop for every state the observer never reports its way out of.
+ // Two were found one live incident at a time (a hidden document, a pane
+ // that came back at the size it left), and the symptom of the next one
+ // would be identical: an agent working behind an empty rectangle while the
+ // user is told the prompt was handed over. A parked pane that is still
+ // being written to measures itself instead of waiting for a callback.
+ mount();
+ act(() => harness.fire?.(false));
+
+ vi.spyOn(Element.prototype, "getBoundingClientRect").mockReturnValue({
+ top: 10, bottom: 400, left: 10, right: 400, width: 390, height: 390,
+ x: 10, y: 10, toJSON: () => ({}),
+ } as DOMRect);
+
+ act(() => harness.handlers?.onOutput("the prompt Jarvis just typed"));
+ expect(harness.writes.join("")).toContain("the prompt Jarvis just typed");
+ });
+
+ it("keeps withholding from a pane that is genuinely off screen", () => {
+ // The measurement must not become a way back for a pane scrolled out of a
+ // tall grid — that pane is exactly what parking exists for.
+ mount();
+ act(() => harness.fire?.(false));
+
+ vi.spyOn(Element.prototype, "getBoundingClientRect").mockReturnValue({
+ top: 4000, bottom: 4400, left: 10, right: 400, width: 390, height: 390,
+ x: 10, y: 4000, toJSON: () => ({}),
+ } as DOMRect);
+
+ act(() => harness.handlers?.onOutput("nobody is looking at this"));
+ expect(harness.writes).toEqual([]);
+ });
+
it("stays visible where IntersectionObserver does not exist", () => {
// Old engines and bare test environments: the pane must keep drawing
// rather than go permanently silent.
diff --git a/jarvis/ui/web/frontend/src/components/agentic/AgenticTerminal.tsx b/jarvis/ui/web/frontend/src/components/agentic/AgenticTerminal.tsx
index b0477e39f7..edda84dc4f 100644
--- a/jarvis/ui/web/frontend/src/components/agentic/AgenticTerminal.tsx
+++ b/jarvis/ui/web/frontend/src/components/agentic/AgenticTerminal.tsx
@@ -83,6 +83,7 @@ import {
boxOnScreen,
OffscreenBuffer,
OFFSCREEN_MARGIN_PX,
+ PARKED_RECHECK_MS,
} from "./offscreenBuffer";
import { installQuerySuppression } from "./terminalQueries";
import { PaneScrollbar } from "./PaneScrollbar";
@@ -447,6 +448,8 @@ export function AgenticTerminal({
*/
let paneVisible = true;
const offscreen = new OffscreenBuffer();
+ /** When this pane last measured itself while parked (see `recheckParked`). */
+ let parkedCheckedAt = 0;
const showPane = () => {
if (paneVisible) return;
@@ -455,6 +458,13 @@ export function AgenticTerminal({
if (held) term.write(held);
};
+ const parkPane = () => {
+ paneVisible = false;
+ // The next chunk of output measures immediately rather than waiting out
+ // an interval that started before this pane was even parked.
+ parkedCheckedAt = 0;
+ };
+
/**
* Un-park this pane if it is genuinely on screen — measured, not remembered.
*
@@ -473,10 +483,37 @@ export function AgenticTerminal({
if (boxOnScreen(box, viewport)) showPane();
};
+ /**
+ * A parked pane that is still being talked to, asking the only question
+ * that matters: can the user see me right now?
+ *
+ * The observer answers that for every state it reports. The failure this
+ * guards is the state it does NOT report — and the two known ones
+ * (`visibilitychange`, resize) were found one live incident at a time, so
+ * assuming they are the last two is how the next one costs another
+ * afternoon. The symptom is always identical and always severe: Jarvis
+ * types a prompt into a pane, the agent starts work, and the user watches
+ * an empty rectangle and concludes nothing was sent (reported 2026-07-27,
+ * where the prompt reached the agent 1.4 s BEFORE it was announced and the
+ * pane showed its boot screen for another minute).
+ *
+ * Throttled, because output arrives in frames and a rectangle measurement
+ * forces layout: at most one per {@link PARKED_RECHECK_MS} per parked pane,
+ * and none at all for a parked pane whose agent has gone quiet — nobody
+ * misses a screen that is not changing.
+ */
+ const recheckParked = () => {
+ const now = Date.now();
+ if (now - parkedCheckedAt < PARKED_RECHECK_MS) return;
+ parkedCheckedAt = now;
+ revealIfOnScreen();
+ };
+
// Everything this pane draws goes through here, not just the agent's
// stream: an exit banner written straight to xterm while output is parked
// would appear ABOVE the output it is supposed to follow.
const writeToPane = (text: string) => {
+ if (!paneVisible) recheckParked();
if (paneVisible) {
term.write(text);
return;
@@ -682,7 +719,7 @@ export function AgenticTerminal({
// nothing, so there is no frame budget being defended. The whole
// reason this exists is panes competing for the main thread WHILE the
// user watches another one.
- if (!documentHidden()) paneVisible = false;
+ if (!documentHidden()) parkPane();
},
{ rootMargin: `${OFFSCREEN_MARGIN_PX}px` },
);
diff --git a/jarvis/ui/web/frontend/src/components/agentic/offscreenBuffer.ts b/jarvis/ui/web/frontend/src/components/agentic/offscreenBuffer.ts
index a455b25437..558dccecea 100644
--- a/jarvis/ui/web/frontend/src/components/agentic/offscreenBuffer.ts
+++ b/jarvis/ui/web/frontend/src/components/agentic/offscreenBuffer.ts
@@ -41,6 +41,25 @@
*/
export const OFFSCREEN_LIMIT_CHARS = 256 * 1024;
+/**
+ * How often a parked pane re-measures itself while its agent keeps talking.
+ *
+ * The two moments {@link boxOnScreen} is asked about — the document becoming
+ * visible, the pane being resized — are the ones we KNOW the observer cannot
+ * report its way out of. They are not a proof that no third one exists: the
+ * observer lives in the browser engine, an embedded WebView is not a browser
+ * tab, and every state it fails to report looks identical from here (a pane
+ * holding its agent's screen while the user watches an empty rectangle and is
+ * told the work was handed over).
+ *
+ * So a parked pane that is still RECEIVING output — the only parked pane whose
+ * silence a user can notice — checks for itself, at most this often. It costs
+ * one rectangle measurement per second per parked, chatty pane, and it bounds
+ * every unknown member of this bug class at one second instead of "until the
+ * agent finishes".
+ */
+export const PARKED_RECHECK_MS = 1000;
+
/**
* How far outside the window a pane still counts as worth drawing.
*