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.

feat(ui): detach button, single-IDE exclusivity, detached placeholder

rubenluetke10-beepebe774ca4f91
diff --git a/jarvis/ui/web/frontend/src/App.tsx b/jarvis/ui/web/frontend/src/App.tsx
index 0314ea8b50..4ecc6292bd 100644
--- a/jarvis/ui/web/frontend/src/App.tsx
+++ b/jarvis/ui/web/frontend/src/App.tsx
@@ -1,6 +1,6 @@
import { useCallback, useEffect, useState } from "react";
-import { useEventStore } from "@/store/events";
+import { isSectionId, useEventStore } from "@/store/events";
import { useWebSocket } from "@/hooks/useWebSocket";
import { useBrainStatus } from "@/hooks/useBrainStatus";
import { useVoiceStatus } from "@/hooks/useVoiceStatus";
@@ -60,6 +60,31 @@ export default function App() {
*/
useEffect(() => installDictationFocusTracker(), []);
+ /*
+ * Resync the detached-window registry once per document. The WS events keep
+ * it live afterwards; this fetch covers the window that (re)loaded after the
+ * events fired — preload recovery reloads every window after a frontend
+ * rebuild, and a fresh solo window mounts long after its own "opened" event.
+ */
+ useEffect(() => {
+ let cancelled = false;
+ void fetch("/api/window/detached")
+ .then(async (res) => {
+ if (!res.ok) return;
+ const data = (await res.json().catch(() => null)) as {
+ views?: unknown[];
+ } | null;
+ if (cancelled || !Array.isArray(data?.views)) return;
+ useEventStore.getState().setDetachedViews(data.views.filter(isSectionId));
+ })
+ .catch(() => {
+ /* headless or warming backend — the WS events will catch us up */
+ });
+ return () => {
+ cancelled = true;
+ };
+ }, []);
+
/*
* The sidebar is draggable, app-wide.
*
diff --git a/jarvis/ui/web/frontend/src/components/layout/DetachedViewPlaceholder.tsx b/jarvis/ui/web/frontend/src/components/layout/DetachedViewPlaceholder.tsx
new file mode 100644
index 0000000000..08a7aee498
--- /dev/null
+++ b/jarvis/ui/web/frontend/src/components/layout/DetachedViewPlaceholder.tsx
@@ -0,0 +1,77 @@
+import { useState } from "react";
+import { AppWindow } from "lucide-react";
+
+import { useT } from "@/i18n";
+import type { SectionId } from "@/store/events";
+
+/**
+ * What a section shows in the MAIN window while it lives in its own detached
+ * desktop window.
+ *
+ * The Agentic IDE must genuinely unmount here — a second mounted instance
+ * steals every pane's output stream (see MainView) — so the section cannot
+ * simply keep rendering. Instead of an empty screen, this explains where the
+ * view went and offers the two useful moves: focus the detached window
+ * (an idempotent re-detach — the backend focuses the existing window) or
+ * close it so the section returns to this window (the close travels through
+ * the same pywebview closed-hook as the window's own X).
+ */
+export function DetachedViewPlaceholder({ view }: { view: SectionId }) {
+ const t = useT();
+ const [busy, setBusy] = useState(false);
+
+ async function post(path: string) {
+ if (busy) return;
+ setBusy(true);
+ try {
+ await fetch(path, {
+ method: "POST",
+ headers: { "Content-Type": "application/json" },
+ body: JSON.stringify({ view }),
+ });
+ // No local state flip: the DetachedViewClosed WS event is the single
+ // source of truth for the remount, same as a manual window close.
+ } catch {
+ /* backend unreachable — the buttons stay, the user can retry */
+ } finally {
+ setBusy(false);
+ }
+ }
+
+ return (
+ <div
+ className="flex h-full w-full flex-col items-center justify-center gap-4 text-center"
+ data-testid="detached-view-placeholder"
+ >
+ <AppWindow aria-hidden className="h-10 w-10 text-muted-foreground/60" />
+ <div className="max-w-sm space-y-1">
+ <div className="text-sm font-medium text-foreground">
+ {t("topbar.detached_title")}
+ </div>
+ <div className="text-xs text-muted-foreground">
+ {t("topbar.detached_body")}
+ </div>
+ </div>
+ <div className="flex items-center gap-2">
+ <button
+ type="button"
+ disabled={busy}
+ onClick={() => void post("/api/window/detach")}
+ data-testid="detached-focus-button"
+ className="inline-flex items-center gap-1.5 rounded-md border border-border bg-secondary/40 px-3 py-1.5 text-xs font-medium text-muted-foreground transition-colors hover:border-primary/50 hover:text-foreground disabled:cursor-default disabled:opacity-70"
+ >
+ {t("topbar.detach_focus")}
+ </button>
+ <button
+ type="button"
+ disabled={busy}
+ onClick={() => void post("/api/window/reattach")}
+ data-testid="detached-reattach-button"
+ className="inline-flex items-center gap-1.5 rounded-md border border-primary/50 bg-primary/10 px-3 py-1.5 text-xs font-medium text-primary transition-colors hover:bg-primary/20 disabled:cursor-default disabled:opacity-70"
+ >
+ {t("topbar.detach_bring_back")}
+ </button>
+ </div>
+ </div>
+ );
+}
diff --git a/jarvis/ui/web/frontend/src/components/layout/MainView.tsx b/jarvis/ui/web/frontend/src/components/layout/MainView.tsx
index 3f3a338fde..88c2bc6956 100644
--- a/jarvis/ui/web/frontend/src/components/layout/MainView.tsx
+++ b/jarvis/ui/web/frontend/src/components/layout/MainView.tsx
@@ -9,6 +9,7 @@ import {
import { useEventStore } from "@/store/events";
import { cn } from "@/lib/utils";
import { ViewErrorBoundary } from "@/components/ViewErrorBoundary";
+import { DetachedViewPlaceholder } from "@/components/layout/DetachedViewPlaceholder";
// Type-only, so the section's chunk stays split out of the entry bundle.
import type { AgenticIdeViewProps } from "@/views/AgenticIdeView";
// The default section is the one view that must be on screen the moment React
@@ -267,14 +268,38 @@ const STICKY_SECTION = "agentic-ide";
export function MainView() {
const active = useEventStore((s) => s.activeSection);
const setActive = useEventStore((s) => s.setActiveSection);
+ const solo = useEventStore((s) => s.solo);
+ const detachedViews = useEventStore((s) => s.detachedViews);
useIdleViewPrefetch();
- const stickyActive = (CODING_SECTION_IDS as readonly string[]).includes(active);
+ /*
+ * While a coding view lives in a detached solo window, THIS (non-solo)
+ * window must not keep a mounted IDE instance around — not even hidden: the
+ * detached window's panes claim the PTY streams, and a second connected
+ * instance steals every pane's output (the exact defect the sticky-mount
+ * comment below warns about). The solo window itself is exempt — it IS the
+ * detached instance the registry entry refers to.
+ */
+ const codingDetached =
+ !solo &&
+ detachedViews.some((v) => (CODING_SECTION_IDS as readonly string[]).includes(v));
+
+ const stickyActive =
+ (CODING_SECTION_IDS as readonly string[]).includes(active) && !codingDetached;
const [stickyMounted, setStickyMounted] = useState(stickyActive);
useEffect(() => {
if (stickyActive) setStickyMounted(true);
}, [stickyActive]);
+ useEffect(() => {
+ // Genuine unmount on detach — and remount happens through the normal
+ // sticky path once DetachedViewClosed clears the registry.
+ if (codingDetached) setStickyMounted(false);
+ }, [codingDetached]);
+
+ if (codingDetached && (CODING_SECTION_IDS as readonly string[]).includes(active)) {
+ return <DetachedViewPlaceholder view={active} />;
+ }
return (
<>
diff --git a/jarvis/ui/web/frontend/src/components/layout/TopBar.tsx b/jarvis/ui/web/frontend/src/components/layout/TopBar.tsx
index 15c42d7311..d521bb096f 100644
--- a/jarvis/ui/web/frontend/src/components/layout/TopBar.tsx
+++ b/jarvis/ui/web/frontend/src/components/layout/TopBar.tsx
@@ -1,11 +1,13 @@
import { useCallback, useEffect, useRef, useState } from "react";
-import { Download, RotateCw } from "lucide-react";
+import { AppWindow, Download, RotateCw } from "lucide-react";
-import { useEventStore } from "@/store/events";
+import { useEventStore, type SectionId } from "@/store/events";
import { useUpdate } from "@/hooks/useUpdate";
import { useT } from "@/i18n";
import { cn } from "@/lib/utils";
import { CodingModeBadge } from "@/components/layout/CodingModeBadge";
+import { hasEmbeddedDesktopBridge } from "@/components/voice/BrowserRealtimeControl";
+import { openExternalUrl } from "@/lib/openExternal";
/**
* Global top bar rendered above every view (see App.tsx). It carries the app-
@@ -72,12 +74,93 @@ export function TopBar() {
export function TopBarActions() {
return (
<>
+ <DetachButton />
<UpdateButton />
<RestartButton />
</>
);
}
+/**
+ * The views the desktop shell can split off into their own solo window.
+ * Mirrors the backend ``DETACHABLE_VIEWS`` registry (jarvis/ui/desktop_app.py)
+ * — the server validates again, this set only decides where the button shows.
+ */
+const DETACHABLE_SECTIONS = new Set<SectionId>([
+ "agentic-ide",
+ "agentic-ide-classic",
+ "chat-workspace",
+ "chats",
+]);
+
+/**
+ * "Open this view in its own window" — the detach entry point.
+ *
+ * Bridge-first like `openExternalUrl`: inside the embedded desktop shell the
+ * backend spawns a real second pywebview window (WebView2 silently drops
+ * `window.open`, so the frontend cannot do it itself); in a plain browser the
+ * solo URL simply opens as a new tab. A shell whose webview backend cannot
+ * create runtime windows answers `ok: false` with a fallback URL and the view
+ * opens in the user's real browser instead — honest on every host. Idempotent:
+ * re-clicking while detached focuses the existing window.
+ */
+function DetachButton() {
+ const t = useT();
+ const activeSection = useEventStore((s) => s.activeSection);
+ const solo = useEventStore((s) => s.solo);
+ const pushToast = useEventStore((s) => s.pushToast);
+ const [busy, setBusy] = useState(false);
+
+ // A solo window never detaches further, and most sections have no solo mode.
+ if (solo || !DETACHABLE_SECTIONS.has(activeSection)) return null;
+
+ async function onClick() {
+ if (busy) return;
+ const view = activeSection;
+ const soloPath = `/?view=${view}&solo=1`;
+ if (!hasEmbeddedDesktopBridge()) {
+ // A real browser: a tab of this same browser IS the detached window.
+ window.open(soloPath, "_blank", "noopener,noreferrer");
+ return;
+ }
+ setBusy(true);
+ try {
+ const res = await fetch("/api/window/detach", {
+ method: "POST",
+ headers: { "Content-Type": "application/json" },
+ body: JSON.stringify({ view }),
+ });
+ const data = (await res.json().catch(() => null)) as {
+ ok?: boolean;
+ fallback_url?: string;
+ } | null;
+ if (data?.ok) return;
+ // The shell could not create a runtime window — open a browser tab.
+ await openExternalUrl(
+ `${window.location.origin}${data?.fallback_url ?? soloPath}`,
+ );
+ } catch {
+ pushToast("error", t("topbar.detach_failed"));
+ } finally {
+ setBusy(false);
+ }
+ }
+
+ return (
+ <button
+ type="button"
+ onClick={() => void onClick()}
+ disabled={busy}
+ title={t("topbar.detach_hint")}
+ data-testid="detach-view-button"
+ className="inline-flex shrink-0 items-center gap-1.5 rounded-md border border-border bg-secondary/40 px-2.5 py-1 text-xs font-medium text-muted-foreground transition-colors hover:border-primary/50 hover:text-foreground disabled:cursor-default disabled:opacity-70"
+ >
+ <AppWindow aria-hidden className="h-3.5 w-3.5" />
+ {t("topbar.detach")}
+ </button>
+ );
+}
+
function RestartButton() {
const t = useT();
const pushToast = useEventStore((s) => s.pushToast);
diff --git a/jarvis/ui/web/frontend/src/hooks/useWebSocket.ts b/jarvis/ui/web/frontend/src/hooks/useWebSocket.ts
index bf3c59fc38..93ea89ea53 100644
--- a/jarvis/ui/web/frontend/src/hooks/useWebSocket.ts
+++ b/jarvis/ui/web/frontend/src/hooks/useWebSocket.ts
@@ -341,6 +341,27 @@ export function useWebSocket(): void {
}
}
+ if (
+ env.event_name === "DetachedViewOpened" ||
+ env.event_name === "DetachedViewClosed"
+ ) {
+ // Mirror the desktop shell's detached-window registry into EVERY
+ // window: the origin unmounts its copy of a detached section (one
+ // mounted Agentic IDE max — a second instance steals the pane
+ // streams) and remounts when the detached window closes.
+ const p = env.payload as { view?: string };
+ if (isSectionId(p.view)) {
+ const state = useEventStore.getState();
+ const next =
+ env.event_name === "DetachedViewOpened"
+ ? state.detachedViews.includes(p.view)
+ ? state.detachedViews
+ : [...state.detachedViews, p.view]
+ : state.detachedViews.filter((v) => v !== p.view);
+ if (next !== state.detachedViews) state.setDetachedViews(next);
+ }
+ }
+
if (env.event_name === "BrainProviderSwitched") {
const p = env.payload as { to_provider?: string; from_provider?: string };
if (typeof p.to_provider === "string") {
diff --git a/jarvis/ui/web/frontend/src/i18n/locales/de.json b/jarvis/ui/web/frontend/src/i18n/locales/de.json
index 53d88f31fe..a7db278475 100644
--- a/jarvis/ui/web/frontend/src/i18n/locales/de.json
+++ b/jarvis/ui/web/frontend/src/i18n/locales/de.json
@@ -59,7 +59,14 @@
"update_finish_restart": "Update abschließen",
"update_staged_restart_failed": "Update heruntergeladen — starte {name} neu, um die Installation abzuschließen",
"update_rolled_back": "Das letzte Update konnte nicht installiert werden — {name} wurde auf die vorherige Version zurückgesetzt",
- "update_network_error": "Netzwerkfehler"
+ "update_network_error": "Netzwerkfehler",
+ "detach": "Eigenes Fenster",
+ "detach_hint": "Diese Ansicht in einem eigenen Fenster öffnen",
+ "detach_failed": "Eigenes Fenster konnte nicht geöffnet werden",
+ "detached_title": "Diese Ansicht ist in einem eigenen Fenster geöffnet",
+ "detached_body": "Arbeite dort weiter oder hole sie hierher zurück.",
+ "detach_focus": "Fenster zeigen",
+ "detach_bring_back": "Zurückholen"
},
"nav": {
"chat_workspace": "Chat",
diff --git a/jarvis/ui/web/frontend/src/i18n/locales/en.json b/jarvis/ui/web/frontend/src/i18n/locales/en.json
index 2ffe38a6d5..320cbfe89e 100644
--- a/jarvis/ui/web/frontend/src/i18n/locales/en.json
+++ b/jarvis/ui/web/frontend/src/i18n/locales/en.json
@@ -59,7 +59,14 @@
"update_finish_restart": "Finish update",
"update_staged_restart_failed": "Update downloaded — restart {name} to finish installing it",
"update_rolled_back": "The last update could not be installed — {name} was rolled back to the previous version",
- "update_network_error": "network error"
+ "update_network_error": "network error",
+ "detach": "Own window",
+ "detach_hint": "Open this view in its own window",
+ "detach_failed": "Could not open a separate window",
+ "detached_title": "This view is open in its own window",
+ "detached_body": "Keep working there, or bring it back into this window.",
+ "detach_focus": "Show window",
+ "detach_bring_back": "Bring it back"
},
"nav": {
"chat_workspace": "Chat",
diff --git a/jarvis/ui/web/frontend/src/i18n/locales/es.json b/jarvis/ui/web/frontend/src/i18n/locales/es.json
index 3678b445f7..2566772633 100644
--- a/jarvis/ui/web/frontend/src/i18n/locales/es.json
+++ b/jarvis/ui/web/frontend/src/i18n/locales/es.json
@@ -59,7 +59,14 @@
"update_finish_restart": "Finalizar actualización",
"update_staged_restart_failed": "Actualización descargada — reinicia {name} para terminar la instalación",
"update_rolled_back": "La última actualización no se pudo instalar — {name} volvió a la versión anterior",
- "update_network_error": "error de red"
+ "update_network_error": "error de red",
+ "detach": "Ventana propia",
+ "detach_hint": "Abrir esta vista en su propia ventana",
+ "detach_failed": "No se pudo abrir una ventana separada",
+ "detached_title": "Esta vista está abierta en su propia ventana",
+ "detached_body": "Sigue trabajando allí o tráela de vuelta aquí.",
+ "detach_focus": "Mostrar ventana",
+ "detach_bring_back": "Traer de vuelta"
},
"nav": {
"chat_workspace": "Chat",