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
fix(agentic-ide): keep recents user-selected
Ruben Lütke843a4f8ddeb2
diff --git a/jarvis/agentic_ide/session.py b/jarvis/agentic_ide/session.pyindex 02f69fdbab..75ba29cae5 100644--- a/jarvis/agentic_ide/session.py+++ b/jarvis/agentic_ide/session.py@@ -420,22 +420,6 @@ class Registry:file_index.prime_index(str(root))except Exception as exc: # noqa: BLE001 - the index is a conveniencelogger.warning("Agentic IDE: file index not primed: {}", exc)- # Remember the workspace so the next visit is one click, replaying- # the same terminal count and agent split (see recents.py).- split: dict[str, int] = {}- for term in terminals:- split[term.agent] = split.get(term.agent, 0) + 1- try:- from . import recents-- await asyncio.to_thread(- recents.remember,- str(root),- terminals=len(terminals),- agents=split,- )- except Exception as exc: # noqa: BLE001 - convenience, never fatal- logger.warning("Agentic IDE: recents not updated: {}", exc)logger.info("Agentic IDE session started: {} terminals in {}",len(terminals),diff --git a/jarvis/ui/web/agentic_ide_routes.py b/jarvis/ui/web/agentic_ide_routes.pyindex 8acf80170c..5fd7638453 100644--- a/jarvis/ui/web/agentic_ide_routes.py+++ b/jarvis/ui/web/agentic_ide_routes.py@@ -353,13 +353,32 @@ def _unwrap_file_uri(value: str) -> str:@router.post("/session", summary="Open an Agentic-IDE workspace")async def start_session(req: StartSessionRequest) -> dict:- """Open ``folder`` with one named terminal per requested agent."""+ """Open ``folder`` with one named terminal per requested agent.++ The recent-folder history is updated here, at the user-facing open action,+ rather than inside ``Registry.start``. Internal callers (especially unit+ tests using temporary directories) therefore cannot pollute the user's real+ history with folders the user never selected.+ """try:session = await get_registry().start(req.folder, [t.model_dump() for t in req.terminals])except SessionError as exc:raise HTTPException(status_code=422, detail=str(exc)) from exc++ split: dict[str, int] = {}+ for terminal in session.terminals:+ split[terminal.agent] = split.get(terminal.agent, 0) + 1+ try:+ await asyncio.to_thread(+ recents.remember,+ session.folder,+ terminals=len(session.terminals),+ agents=split,+ )+ except Exception: # noqa: BLE001 - history must never block opening a folder+ log.warning("Agentic IDE recent-folder history was not updated", exc_info=True)return {"ok": True, "session": session.to_dict()}diff --git a/jarvis/ui/web/frontend/src/components/agentic/FolderPicker.test.tsx b/jarvis/ui/web/frontend/src/components/agentic/FolderPicker.test.tsxindex 023a4957e0..5810ced3bb 100644--- a/jarvis/ui/web/frontend/src/components/agentic/FolderPicker.test.tsx+++ b/jarvis/ui/web/frontend/src/components/agentic/FolderPicker.test.tsx@@ -159,6 +159,8 @@ describe("FolderPicker", () => {);const card = await screen.findByText("/home/ruben/webshop");+ expect(screen.getByText("Recent folders")).toBeTruthy();+ expect(screen.getByTestId("recent-folder-star")).toBeTruthy();fireEvent.click(card);expect(onSelect).toHaveBeenCalledWith("/home/ruben/webshop");expect(onSelectRecent).toHaveBeenCalledWith(diff --git a/jarvis/ui/web/frontend/src/components/agentic/FolderPicker.tsx b/jarvis/ui/web/frontend/src/components/agentic/FolderPicker.tsxindex cdb71cf5cf..4b174ac95e 100644--- a/jarvis/ui/web/frontend/src/components/agentic/FolderPicker.tsx+++ b/jarvis/ui/web/frontend/src/components/agentic/FolderPicker.tsx@@ -22,7 +22,6 @@*/import { useCallback, useEffect, useMemo, useRef, useState } from "react";import {- Clock,CornerLeftUp,Folder,FolderGit2,@@ -31,6 +30,7 @@ import {Loader2,RefreshCw,Search,+ Star,Terminal,X,} from "lucide-react";@@ -259,8 +259,8 @@ export function FolderPicker({ selected, onSelect, onSelectRecent }: FolderPicke{recents.length > 0 && searchHits === null && (<section className="space-y-2"><h4 className="flex items-center gap-2 text-[11px] uppercase tracking-wider text-muted-foreground">- <Clock className="h-3.5 w-3.5" />- Recent workspaces+ <Star className="h-3.5 w-3.5 fill-current text-primary" />+ Recent folders</h4><ul className="grid gap-2 sm:grid-cols-2">{recents.map((recent) => (@@ -275,7 +275,10 @@ export function FolderPicker({ selected, onSelect, onSelectRecent }: FolderPicke: "border-border bg-card/60 hover:border-primary/40",)}>- <FolderOpen className="h-4 w-4 shrink-0 text-primary/80" />+ <Star+ data-testid="recent-folder-star"+ className="h-4 w-4 shrink-0 fill-current text-primary"+ /><span className="min-w-0 flex-1"><span className="block truncate text-sm font-medium">{recent.name}</span><span className="block truncate font-mono text-[10px] text-muted-foreground">diff --git a/tests/unit/agentic_ide/test_session.py b/tests/unit/agentic_ide/test_session.pyindex ba812ee55a..75ef94ccbe 100644--- a/tests/unit/agentic_ide/test_session.py+++ b/tests/unit/agentic_ide/test_session.py@@ -13,6 +13,7 @@ from pathlib import Pathimport pytest+from jarvis.agentic_ide import recentsfrom jarvis.agentic_ide import session as session_modfrom jarvis.agentic_ide.session import Registry, SessionError, sanitize_promptfrom tests.fakes.fake_pty_manager import FakePtyManager@@ -99,6 +100,22 @@ async def test_start_creates_named_terminals(registry: Registry, tmp_path: Path)assert session.folder == str(tmp_path)+async def test_internal_start_does_not_write_user_recents(+ registry: Registry, tmp_path: Path, monkeypatch: pytest.MonkeyPatch+) -> None:+ """Only the user-facing open route owns recent-folder history."""+ remembered: list[str] = []+ monkeypatch.setattr(+ recents,+ "remember",+ lambda path, **_kwargs: remembered.append(path),+ )++ await _open(registry, tmp_path, [{"agent": "claude"}])++ assert remembered == []++async def test_custom_names_are_kept_and_deduplicated(registry: Registry, tmp_path: Path) -> None:diff --git a/tests/unit/web/test_agentic_ide_recents.py b/tests/unit/web/test_agentic_ide_recents.pynew file mode 100644index 0000000000..00c37fd49d--- /dev/null+++ b/tests/unit/web/test_agentic_ide_recents.py@@ -0,0 +1,52 @@+"""Recent folders belong to explicit Agentic-IDE open actions only."""++from __future__ import annotations++from pathlib import Path+from types import SimpleNamespace++import pytest++from jarvis.ui.web import agentic_ide_routes as routes+++async def test_open_route_remembers_the_user_selected_folder(+ tmp_path: Path, monkeypatch: pytest.MonkeyPatch+) -> None:+ session = SimpleNamespace(+ folder=str(tmp_path),+ terminals=[+ SimpleNamespace(agent="codex"),+ SimpleNamespace(agent="codex"),+ SimpleNamespace(agent="claude"),+ ],+ to_dict=lambda: {"folder": str(tmp_path)},+ )++ class FakeRegistry:+ async def start(self, folder: str, terminals: list[dict]) -> object:+ assert folder == str(tmp_path)+ assert len(terminals) == 3+ return session++ remembered: list[tuple[str, int, dict[str, int]]] = []+ monkeypatch.setattr(routes, "get_registry", lambda: FakeRegistry())+ monkeypatch.setattr(+ routes.recents,+ "remember",+ lambda path, *, terminals, agents: remembered.append((path, terminals, agents)),+ )++ response = await routes.start_session(+ routes.StartSessionRequest(+ folder=str(tmp_path),+ terminals=[+ routes.TerminalRequest(agent="codex"),+ routes.TerminalRequest(agent="codex"),+ routes.TerminalRequest(agent="claude"),+ ],+ )+ )++ assert response["ok"] is True+ assert remembered == [(str(tmp_path), 3, {"codex": 2, "claude": 1})]