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): move, copy and multi-select files in the explorer

rubenluetke10-beep256b94c3724d
diff --git a/jarvis/agentic_ide/file_editing.py b/jarvis/agentic_ide/file_editing.py
index fb3afcc4e2..cbecc1a30d 100644
--- a/jarvis/agentic_ide/file_editing.py
+++ b/jarvis/agentic_ide/file_editing.py
@@ -47,6 +47,7 @@ __all__ = [
"EditError",
"TextFile",
"TrashUnavailable",
+ "copy_entry",
"create_entry",
"delete_entry",
"file_version",
@@ -449,6 +450,52 @@ def rename_entry(root: str | os.PathLike[str], source: str, destination: str) ->
return relative
+def _free_name(target: Path) -> Path:
+ """``name copy.ext``, ``name copy 2.ext``, … — the first that is free."""
+ if not (target.exists() or target.is_symlink()):
+ return target
+ stem, suffix = target.stem, target.suffix
+ if target.is_dir():
+ stem, suffix = target.name, ""
+ for number in range(1, 1000):
+ label = " copy" if number == 1 else f" copy {number}"
+ candidate = target.with_name(f"{stem}{label}{suffix}")
+ if not (candidate.exists() or candidate.is_symlink()):
+ return candidate
+ raise EditError("There are too many copies with that name already.")
+
+
+def copy_entry(
+ root: str | os.PathLike[str], source: str, destination: str, *, unique: bool = False
+) -> str:
+ """Copy a file or folder inside the workspace; returns the new path.
+
+ With ``unique`` an existing destination gets a free "copy" name instead of
+ refusing, the way pasting into the same folder works in a file manager.
+ Symlinks are copied as links, never followed out of the workspace.
+ """
+ _, source_path = _resolve_entry(root, source)
+ _, target = _resolve_entry(root, destination)
+ if not (source_path.is_symlink() or source_path.exists()):
+ raise EditError("That file or folder no longer exists.")
+ if not target.parent.is_dir():
+ raise EditError("The destination folder does not exist.")
+ if target.exists() or target.is_symlink():
+ if not unique:
+ raise EditError("Something with that name already exists.")
+ target = _free_name(target)
+ is_folder = source_path.is_dir() and not source_path.is_symlink()
+ if is_folder:
+ source_key = os.path.normcase(str(source_path))
+ if os.path.normcase(os.path.realpath(target)).startswith(source_key + os.sep):
+ raise EditError("A folder cannot be copied into itself.")
+ shutil.copytree(source_path, target, symlinks=True)
+ else:
+ shutil.copy2(source_path, target, follow_symlinks=False)
+ real_root = Path(os.path.realpath(os.fspath(root)))
+ return target.relative_to(real_root).as_posix()
+
+
#: Quick Open lists at most this many paths; a home directory opened as a
#: workspace must not stall the editor.
MAX_LISTED_FILES = 50_000
diff --git a/jarvis/ui/web/agentic_ide_routes.py b/jarvis/ui/web/agentic_ide_routes.py
index e530d0a3d7..bc138d6b94 100644
--- a/jarvis/ui/web/agentic_ide_routes.py
+++ b/jarvis/ui/web/agentic_ide_routes.py
@@ -1037,6 +1037,16 @@ class ReplaceInFilesRequest(BaseModel):
paths: list[str] = Field(min_length=1, max_length=5000)
+class CopyWorkspaceEntryRequest(BaseModel):
+ """Copy one file or folder inside a workspace."""
+
+ source: str = Field(min_length=1, max_length=4096)
+ destination: str = Field(min_length=1, max_length=4096)
+ unique: bool = Field(
+ default=False, description="Pick a free 'copy' name when the destination is taken."
+ )
+
+
class DeleteWorkspaceEntryRequest(BaseModel):
"""Delete one file or folder; it goes to the system trash unless permanent."""
@@ -2287,6 +2297,26 @@ async def delete_editor_backup(workspace_id: str, path: str) -> dict[str, object
return {"ok": True}
+ "/workspaces/{workspace_id}/entries/copy",
+ summary="Copy a file or folder in a workspace",
+)
+async def copy_workspace_entry(
+ workspace_id: str, req: CopyWorkspaceEntryRequest
+) -> dict[str, object]:
+ folder = _workspace_folder(workspace_id)
+ try:
+ copied = await asyncio.to_thread(
+ file_editing.copy_entry, folder, req.source, req.destination, unique=req.unique
+ )
+ except file_editing.EditError as exc:
+ raise HTTPException(status_code=409, detail=str(exc)) from exc
+ except OSError as exc:
+ log.warning("Agentic IDE editor: copy failed for %s: %s", req.source, exc)
+ raise HTTPException(status_code=500, detail="It could not be copied.") from exc
+ return {"workspace_id": workspace_id, "path": copied}
+
+
@router.post(
"/workspaces/{workspace_id}/entries/delete",
summary="Delete a file or folder in a workspace",
diff --git a/jarvis/ui/web/frontend/src/components/agentic/editor/editorApi.ts b/jarvis/ui/web/frontend/src/components/agentic/editor/editorApi.ts
index b9e77f3eb9..ccaea40805 100644
--- a/jarvis/ui/web/frontend/src/components/agentic/editor/editorApi.ts
+++ b/jarvis/ui/web/frontend/src/components/agentic/editor/editorApi.ts
@@ -131,6 +131,11 @@ export function createEntry(workspaceId: string, path: string, kind: "file" | "d
return send(`${base(workspaceId)}/entries`, json("POST", { path, kind }));
}
+/** Copy a file or folder; `unique` picks a free "copy" name when the destination is taken. */
+export function copyEntry(workspaceId: string, source: string, destination: string, unique = false): Promise<{ path: string }> {
+ return send(`${base(workspaceId)}/entries/copy`, json("POST", { source, destination, unique }));
+}
+
export function moveEntry(workspaceId: string, source: string, destination: string): Promise<{ path: string }> {
return send(`${base(workspaceId)}/entries/move`, json("POST", { source, destination }));
}
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 c8ff52f991..65af2418a7 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
@@ -167,6 +167,60 @@ describe("ExplorerPanel", () => {
await waitFor(() => expect(sent()).toEqual(["src/new.ts", "src/lib", "top.ts"]));
});
+ it("selects several rows with Ctrl+click and deletes them together", async () => {
+ render(<ExplorerPanel view="files" />);
+ await waitFor(() => expect(screen.getAllByTestId("explorer-tree-row")).toHaveLength(2));
+ const [src, readme] = screen.getAllByTestId("explorer-tree-row");
+ fireEvent.click(readme);
+ fireEvent.click(src, { ctrlKey: true });
+ expect(screen.getAllByTestId("explorer-tree-row").filter((row) => row.dataset.selected)).toHaveLength(2);
+
+ fireEvent.keyDown(readme, { key: "Delete" });
+ expect(screen.getByTestId("explorer-delete-dialog").textContent).toContain("2");
+ fireEvent.click(screen.getByTestId("explorer-delete-confirm"));
+ await waitFor(() => expect(calls.filter((call) => call.url.includes("/entries/delete"))).toHaveLength(2));
+ const sent = calls.filter((call) => call.url.includes("/entries/delete")).map((call) => JSON.parse(call.body).path);
+ expect(sent.sort()).toEqual(["README.md", "src"]);
+ });
+
+ it("copies with Ctrl+C and pastes into the selected folder with a free name", async () => {
+ render(<ExplorerPanel view="files" />);
+ await waitFor(() => expect(screen.getAllByTestId("explorer-tree-row")).toHaveLength(2));
+ const [src, readme] = screen.getAllByTestId("explorer-tree-row");
+ fireEvent.click(readme);
+ fireEvent.keyDown(readme, { key: "c", ctrlKey: true });
+ fireEvent.keyDown(src, { key: "v", ctrlKey: true });
+
+ await waitFor(() => expect(calls.some((call) => call.url.endsWith("/entries/copy"))).toBe(true));
+ const sent = JSON.parse(calls.find((call) => call.url.endsWith("/entries/copy"))!.body);
+ expect(sent).toEqual({ source: "README.md", destination: "src/README.md", unique: true });
+ });
+
+ it("moves a dragged row into the folder it is dropped on", async () => {
+ render(<ExplorerPanel view="files" />);
+ await waitFor(() => expect(screen.getAllByTestId("explorer-tree-row")).toHaveLength(2));
+ const [src, readme] = screen.getAllByTestId("explorer-tree-row");
+ const data: Record<string, string> = {};
+ const dataTransfer = {
+ setData: (type: string, value: string) => {
+ data[type] = value;
+ },
+ getData: (type: string) => data[type] ?? "",
+ get types() {
+ return Object.keys(data);
+ },
+ effectAllowed: "",
+ dropEffect: "",
+ };
+ fireEvent.dragStart(readme, { dataTransfer });
+ fireEvent.dragOver(src, { dataTransfer });
+ fireEvent.drop(src, { dataTransfer });
+
+ await waitFor(() => expect(calls.some((call) => call.url.endsWith("/entries/move"))).toBe(true));
+ const sent = JSON.parse(calls.find((call) => call.url.endsWith("/entries/move"))!.body);
+ expect(sent).toEqual({ source: "README.md", destination: "src/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 ec0b070dd0..bd798db323 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
@@ -2,7 +2,9 @@ import { useCallback, useEffect, useMemo, useRef, useState, type DragEvent, type
import {
ChevronRight,
ChevronsDownUp,
+ ClipboardPaste,
Copy,
+ CopyPlus,
ExternalLink,
FilePlus,
Folder,
@@ -12,6 +14,7 @@ import {
Loader2,
Pencil,
RefreshCw,
+ Scissors,
Search,
SquareArrowOutUpRight,
SquarePen,
@@ -28,7 +31,7 @@ import {
} from "@/lib/agenticIdeApi";
import { setWorkspaceDragPaths } from "@/components/agentic/paneDrop";
import { AgentMark } from "@/components/agentic/AgentMark";
-import { createEntry, deleteEntry, moveEntry, TrashUnavailableError } from "@/components/agentic/editor/editorApi";
+import { copyEntry, createEntry, deleteEntry, moveEntry, TrashUnavailableError } from "@/components/agentic/editor/editorApi";
import { moveModels } from "@/components/agentic/editor/editorModels";
import { forgetFileList } from "@/components/agentic/editor/QuickOpen";
import { ThreadMenuItem, ThreadMenuSeparator, ThreadPopover } from "@/components/agentic/threads/ThreadPopover";
@@ -72,14 +75,27 @@ 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);
-/** Start a drag that a terminal pane turns into a file reference. */
-function startFileDrag(event: DragEvent, absolute: string): void {
- if (!setWorkspaceDragPaths(event.dataTransfer, [absolute])) {
+/** The tree's own drag payload: the workspace paths being moved. */
+const EXPLORER_DRAG_TYPE = "application/x-jarvis-explorer-paths";
+
+/**
+ * Start a drag that a terminal pane turns into file references, and that a
+ * folder in the tree turns into a move (`moving` lists the workspace paths).
+ */
+function startFileDrag(event: DragEvent, absolute: string | string[], moving?: string[]): void {
+ const paths = Array.isArray(absolute) ? absolute : [absolute];
+ if (!setWorkspaceDragPaths(event.dataTransfer, paths)) {
event.preventDefault();
return;
}
- event.dataTransfer.setData("text/plain", absolute);
- event.dataTransfer.effectAllowed = "copy";
+ event.dataTransfer.setData("text/plain", paths.join("\n"));
+ if (moving) event.dataTransfer.setData(EXPLORER_DRAG_TYPE, JSON.stringify(moving));
+ event.dataTransfer.effectAllowed = moving ? "copyMove" : "copy";
+}
+
+/** Drop the paths that lie inside another listed path: moving the folder moves them. */
+function topLevel(paths: string[]): string[] {
+ return paths.filter((path) => !paths.some((other) => other !== path && isUnder(path, other)));
}
function useWorkspaceChanges(workspaceId: string | null) {
@@ -530,7 +546,13 @@ function FileTree({
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 [confirm, setConfirm] = useState<{ path: string; isDirectory: boolean; permanent: boolean } | null>(null);
+ 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.
+ const [selected, setSelected] = useState<ReadonlySet<string>>(() => new Set());
+ const anchorRef = useRef<string | null>(null);
+ const [clip, setClip] = useState<{ paths: string[]; cut: boolean } | null>(null);
+ const [dropTarget, setDropTarget] = useState<string | null>(null);
const menuAnchor = useRef<HTMLElement | null>(null);
const list = useRef<HTMLUListElement>(null);
const loaded = useRef<Set<string>>(new Set());
@@ -669,17 +691,16 @@ function FileTree({
}
};
- const rename = async (path: string, name: string) => {
- setRenaming(null);
+ /** Rename or move one entry; open buffers, tabs and open folders follow it. */
+ const moveTo = async (path: string, destination: string): Promise<string | null> => {
const saving = Object.values(useCodeEditorStore.getState().files).some(
(file) => file.workspaceId === workspaceId && file.saving && isUnder(file.path, path),
);
// A save in flight would land under the old name; wait for it.
if (saving) {
pushToast("error", t("ide_side_panel.explorer.busy_saving"));
- return;
+ return null;
}
- const destination = joinPath(parentPath(path), name);
try {
const moved = await moveEntry(workspaceId, path, destination);
forgetFileList(workspaceId);
@@ -692,25 +713,79 @@ function FileTree({
});
loaded.current = new Set([...loaded.current].filter((entry) => !isUnder(entry, path)));
await load(parentPath(path));
- setFocused(moved.path);
+ if (parentPath(moved.path) !== parentPath(path)) await load(parentPath(moved.path));
+ return moved.path;
} catch (err) {
fail(err);
+ return null;
}
};
- const remove = async (path: string, permanent: boolean) => {
+ const rename = async (path: string, name: string) => {
+ setRenaming(null);
+ const moved = await moveTo(path, joinPath(parentPath(path), name));
+ if (moved) setFocused(moved);
+ };
+
+ const isDirectory = (path: string) =>
+ (children[parentPath(path)] ?? []).find((entry) => entry.path === path)?.is_directory ?? false;
+ /** The folder a paste or a drop lands in: the folder itself, or a file's folder. */
+ const folderFor = (path: string | null) => (!path ? "" : isDirectory(path) ? path : parentPath(path));
+ /** What an action on `path` covers: the whole selection when the row is part of it. */
+ const selectionFor = (path: string) => (selected.has(path) && selected.size > 1 ? topLevel([...selected]) : [path]);
+
+ const moveInto = async (paths: string[], folder: string) => {
+ let last: string | null = null;
+ for (const path of topLevel(paths)) {
+ if (parentPath(path) === folder || isUnder(folder, path)) continue;
+ last = (await moveTo(path, joinPath(folder, baseName(path)))) ?? last;
+ }
+ if (folder) expand(folder);
+ if (last) {
+ setFocused(last);
+ setSelected(new Set([last]));
+ }
+ };
+
+ const paste = async (folder: string) => {
+ if (!clip) return;
+ if (clip.cut) {
+ await moveInto(clip.paths, folder);
+ setClip(null);
+ return;
+ }
+ let last: string | null = null;
+ for (const path of topLevel(clip.paths)) {
+ try {
+ last = (await copyEntry(workspaceId, path, joinPath(folder, baseName(path)), true)).path;
+ } catch (err) {
+ fail(err);
+ }
+ }
+ forgetFileList(workspaceId);
+ await load(folder);
+ if (folder) expand(folder);
+ if (last) setFocused(last);
+ };
+
+ const remove = async (paths: string[], permanent: boolean) => {
setConfirm(null);
- try {
- await deleteEntry(workspaceId, path, permanent);
- forgetFileList(workspaceId);
- editor.markDeleted(workspaceId, path);
- await load(parentPath(path));
- } catch (err) {
- if (err instanceof TrashUnavailableError) {
- const isDirectory = (children[parentPath(path)] ?? []).find((entry) => entry.path === path)?.is_directory ?? false;
- setConfirm({ path, isDirectory, permanent: true });
- } else fail(err);
+ for (const [index, path] of paths.entries()) {
+ try {
+ await deleteEntry(workspaceId, path, permanent);
+ editor.markDeleted(workspaceId, path);
+ } catch (err) {
+ if (err instanceof TrashUnavailableError) {
+ // No trash on this computer: ask once for the rest, permanently.
+ setConfirm({ paths: paths.slice(index), isDirectory: isDirectory(path), permanent: true });
+ break;
+ }
+ fail(err);
+ }
}
+ forgetFileList(workspaceId);
+ setSelected(new Set());
+ for (const folder of new Set(paths.map(parentPath))) await load(folder);
};
const copy = (text: string) => void navigator.clipboard?.writeText(text).catch(fail);
@@ -736,7 +811,17 @@ function FileTree({
setRenaming(item.path);
} else if (event.key === "Delete") {
event.preventDefault();
- setConfirm({ path: item.path, isDirectory: item.is_directory, permanent: false });
+ setConfirm({ paths: selectionFor(item.path), isDirectory: item.is_directory, permanent: false });
+ } else if ((event.ctrlKey || event.metaKey) && ["c", "x"].includes(event.key.toLowerCase())) {
+ event.preventDefault();
+ setClip({ paths: selectionFor(item.path), cut: event.key.toLowerCase() === "x" });
+ } else if ((event.ctrlKey || event.metaKey) && event.key.toLowerCase() === "v") {
+ event.preventDefault();
+ void paste(folderFor(item.path));
+ } else if (event.key === "Escape" && (selected.size > 1 || clip)) {
+ event.preventDefault();
+ setSelected(new Set([item.path]));
+ setClip(null);
} else if (event.key === "ArrowRight" && item.is_directory && !expanded.has(item.path)) {
event.preventDefault();
expand(item.path);
@@ -784,9 +869,27 @@ function FileTree({
// A click on the empty space below the rows clears the selection, so
// New File / New Folder go to the workspace root again.
onClick={(event) => {
- if (event.target === event.currentTarget) setFocused(null);
+ if (event.target === event.currentTarget) {
+ setFocused(null);
+ setSelected(new Set());
+ }
}}
onContextMenu={(event) => openMenu(event, "", true)}
+ // Dropped on the empty space below the rows: into the workspace root.
+ onDragOver={(event) => {
+ if (event.target !== event.currentTarget || !event.dataTransfer.types.includes(EXPLORER_DRAG_TYPE)) return;
+ event.preventDefault();
+ event.dataTransfer.dropEffect = "move";
+ setDropTarget("");
+ }}
+ onDragLeave={() => setDropTarget(null)}
+ onDrop={(event) => {
+ setDropTarget(null);
+ const raw = event.dataTransfer.getData(EXPLORER_DRAG_TYPE);
+ if (!raw) return;
+ event.preventDefault();
+ void moveInto(JSON.parse(raw) as string[], "");
+ }}
>
{error && <li className="px-3 py-2 text-[11px] text-destructive">{error}</li>}
{rows.map((row) => {
@@ -827,9 +930,46 @@ function FileTree({
<button
type="button"
draggable
- onDragStart={(event) => startFileDrag(event, absolute(item.path))}
- onClick={() => {
+ onDragStart={(event) => startFileDrag(event, selectionFor(item.path).map(absolute), selectionFor(item.path))}
+ onDragOver={(event) => {
+ if (!event.dataTransfer.types.includes(EXPLORER_DRAG_TYPE)) return;
+ event.preventDefault();
+ event.stopPropagation();
+ event.dataTransfer.dropEffect = "move";
+ setDropTarget(folderFor(item.path));
+ }}
+ onDragLeave={() => setDropTarget(null)}
+ onDrop={(event) => {
+ setDropTarget(null);
+ const raw = event.dataTransfer.getData(EXPLORER_DRAG_TYPE);
+ if (!raw) return;
+ event.preventDefault();
+ event.stopPropagation();
+ void moveInto(JSON.parse(raw) as string[], folderFor(item.path));
+ }}
+ onClick={(event) => {
setFocused(item.path);
+ if (event.ctrlKey || event.metaKey) {
+ setSelected((current) => {
+ const next = new Set(current);
+ if (next.has(item.path)) next.delete(item.path);
+ else next.add(item.path);
+ return next;
+ });
+ anchorRef.current = item.path;
+ return;
+ }
+ if (event.shiftKey && anchorRef.current) {
+ const order = rows.flatMap((entry) => (entry.kind === "item" ? [entry.item.path] : []));
+ const from = order.indexOf(anchorRef.current);
+ const to = order.indexOf(item.path);
+ if (from >= 0 && to >= 0) {
+ setSelected(new Set(order.slice(Math.min(from, to), Math.max(from, to) + 1)));
+ return;
+ }
+ }
+ setSelected(new Set([item.path]));
+ anchorRef.current = item.path;
if (item.is_directory) toggle(item.path);
else editor.openFile(workspaceId, item.path);
}}
@@ -839,12 +979,16 @@ function FileTree({
data-testid="explorer-tree-row"
data-path={item.path}
data-active={current || undefined}
+ data-selected={selected.has(item.path) || undefined}
title={item.path}
style={{ paddingLeft: 10 + depth * 14 }}
className={cn(
"flex h-7 w-full items-center gap-1.5 pr-3 text-left text-[13px] hover:bg-muted/60 focus-visible:bg-muted/60 focus-visible:outline-none",
current && "bg-secondary",
+ selected.has(item.path) && selected.size > 1 && "bg-primary/10",
focused === item.path && "ring-1 ring-inset ring-ring/50",
+ item.is_directory && dropTarget === item.path && "bg-primary/15 ring-1 ring-inset ring-primary/50",
+ clip?.cut && clip.paths.includes(item.path) && "opacity-50",
)}
>
<ChevronRight
@@ -871,6 +1015,14 @@ function FileTree({
<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))}
+ />
+ )}
{menu.path && (
<>
<ThreadMenuSeparator />
@@ -886,6 +1038,19 @@ function FileTree({
)}
<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))} />
<ThreadMenuSeparator />
+ <ThreadMenuItem
+ icon={<Scissors className="h-4 w-4" />}
+ label={t("ide_side_panel.explorer.cut")}
+ hint="Ctrl+X"
+ onSelect={pick(() => setClip({ paths: selectionFor(menu.path), cut: true }))}
+ />
+ <ThreadMenuItem
+ icon={<CopyPlus className="h-4 w-4" />}
+ label={t("ide_side_panel.explorer.copy")}
+ 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))} />
<ThreadMenuSeparator />
@@ -895,7 +1060,7 @@ function FileTree({
label={t("ide_side_panel.explorer.delete")}
hint="Del"
danger
- onSelect={pick(() => setConfirm({ path: menu.path, isDirectory: menu.isDirectory, permanent: false }))}
+ onSelect={pick(() => setConfirm({ paths: selectionFor(menu.path), isDirectory: menu.isDirectory, permanent: false }))}
/>
</>
)}
@@ -905,11 +1070,12 @@ function FileTree({
{confirm && (
<DeleteDialog
- name={baseName(confirm.path)}
+ name={baseName(confirm.paths[0])}
+ count={confirm.paths.length}
isDirectory={confirm.isDirectory}
permanent={confirm.permanent}
onCancel={() => setConfirm(null)}
- onConfirm={() => void remove(confirm.path, confirm.permanent)}
+ onConfirm={() => void remove(confirm.paths, confirm.permanent)}
/>
)}
</>
@@ -918,12 +1084,14 @@ function FileTree({
function DeleteDialog({
name,
+ count,
isDirectory,
permanent,
onConfirm,
onCancel,
}: {
name: string;
+ count: number;
isDirectory: boolean;
permanent: boolean;
onConfirm: () => void;
@@ -932,7 +1100,14 @@ function DeleteDialog({
const t = useT();
const confirmButton = useRef<HTMLButtonElement>(null);
useEffect(() => confirmButton.current?.focus(), []);
- const title = permanent ? "ide_side_panel.explorer.delete_permanent_title" : isDirectory ? "ide_side_panel.explorer.delete_folder_title" : "ide_side_panel.explorer.delete_file_title";
+ const title =
+ count > 1
+ ? "ide_side_panel.explorer.delete_many_title"
+ : permanent
+ ? "ide_side_panel.explorer.delete_permanent_title"
+ : isDirectory
+ ? "ide_side_panel.explorer.delete_folder_title"
+ : "ide_side_panel.explorer.delete_file_title";
return (
<div
role="presentation"
@@ -952,7 +1127,7 @@ function DeleteDialog({
className="w-full max-w-sm rounded-xl border border-border bg-popover p-4 text-popover-foreground shadow-float"
>
<h2 id="explorer-delete-title" className="text-sm font-semibold text-foreground-strong">
- {fill(t(title), { file: name })}
+ {fill(t(title), { file: name, count })}
</h2>
<p className="mt-1.5 text-xs text-muted-foreground">
{t(permanent ? "ide_side_panel.explorer.delete_permanent_body" : "ide_side_panel.explorer.delete_body")}
diff --git a/jarvis/ui/web/frontend/src/i18n/locales/de.json b/jarvis/ui/web/frontend/src/i18n/locales/de.json
index ae4aa22f4b..d513c04304 100644
--- a/jarvis/ui/web/frontend/src/i18n/locales/de.json
+++ b/jarvis/ui/web/frontend/src/i18n/locales/de.json
@@ -6279,6 +6279,10 @@
"delete_body": "Es landet im Papierkorb und lässt sich von dort wiederherstellen.",
"delete_permanent_body": "Dieser Computer hat keinen Papierkorb. Endgültiges Löschen lässt sich nicht rückgängig machen.",
"delete_permanent": "Endgültig löschen",
+ "cut": "Ausschneiden",
+ "copy": "Kopieren",
+ "paste": "Einfügen",
+ "delete_many_title": "{count} Einträge löschen?",
"busy_saving": "Eine Datei darin wird noch gespeichert. Versuche es gleich noch einmal.",
"cancel": "Abbrechen"
},
diff --git a/jarvis/ui/web/frontend/src/i18n/locales/en.json b/jarvis/ui/web/frontend/src/i18n/locales/en.json
index c1925f5cb2..3c2f80244a 100644
--- a/jarvis/ui/web/frontend/src/i18n/locales/en.json
+++ b/jarvis/ui/web/frontend/src/i18n/locales/en.json
@@ -6279,6 +6279,10 @@
"delete_body": "It goes to the trash, so you can still restore it.",
"delete_permanent_body": "This computer has no trash to move it to. A permanent delete cannot be undone.",
"delete_permanent": "Delete permanently",
+ "cut": "Cut",
+ "copy": "Copy",
+ "paste": "Paste",
+ "delete_many_title": "Delete {count} items?",
"busy_saving": "A file in there is still saving. Try again in a moment.",
"cancel": "Cancel"
},
diff --git a/jarvis/ui/web/frontend/src/i18n/locales/es.json b/jarvis/ui/web/frontend/src/i18n/locales/es.json
index 2c7759b238..f283edd56d 100644
--- a/jarvis/ui/web/frontend/src/i18n/locales/es.json
+++ b/jarvis/ui/web/frontend/src/i18n/locales/es.json
@@ -6279,6 +6279,10 @@
"delete_body": "Irá a la papelera, así que aún podrás restaurarlo.",
"delete_permanent_body": "Este equipo no tiene papelera. Una eliminación definitiva no se puede deshacer.",
"delete_permanent": "Eliminar definitivamente",
+ "cut": "Cortar",
+ "copy": "Copiar",
+ "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.",
"cancel": "Cancelar"
},
diff --git a/tests/unit/agentic_ide/test_file_editing.py b/tests/unit/agentic_ide/test_file_editing.py
index 76c98a9df6..e51c2cb49a 100644
--- a/tests/unit/agentic_ide/test_file_editing.py
+++ b/tests/unit/agentic_ide/test_file_editing.py
@@ -16,6 +16,7 @@ from jarvis.agentic_ide.file_editing import (
EditConflict,
EditError,
TrashUnavailable,
+ copy_entry,
create_entry,
delete_entry,
list_files,
@@ -232,6 +233,23 @@ def test_create_rename_and_permanent_delete(tmp_path: Path) -> None:
assert not (tmp_path / "src").exists()
+def test_copy_files_and_folders_with_free_names(tmp_path: Path) -> None:
+ (tmp_path / "src").mkdir()
+ (tmp_path / "src" / "a.py").write_text("x", encoding="utf-8")
+ (tmp_path / "lib").mkdir()
+
+ assert copy_entry(tmp_path, "src/a.py", "lib/a.py") == "lib/a.py"
+ with pytest.raises(EditError):
+ copy_entry(tmp_path, "src/a.py", "lib/a.py")
+ assert copy_entry(tmp_path, "src/a.py", "src/a.py", unique=True) == "src/a copy.py"
+ assert copy_entry(tmp_path, "src/a.py", "src/a.py", unique=True) == "src/a copy 2.py"
+
+ assert copy_entry(tmp_path, "src", "lib/src") == "lib/src"
+ assert (tmp_path / "lib" / "src" / "a copy.py").read_text(encoding="utf-8") == "x"
+ with pytest.raises(EditError):
+ copy_entry(tmp_path, "src", "src/inner")
+
+
def test_delete_without_trash_asks_for_a_permanent_delete(
tmp_path: Path, monkeypatch: pytest.MonkeyPatch
) -> None: