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): find a pane's own changes past a folder full of build output
rubenluetke10-beepafd72d1de4e7
diff --git a/jarvis/agentic_ide/git_changes.py b/jarvis/agentic_ide/git_changes.pyindex 56717fc6f4..58cfdc0716 100644--- a/jarvis/agentic_ide/git_changes.py+++ b/jarvis/agentic_ide/git_changes.py@@ -154,8 +154,15 @@ def _count_lines(path: Path) -> int | None:return data.count(b"\n") + (0 if data.endswith(b"\n") else 1)-def workspace_changes(folder: str | Path) -> WorkspaceChanges:- """Every changed path under ``folder``, with line counts where cheap."""+def workspace_changes(folder: str | Path, only: set[str] | None = None) -> WorkspaceChanges:+ """Every changed path under ``folder``, with line counts where cheap.++ ``only`` narrows the answer to those workspace-relative POSIX paths — one+ pane's own files. It is applied BEFORE the :data:`MAX_CHANGED_FILES` cap,+ so a folder full of unrelated untracked files (build output) cannot push+ the pane's files off the list, and untracked files are then listed one by+ one, since a pane writes files, not folders.+ """root = Path(folder).expanduser()if not root.is_dir():return WorkspaceChanges(available=False, reason="The workspace folder is missing.")@@ -166,8 +173,11 @@ def workspace_changes(folder: str | Path) -> WorkspaceChanges:branch_result = _git(["rev-parse", "--abbrev-ref", "HEAD"], root)branch = branch_result.stdout.strip() if branch_result and branch_result.returncode == 0 else ""+ if only is not None and not only:+ return WorkspaceChanges(available=True, branch=branch)+ untracked = "--untracked-files=normal" if only is None else "--untracked-files=all"status = _git(- ["status", "--porcelain=v1", "-z", "--no-renames", "--untracked-files=normal", "--", "."],+ ["status", "--porcelain=v1", "-z", "--no-renames", untracked, "--", "."],root,)if status is None or status.returncode != 0:@@ -200,6 +210,8 @@ def workspace_changes(folder: str | Path) -> WorkspaceChanges:rel = _strip_prefix(repo_path, prefix)if rel is None or not rel:continue+ if only is not None and rel not in only:+ continueif len(files) >= MAX_CHANGED_FILES:truncated = Truebreakdiff --git a/jarvis/ui/web/agentic_ide_routes.py b/jarvis/ui/web/agentic_ide_routes.pyindex b6224e2de6..ac44d0dead 100644--- a/jarvis/ui/web/agentic_ide_routes.py+++ b/jarvis/ui/web/agentic_ide_routes.py@@ -1748,6 +1748,60 @@ async def get_workspace_changes(workspace_id: str) -> WorkspaceChangesResponse:)+ "/workspaces/{workspace_id}/terminals/{name}/changes",+ response_model=WorkspaceChangesResponse,+ summary="Uncommitted files one pane's agent wrote in its workspace",+)+async def get_pane_changes(workspace_id: str, name: str) -> WorkspaceChangesResponse:+ """The pane's "Review changes" list: the files its agent's own record+ names as written, as git sees them now.++ Reads only this pane's record, not every pane's, and filters git's answer+ to those files before any cap, so a folder full of other changes cannot+ hide them. A pane whose record cannot be read answers an empty list.+ """+ session = get_registry().get(workspace_id)+ if session is None:+ raise HTTPException(status_code=404, detail="Workspace not found.")+ term = next((t for t in session.terminals if t.name == name), None)+ if term is None:+ raise HTTPException(status_code=404, detail="Terminal not found.")+ records = (+ [+ change_authors.PaneRecord(+ pane=term.name,+ history_id=term.history_id,+ agent=term.agent,+ display_name=term.display_name,+ session_id=term.resume.id,+ home=account_home(term.agent, term.account),+ folder=term.folder or session.folder,+ )+ ]+ if term.resume is not None and agent_transcript.can_read(term.agent)+ else []+ )+ authors = await asyncio.to_thread(change_authors.change_authors, session.folder, records)+ changes = await asyncio.to_thread(+ git_changes.workspace_changes, session.folder, set(authors)+ )+ return WorkspaceChangesResponse(+ workspace_id=workspace_id,+ available=changes.available,+ branch=changes.branch,+ files=[+ ChangedFileItem(+ **asdict(item),+ authors=[ChangeAuthorItem(**asdict(a)) for a in authors.get(item.path, [])],+ )+ for item in changes.files+ ],+ truncated=changes.truncated,+ reason=changes.reason,+ )++@router.get("/workspaces/{workspace_id}/diff",response_model=WorkspaceFileDiffResponse,diff --git a/jarvis/ui/web/frontend/src/components/agentic/PaneChangesDialog.test.tsx b/jarvis/ui/web/frontend/src/components/agentic/PaneChangesDialog.test.tsxindex bc464f92ff..c5e5c98171 100644--- a/jarvis/ui/web/frontend/src/components/agentic/PaneChangesDialog.test.tsx+++ b/jarvis/ui/web/frontend/src/components/agentic/PaneChangesDialog.test.tsx@@ -42,14 +42,25 @@ function diffFor(path: string) {}const urls: string[] = [];+/** False plays a backend from before the pane route: FastAPI answers 404 "Not Found". */+let paneRoute = true;beforeEach(() => {urls.length = 0;+ paneRoute = true;vi.stubGlobal("fetch", vi.fn(async (input: RequestInfo | URL) => {const url = String(input);urls.push(url);const path = new URL(url, "http://local").searchParams.get("path") ?? "";- const body = url.includes("/diff") ? diffFor(path) : url.includes("/changes") ? CHANGES : {};+ const pane = url.match(/\/terminals\/([^/]+)\/changes/)?.[1];+ if (pane && !paneRoute) {+ return new Response(JSON.stringify({ detail: "Not Found" }), { status: 404, headers: { "Content-Type": "application/json" } });+ }+ const body = url.includes("/diff")+ ? diffFor(path)+ : pane+ ? { ...CHANGES, files: CHANGES.files.filter((file) => file.authors.some((a) => a.pane === pane)) }+ : url.includes("/changes") ? CHANGES : {};return new Response(JSON.stringify(body), { status: 200, headers: { "Content-Type": "application/json" } });}));useCodeEditorStore.setState({ tabs: [], active: {}, files: {}, visible: false, reveal: null, closed: [] });@@ -85,6 +96,21 @@ describe("PaneChangesDialog", () => {expect(urls.some((url) => url.includes("other.ts"))).toBe(false);});+ it("asks the pane route, not the whole workspace, for the pane's own files", async () => {+ render(<PaneChangesDialog open onOpenChange={() => {}} workspaceId="w1" pane="T1" />);+ await screen.findAllByTestId("pane-changes-file");+ expect(urls[0]).toContain("/api/agentic-ide/workspaces/w1/terminals/T1/changes");+ expect(urls.some((url) => url.endsWith("/workspaces/w1/changes"))).toBe(false);+ });++ it("falls back to filtering the workspace list on a backend without the pane route", async () => {+ paneRoute = false;+ render(<PaneChangesDialog open onOpenChange={() => {}} workspaceId="w1" pane="T1" />);+ await screen.findAllByTestId("pane-changes-file");+ expect(paths()).toEqual(["src/app.ts"]);+ expect(urls.some((url) => url.endsWith("/workspaces/w1/changes"))).toBe(true);+ });+it("widens to the whole folder on request", async () => {render(<PaneChangesDialog open onOpenChange={() => {}} workspaceId="w1" pane="T1" />);await screen.findAllByTestId("pane-changes-file");diff --git a/jarvis/ui/web/frontend/src/components/agentic/PaneChangesDialog.tsx b/jarvis/ui/web/frontend/src/components/agentic/PaneChangesDialog.tsxindex aa78198c33..c6424ce3b0 100644--- a/jarvis/ui/web/frontend/src/components/agentic/PaneChangesDialog.tsx+++ b/jarvis/ui/web/frontend/src/components/agentic/PaneChangesDialog.tsx@@ -234,7 +234,7 @@ export function PaneChangesDialog({>{value === "pane"? t("pane_review.scope_pane")- : changes+ : changes?.folderTotal != null? fill(t("pane_review.scope_folder_count"), { count: changes.folderTotal }): t("pane_review.scope_folder")}</button>diff --git a/jarvis/ui/web/frontend/src/components/agentic/WorkspaceTerminalHeader.tsx b/jarvis/ui/web/frontend/src/components/agentic/WorkspaceTerminalHeader.tsxindex f3fea3b928..af89a7715d 100644--- a/jarvis/ui/web/frontend/src/components/agentic/WorkspaceTerminalHeader.tsx+++ b/jarvis/ui/web/frontend/src/components/agentic/WorkspaceTerminalHeader.tsx@@ -1,6 +1,7 @@import { useEffect, useId, useLayoutEffect, useRef, useState, type ComponentType, type CSSProperties, type MouseEvent, type PointerEvent, type SVGProps } from "react";import { createPortal } from "react-dom";import { Check, FileDiff, FolderInput, GitBranch, Maximize2, Minimize2, MoreHorizontal, Plus, Server, X } from "lucide-react";+import { loadLocaleChunk } from "@/i18n";import { AgentMark } from "./AgentMark";import { BranchIcon } from "./branchIcon";import { SessionGitHubBadge } from "./SessionGitHubBadge";@@ -278,7 +279,7 @@ export function WorkspaceTerminalHeader({<SessionGitHubBadge workspaceId={githubStatusEnabled ? workspaceId : undefined} name={name} appearance={appearance} /><div data-header-control="true" className="flex shrink-0 items-center gap-0.5">{onReviewChanges && <button type="button" data-testid={`pane-review-changes-${name}`} aria-label={`Review changes by ${name}`}- title="Review changes" onClick={onReviewChanges} className={action}><FileDiff className="h-[15px] w-[15px]" /></button>}+ title="Review changes" onClick={onReviewChanges} onPointerEnter={() => void loadLocaleChunk("pane_review")} className={action}><FileDiff className="h-[15px] w-[15px]" /></button>}{moreButton}{maximizeButton}{onFork && <button type="button" data-testid={`pane-fork-${name}`} aria-label={`Fork ${name}`} title={`Fork ${name}`}diff --git a/jarvis/ui/web/frontend/src/components/agentic/paneChangesApi.ts b/jarvis/ui/web/frontend/src/components/agentic/paneChangesApi.tsindex 25516a6010..c6051f45d4 100644--- a/jarvis/ui/web/frontend/src/components/agentic/paneChangesApi.ts+++ b/jarvis/ui/web/frontend/src/components/agentic/paneChangesApi.ts@@ -7,10 +7,11 @@* every uncommitted change in it is this agent's. Read through the folder* routes (`/api/agentic-ide/git/changes` and `/diff`).* - A pane in the workspace's shared folder shares it with its neighbours.- * The workspace's Changes reading already names, per file, which panes'- * agents wrote it (read from each agent's own record), so this pane's- * changes are the files that name it. The whole folder stays one toggle away- * for a file a shell command wrote, which no agent record names.+ * Its own files are the ones its agent's record names as written; the pane+ * route reads only that record and filters git's answer to those files+ * before any cap, so a folder full of build output cannot hide them. The+ * whole folder stays one toggle away for a file a shell command wrote,+ * which no agent record names.** Only uncommitted work shows: once the agent commits, the change belongs to* a commit and the Git tab is where it is read.@@ -32,8 +33,8 @@ export interface PaneChanges {branch: string;/** The files in the requested scope. */files: ChangedFile[];- /** How many uncommitted files the folder has in all — the "whole folder" count. */- folderTotal: number;+ /** How many uncommitted files the folder has in all, when that was read. */+ folderTotal: number | null;/** True when the pane has a checkout of its own: every change there is its own. */ownCheckout: boolean;truncated: boolean;@@ -47,6 +48,12 @@ export interface PaneChangesTarget {folder?: string;}+class HttpError extends Error {+ constructor(message: string, readonly status: number) {+ super(message);+ }+}+async function read<T>(url: string): Promise<T> {const res = await fetch(url);if (!res.ok) {@@ -60,7 +67,7 @@ async function read<T>(url: string): Promise<T> {} catch {/* keep the status-code message */}- throw new Error(message);+ throw new HttpError(message, res.status);}return (await res.json()) as T;}@@ -104,6 +111,10 @@ export async function fetchPaneChanges(target: PaneChangesTarget, scope: ChangeStruncated: body.truncated,};}+ if (scope === "pane") {+ const own = await fetchOwnChanges(target);+ if (own) return own;+ }const body = await fetchWorkspaceChanges(target.workspaceId);return {available: body.available,@@ -116,6 +127,33 @@ export async function fetchPaneChanges(target: PaneChangesTarget, scope: ChangeS};}+/**+ * The pane route's answer, or null from a backend that predates it (a running+ * app updates its bundle before its next restart loads the route), which then+ * reads the whole workspace and filters here instead.+ */+async function fetchOwnChanges(target: PaneChangesTarget): Promise<PaneChanges | null> {+ let body: FolderChangesBody;+ try {+ body = await read<FolderChangesBody>(+ `/api/agentic-ide/workspaces/${encodeURIComponent(target.workspaceId)}/terminals/${encodeURIComponent(target.pane)}/changes`,+ );+ } catch (error) {+ // FastAPI's own "Not Found" means no such route; the route's 404s say what is missing.+ if (error instanceof HttpError && error.status === 404 && error.message === "Not Found") return null;+ throw error;+ }+ return {+ available: body.available,+ reason: body.reason,+ branch: body.branch,+ files: body.files,+ folderTotal: null,+ ownCheckout: false,+ truncated: body.truncated,+ };+}+export function fetchPaneFileDiff(target: PaneChangesTarget, path: string): Promise<FileDiff> {if (target.folder) {return read<FileDiff>(diff --git a/tests/unit/agentic_ide/test_git_changes.py b/tests/unit/agentic_ide/test_git_changes.pyindex af11a4627a..05278e97c2 100644--- a/tests/unit/agentic_ide/test_git_changes.py+++ b/tests/unit/agentic_ide/test_git_changes.py@@ -48,6 +48,31 @@ def test_reports_modified_deleted_and_untracked_with_line_counts(repo: Path) ->assert by_path["app/new.py"].added == 2+def test_only_narrows_to_named_files_before_the_cap(+ repo: Path, monkeypatch: pytest.MonkeyPatch+) -> None:+ # A folder of unrelated untracked files (build output) sorts first and+ # would fill the whole list; the named file must still be found.+ monkeypatch.setattr(git_changes, "MAX_CHANGED_FILES", 3)+ for index in range(10):+ (repo / f"aaa_chunk{index}.js").write_text("x\n", encoding="utf-8")+ (repo / "app" / "main.py").write_text("changed\n", encoding="utf-8")+ (repo / "app" / "fresh").mkdir()+ (repo / "app" / "fresh" / "new.py").write_text("a\n", encoding="utf-8")++ assert git_changes.workspace_changes(repo).truncated++ changes = git_changes.workspace_changes(repo, only={"app/main.py", "app/fresh/new.py"})++ assert not changes.truncated+ # An untracked folder is listed file by file, so the named file matches.+ assert [(f.path, f.status) for f in changes.files] == [+ ("app/fresh/new.py", "untracked"),+ ("app/main.py", "modified"),+ ]+ assert git_changes.workspace_changes(repo, only=set()).files == []++def test_a_sub_folder_workspace_sees_only_its_own_changes_relative_to_itself(repo: Path) -> None:(repo / "app" / "main.py").write_text("changed\n", encoding="utf-8")(repo / "top.txt").write_text("changed\n", encoding="utf-8")diff --git a/tests/unit/web/test_agentic_ide_pane_changes_route.py b/tests/unit/web/test_agentic_ide_pane_changes_route.pynew file mode 100644index 0000000000..a2fc438596--- /dev/null+++ b/tests/unit/web/test_agentic_ide_pane_changes_route.py@@ -0,0 +1,108 @@+"""The endpoint behind a pane's "Review changes" dialog.++It must list the files the pane's OWN agent wrote, and find them even when+the folder holds more uncommitted files than one answer carries — a shared+working tree with thousands of untracked build chunks once filled the whole+list and left the dialog saying the agent had changed nothing.+"""+from __future__ import annotations++import shutil+import subprocess+from pathlib import Path+from types import SimpleNamespace++import pytest+from fastapi import HTTPException++from jarvis.agentic_ide import agent_transcript, change_authors, git_changes+from jarvis.ui.web import agentic_ide_routes as routes++pytestmark = pytest.mark.skipif(shutil.which("git") is None, reason="git is not installed")+++def _git(cwd: Path, *args: str) -> None:+ subprocess.run(["git", *args], cwd=cwd, check=True, capture_output=True)+++def repo(tmp_path: Path) -> Path:+ _git(tmp_path, "init", "-q")+ _git(tmp_path, "config", "user.email", "[email protected]")+ _git(tmp_path, "config", "user.name", "Test")+ _git(tmp_path, "config", "core.autocrlf", "false")+ (tmp_path / "mine.py").write_text("one\n", encoding="utf-8")+ (tmp_path / "theirs.py").write_text("one\n", encoding="utf-8")+ _git(tmp_path, "add", "-A")+ _git(tmp_path, "commit", "-q", "-m", "init")+ return tmp_path+++def _pane(name: str, session_id: str) -> SimpleNamespace:+ return SimpleNamespace(+ name=name,+ history_id=f"h-{name}",+ agent="claude",+ display_name="Claude",+ resume=SimpleNamespace(id=session_id),+ account=None,+ folder="",+ )+++def _write(path: str, call_id: str) -> list[dict]:+ return [+ {+ "kind": "tool_call",+ "ts_ms": 5,+ "payload": {"call_id": call_id, "name": "Edit", "input": {"file_path": path}},+ },+ {"kind": "tool_result", "payload": {"call_id": call_id, "is_error": False}},+ ]+++def workspace(repo: Path, monkeypatch: pytest.MonkeyPatch) -> SimpleNamespace:+ session = SimpleNamespace(folder=str(repo), terminals=[_pane("T1", "s1"), _pane("T2", "s2")])+ registry = SimpleNamespace(get=lambda wid: session if wid == "w1" else None)+ monkeypatch.setattr(routes, "get_registry", lambda: registry)+ records = {"s1": _write(str(repo / "mine.py"), "c1"), "s2": _write("theirs.py", "c2")}+ monkeypatch.setattr(agent_transcript, "can_read", lambda agent: True)+ monkeypatch.setattr(agent_transcript, "read_events", lambda agent, sid, home=None: records[sid])+ monkeypatch.setattr(change_authors, "_cache", {})+ return session+++async def test_lists_only_the_panes_own_files_past_a_full_folder(+ repo: Path, workspace: SimpleNamespace, monkeypatch: pytest.MonkeyPatch+) -> None:+ monkeypatch.setattr(git_changes, "MAX_CHANGED_FILES", 2)+ for index in range(5):+ (repo / f"aaa_chunk{index}.js").write_text("x\n", encoding="utf-8")+ (repo / "mine.py").write_text("two\n", encoding="utf-8")+ (repo / "theirs.py").write_text("two\n", encoding="utf-8")++ answer = await routes.get_pane_changes("w1", "T1")++ assert [(f.path, [a.pane for a in f.authors]) for f in answer.files] == [("mine.py", ["T1"])]+ assert not answer.truncated+++async def test_a_pane_that_wrote_nothing_gets_an_empty_list(+ repo: Path, workspace: SimpleNamespace+) -> None:+ (repo / "theirs.py").write_text("two\n", encoding="utf-8")++ answer = await routes.get_pane_changes("w1", "T1")++ assert answer.available+ assert answer.files == []+++async def test_unknown_workspace_or_pane_is_a_404(workspace: SimpleNamespace) -> None:+ with pytest.raises(HTTPException) as missing_pane:+ await routes.get_pane_changes("w1", "T9")+ assert missing_pane.value.status_code == 404+ with pytest.raises(HTTPException) as missing_workspace:+ await routes.get_pane_changes("nope", "T1")+ assert missing_workspace.value.status_code == 404