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): explorer right-click menu and a second editor to the side (#547)

Ruben Lütke3c26dd3f0478
diff --git a/docs/code-editor.md b/docs/code-editor.md
index 9581930cfa..1f37a33285 100644
--- a/docs/code-editor.md
+++ b/docs/code-editor.md
@@ -15,6 +15,9 @@ terminals back without closing a file.
| Delete | **Del** or right-click; the entry goes to the system trash |
| Select several | **Ctrl/Cmd+click** adds a row, **Shift+click** selects a range; delete, cut, copy and drag act on the whole selection |
| Move, copy | Drag rows onto a folder (or the empty space for the root), or **Ctrl+X / Ctrl+C** then **Ctrl+V** on the target. Pasting into the same folder makes a "copy" |
+| Right-click a file or folder | The menu opens at the pointer and acts on that row: new file or folder, open in the editor or on this computer, show it in the system file manager (**Shift+Alt+R**), open a terminal in that folder, find in folder (**Shift+Alt+F**), cut, copy, paste, copy path (**Shift+Alt+C**), copy relative path (**Ctrl+K Ctrl+Shift+C**), rename, delete. Right-click the empty space for the workspace root |
+| Two files side by side | Right-click a file and choose **Open to the side** (or **Ctrl+Enter** on it in the Folder tab), or right-click a tab. The file opens in a second editor on the right; drag the divider to resize, double-click it for equal halves. Files you open next go to the editor you last clicked in, and **Ctrl+S**, **Ctrl+Tab** and the status bar follow it. **Ctrl+W** in the second editor, or its close button, goes back to one editor and keeps the tab |
+| Compare two files | Right-click one file and choose **Select for compare**, then right-click another and choose **Compare with …**: the two open side by side, the second one editable |
| Search in all files | **Ctrl+Shift+F** opens the **Search** tab: match case, whole word, regular expressions, include/exclude globs, and **Replace all** (a second click confirms; files with unsaved changes are left out) |
| See what changed | Coloured marks in the gutter (added, modified, deleted lines against the last commit), the **Changes** tab, or **Show changes**: the file against the last commit, editable on the right |
| Rendered view | **Ctrl+Shift+V** for Markdown, HTML and SVG |
diff --git a/jarvis/ui/web/agentic_ide_routes.py b/jarvis/ui/web/agentic_ide_routes.py
index 964ca36ae2..ed6ebc1ca4 100644
--- a/jarvis/ui/web/agentic_ide_routes.py
+++ b/jarvis/ui/web/agentic_ide_routes.py
@@ -13,6 +13,7 @@ Endpoints (prefix ``/api/agentic-ide``):
* ``POST /folders/native`` → open it and return what was picked
* ``POST /folders/create`` → make one new folder inside an existing one
* ``POST /terminal-target/open`` → open a path printed by one terminal
+* ``POST /terminal-target/reveal`` → show a workspace path in the file manager
* ``GET /workspaces`` → every open workspace, in tab order
* ``PUT /workspaces/order`` → reorder workspace tabs via drag and drop
* ``GET /workspaces/{id}/files`` → browse that workspace's file tree
@@ -2582,14 +2583,10 @@ async def delete_workspace_entry(
return {"workspace_id": workspace_id, "path": req.path, "trashed": trashed}
- "/terminal-target/open",
- summary="Open a file or folder linked in an Agentic-IDE terminal",
-)
-async def open_terminal_target(
- request: Request, req: OpenTerminalTargetRequest
+async def _launch_terminal_target(
+ request: Request, req: OpenTerminalTargetRequest, *, reveal: bool
) -> dict[str, object]:
- """Open a modifier-clicked workspace path with the operating-system default.
+ """Open a workspace path, or show it selected in the system file manager.
This is local-desktop-only: a remote browser would otherwise act on the
server's screen. Resolution is confined to the addressed open workspace
@@ -2615,18 +2612,47 @@ async def open_terminal_target(
from jarvis.platform import open_path
- opened = await asyncio.to_thread(open_path.open_file, target)
+ opener = open_path.reveal_in_folder if reveal else open_path.open_file
+ opened = await asyncio.to_thread(opener, target)
kind = "directory" if target.is_dir() else "file"
log.info(
- "Agentic IDE terminal target: workspace=%s kind=%s opened=%s path=%s",
+ "Agentic IDE terminal target: workspace=%s kind=%s reveal=%s opened=%s path=%s",
req.workspace_id,
kind,
+ reveal,
opened,
target,
)
return {"opened": bool(opened), "kind": kind, "path": str(target)}
+ "/terminal-target/open",
+ summary="Open a file or folder linked in an Agentic-IDE terminal",
+)
+async def open_terminal_target(
+ request: Request, req: OpenTerminalTargetRequest
+) -> dict[str, object]:
+ """Open a modifier-clicked workspace path with the operating-system default."""
+ return await _launch_terminal_target(request, req, reveal=False)
+
+
+ "/terminal-target/reveal",
+ summary="Show a workspace file or folder in the system file manager",
+)
+async def reveal_terminal_target(
+ request: Request, req: OpenTerminalTargetRequest
+) -> dict[str, object]:
+ """Show a workspace path selected in the file manager, without launching it.
+
+ A route of its own rather than a flag on ``/terminal-target/open``: a
+ backend that does not know it answers 404, where an ignored flag would
+ have launched the file.
+ """
+ return await _launch_terminal_target(request, req, reveal=True)
+
+
@router.get("/recents", response_model=RecentsResponse, summary="Recently opened workspaces")
async def get_recents() -> RecentsResponse:
"""Workspaces opened before, newest first, with their previous layout."""
diff --git a/jarvis/ui/web/frontend/src/components/agentic/editor/CodeEditorStage.tsx b/jarvis/ui/web/frontend/src/components/agentic/editor/CodeEditorStage.tsx
index 11d63a8f08..f7766b3de9 100644
--- a/jarvis/ui/web/frontend/src/components/agentic/editor/CodeEditorStage.tsx
+++ b/jarvis/ui/web/frontend/src/components/agentic/editor/CodeEditorStage.tsx
@@ -1,9 +1,10 @@
-import { Suspense, lazy, useEffect, useMemo, useRef, useState, type ReactNode } from "react";
+import { Suspense, lazy, useEffect, useMemo, useRef, useState, type PointerEvent as ReactPointerEvent, type ReactNode } from "react";
import { useShallow } from "zustand/react/shallow";
import {
AlertTriangle,
ChevronRight,
Code2,
+ Columns2,
Copy,
Eye,
ExternalLink,
@@ -39,6 +40,11 @@ const EditorSurface = lazy(() => import("./EditorSurface"));
const DISK_POLL_MS = 3000;
const DISK_JITTER_MS = 1500;
+/** How far the divider between two editors may be dragged, as a share of the width. */
+const SPLIT_MIN = 0.2;
+const SPLIT_MAX = 0.8;
+const clampSplit = (ratio: number) => Math.min(SPLIT_MAX, Math.max(SPLIT_MIN, ratio));
+
const baseName = (path: string) => path.split("/").pop() ?? path;
interface PendingClose {
@@ -73,12 +79,18 @@ export function CodeEditorStage({
const stage = useRef<HTMLDivElement>(null);
const tabs = useCodeEditorStore(useShallow((state) => tabsOf(state, workspaceId)));
const activeKey = useCodeEditorStore((state) => (workspaceId ? (state.active[workspaceId] ?? null) : null));
+ const sideKey = useCodeEditorStore((state) => (workspaceId ? (state.side[workspaceId] ?? null) : null));
+ const sideHasKeyboard = useCodeEditorStore((state) => state.sideFocused);
const visible = useCodeEditorStore((state) => state.visible);
const quickOpen = useCodeEditorStore((state) => state.quickOpen);
const files = useCodeEditorStore((state) => state.files);
const diffBases = useCodeEditorStore((state) => state.diffBases);
const [pending, setPending] = useState<PendingClose | null>(null);
const [menu, setMenu] = useState<EditorTab | null>(null);
+ // The first editor's share of the width while two are open.
+ const [split, setSplit] = useState(0.5);
+ const splitHost = useRef<HTMLDivElement>(null);
+ const dragging = useRef(false);
// Tabs whose Markdown, HTML or SVG is shown rendered (Ctrl+Shift+V).
const [rendered, setRendered] = useState<ReadonlySet<string>>(() => new Set());
const toggleRendered = (key: string) =>
@@ -94,7 +106,10 @@ export function CodeEditorStage({
const pushToast = useEventStore((state) => state.pushToast);
const activeTab = tabs.find((tab) => tab.key === activeKey) ?? tabs[tabs.length - 1] ?? null;
- const activeFile = activeTab ? files[activeTab.fileKey] : undefined;
+ // A second editor beside the first ("Open to the side"). The breadcrumbs,
+ // banners and status bar describe whichever of the two has the keyboard.
+ const sideTab = activeTab && sideKey ? (tabs.find((tab) => tab.key === sideKey) ?? null) : null;
+ const sideFocused = sideHasKeyboard && sideTab !== null;
const shown = visible && activeTab !== null;
// Reopen what this workspace had open last run, unsaved text included.
@@ -157,7 +172,9 @@ export function CodeEditorStage({
if (!state.visible || !host) return;
if (target && target !== document.body && !host.contains(target)) return;
const own = tabsOf(state, workspaceId);
- const current = own.find((tab) => tab.key === state.active[workspaceId]) ?? own[own.length - 1];
+ // Keys go to the editor that has the keyboard.
+ const beside = state.sideFocused ? own.find((tab) => tab.key === state.side[workspaceId]) : undefined;
+ const current = beside ?? own.find((tab) => tab.key === state.active[workspaceId]) ?? own[own.length - 1];
if (!current) return;
const handled = () => {
event.preventDefault();
@@ -169,7 +186,9 @@ export function CodeEditorStage({
else void saveFile(current.fileKey);
} else if (key === "w" && !event.shiftKey) {
handled();
- requestCloseRef.current([current.key]);
+ // In the second editor, Ctrl+W ends the split; the tab stays open.
+ if (beside) state.closeSide(workspaceId);
+ else requestCloseRef.current([current.key]);
} else if (key === "tab" || key === "pagedown" || key === "pageup") {
handled();
state.cycle(workspaceId, event.shiftKey || key === "pageup" ? -1 : 1);
@@ -185,15 +204,15 @@ export function CodeEditorStage({
return () => window.removeEventListener("keydown", onKey, true);
}, [workspaceId]);
- // Notice an agent's edit to the open file: on a timer and when the window regains focus.
- const activeFileKey = shown ? activeTab.fileKey : null;
+ // Notice an agent's edit to the open files: on a timer and when the window regains focus.
+ const watchedFileKeys = shown ? [...new Set([activeTab.fileKey, ...(sideTab ? [sideTab.fileKey] : [])])].join("\n") : "";
useEffect(() => {
- if (!activeFileKey) return;
+ if (!watchedFileKeys) return;
let alive = true;
let timer: number | undefined;
const check = () => {
if (document.visibilityState === "visible" && useEventStore.getState().activeSection === "agentic-ide") {
- void checkDisk(activeFileKey);
+ for (const fileKey of watchedFileKeys.split("\n")) void checkDisk(fileKey);
}
};
const tick = () => {
@@ -207,7 +226,7 @@ export function CodeEditorStage({
window.clearTimeout(timer);
window.removeEventListener("focus", check);
};
- }, [activeFileKey]);
+ }, [watchedFileKeys]);
const duplicateNames = useMemo(() => {
// Two different files with one name get their folder beside it; the edit
@@ -227,14 +246,30 @@ export function CodeEditorStage({
if (!shown) return quick;
const store = useCodeEditorStore.getState();
- const segments = activeTab.path.split("/");
+ const starting = (
+ <p className="flex h-full items-center justify-center gap-2 text-sm text-muted-foreground">
+ <Loader2 className="h-4 w-4 animate-spin" aria-hidden />
+ {t("code_editor.starting")}
+ </p>
+ );
+ const shownTab = sideFocused && sideTab ? sideTab : activeTab;
+ const shownFile = files[shownTab.fileKey];
+ const segments = shownTab.path.split("/");
+
+ // Dragging the divider between the two editors.
+ const dragSplit = (event: ReactPointerEvent<HTMLDivElement>) => {
+ const host = splitHost.current;
+ if (!dragging.current || !host) return;
+ const rect = host.getBoundingClientRect();
+ if (rect.width > 0) setSplit(clampSplit((event.clientX - rect.left) / rect.width));
+ };
return (
<>
<div
ref={stage}
data-testid="code-editor"
- data-path={activeTab.path}
+ data-path={shownTab.path}
className="absolute inset-0 z-20 flex min-h-0 flex-col bg-background"
>
{/* Tab bar */}
@@ -278,10 +313,15 @@ export function CodeEditorStage({
active ? "bg-background text-foreground-strong" : "text-muted-foreground hover:bg-secondary/60 hover:text-foreground",
)}
>
- {active && <span className="absolute inset-x-0 top-0 h-px bg-primary" aria-hidden />}
+ {active && <span className={cn("absolute inset-x-0 top-0 h-px", sideFocused ? "bg-muted-foreground/50" : "bg-primary")} aria-hidden />}
{tab.mode === "diff" ? <FileDiff className="h-3.5 w-3.5 shrink-0 text-muted-foreground" aria-hidden /> : <FileTypeIcon path={tab.path} />}
<span className={cn("truncate", tab.preview && "italic", file?.deleted && "line-through decoration-destructive/70")}>{name}</span>
{(duplicateNames.get(name) ?? 0) > 1 && folder && <span className="shrink-0 truncate text-[11px] text-muted-foreground">{folder}</span>}
+ {sideTab?.key === tab.key && (
+ <span title={t("code_editor.side_tab_hint")} data-testid="code-editor-tab-side" className="inline-flex shrink-0 text-muted-foreground">
+ <Columns2 className="h-3 w-3" aria-hidden />
+ </span>
+ )}
<button
type="button"
aria-label={fill(t("code_editor.close_tab"), { file: name })}
@@ -326,29 +366,29 @@ export function CodeEditorStage({
<span className={cn("truncate", index === segments.length - 1 && "text-foreground")}>{segment}</span>
</span>
))}
- {activeTab.mode === "diff" && <span className="ml-1.5 shrink-0 rounded bg-secondary px-1.5 py-px text-[11px]">{diffBases[activeTab.fileKey]?.label ?? t("code_editor.diff_badge")}</span>}
+ {shownTab.mode === "diff" && <span className="ml-1.5 shrink-0 rounded bg-secondary px-1.5 py-px text-[11px]">{diffBases[shownTab.fileKey]?.label ?? t("code_editor.diff_badge")}</span>}
</nav>
- {activeTab.mode === "edit" && activeFile?.status === "ready" && renderKindOf(activeTab.path) && (
+ {shownTab.mode === "edit" && shownFile?.status === "ready" && renderKindOf(shownTab.path) && (
<ActionButton
- onClick={() => toggleRendered(activeTab.key)}
- icon={rendered.has(activeTab.key) ? <Code2 className="h-3.5 w-3.5" aria-hidden /> : <Eye className="h-3.5 w-3.5" aria-hidden />}
- label={rendered.has(activeTab.key) ? t("code_editor.show_source") : t("code_editor.preview")}
+ onClick={() => toggleRendered(shownTab.key)}
+ icon={rendered.has(shownTab.key) ? <Code2 className="h-3.5 w-3.5" aria-hidden /> : <Eye className="h-3.5 w-3.5" aria-hidden />}
+ label={rendered.has(shownTab.key) ? t("code_editor.show_source") : t("code_editor.preview")}
hint="Ctrl+Shift+V"
wide
/>
)}
{/* A text comparison only means something for a text file. */}
- {(activeTab.mode === "diff" || activeFile?.status === "ready") && (
+ {(shownTab.mode === "diff" || shownFile?.status === "ready") && (
<ActionButton
- onClick={() => store.openFile(workspaceId, activeTab.path, { mode: activeTab.mode === "diff" ? "edit" : "diff", preview: false })}
- icon={activeTab.mode === "diff" ? <FileText className="h-3.5 w-3.5" aria-hidden /> : <FileDiff className="h-3.5 w-3.5" aria-hidden />}
- label={activeTab.mode === "diff" ? t("code_editor.open_file") : t("code_editor.open_changes")}
+ onClick={() => store.openFile(workspaceId, shownTab.path, { mode: shownTab.mode === "diff" ? "edit" : "diff", preview: false })}
+ icon={shownTab.mode === "diff" ? <FileText className="h-3.5 w-3.5" aria-hidden /> : <FileDiff className="h-3.5 w-3.5" aria-hidden />}
+ label={shownTab.mode === "diff" ? t("code_editor.open_file") : t("code_editor.open_changes")}
/>
)}
{stagedPane && (
<ActionButton
onClick={() =>
- void attachToTerminal(stagedPane, { paths: [absolute(activeTab.path)] }).catch((error: unknown) =>
+ void attachToTerminal(stagedPane, { paths: [absolute(shownTab.path)] }).catch((error: unknown) =>
pushToast("error", (error as Error).message),
)
}
@@ -357,44 +397,114 @@ export function CodeEditorStage({
/>
)}
<ActionButton
- onClick={() => openExternally(activeTab.path)}
+ onClick={() => openExternally(shownTab.path)}
icon={<ExternalLink className="h-3.5 w-3.5" aria-hidden />}
label={t("code_editor.open_externally")}
iconOnly
/>
</div>
- {activeFile?.conflict && (
+ {shownFile?.conflict && (
<Banner tone="warning" testId="code-editor-conflict" text={t("code_editor.conflict")}>
- <BannerButton onClick={() => void revertFile(activeTab.fileKey)}>{t("code_editor.conflict_load_disk")}</BannerButton>
- <BannerButton onClick={() => void saveFile(activeTab.fileKey, { overwrite: true })}>{t("code_editor.conflict_keep_mine")}</BannerButton>
+ <BannerButton onClick={() => void revertFile(shownTab.fileKey)}>{t("code_editor.conflict_load_disk")}</BannerButton>
+ <BannerButton onClick={() => void saveFile(shownTab.fileKey, { overwrite: true })}>{t("code_editor.conflict_keep_mine")}</BannerButton>
</Banner>
)}
- {activeFile?.mixedEol && !activeFile.conflict && (
+ {shownFile?.mixedEol && !shownFile.conflict && (
<Banner
tone="muted"
testId="code-editor-mixed-eol"
- text={fill(t("code_editor.mixed_eol"), { eol: activeFile.eol === "\r\n" ? "CRLF" : "LF" })}
+ text={fill(t("code_editor.mixed_eol"), { eol: shownFile.eol === "\r\n" ? "CRLF" : "LF" })}
/>
)}
- {activeFile?.deleted && !activeFile.conflict && (
+ {shownFile?.deleted && !shownFile.conflict && (
<Banner tone="muted" testId="code-editor-deleted" text={t("code_editor.deleted")} />
)}
- <div className="relative min-h-0 flex-1">
- <Suspense
- fallback={
- <p className="flex h-full items-center justify-center gap-2 text-sm text-muted-foreground">
- <Loader2 className="h-4 w-4 animate-spin" aria-hidden />
- {t("code_editor.starting")}
- </p>
- }
+ <div ref={splitHost} className="flex min-h-0 flex-1">
+ <div
+ data-testid="code-editor-main"
+ className="relative min-h-0 min-w-0"
+ style={{ flex: sideTab ? `${split} 1 0%` : "1 1 0%" }}
+ onFocusCapture={() => store.focusGroup(false)}
+ onPointerDownCapture={() => store.focusGroup(false)}
>
- <EditorSurface tab={activeTab} rendered={rendered.has(activeTab.key)} onOpenExternally={openExternally} />
- </Suspense>
+ <Suspense fallback={starting}>
+ <EditorSurface tab={activeTab} rendered={rendered.has(activeTab.key)} onOpenExternally={openExternally} />
+ </Suspense>
+ </div>
+ {sideTab && (
+ <>
+ <div
+ role="separator"
+ aria-orientation="vertical"
+ aria-label={t("code_editor.resize_split")}
+ aria-valuemin={SPLIT_MIN * 100}
+ aria-valuemax={SPLIT_MAX * 100}
+ aria-valuenow={Math.round(split * 100)}
+ tabIndex={0}
+ title={t("code_editor.resize_split")}
+ data-testid="code-editor-split-handle"
+ onPointerDown={(event) => {
+ event.preventDefault();
+ dragging.current = true;
+ event.currentTarget.setPointerCapture?.(event.pointerId);
+ }}
+ onPointerMove={dragSplit}
+ onPointerUp={(event) => {
+ dragging.current = false;
+ event.currentTarget.releasePointerCapture?.(event.pointerId);
+ }}
+ onPointerCancel={() => {
+ dragging.current = false;
+ }}
+ onDoubleClick={() => setSplit(0.5)}
+ onKeyDown={(event) => {
+ if (event.key !== "ArrowLeft" && event.key !== "ArrowRight") return;
+ event.preventDefault();
+ setSplit((current) => clampSplit(current + (event.key === "ArrowLeft" ? -0.05 : 0.05)));
+ }}
+ className="w-1 shrink-0 cursor-col-resize bg-border/70 transition-colors hover:bg-primary/60 focus-visible:bg-primary/60 focus-visible:outline-none"
+ />
+ <section
+ aria-label={t("code_editor.side_label")}
+ data-testid="code-editor-side"
+ data-path={sideTab.path}
+ data-focused={sideFocused || undefined}
+ className="flex min-h-0 min-w-0 flex-col"
+ style={{ flex: `${1 - split} 1 0%` }}
+ onFocusCapture={() => store.focusGroup(true)}
+ onPointerDownCapture={() => store.focusGroup(true)}
+ >
+ <div className="relative flex h-8 shrink-0 items-center gap-1.5 border-b border-border/50 bg-sidebar pl-3 pr-1.5 text-[13px]">
+ {sideFocused && <span className="absolute inset-x-0 top-0 h-px bg-primary" aria-hidden />}
+ {sideTab.mode === "diff" ? <FileDiff className="h-3.5 w-3.5 shrink-0 text-muted-foreground" aria-hidden /> : <FileTypeIcon path={sideTab.path} />}
+ <span className={cn("min-w-0 flex-1 truncate", sideFocused ? "text-foreground-strong" : "text-muted-foreground")} title={sideTab.path}>
+ {baseName(sideTab.path)}
+ </span>
+ {files[sideTab.fileKey]?.dirty && <span className="h-2 w-2 shrink-0 rounded-full bg-foreground/70" aria-hidden />}
+ <button
+ type="button"
+ data-testid="code-editor-side-close"
+ aria-label={t("code_editor.close_side")}
+ title={t("code_editor.close_side")}
+ onClick={() => store.closeSide(workspaceId)}
+ className="inline-flex h-5 w-5 shrink-0 items-center justify-center rounded text-muted-foreground hover:bg-secondary hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"
+ >
+ <X className="h-3.5 w-3.5" aria-hidden />
+ </button>
+ </div>
+ <div className="relative min-h-0 flex-1">
+ <Suspense fallback={starting}>
+ <EditorSurface tab={sideTab} rendered={rendered.has(sideTab.key)} secondary onOpenExternally={openExternally} />
+ </Suspense>
+ </div>
+ </section>
+ </>
+ )}
</div>
- <StatusBar fileKey={activeTab.fileKey} />
+ <StatusBar fileKey={shownTab.fileKey} />
</div>
<ThreadPopover anchor={menuAnchor} open={menu !== null} onClose={() => setMenu(null)} label={t("code_editor.tab_menu")} width={230}>
@@ -405,6 +515,8 @@ export function CodeEditorStage({
<ThreadMenuItem icon={<span aria-hidden />} label={t("code_editor.menu.close_saved")} onSelect={() => { setMenu(null); requestClose(tabs.filter((tab) => !files[tab.fileKey]?.dirty).map((tab) => tab.key)); }} />
<ThreadMenuItem icon={<span aria-hidden />} label={t("code_editor.menu.close_all")} onSelect={() => { setMenu(null); requestClose(tabs.map((tab) => tab.key)); }} />
<ThreadMenuSeparator />
+ <ThreadMenuItem icon={<Columns2 className="h-4 w-4" />} label={t("code_editor.menu.open_side")} onSelect={() => { setMenu(null); store.openToSide(workspaceId, menu.path, { mode: menu.mode }); }} />
+ <ThreadMenuSeparator />
<ThreadMenuItem icon={<Copy className="h-4 w-4" />} label={t("code_editor.menu.copy_path")} onSelect={() => { setMenu(null); copyText(absolute(menu.path)); }} />
<ThreadMenuItem icon={<span aria-hidden />} label={t("code_editor.menu.copy_relative_path")} onSelect={() => { setMenu(null); copyText(menu.path); }} />
<ThreadMenuItem icon={<FolderSearch className="h-4 w-4" />} label={t("code_editor.menu.reveal")} onSelect={() => { setMenu(null); revealInExplorer({ workspaceId, path: menu.path }); }} />
diff --git a/jarvis/ui/web/frontend/src/components/agentic/editor/EditorSurface.tsx b/jarvis/ui/web/frontend/src/components/agentic/editor/EditorSurface.tsx
index 1cedb572a8..95c1141cdb 100644
--- a/jarvis/ui/web/frontend/src/components/agentic/editor/EditorSurface.tsx
+++ b/jarvis/ui/web/frontend/src/components/agentic/editor/EditorSurface.tsx
@@ -51,9 +51,12 @@ const keepContextMenu = (event: MouseEvent) => event.stopPropagation();
export default function EditorSurface({
tab,
rendered,
+ secondary = false,
onOpenExternally,
}: {
tab: EditorTab;
+ /** The second editor of a split view: closing it leaves the first one's status bar alone. */
+ secondary?: boolean;
/** Show a Markdown, HTML or SVG file rendered instead of its source. */
rendered: boolean;
onOpenExternally: (path: string) => void;
@@ -95,8 +98,10 @@ export default function EditorSurface({
diffRef.current?.dispose();
diffRef.current = null;
editorRef.current = null;
- useCodeEditorStore.getState().setCursor(null);
+ if (!secondary) useCodeEditorStore.getState().setCursor(null);
};
+ // `secondary` never changes for a mounted editor.
+ // eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
useEffect(() => {
diff --git a/jarvis/ui/web/frontend/src/components/agentic/editor/editorModels.ts b/jarvis/ui/web/frontend/src/components/agentic/editor/editorModels.ts
index 885fbe8ee8..460fecf426 100644
--- a/jarvis/ui/web/frontend/src/components/agentic/editor/editorModels.ts
+++ b/jarvis/ui/web/frontend/src/components/agentic/editor/editorModels.ts
@@ -339,7 +339,11 @@ export function loadHead(fileKey: string): Promise<Monaco.editor.ITextModel | nu
if (!file || !api) return null;
let text: string | null = null;
try {
- text = await fetchHeadText(file.workspaceId, file.path, store().diffBases[fileKey]?.ref);
+ const base = store().diffBases[fileKey];
+ // A file-to-file compare reads the other file from disk; any other diff asks git.
+ text = base?.path
+ ? (await loadTextFile(file.workspaceId, base.path)).text
+ : await fetchHeadText(file.workspaceId, file.path, base?.ref);
} catch (error) {
toast((error as Error).message);
}
diff --git a/jarvis/ui/web/frontend/src/components/agentic/sidePanel/IdeSidePanel.tsx b/jarvis/ui/web/frontend/src/components/agentic/sidePanel/IdeSidePanel.tsx
index f9b21faccd..e08eae1655 100644
--- a/jarvis/ui/web/frontend/src/components/agentic/sidePanel/IdeSidePanel.tsx
+++ b/jarvis/ui/web/frontend/src/components/agentic/sidePanel/IdeSidePanel.tsx
@@ -339,7 +339,10 @@ export function IdeSidePanel({ appearance, onScreen = true }: { appearance?: Ter
))}
{terminals.map((terminal) => <div key={terminal.id} hidden={!open || terminal.id !== active}
className="absolute inset-0" data-testid={`ide-side-panel-terminal-${terminal.id}`}>
- <WorkspaceTerminal paneKey={terminal.id} agentName="shell" workspaceId={terminal.workspaceId}
+ {/* A terminal opened on a folder of the tree starts there; `folder` only
+ counts when no workspace id is named. */}
+ <WorkspaceTerminal paneKey={terminal.id} agentName="shell"
+ workspaceId={terminal.folder ? undefined : terminal.workspaceId} folder={terminal.folder}
title={`${t("ide_side_panel.terminal_label")} ${terminal.number} · ${terminal.workspaceName}`}
active={onScreen && open && terminal.id === active} appearance={appearance} />
</div>)}
diff --git a/jarvis/ui/web/frontend/src/components/agentic/sidePanel/explorer/ExplorerPanel.test.tsx b/jarvis/ui/web/frontend/src/components/agentic/sidePanel/explorer/ExplorerPanel.test.tsx
index 65af2418a7..40e8882c64 100644
--- a/jarvis/ui/web/frontend/src/components/agentic/sidePanel/explorer/ExplorerPanel.test.tsx
+++ b/jarvis/ui/web/frontend/src/components/agentic/sidePanel/explorer/ExplorerPanel.test.tsx
@@ -221,6 +221,88 @@ describe("ExplorerPanel", () => {
expect(sent).toEqual({ source: "README.md", destination: "src/README.md" });
});
+ const openRowMenu = async (path: string) => {
+ render(<ExplorerPanel view="files" />);
+ await waitFor(() => expect(screen.getAllByTestId("explorer-tree-row")).toHaveLength(2));
+ const row = screen.getAllByTestId("explorer-tree-row").find((entry) => entry.dataset.path === path)!;
+ fireEvent.contextMenu(row, { clientX: 40, clientY: 60 });
+ return { row, menu: await screen.findByTestId("explorer-menu") };
+ };
+ const item = (menu: HTMLElement, name: RegExp) =>
+ [...menu.querySelectorAll<HTMLButtonElement>('[role="menuitem"]')].find((entry) => name.test(entry.textContent ?? ""));
+
+ it("offers the folder actions on a right-click, with paste greyed out until something is copied", async () => {
+ const { row, menu } = await openRowMenu("src");
+ expect(row.dataset.selected).toBe("true");
+ for (const name of [/New file/, /New folder/, /Open in terminal/, /Find in folder/, /Cut/, /Copy path/, /Copy relative path/, /Rename/, /Delete/]) {
+ expect(item(menu, name), String(name)).toBeTruthy();
+ }
+ expect(item(menu, /Paste/)?.disabled).toBe(true);
+ // Comparing is for files.
+ expect(item(menu, /Select for compare/)).toBeUndefined();
+ });
+
+ it("shows an entry in the system file manager", async () => {
+ const { menu } = await openRowMenu("README.md");
+ fireEvent.click(item(menu, /Reveal in|Open containing folder/)!);
+ await waitFor(() => expect(calls.some((call) => call.url.endsWith("terminal-target/reveal"))).toBe(true));
+ const sent = JSON.parse(calls.find((call) => call.url.endsWith("terminal-target/reveal"))!.body);
+ expect(sent).toEqual({ workspace_id: "w1", target: "README.md" });
+ expect(calls.some((call) => call.url.endsWith("terminal-target/open"))).toBe(false);
+ });
+
+ it("opens a terminal in the right-clicked folder", async () => {
+ useIdeSidePanelStore.setState({ terminals: [] });
+ const { menu } = await openRowMenu("src");
+ fireEvent.click(item(menu, /Open in terminal/)!);
+ expect(useIdeSidePanelStore.getState().terminals).toMatchObject([{ workspaceId: "w1", workspaceName: "src", folder: "/code/app/src" }]);
+ });
+
+ it("opens the Search tab for Find in folder", async () => {
+ const { menu } = await openRowMenu("src");
+ fireEvent.click(item(menu, /Find in folder/)!);
+ expect(useIdeSidePanelStore.getState()).toMatchObject({ open: true, active: "search" });
+ });
+
+ it("compares a file with the one selected for compare", async () => {
+ const { menu } = await openRowMenu("README.md");
+ fireEvent.click(item(menu, /Select for compare/)!);
+ fireEvent.click(screen.getAllByTestId("explorer-tree-row")[0]);
+ await waitFor(() => expect(screen.getAllByTestId("explorer-tree-row")).toHaveLength(3));
+ const other = screen.getAllByTestId("explorer-tree-row").find((entry) => entry.dataset.path === "src/app.ts")!;
+ fireEvent.contextMenu(other, { clientX: 40, clientY: 90 });
+ fireEvent.click(item(await screen.findByTestId("explorer-menu"), /Compare with README\.md/)!);
+ const state = useCodeEditorStore.getState();
+ expect(state.tabs).toMatchObject([{ path: "src/app.ts", mode: "diff", preview: false }]);
+ expect(Object.values(state.diffBases)).toMatchObject([{ path: "README.md" }]);
+ });
+
+ it("opens a file beside the one already open, from the menu and with Ctrl+Enter", async () => {
+ useCodeEditorStore.setState({ side: {}, sideFocused: false });
+ useCodeEditorStore.getState().openFile("w1", "notes.md", { preview: false });
+ const { row, menu } = await openRowMenu("README.md");
+ fireEvent.click(item(menu, /Open to the side/)!);
+ const tabKey = (path: string) => useCodeEditorStore.getState().tabs.find((tab) => tab.path === path)!.key;
+ expect(useCodeEditorStore.getState().side.w1).toBe(tabKey("README.md"));
+ expect(useCodeEditorStore.getState().active.w1).toBe(tabKey("notes.md"));
+
+ useCodeEditorStore.getState().closeSide("w1");
+ fireEvent.keyDown(row, { key: "Enter", ctrlKey: true });
+ expect(useCodeEditorStore.getState().side.w1).toBe(tabKey("README.md"));
+ });
+
+ it("copies the path with Shift+Alt+C and the relative path with Ctrl+K Ctrl+Shift+C", async () => {
+ const written: string[] = [];
+ vi.stubGlobal("navigator", { ...navigator, userAgent: navigator.userAgent, clipboard: { writeText: async (text: string) => void written.push(text) } });
+ render(<ExplorerPanel view="files" />);
+ await waitFor(() => expect(screen.getAllByTestId("explorer-tree-row")).toHaveLength(2));
+ const readme = screen.getAllByTestId("explorer-tree-row")[1];
+ fireEvent.keyDown(readme, { key: "C", code: "KeyC", shiftKey: true, altKey: true });
+ fireEvent.keyDown(readme, { key: "k", code: "KeyK", ctrlKey: true });
+ fireEvent.keyDown(readme, { key: "C", code: "KeyC", ctrlKey: true, shiftKey: true });
+ expect(written).toEqual(["/code/app/README.md", "README.md"]);
+ });
+
it("asks before deleting and sends the file to the trash", async () => {
render(<ExplorerPanel view="files" />);
await waitFor(() => expect(screen.getAllByTestId("explorer-tree-row")).toHaveLength(2));
diff --git a/jarvis/ui/web/frontend/src/components/agentic/sidePanel/explorer/ExplorerPanel.tsx b/jarvis/ui/web/frontend/src/components/agentic/sidePanel/explorer/ExplorerPanel.tsx
index bd798db323..831c7bfc50 100644
--- a/jarvis/ui/web/frontend/src/components/agentic/sidePanel/explorer/ExplorerPanel.tsx
+++ b/jarvis/ui/web/frontend/src/components/agentic/sidePanel/explorer/ExplorerPanel.tsx
@@ -3,14 +3,18 @@ import {
ChevronRight,
ChevronsDownUp,
ClipboardPaste,
+ Columns2,
Copy,
CopyPlus,
ExternalLink,
+ FileDiff,
FilePlus,
Folder,
FolderOpen,
FolderPlus,
+ FolderSearch,
GitBranch,
+ GitCompareArrows,
Loader2,
Pencil,
RefreshCw,
@@ -18,6 +22,7 @@ import {
Search,
SquareArrowOutUpRight,
SquarePen,
+ SquareTerminal,
Trash2,
X,
} from "lucide-react";
@@ -27,6 +32,7 @@ import {
attachToTerminal,
fetchWorkspaceFiles,
openTerminalTarget,
+ revealTerminalTarget,
type WorkspaceFileItem,
} from "@/lib/agenticIdeApi";
import { setWorkspaceDragPaths } from "@/components/agentic/paneDrop";
@@ -39,6 +45,9 @@ import { useCodeEditorStore, isUnder } from "@/store/codeEditor";
import { useEventStore } from "@/store/events";
import { useIdeChatStore } from "@/store/ideChat";
import { useIdeExplorerStore, type ExplorerView } from "@/store/ideExplorer";
+import { MAX_TERMINAL_TABS, useIdeSidePanelStore } from "@/store/ideSidePanel";
+import { isMacClient } from "@/lib/embeddedDesktop";
+import { searchInFolder } from "@/components/agentic/sidePanel/search/SearchPanel";
import { paneTitleFrom, recapsFor, usePaneRecapPoll, usePaneRecapsStore } from "@/store/paneRecaps";
import { useWorkspacePanesStore } from "@/store/workspacePanes";
import {
@@ -75,6 +84,16 @@ const baseName = (path: string) => path.split("/").filter(Boolean).pop() ?? path
const parentPath = (path: string) => path.split("/").slice(0, -1).join("/");
const joinPath = (folder: string, name: string) => (folder ? `${folder}/${name}` : name);
+/** How long after Ctrl+K the second key of a two-step shortcut still counts. */
+const CHORD_WINDOW_MS = 2000;
+
+/** The file manager goes by a different name on each system. */
+function revealLabelKey(): string {
+ const agent = typeof navigator === "undefined" ? "" : navigator.userAgent;
+ if (isMacClient(agent)) return "ide_side_panel.explorer.reveal_mac";
+ return /win/i.test(agent) ? "ide_side_panel.explorer.reveal_windows" : "ide_side_panel.explorer.reveal_linux";
+}
+
/** The tree's own drag payload: the workspace paths being moved. */
const EXPLORER_DRAG_TYPE = "application/x-jarvis-explorer-paths";
@@ -545,7 +564,11 @@ function FileTree({
const [error, setError] = useState("");
const [renaming, setRenaming] = useState<string | null>(null);
const [focused, setFocused] = useState<string | null>(null);
- const [menu, setMenu] = useState<{ path: string; isDirectory: boolean } | null>(null);
+ const workspaceName = useIdeChatStore((state) => state.workspace?.name ?? "");
+ const [menu, setMenu] = useState<{ path: string; isDirectory: boolean; point: { x: number; y: number } } | null>(null);
+ // "Select for compare" remembers one file; "Compare with …" on another opens the two side by side.
+ const [compareFrom, setCompareFrom] = useState<string | null>(null);
+ const chordAt = useRef(0);
const [confirm, setConfirm] = useState<{ paths: string[]; isDirectory: boolean; permanent: boolean } | null>(null);
// Several rows can be selected (Ctrl/Cmd+click, Shift+click) for delete,
// cut/copy/paste and drag; a plain click selects one row again.
@@ -789,6 +812,30 @@ function FileTree({
};
const copy = (text: string) => void navigator.clipboard?.writeText(text).catch(fail);
+ /** The path as the system writes it; the workspace folder itself for "". */
+ const fullPath = (path: string) => (path ? absolute(path) : absolute("").replace(/[\\/]+$/, ""));
+
+ /** Show the entry selected in the system file manager. */
+ const revealInSystem = (path: string) => void revealTerminalTarget(workspaceId, path || ".").catch(fail);
+
+ /** A plain terminal in the side panel, started in `folder`. */
+ const openTerminal = (folder: string) => {
+ const panel = useIdeSidePanelStore.getState();
+ if (panel.terminals.filter((terminal) => terminal.workspaceId === workspaceId).length >= MAX_TERMINAL_TABS) {
+ pushToast("error", t("ide_side_panel.terminal_limit"));
+ return;
+ }
+ panel.addTerminalTab(workspaceId, folder ? baseName(folder) : workspaceName, folder ? absolute(folder) : undefined);
+ };
+
+ const compareWith = (path: string) => {
+ if (!compareFrom) return;
+ editor.openFile(workspaceId, path, {
+ mode: "diff",
+ preview: false,
+ base: { ref: `file:${compareFrom}`, path: compareFrom, label: `${baseName(compareFrom)} ↔ ${baseName(path)}` },
+ });
+ };
const rows: Row[] = [];
const walk = (path: string, depth: number) => {
@@ -806,7 +853,27 @@ function FileTree({
walk("", 0);
const onRowKey = (event: ReactKeyboardEvent, item: WorkspaceFileItem) => {
- if (event.key === "F2") {
+ // The physical key: Alt changes the typed character on some keyboards.
+ const letter = event.code?.startsWith("Key") ? event.code.slice(3).toLowerCase() : event.key.toLowerCase();
+ const mod = event.ctrlKey || event.metaKey;
+ if (event.shiftKey && event.altKey && !mod && ["r", "c", "f"].includes(letter)) {
+ event.preventDefault();
+ if (letter === "r") revealInSystem(item.path);
+ else if (letter === "c") copy(fullPath(item.path));
+ else searchInFolder(folderFor(item.path));
+ } else if (mod && !event.shiftKey && !event.altKey && letter === "k") {
+ // First half of Ctrl+K Ctrl+Shift+C.
+ event.preventDefault();
+ chordAt.current = Date.now();
+ } else if (mod && event.shiftKey && letter === "c" && Date.now() - chordAt.current < CHORD_WINDOW_MS) {
+ event.preventDefault();
+ chordAt.current = 0;
+ copy(item.path);
+ } else if (event.key === "Enter" && mod && !item.is_directory) {
+ // Ctrl+Enter: beside the file already open, instead of in its place.
+ event.preventDefault();
+ editor.openToSide(workspaceId, item.path);
+ } else if (event.key === "F2") {
event.preventDefault();
setRenaming(item.path);
} else if (event.key === "Delete") {
@@ -840,7 +907,12 @@ function FileTree({
event.preventDefault();
event.stopPropagation();
menuAnchor.current = event.currentTarget;
- setMenu({ path, isDirectory });
+ // The menu acts on the row under the pointer; a row outside the selection replaces it.
+ if (path) {
+ setFocused(path);
+ if (!selected.has(path)) setSelected(new Set([path]));
+ }
+ setMenu({ path, isDirectory, point: { x: event.clientX, y: event.clientY } });
};
if (!children[""] && loading.has("")) {
@@ -1010,34 +1082,53 @@ function FileTree({
})}
</ul>
- <ThreadPopover anchor={menuAnchor} open={menu !== null} onClose={() => setMenu(null)} label={t("ide_side_panel.explorer.menu_label")} width={240}>
+ <ThreadPopover anchor={menuAnchor} point={menu?.point} open={menu !== null} onClose={() => setMenu(null)} label={t("ide_side_panel.explorer.menu_label")} width={300}>
{menu && (
<div role="menu" data-testid="explorer-menu">
<ThreadMenuItem icon={<FilePlus className="h-4 w-4" />} label={t("ide_side_panel.explorer.new_file")} onSelect={pick(() => onCreate(menuFolder, "file"))} />
<ThreadMenuItem icon={<FolderPlus className="h-4 w-4" />} label={t("ide_side_panel.explorer.new_folder")} onSelect={pick(() => onCreate(menuFolder, "directory"))} />
- {clip && (
- <ThreadMenuItem
- icon={<ClipboardPaste className="h-4 w-4" />}
- label={t("ide_side_panel.explorer.paste")}
- hint="Ctrl+V"
- onSelect={pick(() => void paste(menuFolder))}
- />
+ <ThreadMenuSeparator />
+ {menu.path && !menu.isDirectory && (
+ <>
+ <ThreadMenuItem icon={<SquarePen className="h-4 w-4" />} label={t("ide_side_panel.explorer.open_editor")} onSelect={pick(() => editor.openFile(workspaceId, menu.path, { preview: false }))} />
+ <ThreadMenuItem icon={<Columns2 className="h-4 w-4" />} label={t("ide_side_panel.explorer.open_side")} hint="Ctrl+Enter" onSelect={pick(() => editor.openToSide(workspaceId, menu.path))} />
+ <ThreadMenuItem icon={<ExternalLink className="h-4 w-4" />} label={t("ide_side_panel.explorer.open_externally")} onSelect={pick(() => void openTerminalTarget(workspaceId, menu.path).catch(fail))} />
+ </>
)}
- {menu.path && (
+ <ThreadMenuItem icon={<FolderSearch className="h-4 w-4" />} label={t(revealLabelKey())} hint="Shift+Alt+R" onSelect={pick(() => revealInSystem(menu.path))} />
+ <ThreadMenuItem icon={<SquareTerminal className="h-4 w-4" />} label={t("ide_side_panel.explorer.open_terminal")} onSelect={pick(() => openTerminal(menuFolder))} />
+ {menu.isDirectory && (
<>
<ThreadMenuSeparator />
- {!menu.isDirectory && (
- <ThreadMenuItem icon={<SquarePen className="h-4 w-4" />} label={t("ide_side_panel.explorer.open_editor")} onSelect={pick(() => editor.openFile(workspaceId, menu.path, { preview: false }))} />
- )}
- {stagedPane && (
+ <ThreadMenuItem icon={<Search className="h-4 w-4" />} label={t("ide_side_panel.explorer.find_in_folder")} hint="Shift+Alt+F" onSelect={pick(() => searchInFolder(menu.path))} />
+ </>
+ )}
+ {menu.path && !menu.isDirectory && (
+ <>
+ <ThreadMenuSeparator />
+ <ThreadMenuItem icon={<GitCompareArrows className="h-4 w-4" />} label={t("ide_side_panel.explorer.select_compare")} onSelect={pick(() => setCompareFrom(menu.path))} />
+ {compareFrom && compareFrom !== menu.path && (
<ThreadMenuItem
- icon={<SquareArrowOutUpRight className="h-4 w-4" />}
- label={fill(t("ide_side_panel.explorer.reference_in"), { pane: stagedPane })}
- onSelect={pick(() => void attachToTerminal(stagedPane, { paths: [absolute(menu.path)] }).catch(fail))}
+ icon={<FileDiff className="h-4 w-4" />}
+ label={fill(t("ide_side_panel.explorer.compare_with"), { file: baseName(compareFrom) })}
+ onSelect={pick(() => compareWith(menu.path))}
/>
)}
- <ThreadMenuItem icon={<ExternalLink className="h-4 w-4" />} label={t("ide_side_panel.explorer.open_externally")} onSelect={pick(() => void openTerminalTarget(workspaceId, menu.path).catch(fail))} />
+ </>
+ )}
+ {menu.path && stagedPane && (
+ <>
<ThreadMenuSeparator />
+ <ThreadMenuItem
+ icon={<SquareArrowOutUpRight className="h-4 w-4" />}
+ label={fill(t("ide_side_panel.explorer.reference_in"), { pane: stagedPane })}
+ onSelect={pick(() => void attachToTerminal(stagedPane, { paths: selectionFor(menu.path).map(absolute) }).catch(fail))}
+ />
+ </>
+ )}
+ <ThreadMenuSeparator />
+ {menu.path && (
+ <>
<ThreadMenuItem
icon={<Scissors className="h-4 w-4" />}
label={t("ide_side_panel.explorer.cut")}
@@ -1050,9 +1141,20 @@ function FileTree({
hint="Ctrl+C"
onSelect={pick(() => setClip({ paths: selectionFor(menu.path), cut: false }))}
/>
- <ThreadMenuSeparator />
- <ThreadMenuItem icon={<Copy className="h-4 w-4" />} label={t("ide_side_panel.explorer.copy_path")} onSelect={pick(() => copy(absolute(menu.path)))} />
- <ThreadMenuItem icon={<span aria-hidden />} label={t("ide_side_panel.explorer.copy_relative_path")} onSelect={pick(() => copy(menu.path))} />
+ </>
+ )}
+ <ThreadMenuItem
+ icon={<ClipboardPaste className="h-4 w-4" />}
+ label={t("ide_side_panel.explorer.paste")}
+ hint="Ctrl+V"
+ disabled={!clip}
+ onSelect={pick(() => void paste(menuFolder))}
+ />
+ <ThreadMenuSeparator />
+ <ThreadMenuItem icon={<Copy className="h-4 w-4" />} label={t("ide_side_panel.explorer.copy_path")} hint="Shift+Alt+C" onSelect={pick(() => copy(fullPath(menu.path)))} />
+ {menu.path && (
+ <>
+ <ThreadMenuItem icon={<span aria-hidden />} label={t("ide_side_panel.explorer.copy_relative_path")} hint="Ctrl+K Ctrl+Shift+C" onSelect={pick(() => copy(menu.path))} />
<ThreadMenuSeparator />
<ThreadMenuItem icon={<Pencil className="h-4 w-4" />} label={t("ide_side_panel.explorer.rename")} hint="F2" onSelect={pick(() => setRenaming(menu.path))} />
<ThreadMenuItem
diff --git a/jarvis/ui/web/frontend/src/components/agentic/sidePanel/search/SearchPanel.tsx b/jarvis/ui/web/frontend/src/components/agentic/sidePanel/search/SearchPanel.tsx
index 2cc92a8c82..cc2e7b98ff 100644
--- a/jarvis/ui/web/frontend/src/components/agentic/sidePanel/search/SearchPanel.tsx
+++ b/jarvis/ui/web/frontend/src/components/agentic/sidePanel/search/SearchPanel.tsx
@@ -5,6 +5,7 @@ import { fill, useT } from "@/i18n";
import { cn } from "@/lib/utils";
import { useCodeEditorStore, type EditorFile } from "@/store/codeEditor";
import { useIdeChatStore } from "@/store/ideChat";
+import { useIdeSidePanelStore } from "@/store/ideSidePanel";
import { replaceInFiles, searchWorkspace, type SearchQuery, type SearchResult } from "@/components/agentic/editor/editorApi";
import { checkDisk } from "@/components/agentic/editor/editorModels";
import { forgetFileList } from "@/components/agentic/editor/QuickOpen";
@@ -16,6 +17,16 @@ const SEARCH_DELAY_MS = 350;
/** Ask the Search tab to take the keyboard (Ctrl+Shift+F). */
export const SEARCH_FOCUS_EVENT = "jarvis:editor-search-focus";
+/** The folder a "Find in folder" asked for, until the Search tab picks it up. */
+let pendingFolder: string | null = null;
+
+/** Open the Search tab limited to one folder of the workspace ("" = all of it). */
+export function searchInFolder(folder: string): void {
+ pendingFolder = folder;
+ useIdeSidePanelStore.getState().openTab("search");
+ window.dispatchEvent(new Event(SEARCH_FOCUS_EVENT));
+}
+
const baseName = (path: string) => path.split("/").pop() ?? path;
const folderOf = (path: string) => path.split("/").slice(0, -1).join("/");
@@ -72,8 +83,17 @@ export function SearchPanel() {
);
useEffect(() => {
+ // "Find in folder" limits the search to that folder, shown in the filters.
+ const takeFolder = () => {
+ if (pendingFolder === null) return;
+ setInclude(pendingFolder);
+ setShowFilters(pendingFolder !== "");
+ pendingFolder = null;
+ };
+ takeFolder();
input.current?.focus();
const focus = () => {
+ takeFolder();
input.current?.focus();
input.current?.select();
};
diff --git a/jarvis/ui/web/frontend/src/components/agentic/threads/ThreadPopover.tsx b/jarvis/ui/web/frontend/src/components/agentic/threads/ThreadPopover.tsx
index 36c312ebf5..d58be95112 100644
--- a/jarvis/ui/web/frontend/src/components/agentic/threads/ThreadPopover.tsx
+++ b/jarvis/ui/web/frontend/src/components/agentic/threads/ThreadPopover.tsx
@@ -12,6 +12,7 @@ import { cn } from "@/lib/utils";
*/
export function ThreadPopover({
anchor,
+ point,
open,
onClose,
align = "start",
@@ -22,6 +23,8 @@ export function ThreadPopover({
children,
}: {
anchor: RefObject<HTMLElement | null>;
+ /** Open at this viewport position (a right-click) instead of below the anchor. */
+ point?: { x: number; y: number } | null;
open: boolean;
onClose: () => void;
align?: "start" | "end";
@@ -37,8 +40,10 @@ export function ThreadPopover({
const measure = useCallback(() => {
const host = anchor.current;
- if (!host) return;
- const rect = host.getBoundingClientRect();
+ if (!host && !point) return;
+ const rect = point
+ ? { left: point.x, right: point.x, top: point.y, bottom: point.y }
+ : host!.getBoundingClientRect();
const margin = 8;
const height = panel.current?.offsetHeight ?? 0;
const below = window.innerHeight - rect.bottom - margin;
@@ -49,7 +54,7 @@ export function ThreadPopover({
const room = Math.max(120, wantTop ? above - 4 : below - 4);
const top = wantTop ? Math.max(margin, rect.top - 4 - Math.min(height, room)) : rect.bottom + 4;
setPlace({ left: clampedLeft, top, maxHeight: room });
- }, [anchor, align, side, width]);
+ }, [anchor, point, align, side, width]);
useLayoutEffect(() => {
if (!open) { setPlace(null); return; }
diff --git a/jarvis/ui/web/frontend/src/i18n/locales/de.json b/jarvis/ui/web/frontend/src/i18n/locales/de.json
index 535088bb56..72a4eafa09 100644
--- a/jarvis/ui/web/frontend/src/i18n/locales/de.json
+++ b/jarvis/ui/web/frontend/src/i18n/locales/de.json
@@ -6657,6 +6657,10 @@
"tabs": "Geöffnete Dateien",
"close_tab": "{file} schließen",
"close_tab_hint": "Schließen (Strg+W)",
+ "close_side": "Seitlichen Editor schließen",
+ "side_label": "Seitlicher Editor",
+ "resize_split": "Größe der beiden Editoren ändern",
+ "side_tab_hint": "Im seitlichen Editor geöffnet",
"show_terminals": "Terminals",
"show_terminals_hint": "Terminals zeigen; deine Dateien bleiben offen",
"breadcrumbs": "Dateipfad",
@@ -6683,6 +6687,7 @@
"close_all": "Alle schließen",
"copy_path": "Pfad kopieren",
"copy_relative_path": "Relativen Pfad kopieren",
+ "open_side": "An der Seite öffnen",
"reveal": "Im Ordner zeigen"
},
"status": {
@@ -6782,6 +6787,14 @@
"paste": "Einfügen",
"delete_many_title": "{count} Einträge löschen?",
"busy_saving": "Eine Datei darin wird noch gespeichert. Versuche es gleich noch einmal.",
+ "open_side": "An der Seite öffnen",
+ "reveal_windows": "Im Datei-Explorer anzeigen",
+ "reveal_mac": "Im Finder anzeigen",
+ "reveal_linux": "Enthaltenden Ordner öffnen",
+ "open_terminal": "Im Terminal öffnen",
+ "find_in_folder": "In Ordner suchen…",
+ "select_compare": "Für Vergleich auswählen",
+ "compare_with": "Mit {file} vergleichen",
"cancel": "Abbrechen"
},
"search": {
diff --git a/jarvis/ui/web/frontend/src/i18n/locales/en.json b/jarvis/ui/web/frontend/src/i18n/locales/en.json
index 006e29936f..03fe60fb28 100644
--- a/jarvis/ui/web/frontend/src/i18n/locales/en.json
+++ b/jarvis/ui/web/frontend/src/i18n/locales/en.json
@@ -6657,6 +6657,10 @@
"tabs": "Open files",
"close_tab": "Close {file}",
"close_tab_hint": "Close (Ctrl+W)",
+ "close_side": "Close the side editor",
+ "side_label": "Side editor",
+ "resize_split": "Resize the two editors",
+ "side_tab_hint": "Shown in the side editor",
"show_terminals": "Terminals",
"show_terminals_hint": "Show the terminals; your files stay open",
"breadcrumbs": "File path",
@@ -6683,6 +6687,7 @@
"close_all": "Close all",
"copy_path": "Copy path",
"copy_relative_path": "Copy relative path",
+ "open_side": "Open to the side",
"reveal": "Reveal in Folder"
},
"status": {
@@ -6782,6 +6787,14 @@
"paste": "Paste",
"delete_many_title": "Delete {count} items?",
"busy_saving": "A file in there is still saving. Try again in a moment.",
+ "open_side": "Open to the side",
+ "reveal_windows": "Reveal in File Explorer",
+ "reveal_mac": "Reveal in Finder",
+ "reveal_linux": "Open containing folder",
+ "open_terminal": "Open in terminal",
+ "find_in_folder": "Find in folder…",
+ "select_compare": "Select for compare",
+ "compare_with": "Compare with {file}",
"cancel": "Cancel"
},
"search": {
diff --git a/jarvis/ui/web/frontend/src/i18n/locales/es.json b/jarvis/ui/web/frontend/src/i18n/locales/es.json
index 82d099dbfc..ae0a76e247 100644
--- a/jarvis/ui/web/frontend/src/i18n/locales/es.json
+++ b/jarvis/ui/web/frontend/src/i18n/locales/es.json
@@ -6657,6 +6657,10 @@
"tabs": "Archivos abiertos",
"close_tab": "Cerrar {file}",
"close_tab_hint": "Cerrar (Ctrl+W)",
+ "close_side": "Cerrar el editor lateral",
+ "side_label": "Editor lateral",
+ "resize_split": "Cambiar el tamaño de los dos editores",
+ "side_tab_hint": "Abierto en el editor lateral",
"show_terminals": "Terminales",
"show_terminals_hint": "Mostrar las terminales; tus archivos siguen abiertos",
"breadcrumbs": "Ruta del archivo",
@@ -6683,6 +6687,7 @@
"close_all": "Cerrar todas",
"copy_path": "Copiar ruta",
"copy_relative_path": "Copiar ruta relativa",
+ "open_side": "Abrir al lado",
"reveal": "Mostrar en la carpeta"
},
"status": {
@@ -6782,6 +6787,14 @@
"paste": "Pegar",
"delete_many_title": "¿Eliminar {count} elementos?",
"busy_saving": "Un archivo de ahí aún se está guardando. Inténtalo de nuevo en un momento.",
+ "open_side": "Abrir al lado",
+ "reveal_windows": "Mostrar en el Explorador de archivos",
+ "reveal_mac": "Mostrar en Finder",
+ "reveal_linux": "Abrir la carpeta contenedora",
+ "open_terminal": "Abrir en el terminal",
+ "find_in_folder": "Buscar en la carpeta…",
+ "select_compare": "Seleccionar para comparar",
+ "compare_with": "Comparar con {file}",
"cancel": "Cancelar"
},
"search": {
diff --git a/jarvis/ui/web/frontend/src/i18n/locales/zh.json b/jarvis/ui/web/frontend/src/i18n/locales/zh.json
index b750bbb3e1..9d9a8a4b37 100644
--- a/jarvis/ui/web/frontend/src/i18n/locales/zh.json
+++ b/jarvis/ui/web/frontend/src/i18n/locales/zh.json
@@ -6663,6 +6663,10 @@
"tabs": "已打开的文件",
"close_tab": "关闭 {file}",
"close_tab_hint": "关闭(Ctrl+W)",
+ "close_side": "关闭侧边编辑器",
+ "side_label": "侧边编辑器",
+ "resize_split": "调整两个编辑器的大小",
+ "side_tab_hint": "已在侧边编辑器中打开",
"show_terminals": "终端",
"show_terminals_hint": "显示终端;你的文件保持打开",
"breadcrumbs": "文件路径",
@@ -6689,6 +6693,7 @@
"close_all": "全部关闭",
"copy_path": "复制路径",
"copy_relative_path": "复制相对路径",
+ "open_side": "在侧边打开",
"reveal": "在文件夹中显示"
},
"status": {
@@ -6788,6 +6793,14 @@
"paste": "粘贴",
"delete_many_title": "要删除 {count} 项吗?",
"busy_saving": "里面有文件仍在保存。请稍后再试。",
+ "open_side": "在侧边打开",
+ "reveal_windows": "在文件资源管理器中显示",
+ "reveal_mac": "在访达中显示",
+ "reveal_linux": "打开所在文件夹",
+ "open_terminal": "在终端中打开",
+ "find_in_folder": "在文件夹中查找…",
+ "select_compare": "选择以进行比较",
+ "compare_with": "与 {file} 比较",
"cancel": "取消"
},
"search": {
diff --git a/jarvis/ui/web/frontend/src/lib/agenticIdeApi.ts b/jarvis/ui/web/frontend/src/lib/agenticIdeApi.ts
index 64fd928aa6..39aa31b0eb 100644
--- a/jarvis/ui/web/frontend/src/lib/agenticIdeApi.ts
+++ b/jarvis/ui/web/frontend/src/lib/agenticIdeApi.ts
@@ -1145,12 +1145,12 @@ export interface OpenTerminalTargetResult {
path: string;
}
-/** Open a modifier-clicked path from one terminal's own workspace. */
-export async function openTerminalTarget(
+async function launchTerminalTarget(
+ action: "open" | "reveal",
workspaceId: string,
target: string,
): Promise<OpenTerminalTargetResult> {
- const res = await fetch("/api/agentic-ide/terminal-target/open", {
+ const res = await fetch(`/api/agentic-ide/terminal-target/${action}`, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ workspace_id: workspaceId, target }),
@@ -1163,6 +1163,22 @@ export async function openTerminalTarget(
return result;
}
+/** Open a modifier-clicked path from one terminal's own workspace. */
+export function openTerminalTarget(
+ workspaceId: string,
+ target: string,
+): Promise<OpenTerminalTargetResult> {
+ return launchTerminalTarget("open", workspaceId, target);
+}
+
+/** Show a workspace path selected in the system file manager, without opening it. */
+export function revealTerminalTarget(
+ workspaceId: string,
+ target: string,
+): Promise<OpenTerminalTargetResult> {
+ return launchTerminalTarget("reveal", workspaceId, target);
+}
+
/**
* Turn a drag-and-drop payload into a folder path.
*
diff --git a/jarvis/ui/web/frontend/src/store/codeEditor.split.test.ts b/jarvis/ui/web/frontend/src/store/codeEditor.split.test.ts
new file mode 100644
index 0000000000..5dd0ca8791
--- /dev/null
+++ b/jarvis/ui/web/frontend/src/store/codeEditor.split.test.ts
@@ -0,0 +1,125 @@
+import { beforeEach, describe, expect, it } from "vitest";
+
+import { fileKeyOf, tabKeyOf, useCodeEditorStore } from "./codeEditor";
+
+const store = () => useCodeEditorStore.getState();
+const edit = (path: string) => tabKeyOf("edit", fileKeyOf("w1", path));
+
+beforeEach(() => {
+ useCodeEditorStore.setState({
+ tabs: [],
+ active: {},
+ files: {},
+ visible: false,
+ quickOpen: false,
+ cursor: null,
+ reveal: null,
+ closed: [],
+ side: {},
+ sideFocused: false,
+ });
+});
+
+describe("two editors side by side", () => {
+ it("opens a file beside the active one and gives it the keyboard", () => {
+ store().openFile("w1", "a.ts", { preview: false });
+ store().openToSide("w1", "b.ts");
+ expect(store().active.w1).toBe(edit("a.ts"));
+ expect(store().side.w1).toBe(edit("b.ts"));
+ expect(store().sideFocused).toBe(true);
+ expect(store().tabs.map((tab) => tab.path)).toEqual(["a.ts", "b.ts"]);
+ expect(store().tabs[1].preview).toBe(false);
+ });
+
+ it("simply opens the file when nothing is open yet", () => {
+ store().openToSide("w1", "a.ts");
+ expect(store().active.w1).toBe(edit("a.ts"));
+ expect(store().side.w1 ?? null).toBeNull();
+ expect(store().sideFocused).toBe(false);
+ });
+
+ it("shows the same file twice when the active file is opened to the side", () => {
+ store().openFile("w1", "a.ts", { preview: false });
+ store().openToSide("w1", "a.ts");
+ expect(store().active.w1).toBe(edit("a.ts"));
+ expect(store().side.w1).toBe(edit("a.ts"));
+ expect(store().tabs).toHaveLength(1);
+ });
+
+ it("sends the next opened file to the editor that has the keyboard", () => {
+ store().openFile("w1", "a.ts", { preview: false });
+ store().openToSide("w1", "b.ts");
+ store().openFile("w1", "c.ts");
+ expect(store().side.w1).toBe(edit("c.ts"));
+ expect(store().active.w1).toBe(edit("a.ts"));
+
+ store().focusGroup(false);
+ store().openFile("w1", "d.ts", { preview: false });
+ expect(store().active.w1).toBe(edit("d.ts"));
+ expect(store().side.w1).toBe(edit("c.ts"));
+ });
+
+ it("never lets a preview replace the tab the other editor shows", () => {
+ store().openFile("w1", "a.ts");
+ store().openToSide("w1", "b.ts");
+ expect(store().tabs.map((tab) => tab.path)).toEqual(["a.ts", "b.ts"]);
+ // The first editor still shows its preview tab.
+ expect(store().active.w1).toBe(edit("a.ts"));
+
+ store().focusGroup(false);
+ store().openFile("w1", "c.ts");
+ // c replaces the preview a in the first editor, never b on the right.
+ expect(store().tabs.map((tab) => tab.path)).toEqual(["c.ts", "b.ts"]);
+ expect(store().side.w1).toBe(edit("b.ts"));
+ });
+
+ it("ends the split when its tab closes, or when one tab would be left twice", () => {
+ store().openFile("w1", "a.ts", { preview: false });
+ store().openToSide("w1", "b.ts");
+ store().closeTab(edit("b.ts"));
+ expect(store().side.w1).toBeNull();
+ expect(store().active.w1).toBe(edit("a.ts"));
+
+ store().openToSide("w1", "b.ts");
+ store().closeTab(edit("a.ts"));
+ expect(store().active.w1).toBe(edit("b.ts"));
+ expect(store().side.w1).toBeNull();
+ });
+
+ it("closes the split and keeps the tab", () => {
+ store().openFile("w1", "a.ts", { preview: false });
+ store().openToSide("w1", "b.ts");
+ store().closeSide("w1");
+ expect(store().side.w1).toBeNull();
+ expect(store().sideFocused).toBe(false);
+ expect(store().tabs.map((tab) => tab.path)).toEqual(["a.ts", "b.ts"]);
+ });
+
+ it("gives the keyboard back to the first editor when a tab is clicked", () => {
+ store().openFile("w1", "a.ts", { preview: false });
+ store().openToSide("w1", "b.ts");
+ store().activate(edit("b.ts"));
+ expect(store().active.w1).toBe(edit("b.ts"));
+ expect(store().sideFocused).toBe(false);
+ });
+
+ it("steps through the tabs of the editor that has the keyboard", () => {
+ store().openFile("w1", "a.ts", { preview: false });
+ store().openFile("w1", "b.ts", { preview: false });
+ store().openToSide("w1", "c.ts");
+ store().cycle("w1", 1);
+ expect(store().side.w1).toBe(edit("a.ts"));
+ expect(store().active.w1).toBe(edit("b.ts"));
+
+ store().focusGroup(false);
+ store().cycle("w1", 1);
+ expect(store().active.w1).toBe(edit("c.ts"));
+ });
+
+ it("follows a rename of the file it shows", () => {
+ store().openFile("w1", "a.ts", { preview: false });
+ store().openToSide("w1", "src/b.ts");
+ store().renamePath("w1", "src", "lib");
+ expect(store().side.w1).toBe(edit("lib/b.ts"));
+ });
+});
diff --git a/jarvis/ui/web/frontend/src/store/codeEditor.ts b/jarvis/ui/web/frontend/src/store/codeEditor.ts
index 3d75489481..046968a734 100644
--- a/jarvis/ui/web/frontend/src/store/codeEditor.ts
+++ b/jarvis/ui/web/frontend/src/store/codeEditor.ts
@@ -77,8 +77,10 @@ interface ClosedTab {
/** What a diff tab compares against instead of the last commit. */
export interface DiffBase {
- /** A commit id. */
+ /** A commit id, or a unique key for a file base. */
ref: string;
+ /** Compare against this workspace file as it is on disk, instead of a commit. */
+ path?: string;
/** Shown in the diff badge in place of "Changes since the last commit". */
label: string;
}
@@ -92,6 +94,11 @@ export interface OpenOptions {
line?: number;
column?: number;
length?: number;
+ /**
+ * true = the second editor, beside the first; false = the first. Omitted =
+ * whichever of the two has the keyboard.
+ */
+ side?: boolean;
}
interface CodeEditorState {
@@ -107,6 +114,16 @@ interface CodeEditorState {
closed: ClosedTab[];
/** Per file: the commit its diff tab compares against, when it is not the last commit. */
diffBases: Record<string, DiffBase>;
+ /** Per workspace: the tab shown in a second editor beside the active one; null = one editor. */
+ side: Record<string, string | null>;
+ /** The second editor has the keyboard: opened files, saves and tab switches go to it. */
+ sideFocused: boolean;
+ /** Open a file in the second editor, splitting the view when it is not split yet. */
+ openToSide: (workspaceId: string, path: string, options?: OpenOptions) => void;
+ /** Back to one editor; the tab stays open. */
+ closeSide: (workspaceId: string) => void;
+ /** Which of the two editors has the keyboard. */
+ focusGroup: (side: boolean) => void;
openFile: (workspaceId: string, path: string, options?: OpenOptions) => void;
closeTab: (key: string) => void;
closeTabs: (keys: string[]) => void;
@@ -183,6 +200,16 @@ export const useCodeEditorStore = create<CodeEditorState>((set, get) => ({
reveal: null,
closed: [],
diffBases: {},
+ side: {},
+ sideFocused: false,
+
+ openToSide: (workspaceId, path, options = {}) => get().openFile(workspaceId, path, { preview: false, ...options, side: true }),
+
+ closeSide: (workspaceId) => set((state) => ({ side: { ...state.side, [workspaceId]: null }, sideFocused: false })),
+
+ focusGroup: (side) => {
+ if (get().sideFocused !== side) set({ sideFocused: side });
+ },
openFile: (workspaceId, path, options = {}) => {
const mode = options.mode ?? "edit";
@@ -191,13 +218,22 @@ export const useCodeEditorStore = create<CodeEditorState>((set, get) => ({
const key = tabKeyOf(mode, fileKey);
set((state) => {
let tabs = state.tabs;
+ // Which of the two editors takes the file. The second one only exists
+ // beside a first: with nothing open, the file simply opens.
+ const mainKey = state.active[workspaceId] ?? null;
+ const sideKey = state.side[workspaceId] ?? null;
+ const hasMain = mainKey !== null && tabs.some((tab) => tab.key === mainKey);
+ const toSide = hasMain && (options.side ?? (state.sideFocused && sideKey !== null));
+ // The tab the other editor shows is never the one a preview replaces.
+ const otherKey = toSide ? mainKey : sideKey;
const existing = tabs.find((tab) => tab.key === key);
if (existing) {
if (!preview && existing.preview) tabs = tabs.map((tab) => (tab.key === key ? { ...tab, preview: false } : tab));
} else {
const tab: EditorTab = { key, fileKey, workspaceId, path, mode, preview };
const replaced = tabs.find(
- (entry) => entry.workspaceId === workspaceId && entry.preview && !state.files[entry.fileKey]?.dirty,
+ (entry) =>
+ entry.workspaceId === workspaceId && entry.preview && entry.key !== otherKey && !state.files[entry.fileKey]?.dirty,
);
if (replaced) {
tabs = tabs.map((entry) => (entry.key === replaced.key ? tab : entry));
@@ -223,7 +259,9 @@ export const useCodeEditorStore = create<CodeEditorState>((set, get) => ({
return {
tabs,
files: prune(files, tabs),
- active: { ...state.active, [workspaceId]: key },
+ active: toSide ? state.active : { ...state.active, [workspaceId]: key },
+ side: toSide ? { ...state.side, [workspaceId]: key } : state.side,
+ sideFocused: toSide,
visible: true,
reveal,
diffBases,
@@ -240,19 +278,25 @@ export const useCodeEditorStore = create<CodeEditorState>((set, get) => ({
if (gone.length === 0) return {};
const tabs = state.tabs.filter((tab) => !closing.has(tab.key));
const active = { ...state.active };
+ const side = { ...state.side };
for (const workspaceId of new Set(gone.map((tab) => tab.workspaceId))) {
const current = active[workspaceId];
- if (!current || !closing.has(current)) continue;
- active[workspaceId] = successor(state.tabs.filter((tab) => tab.workspaceId === workspaceId), current, closing);
+ if (current && closing.has(current)) {
+ active[workspaceId] = successor(state.tabs.filter((tab) => tab.workspaceId === workspaceId), current, closing);
+ }
+ // The split ends when its tab closes, or when both editors would be
+ // left showing the one tab that remains.
+ const beside = side[workspaceId];
+ if (beside && (closing.has(beside) || (closing.has(current ?? "") && active[workspaceId] === beside))) side[workspaceId] = null;
}
const closed = [...state.closed, ...gone.map(({ workspaceId, path, mode }) => ({ workspaceId, path, mode }))];
- return { tabs, active, files: prune(state.files, tabs), closed: closed.slice(-MAX_CLOSED) };
+ return { tabs, active, side, files: prune(state.files, tabs), closed: closed.slice(-MAX_CLOSED) };
}),
activate: (key) =>
set((state) => {
const tab = state.tabs.find((entry) => entry.key === key);
- return tab ? { active: { ...state.active, [tab.workspaceId]: key }, visible: true } : {};
+ return tab ? { active: { ...state.active, [tab.workspaceId]: key }, sideFocused: false, visible: true } : {};
}),
pinTab: (key) =>
@@ -262,9 +306,12 @@ export const useCodeEditorStore = create<CodeEditorState>((set, get) => ({
set((state) => {
const own = state.tabs.filter((tab) => tab.workspaceId === workspaceId);
if (own.length === 0) return {};
- const index = own.findIndex((tab) => tab.key === state.active[workspaceId]);
+ // Ctrl+Tab steps through the tabs of the editor that has the keyboard.
+ const beside = state.side[workspaceId];
+ const inSide = state.sideFocused && own.some((tab) => tab.key === beside);
+ const index = own.findIndex((tab) => tab.key === (inSide ? beside : state.active[workspaceId]));
const next = own[(index + step + own.length) % own.length];
- return { active: { ...state.active, [workspaceId]: next.key } };
+ return inSide ? { side: { ...state.side, [workspaceId]: next.key } } : { active: { ...state.active, [workspaceId]: next.key } };
}),
reopenClosed: (workspaceId) => {
@@ -315,9 +362,12 @@ export const useCodeEditorStore = create<CodeEditorState>((set, get) => ({
}
const activeKey = state.active[workspaceId];
const activeTab = activeKey ? state.tabs.findIndex((tab) => tab.key === activeKey) : -1;
+ const sideKey = state.side[workspaceId];
+ const sideTab = sideKey ? state.tabs.findIndex((tab) => tab.key === sideKey) : -1;
return {
tabs,
files,
+ side: { ...state.side, [workspaceId]: sideTab >= 0 ? tabs[sideTab].key : null },
active: { ...state.active, [workspaceId]: activeTab >= 0 ? tabs[activeTab].key : (activeKey ?? null) },
};
}),
diff --git a/jarvis/ui/web/frontend/src/store/ideSidePanel.ts b/jarvis/ui/web/frontend/src/store/ideSidePanel.ts
index 15df031239..f996f5ddd0 100644
--- a/jarvis/ui/web/frontend/src/store/ideSidePanel.ts
+++ b/jarvis/ui/web/frontend/src/store/ideSidePanel.ts
@@ -17,6 +17,8 @@ export interface SidePanelTerminal {
workspaceId: string;
workspaceName: string;
number: number;
+ /** Absolute folder the shell starts in; omitted = the workspace's own folder. */
+ folder?: string;
}
export const MAX_TERMINAL_TABS = 16;
@@ -93,7 +95,8 @@ interface IdeSidePanelState {
tabs: SidePanelTabId[];
active: SidePanelTabId;
terminals: SidePanelTerminal[];
- addTerminalTab: (workspaceId: string, workspaceName: string) => void;
+ /** `folder` starts the shell in that folder of the workspace instead of its root. */
+ addTerminalTab: (workspaceId: string, workspaceName: string, folder?: string) => void;
setOpen: (open: boolean) => void;
/** Open a tab (or bring it forward when it is already open). */
openTab: (id: SidePanelTabId) => void;
@@ -131,14 +134,14 @@ export const useIdeSidePanelStore = create<IdeSidePanelState>((set, get) => {
tabs: initialTabs.tabs,
active: initialTabs.active,
terminals: [],
- addTerminalTab: (workspaceId, workspaceName) => {
+ addTerminalTab: (workspaceId, workspaceName, folder) => {
if (!workspaceId) return;
const { terminals, tabs } = get();
const siblings = terminals.filter((terminal) => terminal.workspaceId === workspaceId);
if (siblings.length >= MAX_TERMINAL_TABS) return;
const id = `terminal:${crypto.randomUUID()}` as const;
const number = Math.max(0, ...siblings.map((terminal) => terminal.number)) + 1;
- set({ terminals: [...terminals, { id, workspaceId, workspaceName, number }] });
+ set({ terminals: [...terminals, { id, workspaceId, workspaceName, number, ...(folder ? { folder } : {}) }] });
commit({ open: true, tabs: [...tabs, id], active: id });
},
spotlight: null,
diff --git a/tests/unit/agentic_ide/test_terminal_target_route.py b/tests/unit/agentic_ide/test_terminal_target_route.py
index 049fad38a9..350a1ae8a3 100644
--- a/tests/unit/agentic_ide/test_terminal_target_route.py
+++ b/tests/unit/agentic_ide/test_terminal_target_route.py
@@ -98,6 +98,29 @@ async def test_a_local_file_uri_is_unwrapped_before_opening(
assert opened == [target.resolve()]
+async def test_reveal_selects_the_path_in_the_file_manager_instead_of_opening_it(
+ workspace: Path, monkeypatch: pytest.MonkeyPatch
+) -> None:
+ target = workspace / "notes.md"
+ target.write_text("notes\n", encoding="utf-8")
+ opened = _record_opens(monkeypatch)
+ revealed: list[Path] = []
+ monkeypatch.setattr(
+ open_path,
+ "reveal_in_folder",
+ lambda path: revealed.append(path) or True,
+ )
+
+ result = await routes.reveal_terminal_target(
+ _request(),
+ routes.OpenTerminalTargetRequest(workspace_id="workspace-1", target="notes.md"),
+ )
+
+ assert result["opened"] is True
+ assert revealed == [target.resolve()]
+ assert opened == []
+
+
@pytest.mark.parametrize("printed", ["../outside.txt", "https://example.com/file"])
async def test_terminal_output_cannot_open_outside_the_workspace(
workspace: Path,