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.
Python agent-orchestrationai-agentai-coding-assistantclaude-codecoding-agentcomputer-usedesktop-applocal-firstmcppersonal-jarvisvoice-assistantvoice-coding
feat(ui): collapse the nav sidebar to its icon rail by default, with an explicit toggle
rubenluetke10-beep20976c4f0b52
diff --git a/jarvis/plugins/realtime/codex_subscription.py b/jarvis/plugins/realtime/codex_subscription.pyindex 8538cf0373..f75b0f4175 100644--- a/jarvis/plugins/realtime/codex_subscription.py+++ b/jarvis/plugins/realtime/codex_subscription.py@@ -2140,11 +2140,17 @@ class CodexSubscriptionRealtimeProvider:# project is before the user's first word arrives.await session._deliver_context(getattr(cfg, "instructions", ""))await session._deliver_history(getattr(cfg, "history", ()))- # Then the language, so the FIRST reply is already pinned. Without- # this the opening answer came back in whatever the far end chose,- # and only the second turn (the first ``update_session``) was- # corrected — the language indicator disagreeing with the voice.- await session._pin_language(getattr(cfg, "language", ""))+ # Then the language — but ONLY when the user explicitly pinned one+ # (brain.reply_language). At open nobody has spoken yet, so the+ # resolved value is just DEFAULT_LOCALE; hard-pinning it nailed+ # every call's first reply to English no matter what language the+ # user then spoke, and the correction structurally arrived one+ # turn late (the server answers on its own VAD before the first+ # local transcript resolves). Unpinned sessions rely on the base+ # instructions, which tell the model to mirror the language of+ # the latest actual user audio.+ if getattr(cfg, "language_is_pinned", False):+ await session._pin_language(getattr(cfg, "language", ""))return sessionexcept BaseException:try:diff --git a/jarvis/ui/web/frontend/src/App.tsx b/jarvis/ui/web/frontend/src/App.tsxindex f362c2bb4d..447041b04d 100644--- a/jarvis/ui/web/frontend/src/App.tsx+++ b/jarvis/ui/web/frontend/src/App.tsx@@ -1,4 +1,4 @@-import { useEffect } from "react";+import { useCallback, useEffect, useState } from "react";import { useWebSocket } from "@/hooks/useWebSocket";import { useBrainStatus } from "@/hooks/useBrainStatus";@@ -25,6 +25,9 @@ import { OnboardingGate } from "@/components/onboarding/OnboardingGate";import { installDictationFocusTracker } from "@/lib/dictationTarget";import { SubscriptionRealtimeTransportBroker } from "@/components/voice/SubscriptionRealtimeTransportBroker";+/** Where the collapsed/expanded choice for the nav sidebar is remembered. */+const NAV_COLLAPSED_KEY = "jarvis.sidebar.collapsed.v1";+export default function App() {useWebSocket();useBrainStatus();@@ -65,6 +68,55 @@ export default function App() {max: 520,});+ /*+ * The sidebar starts COLLAPSED.+ *+ * Navigation is how you get to the thing, never the thing itself, and the+ * window is at its most useful when the work has the width. The icons stay on+ * screen, each with its label on hover, so nothing becomes unreachable — this+ * is a narrower sidebar, not a hidden one.+ *+ * Persisted separately from the drag width on purpose: expanding restores the+ * column the user sized, not the designed default. A storage read that throws+ * (private-mode WebView, storage disabled) degrades to the collapsed default+ * rather than taking the shell down with it.+ */+ const [navCollapsed, setNavCollapsed] = useState<boolean>(() => {+ try {+ return window.localStorage.getItem(NAV_COLLAPSED_KEY) !== "false";+ } catch {+ return true;+ }+ });+ const toggleNav = useCallback(() => {+ setNavCollapsed((current) => {+ const next = !current;+ try {+ window.localStorage.setItem(NAV_COLLAPSED_KEY, next ? "true" : "false");+ } catch {+ /* storage unavailable — the choice simply does not survive a restart */+ }+ return next;+ });+ }, []);+ // Dragging the seam is itself an "I want the sidebar" gesture: a drag that+ // left the rail state behind would snap straight back to icons and read as a+ // broken handle.+ const startSidebarResize = useCallback(+ (event: React.PointerEvent) => {+ if (navCollapsed) {+ setNavCollapsed(false);+ try {+ window.localStorage.setItem(NAV_COLLAPSED_KEY, "false");+ } catch {+ /* see above */+ }+ }+ sidebar.startResize(event);+ },+ [navCollapsed, sidebar],+ );+return (<div className="relative flex h-screen w-screen overflow-hidden bg-background text-foreground"><SubscriptionRealtimeTransportBroker />@@ -74,11 +126,15 @@ export default function App() {aria-hidden/>- <Sidebar width={sidebar.size} />+ <Sidebar+ width={sidebar.size}+ collapsed={navCollapsed}+ onToggleCollapsed={toggleNav}+ /><PaneResizerorientation="vertical"- onPointerDown={sidebar.startResize}+ onPointerDown={startSidebarResize}onDoubleClick={sidebar.reset}onNudge={sidebar.nudge}active={sidebar.isResizing}diff --git a/jarvis/ui/web/frontend/src/components/layout/Sidebar.test.tsx b/jarvis/ui/web/frontend/src/components/layout/Sidebar.test.tsxindex f5b27d9825..d6b27c1829 100644--- a/jarvis/ui/web/frontend/src/components/layout/Sidebar.test.tsx+++ b/jarvis/ui/web/frontend/src/components/layout/Sidebar.test.tsx@@ -545,3 +545,91 @@ describe("Sidebar icon rail", () => {expect(screen.getByTestId("nav-row-chats")).toBeTruthy();});});++/**+ * The explicit collapse toggle.+ *+ * The rail used to be reachable only by dragging the seam far enough — a+ * gesture nobody discovers, on a seam one pixel wide. The button says the same+ * thing out loud, and it is what the app opens in (see `App.tsx`); the drag+ * stays as the second, finer way in.+ */+describe("Sidebar collapse toggle", () => {+ beforeEach(() => {+ useEventStore.setState({ activeSection: "chats", connected: true });+ });++ afterEach(() => cleanup());++ function renderWithToggle(collapsed: boolean, onToggle = () => {}) {+ const client = new QueryClient({+ defaultOptions: { queries: { retry: false }, mutations: { retry: false } },+ });+ return render(+ <QueryClientProvider client={client}>+ <Sidebar+ width={SIDEBAR_DEFAULT_WIDTH}+ collapsed={collapsed}+ onToggleCollapsed={onToggle}+ />+ </QueryClientProvider>,+ );+ }++ test("collapses to the rail even at a wide dragged width", () => {+ renderWithToggle(true);++ const aside = screen.getByTestId("sidebar");+ // The collapse is a STATE, not a width: the dragged 280 px is remembered+ // for the expand, and the rail wins while collapsed.+ expect(aside.dataset.railed).toBe("true");+ expect(aside.style.width).toBe(`${SIDEBAR_RAIL_WIDTH}px`);+ });++ test("reports its state and names itself in both directions", () => {+ const { rerender } = renderWithToggle(true);++ const collapsedButton = screen.getByTestId("sidebar-collapse-toggle");+ expect(collapsedButton.getAttribute("aria-expanded")).toBe("false");+ // WHAT it says is the locale's business; that it says something is not.+ expect(collapsedButton.getAttribute("aria-label")).toBeTruthy();++ const client = new QueryClient({+ defaultOptions: { queries: { retry: false }, mutations: { retry: false } },+ });+ rerender(+ <QueryClientProvider client={client}>+ <Sidebar+ width={SIDEBAR_DEFAULT_WIDTH}+ collapsed={false}+ onToggleCollapsed={() => {}}+ />+ </QueryClientProvider>,+ );++ expect(+ screen.getByTestId("sidebar-collapse-toggle").getAttribute("aria-expanded"),+ ).toBe("true");+ });++ test("asks the shell to toggle rather than deciding for itself", () => {+ // The width and the collapsed flag live together in the shell — a sidebar+ // that flipped its own state would drift from the seam beside it.+ const onToggle = vi.fn();+ renderWithToggle(true, onToggle);++ act(() => {+ screen.getByTestId("sidebar-collapse-toggle").click();+ });++ expect(onToggle).toHaveBeenCalledTimes(1);+ });++ test("is simply absent when the shell offers no toggle", () => {+ // Standalone renders (tests, any future embedding) must not grow a button+ // that cannot do anything.+ renderSidebar(SIDEBAR_DEFAULT_WIDTH);++ expect(screen.queryByTestId("sidebar-collapse-toggle")).toBeNull();+ });+});diff --git a/jarvis/ui/web/frontend/src/components/layout/Sidebar.tsx b/jarvis/ui/web/frontend/src/components/layout/Sidebar.tsxindex 5b1d820336..e4f0d505af 100644--- a/jarvis/ui/web/frontend/src/components/layout/Sidebar.tsx+++ b/jarvis/ui/web/frontend/src/components/layout/Sidebar.tsx@@ -21,6 +21,8 @@ import {Loader2,type LucideIcon,ChevronRight,+ PanelLeftClose,+ PanelLeftOpen,} from "lucide-react";import { useEventStore, type SectionId } from "@/store/events";import { useVoiceReadiness } from "@/hooks/useVoiceReadiness";@@ -180,6 +182,18 @@ export interface SidebarProps {* one-offs) at its designed width.*/width?: number;+ /**+ * Is the sidebar deliberately collapsed to its icon rail?+ *+ * Separate from `width` because the two answer different questions. The width+ * is a drag preference and survives a collapse — expanding restores the+ * column the user sized, not the designed default. Collapsing is a STATE, and+ * the app opens in it: the sidebar is navigation, and navigation is not what+ * the window is for. Left optional so the sidebar still renders standalone.+ */+ collapsed?: boolean;+ /** Toggle `collapsed`. Absent = the toggle button is not offered. */+ onToggleCollapsed?: () => void;}/** Width the sidebar was designed at, and the one a double-click restores. */@@ -205,7 +219,11 @@ export const SIDEBAR_RAIL_WIDTH = 64;*/export const SIDEBAR_RAIL_AT_WIDTH = 168;-export function Sidebar({ width = SIDEBAR_DEFAULT_WIDTH }: SidebarProps = {}) {+export function Sidebar({+ width = SIDEBAR_DEFAULT_WIDTH,+ collapsed = false,+ onToggleCollapsed,+}: SidebarProps = {}) {const t = useT();const active = useEventStore((s) => s.activeSection);const setActive = useEventStore((s) => s.setActiveSection);@@ -307,7 +325,10 @@ export function Sidebar({ width = SIDEBAR_DEFAULT_WIDTH }: SidebarProps = {}) {// realtime control, the brain card's provider and model — steps aside; the// navigation itself never does, because losing it would make the rail a dead// end rather than a narrow sidebar.- const railed = width < SIDEBAR_RAIL_AT_WIDTH;+ // Two independent ways into the rail: the explicit toggle, and dragging the+ // seam past the snap point. Either one alone is enough — a user who dragged+ // the column narrow gets icons without having to also find the button.+ const railed = collapsed || width < SIDEBAR_RAIL_AT_WIDTH;return (// No right border: the draggable seam beside it draws that line now, and@@ -406,6 +427,28 @@ export function Sidebar({ width = SIDEBAR_DEFAULT_WIDTH }: SidebarProps = {}) {aria-hidden/>)}+ {onToggleCollapsed && (+ <button+ type="button"+ data-testid="sidebar-collapse-toggle"+ onClick={onToggleCollapsed}+ aria-expanded={!railed}+ title={railed ? t("sidebar.expand") : t("sidebar.collapse")}+ aria-label={railed ? t("sidebar.expand") : t("sidebar.collapse")}+ className={cn(+ "flex shrink-0 items-center justify-center rounded-md text-muted-foreground",+ "transition-colors hover:bg-accent/60 hover:text-foreground",+ "focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",+ railed ? "h-7 w-7" : "-mr-1 h-7 w-7",+ )}+ >+ {railed ? (+ <PanelLeftOpen className="h-4 w-4" aria-hidden />+ ) : (+ <PanelLeftClose className="h-4 w-4" aria-hidden />+ )}+ </button>+ )}</div>{!railed && (<>diff --git a/jarvis/ui/web/frontend/src/i18n/locales/de.json b/jarvis/ui/web/frontend/src/i18n/locales/de.jsonindex 7e33c222c3..7d2dd90b2f 100644--- a/jarvis/ui/web/frontend/src/i18n/locales/de.json+++ b/jarvis/ui/web/frontend/src/i18n/locales/de.json@@ -394,6 +394,8 @@"indicator_label": "Sprachstatus"},"sidebar": {+ "collapse": "Navigation einklappen",+ "expand": "Navigation ausklappen","wake_hint": "Sag dein Wake-Word…","brain_label": "Brain","brain_tooltip": "Brain-Provider wechseln",@@ -1602,14 +1604,15 @@},"overlay_style": {"title": "Anzeige-Stil",- "description": "Wähle, wie {name} bei Sprachaktivität auf dem Bildschirm erscheint. Die Bar ist der schlanke Standard; das Maskottchen ist der klassische Orb; oder ganz ausblenden.",+ "description": "Wähle, wie {name} bei Sprachaktivität auf dem Bildschirm erscheint. Die Bar ist der schlanke Standard; das Maskottchen ist der klassische Begleiter; der Voice-Orb ist eine leuchtende Kugel; oder ganz ausblenden. Jeder schwebende Stil lässt sich auf jeden Monitor ziehen.","label": "Stil","save": "Speichern","saved": "Anzeige-Stil gewechselt.","restart_required": "Gespeichert — {name} neu starten zum Übernehmen.","options": {"jarvis_bar": "Bar (Standard)",- "mascot": "Maskottchen-Orb",+ "mascot": "Maskottchen",+ "voice_orb": "Voice-Orb","none": "Keins (ausgeblendet)"}},@@ -2118,12 +2121,14 @@"recommended": "Empfohlen","options": {"jarvis_bar": "Jarvis-Leiste",- "mascot": "Orb",+ "mascot": "Maskottchen",+ "voice_orb": "Voice-Orb","none": "Kein Overlay"},"captions": {"jarvis_bar": "Eine schmale schwebende Sprachleiste, immer griffbereit.",- "mascot": "Ein schwebender Begleiter-Orb, der auf deine Stimme reagiert.",+ "mascot": "Ein schwebender Begleiter, der auf deine Stimme reagiert.",+ "voice_orb": "Eine leuchtende Kugel aus ziehendem Licht — auf jeden Bildschirm ziehbar.","none": "Nur das App-Fenster — kein schwebendes Element auf dem Bildschirm."},"needs_restart": "Fast geschafft — dieser Stil wird nach einem kurzen Neustart aktiv.",diff --git a/jarvis/ui/web/frontend/src/i18n/locales/en.json b/jarvis/ui/web/frontend/src/i18n/locales/en.jsonindex 5099ea5bab..f900b2d4e8 100644--- a/jarvis/ui/web/frontend/src/i18n/locales/en.json+++ b/jarvis/ui/web/frontend/src/i18n/locales/en.json@@ -394,6 +394,8 @@"indicator_label": "Voice state"},"sidebar": {+ "collapse": "Collapse the navigation",+ "expand": "Expand the navigation","wake_hint": "Say your wake word…","brain_label": "Brain","brain_tooltip": "Switch brain provider",@@ -1602,14 +1604,15 @@},"overlay_style": {"title": "Display style",- "description": "Choose how {name} appears on screen during voice activity. The bar is the slim default; the mascot is the classic orb; or hide it entirely.",+ "description": "Choose how {name} appears on screen during voice activity. The bar is the slim default; the mascot is the classic companion; the voice orb is a glowing sphere; or hide it entirely. Every floating style can be dragged to any monitor.","label": "Style","save": "Save","saved": "Display style switched.","restart_required": "Saved — restart {name} to apply.","options": {"jarvis_bar": "Bar (default)",- "mascot": "Mascot orb",+ "mascot": "Mascot",+ "voice_orb": "Voice orb","none": "None (hidden)"}},@@ -2118,12 +2121,14 @@"recommended": "Recommended","options": {"jarvis_bar": "Jarvis Bar",- "mascot": "Orb",+ "mascot": "Mascot",+ "voice_orb": "Voice orb","none": "No overlay"},"captions": {"jarvis_bar": "A slim floating voice bar, always within reach.",- "mascot": "A floating companion orb that reacts as you talk.",+ "mascot": "A floating companion that reacts as you talk.",+ "voice_orb": "A glowing sphere of drifting light — drag it to any screen.","none": "Just the app window — no floating surface on screen."},"needs_restart": "Almost there — this style needs a quick restart to take effect.",diff --git a/jarvis/ui/web/frontend/src/i18n/locales/es.json b/jarvis/ui/web/frontend/src/i18n/locales/es.jsonindex 3a69d43b9b..81c0c22dd0 100644--- a/jarvis/ui/web/frontend/src/i18n/locales/es.json+++ b/jarvis/ui/web/frontend/src/i18n/locales/es.json@@ -394,6 +394,8 @@"indicator_label": "Estado de voz"},"sidebar": {+ "collapse": "Contraer la navegación",+ "expand": "Expandir la navegación","wake_hint": "Di tu palabra de activación…","brain_label": "Cerebro","brain_tooltip": "Cambiar proveedor de IA",@@ -1602,14 +1604,15 @@},"overlay_style": {"title": "Estilo de visualización",- "description": "Elige cómo aparece {name} en pantalla durante la actividad de voz. La barra es el valor predeterminado; el mascota es el orbe clásico; o ocúltalo por completo.",+ "description": "Elige cómo aparece {name} en pantalla durante la actividad de voz. La barra es el valor predeterminado; la mascota es el acompañante clásico; el orbe de voz es una esfera luminosa; o ocúltalo por completo. Cualquier estilo flotante se puede arrastrar a cualquier monitor.","label": "Estilo","save": "Guardar","saved": "Estilo de visualización cambiado.","restart_required": "Guardado: reinicia {name} para aplicar.","options": {"jarvis_bar": "Barra (predeterminado)",- "mascot": "Orbe mascota",+ "mascot": "Mascota",+ "voice_orb": "Orbe de voz","none": "Ninguno (oculto)"}},@@ -2118,12 +2121,14 @@"recommended": "Recomendado","options": {"jarvis_bar": "Barra de Jarvis",- "mascot": "Orbe",+ "mascot": "Mascota",+ "voice_orb": "Orbe de voz","none": "Sin superposición"},"captions": {"jarvis_bar": "Una barra de voz flotante y delgada, siempre a mano.",- "mascot": "Un orbe acompañante flotante que reacciona cuando hablas.",+ "mascot": "Un acompañante flotante que reacciona cuando hablas.",+ "voice_orb": "Una esfera luminosa de luz en movimiento — arrástrala a cualquier pantalla.","none": "Solo la ventana de la app — sin elementos flotantes en pantalla."},"needs_restart": "Casi listo — este estilo se aplica tras un breve reinicio.",diff --git a/tests/unit/realtime/test_codex_subscription.py b/tests/unit/realtime/test_codex_subscription.pyindex b169dbbd1c..f19e0525d8 100644--- a/tests/unit/realtime/test_codex_subscription.py+++ b/tests/unit/realtime/test_codex_subscription.py@@ -274,16 +274,13 @@ async def test_direct_sdp_open_uses_safe_experimental_transport_contract() -> Noassert "persona" in base# Jarvis's own persona/context reaches the model as developer context —- # ChatGPT-Live has no client-settable session-instructions field.- # Persona first, then the resolved output language: the FIRST reply has to- # be pinned too, not just every reply after the first ``update_session``.+ # ChatGPT-Live has no client-settable session-instructions field. With no+ # explicit reply-language preference there is NO opening pin: nobody has+ # spoken yet, so the "resolved" language is only DEFAULT_LOCALE, and+ # hard-pinning it nailed every call's first reply to English. The base+ # instructions tell the model to mirror the latest actual user audio.assert client.text_appends == [("thread-1", "Speak concise English.", "developer"),- (- "thread-1",- codex_subscription_mod._language_pin_text("en"),- "developer",- ),]_thread_id, start = client.realtime_starts[0]assert start == {@@ -321,8 +318,9 @@ async def test_reopened_session_restores_bounded_same_call_history() -> None:))- # Persona, then the restored history, then the resolved language pin.- assert len(client.text_appends) == 3+ # Persona, then the restored history. No opening language pin: this+ # session carries no explicit reply-language preference.+ assert len(client.text_appends) == 2thread_id, restored, role = client.text_appends[1]assert thread_id == "thread-1"assert role == "developer"@@ -412,20 +410,37 @@ async def test_language_update_is_developer_context_and_speech_is_authoritative(await session.send_speech("Trusted answer")assert client.text_appends == [- # Pinned once when the session opened...+ # No opening pin without an explicit reply-language preference — the+ # first pin is the one this turn actually resolved to.("thread-1",- codex_subscription_mod._language_pin_text("en"),+ codex_subscription_mod._language_pin_text("es"),"developer",),- # ...and again for the language this turn resolved to.+ ]+ assert client.speech_appends == [("thread-1", "Trusted answer")]+ await session.close()+++async def test_open_pins_language_only_for_an_explicit_reply_language() -> None:+ """brain.reply_language = de must pin the FIRST reply, auto must not."""+ client = _Client()+ session = await _provider(client).open_session(+ RealtimeSessionConfig(+ transport_offer_sdp="v=0\r\no=offer",+ language="de",+ language_is_pinned=True,+ )+ )++ assert client.text_appends == [("thread-1",- codex_subscription_mod._language_pin_text("es"),+ codex_subscription_mod._language_pin_text("de"),"developer",),]- assert client.speech_appends == [("thread-1", "Trusted answer")]await session.close()@@ -438,7 +453,11 @@ async def test_same_language_is_reasserted_at_every_local_turn_boundary() -> Non"""client = _Client()session = await _provider(client).open_session(- RealtimeSessionConfig(language="de", transport_offer_sdp="v=0\r\no=offer")+ RealtimeSessionConfig(+ language="de",+ language_is_pinned=True,+ transport_offer_sdp="v=0\r\no=offer",+ ))await session.update_session(language="de")@@ -2333,6 +2352,7 @@ async def test_context_and_history_writes_never_authorize_a_response() -> None:RealtimeSessionConfig(instructions="You are Nova, the user's own assistant.",history=({"role": "user", "text": "Earlier question"},),+ language_is_pinned=True,))