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.

fix(git): open a session's file in the editor's diff, and filter the Git tab only once per pane request (#744)

Ruben Lütke69898e47af43
diff --git a/dodaios/ui/web/frontend/src/components/agentic/sidePanel/git/GitOverviewTab.test.tsx b/dodaios/ui/web/frontend/src/components/agentic/sidePanel/git/GitOverviewTab.test.tsx
index b4a47e956e..7168b188ae 100644
--- a/dodaios/ui/web/frontend/src/components/agentic/sidePanel/git/GitOverviewTab.test.tsx
+++ b/dodaios/ui/web/frontend/src/components/agentic/sidePanel/git/GitOverviewTab.test.tsx
@@ -325,10 +325,12 @@ describe("GitOverviewTab — one agent session", () => {
expect(within(files[0]).queryByTestId("scm-session-stage")).toBeNull();
fireEvent.click(within(files[1]).getByTestId("scm-session-stage"));
await vi.waitFor(() => expect(posted("scm/stage")).toEqual([{ workspace_id: "w1", paths: ["app.py"] }]));
+ // A file in the shared folder opens in the editor's diff, against the code before the session.
fireEvent.click(files[0]);
- expect(await screen.findByTestId("scm-diff-dialog")).toBeTruthy();
- await vi.waitFor(() => expect(gets.some((url) => url.includes("/scm/session-file") && url.includes("base=b0b0b0b0b0b0"))).toBe(true));
- fireEvent.click(screen.getByTestId("scm-diff-close"));
+ const editor = useCodeEditorStore.getState();
+ expect(editor.tabs.map((tab) => [tab.path, tab.mode])).toEqual([["src/widget.ts", "diff"]]);
+ expect(editor.diffBases[editor.tabs[0].fileKey]?.ref).toBe("b0b0b0b0b0b0");
+ expect(screen.queryByTestId("scm-diff-dialog")).toBeNull();
fireEvent.click(screen.getByTestId("scm-session-clear"));
expect(await screen.findByText("notes.txt")).toBeTruthy();
expect(screen.queryByTestId("scm-session")).toBeNull();
@@ -339,6 +341,12 @@ describe("GitOverviewTab — one agent session", () => {
await screen.findByText("app.py");
act(() => useGitSessionStore.getState().show("w1", "T2"));
expect((await screen.findAllByTestId("scm-session-file")).length).toBe(2);
+ // The ask is used up: the tab opened again later starts on every change.
+ expect(useGitSessionStore.getState().request).toBeNull();
+ cleanup();
+ render(<GitOverviewTab />);
+ expect(await screen.findByText("app.py")).toBeTruthy();
+ expect(screen.queryByTestId("scm-session")).toBeNull();
});
});
diff --git a/dodaios/ui/web/frontend/src/components/agentic/sidePanel/git/GitOverviewTab.tsx b/dodaios/ui/web/frontend/src/components/agentic/sidePanel/git/GitOverviewTab.tsx
index 181281fc03..306f721dca 100644
--- a/dodaios/ui/web/frontend/src/components/agentic/sidePanel/git/GitOverviewTab.tsx
+++ b/dodaios/ui/web/frontend/src/components/agentic/sidePanel/git/GitOverviewTab.tsx
@@ -108,6 +108,7 @@ export function GitOverviewTab() {
if (!sessionRequest || sessionRequest.workspaceId !== workspaceId) return;
setSessionPane(sessionRequest.pane);
setOpen((current) => ({ ...current, changes: true }));
+ useGitSessionStore.getState().consume(sessionRequest.nonce);
}, [sessionRequest, workspaceId]);
// The commit message is kept per workspace, across restarts, until it is committed.
const [message, setMessageState] = useState(() => (workspaceId ? scmStorage.get(MESSAGE_KEY(workspaceId)) : ""));
diff --git a/dodaios/ui/web/frontend/src/components/agentic/sidePanel/git/scm/SessionChanges.tsx b/dodaios/ui/web/frontend/src/components/agentic/sidePanel/git/scm/SessionChanges.tsx
index b4b6755d65..55c8d8712b 100644
--- a/dodaios/ui/web/frontend/src/components/agentic/sidePanel/git/scm/SessionChanges.tsx
+++ b/dodaios/ui/web/frontend/src/components/agentic/sidePanel/git/scm/SessionChanges.tsx
@@ -96,6 +96,16 @@ export function SessionChanges({
return;
}
const base = changes.base;
+ // A file in the shared folder opens in the editor's diff, like any other
+ // change, compared with the code before the session's first edit. A pane's
+ // own worktree and a deleted file have nothing the editor could open.
+ if (!changes.ownCheckout && file.status !== "deleted") {
+ useCodeEditorStore.getState().openFile(workspaceId, file.path, {
+ mode: "diff",
+ base: { ref: base, label: fill(t("ide_side_panel.git.scm.session_diff_badge"), { pane: session.pane }) },
+ });
+ return;
+ }
onDiff({
title: `${baseName(file.path)} (${session.pane})`,
path: file.path,
diff --git a/dodaios/ui/web/frontend/src/i18n/locales/de.json b/dodaios/ui/web/frontend/src/i18n/locales/de.json
index a25f0b173d..dd92fbf705 100644
--- a/dodaios/ui/web/frontend/src/i18n/locales/de.json
+++ b/dodaios/ui/web/frontend/src/i18n/locales/de.json
@@ -8278,7 +8278,8 @@
"follow_busy_build": "Baue die neue Oberfläche…",
"follow_restart_pending": "Neuer Code ist da; die App startet neu, sobald keine Mission und kein Anruf läuft.",
"follow_updated": "Aktualisiert {when}: {subject}",
- "follow_click_off": "Klicken, um main nicht mehr zu folgen."
+ "follow_click_off": "Klicken, um main nicht mehr zu folgen.",
+ "session_diff_badge": "Änderungen von {pane}"
}
},
"skills": {
diff --git a/dodaios/ui/web/frontend/src/i18n/locales/en.json b/dodaios/ui/web/frontend/src/i18n/locales/en.json
index 1006c1f500..2db709c1bb 100644
--- a/dodaios/ui/web/frontend/src/i18n/locales/en.json
+++ b/dodaios/ui/web/frontend/src/i18n/locales/en.json
@@ -8278,7 +8278,8 @@
"follow_busy_build": "Building the new interface…",
"follow_restart_pending": "New code is in; the app restarts as soon as no mission or call is running.",
"follow_updated": "Updated {when}: {subject}",
- "follow_click_off": "Click to stop following main."
+ "follow_click_off": "Click to stop following main.",
+ "session_diff_badge": "Changes by {pane}"
}
},
"skills": {
diff --git a/dodaios/ui/web/frontend/src/i18n/locales/es.json b/dodaios/ui/web/frontend/src/i18n/locales/es.json
index c484b0cc5c..ab80feaf24 100644
--- a/dodaios/ui/web/frontend/src/i18n/locales/es.json
+++ b/dodaios/ui/web/frontend/src/i18n/locales/es.json
@@ -8278,7 +8278,8 @@
"follow_busy_build": "Construyendo la nueva interfaz…",
"follow_restart_pending": "Hay código nuevo; la app se reinicia en cuanto no haya ninguna misión ni llamada en curso.",
"follow_updated": "Actualizado {when}: {subject}",
- "follow_click_off": "Haz clic para dejar de seguir main."
+ "follow_click_off": "Haz clic para dejar de seguir main.",
+ "session_diff_badge": "Cambios de {pane}"
}
},
"skills": {
diff --git a/dodaios/ui/web/frontend/src/i18n/locales/pt.json b/dodaios/ui/web/frontend/src/i18n/locales/pt.json
index a8978f6d81..d9e16a17b4 100644
--- a/dodaios/ui/web/frontend/src/i18n/locales/pt.json
+++ b/dodaios/ui/web/frontend/src/i18n/locales/pt.json
@@ -8278,7 +8278,8 @@
"follow_busy_build": "Construindo a nova interface…",
"follow_restart_pending": "Há código novo; a app reinicia assim que nenhuma missão ou chamada estiver em andamento.",
"follow_updated": "Atualizado {when}: {subject}",
- "follow_click_off": "Clique para deixar de seguir o main."
+ "follow_click_off": "Clique para deixar de seguir o main.",
+ "session_diff_badge": "Alterações de {pane}"
}
},
"skills": {
diff --git a/dodaios/ui/web/frontend/src/i18n/locales/zh.json b/dodaios/ui/web/frontend/src/i18n/locales/zh.json
index 6dc0dff7df..aaad9dea66 100644
--- a/dodaios/ui/web/frontend/src/i18n/locales/zh.json
+++ b/dodaios/ui/web/frontend/src/i18n/locales/zh.json
@@ -8278,7 +8278,8 @@
"follow_busy_build": "正在构建新界面…",
"follow_restart_pending": "新代码已就绪;没有任务或通话进行时应用会自动重启。",
"follow_updated": "{when}已更新:{subject}",
- "follow_click_off": "点击以停止跟随 main。"
+ "follow_click_off": "点击以停止跟随 main。",
+ "session_diff_badge": "{pane} 的更改"
}
},
"skills": {
diff --git a/dodaios/ui/web/frontend/src/store/gitSession.ts b/dodaios/ui/web/frontend/src/store/gitSession.ts
index cd79cfefbd..1b046b5ec2 100644
--- a/dodaios/ui/web/frontend/src/store/gitSession.ts
+++ b/dodaios/ui/web/frontend/src/store/gitSession.ts
@@ -17,6 +17,8 @@ export interface GitSessionRequest {
interface GitSessionStore {
request: GitSessionRequest | null;
show: (workspaceId: string, pane: string) => void;
+ /** The Git tab took the request: a tab opened later starts unfiltered. */
+ consume: (nonce: number) => void;
}
let nonce = 0;
@@ -24,4 +26,5 @@ let nonce = 0;
export const useGitSessionStore = create<GitSessionStore>((set) => ({
request: null,
show: (workspaceId, pane) => set({ request: { workspaceId, pane, nonce: ++nonce } }),
+ consume: (taken) => set((state) => (state.request?.nonce === taken ? { request: null } : {})),
}));