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(agentic-ide): show on every screen whether coding mode is on

Ruben Lütke142e5083ab11
diff --git a/jarvis/agentic_ide/session.py b/jarvis/agentic_ide/session.py
index d8b78d068b..1e5ca6fd5c 100644
--- a/jarvis/agentic_ide/session.py
+++ b/jarvis/agentic_ide/session.py
@@ -2308,6 +2308,49 @@ def terminals_added_event(session: Session, created: list[Terminal], *, source_l
)
+def coding_mode_active() -> bool:
+ """Is Jarvis an Agentic IDE right now?
+
+ ONE answer to that question, for every layer that needs it. A workspace has
+ to be open AND its focused coding mode has to be on — either half alone is
+ not the mode: a workspace with the mode off is just terminals on a screen,
+ and the flag without a workspace addresses nothing.
+
+ It exists as a named predicate rather than as an inline
+ ``session is not None and session.focus_mode`` in each caller because the
+ two halves are exactly the kind of rule that drifts: the global indicator,
+ the context block and (in future) the routing gates must agree, and three
+ hand-written copies of a two-part condition are three chances to disagree
+ about whether the user is in coding mode.
+
+ Never raises — an optional surface must not be able to break a caller.
+ """
+ try:
+ session = get_registry().session
+ except Exception: # noqa: BLE001 - optional surface, never fatal
+ return False
+ return session is not None and bool(session.focus_mode)
+
+
+def coding_mode_event(session: Session | None, *, source_layer: str) -> Any:
+ """The bus event announcing the EFFECTIVE coding mode to every client.
+
+ Built here, next to the predicate it reports, so the payload can never claim
+ a mode the predicate would deny. ``session`` is the workspace the switch
+ happened in, or ``None`` when there is none left to be in coding mode.
+ """
+ from jarvis.core.events import AgenticIdeCodingModeChanged
+
+ enabled = session is not None and bool(session.focus_mode)
+ return AgenticIdeCodingModeChanged(
+ session_id=session.id if session is not None else "",
+ enabled=enabled,
+ folder=session.folder if (session is not None and enabled) else "",
+ workspace=session.name if (session is not None and enabled) else "",
+ source_layer=source_layer,
+ )
+
+
_REGISTRY: Registry | None = None
@@ -2337,6 +2380,8 @@ __all__ = [
"SessionNotReady",
"Terminal",
"agent_argv",
+ "coding_mode_active",
+ "coding_mode_event",
"get_registry",
"reset_registry",
"sanitize_prompt",
diff --git a/jarvis/core/events.py b/jarvis/core/events.py
index d60199a277..41d6de0eb7 100644
--- a/jarvis/core/events.py
+++ b/jarvis/core/events.py
@@ -408,6 +408,42 @@ class AgenticIdeTerminalsAdded(Event):
folder: str = ""
+@dataclass(frozen=True, slots=True)
+class AgenticIdeTerminalsClosed(Event):
+ """Panes were closed outside the Agentic-IDE workspace view."""
+
+ session_id: str = ""
+ names: tuple[str, ...] = ()
+ folder: str = ""
+
+
+@dataclass(frozen=True, slots=True)
+class AgenticIdeCodingModeChanged(Event):
+ """The focused coding mode was switched on or off.
+
+ Coding mode is not a property of the workspace view — it changes how Jarvis
+ answers EVERY turn, on every screen. So the one surface that must never be
+ wrong about it is the app shell, and the shell does not mount the workspace
+ view. Without this event the global indicator would only learn about a
+ switch by being on the screen where the switch happened, which is precisely
+ the screen where it is not needed.
+
+ Carries the EFFECTIVE mode, not merely the flag: ``enabled`` is true only
+ when a workspace is actually open AND its focus mode is on — the same
+ predicate the routing side asks. A client must be able to render the badge
+ straight from this payload without re-deriving that rule and drifting away
+ from it.
+
+ ``folder`` and ``workspace`` let a client name the workspace the mode
+ belongs to; both are empty when the mode went off.
+ """
+
+ session_id: str = ""
+ enabled: bool = False
+ folder: str = ""
+ workspace: str = ""
+
+
# ----------------------------------------------------------------------
# UI / Chat
# ----------------------------------------------------------------------
diff --git a/jarvis/ui/web/agentic_ide_routes.py b/jarvis/ui/web/agentic_ide_routes.py
index a60a141c1a..c56ff267c3 100644
--- a/jarvis/ui/web/agentic_ide_routes.py
+++ b/jarvis/ui/web/agentic_ide_routes.py
@@ -69,6 +69,7 @@ from jarvis.agentic_ide.session import (
Terminal,
account_home,
agent_argv,
+ coding_mode_event,
get_registry,
terminals_added_event,
)
@@ -80,6 +81,30 @@ log = logging.getLogger(__name__)
router = APIRouter(prefix="/api/agentic-ide", tags=["agentic-ide"])
+
+async def _announce_coding_mode(request: Request) -> None:
+ """Tell every connected client what the coding mode is NOW.
+
+ Called from each route that can change the answer — the explicit toggle, and
+ the three workspace transitions that change it as a side effect (closing the
+ front workspace, closing a specific one, switching to another). The mode is
+ read back from the registry rather than passed in, so a caller cannot
+ announce a mode that did not happen.
+
+ Best-effort by design: the mode is already set, and no client notification is
+ worth failing a request over (AP-18). A missed event costs a stale badge
+ until the next navigation, never a wrong workspace state.
+ """
+ bus = getattr(request.app.state, "bus", None)
+ if bus is None:
+ return
+ try:
+ await bus.publish(
+ coding_mode_event(get_registry().session, source_layer="agentic_ide_routes")
+ )
+ except Exception as exc: # noqa: BLE001 - notification is not the work
+ log.debug("AgenticIdeCodingModeChanged publish failed: %s", exc)
+
# One system folder window at a time — see ``open_native_picker``.
_native_picker_lock = asyncio.Lock()
@@ -792,7 +817,9 @@ async def get_workspaces() -> WorkspacesResponse:
@router.put("/workspaces/active", summary="Switch to another workspace")
-async def activate_workspace(req: ActivateWorkspaceRequest) -> dict:
+async def activate_workspace(
+ request: Request, req: ActivateWorkspaceRequest
+) -> dict:
"""Bring one workspace to the front, or clear the front entirely.
Nothing starts, stops or restarts: the agents in every open workspace keep
@@ -809,6 +836,9 @@ async def activate_workspace(req: ActivateWorkspaceRequest) -> dict:
session = await get_registry().activate(req.id)
except SessionError as exc:
raise HTTPException(status_code=404, detail=str(exc)) from exc
+ # Each workspace carries its own coding mode, so bringing a different one to
+ # the front can change the answer without anyone touching the toggle.
+ await _announce_coding_mode(request)
return {
"ok": True,
"active_id": session.id if session else None,
@@ -870,7 +900,7 @@ async def start_session(req: StartSessionRequest) -> dict:
summary="Close the Agentic-IDE workspace",
openapi_extra={"x-jarvis-dangerous": True},
)
-async def end_session() -> dict:
+async def end_session(request: Request) -> dict:
"""Close the workspace on screen and stop every agent running in it.
Other open workspaces are untouched; the most recently used of them takes
@@ -878,6 +908,9 @@ async def end_session() -> dict:
one instead of whichever is showing.
"""
closed = await get_registry().end()
+ # Closing the front workspace ends its coding mode — or hands it to whichever
+ # workspace takes the front, which may have a different one.
+ await _announce_coding_mode(request)
return {"ok": True, "closed": closed, "state": get_registry().state()}
@@ -886,7 +919,7 @@ async def end_session() -> dict:
summary="Close one Agentic-IDE workspace",
openapi_extra={"x-jarvis-dangerous": True},
)
-async def close_workspace(workspace_id: str) -> dict:
+async def close_workspace(request: Request, workspace_id: str) -> dict:
"""Close the workspace with this id and stop every agent inside it.
The only action that stops an agent on the user's behalf. Switching away
@@ -900,6 +933,7 @@ async def close_workspace(workspace_id: str) -> dict:
if registry.get(workspace_id) is None:
raise HTTPException(status_code=404, detail="That workspace is not open.")
await registry.end(workspace_id)
+ await _announce_coding_mode(request)
return {"ok": True, "closed": workspace_id, "state": registry.state()}
@@ -1061,18 +1095,26 @@ async def forget_resume_offer() -> dict:
@router.put("/mode", summary="Toggle focused coding mode")
-async def set_mode(req: ModeRequest) -> dict:
+async def set_mode(request: Request, req: ModeRequest) -> dict:
"""Turn the focused coding mode on or off.
While on, Jarvis answers inside the open workspace — it knows the folder,
the codebase, and what each named terminal is doing. Turning it off returns
the assistant to its normal, whole-machine behaviour; the terminals keep
running either way.
+
+ The switch is announced on the bus because coding mode is NOT local to this
+ view: it changes how Jarvis answers on every screen, so the app-wide
+ indicator has to hear about a switch made anywhere — including one made by
+ voice or by the CLI while the user is looking at a different section.
"""
+ registry = get_registry()
try:
- enabled = get_registry().set_focus_mode(req.enabled)
+ enabled = registry.set_focus_mode(req.enabled)
except SessionError as exc:
raise HTTPException(status_code=409, detail=str(exc)) from exc
+
+ await _announce_coding_mode(request)
return {"ok": True, "focus_mode": enabled}
diff --git a/jarvis/ui/web/frontend/src/App.tsx b/jarvis/ui/web/frontend/src/App.tsx
index 58d18d1461..6c6d88ba12 100644
--- a/jarvis/ui/web/frontend/src/App.tsx
+++ b/jarvis/ui/web/frontend/src/App.tsx
@@ -2,6 +2,7 @@ import { useWebSocket } from "@/hooks/useWebSocket";
import { useBrainStatus } from "@/hooks/useBrainStatus";
import { useVoiceStatus } from "@/hooks/useVoiceStatus";
import { useAssistantNameSeed } from "@/hooks/useAssistantNameSeed";
+import { useCodingMode } from "@/hooks/useCodingMode";
import { Sidebar, SIDEBAR_DEFAULT_WIDTH } from "@/components/layout/Sidebar";
import { PaneResizer } from "@/components/layout/PaneResizer";
import { useResizablePane } from "@/hooks/useResizablePane";
@@ -21,6 +22,7 @@ export default function App() {
useBrainStatus();
useVoiceStatus();
useAssistantNameSeed();
+ useCodingMode();
/*
* The sidebar is draggable, app-wide.
diff --git a/jarvis/ui/web/frontend/src/components/layout/CodingModeBadge.test.tsx b/jarvis/ui/web/frontend/src/components/layout/CodingModeBadge.test.tsx
new file mode 100644
index 0000000000..25e765b3f3
--- /dev/null
+++ b/jarvis/ui/web/frontend/src/components/layout/CodingModeBadge.test.tsx
@@ -0,0 +1,71 @@
+import { afterEach, describe, expect, it } from "vitest";
+import { cleanup, fireEvent, render, screen } from "@testing-library/react";
+
+import { CodingModeBadge } from "@/components/layout/CodingModeBadge";
+import { useEventStore } from "@/store/events";
+
+const OFF = { active: false, hasWorkspace: false, workspace: "" };
+
+afterEach(() => {
+ cleanup();
+ useEventStore.setState({ codingMode: OFF, activeSection: "chats" });
+});
+
+describe("CodingModeBadge", () => {
+ it("says nothing when no coding workspace is open", () => {
+ useEventStore.setState({ codingMode: OFF });
+ render(<CodingModeBadge />);
+ // Silence for everyone who never opens the IDE — a permanent "off" chip
+ // would be noise on every screen of the app.
+ expect(screen.queryByTestId("coding-mode-badge")).toBeNull();
+ });
+
+ it("reports the mode on a screen that is not the workspace", () => {
+ useEventStore.setState({
+ codingMode: { active: true, hasWorkspace: true, workspace: "Personal Jarvis" },
+ activeSection: "settings",
+ });
+ render(<CodingModeBadge />);
+ const badge = screen.getByTestId("coding-mode-badge");
+ // The whole point: the assistant behaves differently here, and until this
+ // badge existed nothing on this screen said so.
+ expect(badge.textContent).toMatch(/ON|AN|ACTIVO/);
+ expect(badge.getAttribute("title")).toContain("Personal Jarvis");
+ });
+
+ it("distinguishes 'agents running' from 'Jarvis is in their context'", () => {
+ useEventStore.setState({
+ codingMode: { active: false, hasWorkspace: true, workspace: "" },
+ activeSection: "settings",
+ });
+ render(<CodingModeBadge />);
+ const badge = screen.getByTestId("coding-mode-badge");
+ expect(badge.textContent).toMatch(/OFF|AUS|INACTIVO/);
+ });
+
+ it("navigates to the workspace instead of toggling the mode", () => {
+ useEventStore.setState({
+ codingMode: { active: true, hasWorkspace: true, workspace: "Repo" },
+ activeSection: "settings",
+ });
+ render(<CodingModeBadge />);
+ fireEvent.click(screen.getByTestId("coding-mode-badge"));
+ expect(useEventStore.getState().activeSection).toBe("agentic-ide");
+ // Turning the mode off changes how the assistant answers everywhere; a
+ // one-click chip on an unrelated screen must not be able to do that.
+ expect(useEventStore.getState().codingMode.active).toBe(true);
+ });
+
+ it("never claims a pressed state it cannot deliver", () => {
+ useEventStore.setState({
+ codingMode: { active: true, hasWorkspace: true, workspace: "Repo" },
+ activeSection: "settings",
+ });
+ render(<CodingModeBadge />);
+ // It navigates, it does not toggle — aria-pressed would tell a screen
+ // reader user this button controls the mode.
+ expect(screen.getByTestId("coding-mode-badge").hasAttribute("aria-pressed")).toBe(
+ false,
+ );
+ });
+});
diff --git a/jarvis/ui/web/frontend/src/components/layout/CodingModeBadge.tsx b/jarvis/ui/web/frontend/src/components/layout/CodingModeBadge.tsx
new file mode 100644
index 0000000000..64acc8f74b
--- /dev/null
+++ b/jarvis/ui/web/frontend/src/components/layout/CodingModeBadge.tsx
@@ -0,0 +1,78 @@
+import { Brain } from "lucide-react";
+
+import { useEventStore } from "@/store/events";
+import { useT } from "@/i18n";
+import { cn } from "@/lib/utils";
+
+/**
+ * App-wide indicator: is Jarvis an Agentic IDE right now?
+ *
+ * Focused coding mode is a mode of the ASSISTANT, not of one screen. While it
+ * is on, Jarvis answers inside the open workspace — it reasons about that
+ * repository and drives the coding agents in it — and that is true on the Chats
+ * screen, in Settings, and for anything said out loud. Until now the only place
+ * that said so was the toggle inside the workspace view: the one screen where
+ * the user can already see the terminals. Everywhere else the assistant behaved
+ * differently with nothing on screen to explain why.
+ *
+ * Rendered in the TopBar, which is the only element mounted above every view
+ * (see the note in TopBar.tsx on why the shell and not the per-view header).
+ *
+ * Three states, and the distinction between the last two is the point:
+ * - no workspace open → nothing rendered. Silence for everyone who never
+ * opens the IDE; a permanent "coding mode off" chip would be pure noise.
+ * - workspace open, mode OFF → a quiet chip. Worth showing, because "there
+ * are agents running but Jarvis is NOT in their context" is exactly the
+ * state a user misreads.
+ * - mode ON → the loud chip, matching the toggle it mirrors.
+ *
+ * Clicking opens the Agentic IDE rather than toggling. Turning the mode off is
+ * a change to how the assistant answers everywhere, and doing that from a
+ * one-click chip on an unrelated screen — where the workspace it applies to is
+ * not even visible — is a footgun. The real switch stays next to the panes it
+ * affects; this takes the user there.
+ */
+export function CodingModeBadge() {
+ const t = useT();
+ const mode = useEventStore((s) => s.codingMode);
+ const setActiveSection = useEventStore((s) => s.setActiveSection);
+ const activeSection = useEventStore((s) => s.activeSection);
+
+ if (!mode.hasWorkspace) return null;
+
+ const label = mode.active
+ ? t("topbar.coding_mode_on")
+ : t("topbar.coding_mode_off");
+ const title = mode.active
+ ? (mode.workspace
+ ? t("topbar.coding_mode_on_hint_named").replace("{0}", mode.workspace)
+ : t("topbar.coding_mode_on_hint"))
+ : t("topbar.coding_mode_off_hint");
+
+ return (
+ <button
+ type="button"
+ onClick={() => setActiveSection("agentic-ide")}
+ title={title}
+ aria-label={title}
+ data-testid="coding-mode-badge"
+ // Announce state changes to a screen reader: the mode can flip from
+ // another surface entirely, which is silent for anyone not watching.
+ aria-live="polite"
+ // Not aria-pressed: this button navigates, it does not toggle the mode.
+ // Claiming a pressed state for something it cannot change would be a lie
+ // to exactly the users who depend on it most.
+ disabled={activeSection === "agentic-ide"}
+ className={cn(
+ "mr-auto inline-flex items-center gap-1.5 rounded-md border px-2.5 py-1",
+ "text-xs font-medium transition-colors disabled:cursor-default",
+ mode.active
+ ? "border-primary/60 bg-primary/15 text-primary hover:bg-primary/25"
+ : "border-border bg-secondary/40 text-muted-foreground hover:border-primary/40 hover:text-foreground",
+ )}
+ >
+ <Brain aria-hidden className="h-3.5 w-3.5" />
+ {label}
+ </button>
+ );
+}
diff --git a/jarvis/ui/web/frontend/src/components/layout/TopBar.tsx b/jarvis/ui/web/frontend/src/components/layout/TopBar.tsx
index a4f16a211d..a8843788aa 100644
--- a/jarvis/ui/web/frontend/src/components/layout/TopBar.tsx
+++ b/jarvis/ui/web/frontend/src/components/layout/TopBar.tsx
@@ -5,6 +5,7 @@ import { useEventStore } from "@/store/events";
import { useUpdate } from "@/hooks/useUpdate";
import { useT } from "@/i18n";
import { cn } from "@/lib/utils";
+import { CodingModeBadge } from "@/components/layout/CodingModeBadge";
/**
* Global top bar rendered above every view (see App.tsx). It carries the app-
@@ -124,6 +125,9 @@ export function TopBar() {
return (
<div className="flex h-10 shrink-0 items-center justify-end gap-2 border-b border-border bg-background/70 px-4 backdrop-blur-sm">
+ {/* Status, not an action — carries its own `mr-auto` so it sits at the
+ left end of this right-aligned bar and never crowds the buttons. */}
+ <CodingModeBadge />
<UpdateButton />
<button
type="button"
diff --git a/jarvis/ui/web/frontend/src/hooks/useCodingMode.ts b/jarvis/ui/web/frontend/src/hooks/useCodingMode.ts
new file mode 100644
index 0000000000..b658ca25aa
--- /dev/null
+++ b/jarvis/ui/web/frontend/src/hooks/useCodingMode.ts
@@ -0,0 +1,73 @@
+import { useEffect } from "react";
+
+import { useEventStore } from "@/store/events";
+import { fetchWorkspaces } from "@/lib/agenticIdeApi";
+
+/**
+ * Keeps the app-wide "coding mode" indicator in sync with the backend.
+ *
+ * Why this is shell state and not workspace state: focused coding mode changes
+ * how Jarvis answers EVERY turn — on the Chats screen, in Settings, by voice
+ * from across the room. The one place it was visible until now was the toggle
+ * inside the workspace view, i.e. the single screen where the user can already
+ * see the terminals and does not need telling. Everywhere else the assistant
+ * silently behaved differently with nothing on screen saying so.
+ *
+ * Four update paths, the same defense-in-depth shape as useBrainStatus:
+ * 1. Mount fetch — the initial value after a reload or an app restart.
+ * 2. WS event AgenticIdeCodingModeChanged, relayed by useWebSocket.ts as
+ * `jarvis:agentic-ide-mode`. Covers a switch made by voice or the CLI, and
+ * the workspace transitions that change the mode as a side effect.
+ * 3. `jarvis:agentic-ide-changed` (panes added/closed) — a workspace that
+ * gains or loses panes can also have appeared or gone entirely.
+ * 4. Section navigation — the cheap catch-all. Anything a local view did to
+ * the mode is reconciled the moment the user leaves it, so a missed event
+ * can never outlive the screen it happened on.
+ *
+ * Deliberately NOT polled. The endpoint is in-memory but a global badge is
+ * exactly the kind of surface that quietly turns into a per-second request for
+ * the entire session; every path above is edge-triggered instead.
+ *
+ * `GET /workspaces` is the light endpoint on purpose: it returns tab cards, so
+ * it costs nothing per pane. `GET /state` would recompute every terminal's recap
+ * to render one chip.
+ */
+export function useCodingMode(): void {
+ const setCodingMode = useEventStore((s) => s.setCodingMode);
+ const activeSection = useEventStore((s) => s.activeSection);
+
+ useEffect(() => {
+ let cancelled = false;
+
+ const read = () =>
+ fetchWorkspaces()
+ .then((res) => {
+ if (cancelled) return;
+ const front = res.workspaces.find((w) => w.active);
+ setCodingMode({
+ active: Boolean(front?.focus_mode),
+ hasWorkspace: res.workspaces.length > 0,
+ workspace: front?.focus_mode ? front.name : "",
+ });
+ })
+ .catch(() => {
+ // Backend not up yet, or a transient failure. Leave the last known
+ // value: blanking the badge on a hiccup would report "not in coding
+ // mode", which is a claim about the assistant, not about the fetch.
+ });
+
+ void read();
+
+ const onChanged = () => void read();
+ window.addEventListener("jarvis:agentic-ide-mode", onChanged);
+ window.addEventListener("jarvis:agentic-ide-changed", onChanged);
+
+ return () => {
+ cancelled = true;
+ window.removeEventListener("jarvis:agentic-ide-mode", onChanged);
+ window.removeEventListener("jarvis:agentic-ide-changed", onChanged);
+ };
+ // activeSection is a dependency, not a listener: re-running the effect on
+ // navigation IS path 4.
+ }, [setCodingMode, activeSection]);
+}
diff --git a/jarvis/ui/web/frontend/src/hooks/useWebSocket.ts b/jarvis/ui/web/frontend/src/hooks/useWebSocket.ts
index c2f6769c27..e2816c21d2 100644
--- a/jarvis/ui/web/frontend/src/hooks/useWebSocket.ts
+++ b/jarvis/ui/web/frontend/src/hooks/useWebSocket.ts
@@ -267,6 +267,16 @@ export function useWebSocket(): void {
);
}
+ if (env.event_name === "AgenticIdeCodingModeChanged") {
+ // Coding mode changes how Jarvis answers on EVERY screen, so the
+ // app-wide indicator has to hear about a switch made anywhere — by
+ // voice, by the CLI, or in a workspace view the user is not looking
+ // at. Trigger only; useCodingMode re-reads the authoritative state.
+ window.dispatchEvent(
+ new CustomEvent("jarvis:agentic-ide-mode", { detail: env.payload }),
+ );
+ }
+
// Live interface-language switch (voice / Control API / another client):
// the whole app re-renders in the new language with no reload. push:false
// so receiving the broadcast does not echo a PUT back.
diff --git a/jarvis/ui/web/frontend/src/i18n/locales/de.json b/jarvis/ui/web/frontend/src/i18n/locales/de.json
index ef49a939c6..7f00c6c416 100644
--- a/jarvis/ui/web/frontend/src/i18n/locales/de.json
+++ b/jarvis/ui/web/frontend/src/i18n/locales/de.json
@@ -38,6 +38,11 @@
"dropped": "Zur Unterhaltung hinzugefügt"
},
"topbar": {
+ "coding_mode_on": "Coding-Modus AN",
+ "coding_mode_off": "Coding-Modus AUS",
+ "coding_mode_on_hint": "Der fokussierte Coding-Modus ist an — Jarvis antwortet in deinem offenen Workspace. Klicken, um dorthin zu wechseln.",
+ "coding_mode_on_hint_named": "Der fokussierte Coding-Modus ist an für „{0}“ — Jarvis antwortet in diesem Workspace. Klicken, um dorthin zu wechseln.",
+ "coding_mode_off_hint": "Ein Coding-Workspace ist offen, aber der fokussierte Coding-Modus ist aus — Jarvis antwortet normal. Klicken, um dorthin zu wechseln.",
"restart": "Neu starten",
"restart_confirm": "Wirklich neu starten?",
"restart_hint": "{name} neu starten",
diff --git a/jarvis/ui/web/frontend/src/i18n/locales/en.json b/jarvis/ui/web/frontend/src/i18n/locales/en.json
index 6bdb36fbcb..7a48c621ba 100644
--- a/jarvis/ui/web/frontend/src/i18n/locales/en.json
+++ b/jarvis/ui/web/frontend/src/i18n/locales/en.json
@@ -38,6 +38,11 @@
"dropped": "Added to conversation"
},
"topbar": {
+ "coding_mode_on": "Coding mode ON",
+ "coding_mode_off": "Coding mode OFF",
+ "coding_mode_on_hint": "Focused coding mode is on — Jarvis answers inside your open workspace. Click to go there.",
+ "coding_mode_on_hint_named": "Focused coding mode is on for “{0}” — Jarvis answers inside that workspace. Click to go there.",
+ "coding_mode_off_hint": "A coding workspace is open, but focused coding mode is off — Jarvis answers normally. Click to go there.",
"restart": "Restart",
"restart_confirm": "Confirm restart?",
"restart_hint": "Restart {name}",
diff --git a/jarvis/ui/web/frontend/src/i18n/locales/es.json b/jarvis/ui/web/frontend/src/i18n/locales/es.json
index 1d4d3024db..4473fe4034 100644
--- a/jarvis/ui/web/frontend/src/i18n/locales/es.json
+++ b/jarvis/ui/web/frontend/src/i18n/locales/es.json
@@ -38,6 +38,11 @@
"dropped": "Añadido a la conversación"
},
"topbar": {
+ "coding_mode_on": "Modo programación ACTIVO",
+ "coding_mode_off": "Modo programación INACTIVO",
+ "coding_mode_on_hint": "El modo de programación enfocado está activo: Jarvis responde dentro de tu espacio de trabajo abierto. Haz clic para ir allí.",
+ "coding_mode_on_hint_named": "El modo de programación enfocado está activo para «{0}»: Jarvis responde dentro de ese espacio de trabajo. Haz clic para ir allí.",
+ "coding_mode_off_hint": "Hay un espacio de trabajo abierto, pero el modo de programación enfocado está inactivo: Jarvis responde con normalidad. Haz clic para ir allí.",
"restart": "Reiniciar",
"restart_confirm": "¿Confirmar reinicio?",
"restart_hint": "Reiniciar {name}",
diff --git a/jarvis/ui/web/frontend/src/store/events.ts b/jarvis/ui/web/frontend/src/store/events.ts
index 9adfd4f2b2..34da56f581 100644
--- a/jarvis/ui/web/frontend/src/store/events.ts
+++ b/jarvis/ui/web/frontend/src/store/events.ts
@@ -176,6 +176,27 @@ export interface CliConnectCoach {
statusCommand: string | null; // e.g. "gh auth status" — optional, for a manual recheck
}
+/**
+ * Whether Jarvis is currently an Agentic IDE, for any surface that must say so.
+ *
+ * `active` mirrors the backend predicate `agentic_ide.session.coding_mode_active`
+ * exactly — a workspace is open AND its focused coding mode is on. It is the
+ * whole reason this is one flag and not two booleans a component combines
+ * itself: the assistant behaves differently only when BOTH hold, so a surface
+ * that re-derives the rule can end up telling the user something the assistant
+ * does not agree with.
+ *
+ * `hasWorkspace` is separate because it drives VISIBILITY, not state: with no
+ * workspace open at all there is nothing to report, and a permanent "coding
+ * mode off" chip would be noise for everyone who never opens the IDE.
+ */
+export interface CodingModeState {
+ active: boolean;
+ hasWorkspace: boolean;
+ /** Label of the workspace the mode belongs to; "" when the mode is off. */
+ workspace: string;
+}
+
interface EventStore {
events: EventItem[];
voiceState: VoiceState;
@@ -221,6 +242,11 @@ interface EventStore {
// "claude-opus-4-8"). Seeded from /api/brain/status on mount and refreshed on
// a provider switch. Empty until the first status fetch resolves.
brainModel: string;
+ // Whether Jarvis is currently an Agentic IDE — see CodingModeState. Lives in
+ // the store rather than in the one component that renders it because the mode
+ // changes how the assistant answers on EVERY screen, so any surface may need
+ // to reflect it. Kept in sync by useCodingMode(), called once in App.tsx.
+ codingMode: CodingModeState;
// How the assistant refers to itself (resolved name: derived from the wake
// phrase with its prefix stripped, else the neutral "Assistant" default —
// [persona].name was removed 2026-06-20). Seeded once at app start by
@@ -276,6 +302,7 @@ interface EventStore {
finishThinking: (messageId: string) => void;
setBrainProvider: (p: string) => void;
setBrainModel: (m: string) => void;
+ setCodingMode: (m: CodingModeState) => void;
setAssistantName: (name: string) => void;
setDictating: (b: boolean) => void;
setDictationInterim: (text: string) => void;
@@ -316,6 +343,7 @@ export const useEventStore = create<EventStore>((set, get) => ({
thinkingStartedTs: null,
thinkingTraces: {},
brainProvider: "unknown",
+ codingMode: { active: false, hasWorkspace: false, workspace: "" },
brainModel: "",
assistantName: readCachedAssistantName(),
dictating: false,
@@ -449,6 +477,7 @@ export const useEventStore = create<EventStore>((set, get) => ({
setBrainProvider: (p) => set({ brainProvider: p }),
setBrainModel: (m) => set({ brainModel: m }),
+ setCodingMode: (m) => set({ codingMode: m }),
setAssistantName: (name) => set({ assistantName: name }),
diff --git a/tests/unit/agentic_ide/test_coding_mode.py b/tests/unit/agentic_ide/test_coding_mode.py
new file mode 100644
index 0000000000..4717daa15d
--- /dev/null
+++ b/tests/unit/agentic_ide/test_coding_mode.py
@@ -0,0 +1,118 @@
+"""The one predicate that answers "is Jarvis an Agentic IDE right now?".
+
+Coding mode changes how the assistant answers on EVERY screen, so more than one
+layer has to agree about it: the app-wide indicator, the focus-mode context
+block, and (in future) the routing gates. These tests pin the two halves of the
+rule and the payload that carries it to the UI, because a surface that reports a
+mode the assistant does not actually have is worse than no indicator at all.
+"""
+from __future__ import annotations
+
+from pathlib import Path
+
+import pytest
+
+from jarvis.agentic_ide import session as session_mod
+from jarvis.agentic_ide.session import (
+ Registry,
+ coding_mode_active,
+ coding_mode_event,
+ reset_registry,
+)
+from tests.fakes.fake_pty_manager import FakePtyManager
+
+
[email protected](autouse=True)
+def clean_registry():
+ reset_registry()
+ yield
+ reset_registry()
+
+
+def wired(monkeypatch: pytest.MonkeyPatch) -> Registry:
+ registry = Registry(pty_manager=FakePtyManager())
+ monkeypatch.setattr(session_mod, "agent_argv", lambda name: (f"/usr/bin/{name}",))
+ monkeypatch.setattr(session_mod, "get_registry", lambda: registry)
+ return registry
+
+
+def test_no_workspace_is_not_coding_mode() -> None:
+ """The flag without a workspace addresses nothing."""
+ assert coding_mode_active() is False
+
+
+async def test_workspace_alone_is_not_coding_mode(
+ wired: Registry, tmp_path: Path
+) -> None:
+ """Terminals on a screen are not the mode — the switch has to be on."""
+ await wired.start(str(tmp_path), [{"agent": "claude"}])
+ assert coding_mode_active() is False
+
+
+async def test_both_halves_make_the_mode(wired: Registry, tmp_path: Path) -> None:
+ await wired.start(str(tmp_path), [{"agent": "claude"}])
+ wired.set_focus_mode(True)
+ assert coding_mode_active() is True
+
+
+async def test_leaving_the_mode_turns_the_predicate_off(
+ wired: Registry, tmp_path: Path
+) -> None:
+ await wired.start(str(tmp_path), [{"agent": "claude"}])
+ wired.set_focus_mode(True)
+ wired.set_focus_mode(False)
+ assert coding_mode_active() is False
+
+
+async def test_closing_the_workspace_ends_the_mode(
+ wired: Registry, tmp_path: Path
+) -> None:
+ """The mode cannot outlive the workspace it applies to."""
+ await wired.start(str(tmp_path), [{"agent": "claude"}])
+ wired.set_focus_mode(True)
+ await wired.end()
+ assert coding_mode_active() is False
+
+
+async def test_event_carries_the_effective_mode_not_the_flag(
+ wired: Registry, tmp_path: Path
+) -> None:
+ """The payload a client renders must agree with the predicate."""
+ session = await wired.start(str(tmp_path), [{"agent": "claude"}])
+ wired.set_focus_mode(True)
+
+ on = coding_mode_event(wired.session, source_layer="test")
+ assert on.enabled is True
+ assert on.session_id == session.id
+ assert on.folder == session.folder
+ assert on.workspace == session.name
+
+ wired.set_focus_mode(False)
+ off = coding_mode_event(wired.session, source_layer="test")
+ assert off.enabled is False
+ # Nothing to name when the mode is off — a client must not render a
+ # workspace label next to an "off" badge.
+ assert off.folder == ""
+ assert off.workspace == ""
+
+
+def test_event_survives_having_no_session() -> None:
+ """The close path passes None; it must produce an honest 'off', not a crash."""
+ event = coding_mode_event(None, source_layer="test")
+ assert event.enabled is False
+ assert event.session_id == ""
+
+
+async def test_event_reaches_the_ui_as_a_ws_envelope(
+ wired: Registry, tmp_path: Path
+) -> None:
+ """The frontend keys off `event_name`; a rename would silently kill the badge."""
+ from jarvis.ui.web.schema import event_to_ws_envelope
+
+ await wired.start(str(tmp_path), [{"agent": "claude"}])
+ wired.set_focus_mode(True)
+ envelope = event_to_ws_envelope(coding_mode_event(wired.session, source_layer="t"))
+
+ assert envelope["event_name"] == "AgenticIdeCodingModeChanged"
+ assert envelope["payload"]["enabled"] is True
diff --git a/tests/unit/agentic_ide/test_coding_mode_route.py b/tests/unit/agentic_ide/test_coding_mode_route.py
new file mode 100644
index 0000000000..aec187470a
--- /dev/null
+++ b/tests/unit/agentic_ide/test_coding_mode_route.py
@@ -0,0 +1,163 @@
+"""Coding mode has to be announced, not just stored.
+
+The app-wide indicator lives in the shell, which never mounts the workspace
+view. So every route that can change the answer to "is Jarvis an Agentic IDE
+right now?" must put it on the bus — otherwise the badge is only correct on the
+one screen where the user can already see the terminals, which is the screen it
+was not built for.
+
+Each test here pins one transition that used to be silent.
+"""
+from __future__ import annotations
+
+from pathlib import Path
+
+import pytest
+from fastapi import FastAPI
+from fastapi.testclient import TestClient
+
+from jarvis.agentic_ide import session as session_mod
+from jarvis.agentic_ide.session import Registry, reset_registry
+from tests.fakes.fake_pty_manager import FakePtyManager
+
+
[email protected](autouse=True)
+def clean_registry():
+ reset_registry()
+ yield
+ reset_registry()
+
+
+def registry(monkeypatch: pytest.MonkeyPatch) -> Registry:
+ monkeypatch.setattr(session_mod, "agent_argv", lambda name: (f"/usr/bin/{name}",))
+ reg = Registry(pty_manager=FakePtyManager())
+ monkeypatch.setattr(session_mod, "get_registry", lambda: reg)
+ from jarvis.ui.web import agentic_ide_routes
+
+ monkeypatch.setattr(agentic_ide_routes, "get_registry", lambda: reg)
+ return reg
+
+
+class _RecordingBus:
+ """Collects the coding-mode announcements a real client would receive."""
+
+ def __init__(self) -> None:
+ self.modes: list[dict] = []
+
+ async def publish(self, event: object) -> None:
+ if type(event).__name__ != "AgenticIdeCodingModeChanged":
+ return
+ self.modes.append(
+ {
+ "enabled": event.enabled,
+ "session_id": event.session_id,
+ "workspace": event.workspace,
+ }
+ )
+
+
+def bus() -> _RecordingBus:
+ return _RecordingBus()
+
+
+def client(registry: Registry, bus: _RecordingBus) -> TestClient:
+ from jarvis.ui.web.agentic_ide_routes import router
+
+ app = FastAPI()
+ app.include_router(router)
+ app.state.bus = bus
+ return TestClient(app)
+
+
+async def _workspace(registry: Registry, folder: Path) -> None:
+ await registry.start(str(folder), [{"agent": "claude"}])
+
+
+async def test_toggling_the_mode_announces_it(
+ client: TestClient, registry: Registry, bus: _RecordingBus, tmp_path: Path
+) -> None:
+ await _workspace(registry, tmp_path)
+
+ assert client.put("/api/agentic-ide/mode", json={"enabled": True}).status_code == 200
+
+ assert [m["enabled"] for m in bus.modes] == [True]
+ assert bus.modes[0]["workspace"]
+
+
+async def test_leaving_the_mode_announces_it_too(
+ client: TestClient, registry: Registry, bus: _RecordingBus, tmp_path: Path
+) -> None:
+ """A badge that only ever hears 'on' is worse than none."""
+ await _workspace(registry, tmp_path)
+ client.put("/api/agentic-ide/mode", json={"enabled": True})
+ bus.modes.clear()
+
+ client.put("/api/agentic-ide/mode", json={"enabled": False})
+
+ assert [m["enabled"] for m in bus.modes] == [False]
+
+
+async def test_closing_the_workspace_announces_the_mode_ending(
+ client: TestClient, registry: Registry, bus: _RecordingBus, tmp_path: Path
+) -> None:
+ """Nobody touched the toggle, yet the mode is over — the badge must learn."""
+ await _workspace(registry, tmp_path)
+ client.put("/api/agentic-ide/mode", json={"enabled": True})
+ bus.modes.clear()
+
+ assert client.delete("/api/agentic-ide/session").status_code == 200
+
+ assert bus.modes and bus.modes[-1]["enabled"] is False
+
+
+async def test_switching_workspaces_announces_the_new_mode(
+ client: TestClient, registry: Registry, bus: _RecordingBus, tmp_path: Path
+) -> None:
+ """Each workspace carries its own mode, so the front one decides the badge."""
+ first, second = tmp_path / "a", tmp_path / "b"
+ first.mkdir()
+ second.mkdir()
+ coding = await registry.start(str(first), [{"agent": "claude"}])
+ plain = await registry.start(str(second), [{"agent": "claude"}])
+ client.put("/api/agentic-ide/workspaces/active", json={"id": coding.id})
+ client.put("/api/agentic-ide/mode", json={"enabled": True})
+ bus.modes.clear()
+
+ # Bring the workspace that is NOT in coding mode to the front.
+ client.put("/api/agentic-ide/workspaces/active", json={"id": plain.id})
+
+ assert bus.modes and bus.modes[-1]["enabled"] is False
+
+
+async def test_closing_one_workspace_by_id_announces_the_mode(
+ client: TestClient, registry: Registry, bus: _RecordingBus, tmp_path: Path
+) -> None:
+ await _workspace(registry, tmp_path)
+ assert registry.session is not None
+ workspace_id = registry.session.id
+ client.put("/api/agentic-ide/mode", json={"enabled": True})
+ bus.modes.clear()
+
+ client.delete(f"/api/agentic-ide/workspaces/{workspace_id}")
+
+ assert bus.modes and bus.modes[-1]["enabled"] is False
+
+
+async def test_a_missing_bus_never_breaks_the_toggle(
+ registry: Registry, tmp_path: Path
+) -> None:
+ """Headless hosts and tests have no bus; the mode must still switch."""
+ from jarvis.ui.web.agentic_ide_routes import router
+
+ app = FastAPI()
+ app.include_router(router)
+ bus_less = TestClient(app)
+ await _workspace(registry, tmp_path)
+
+ response = bus_less.put("/api/agentic-ide/mode", json={"enabled": True})
+
+ assert response.status_code == 200
+ assert response.json()["focus_mode"] is True