Dodaios is an open-source agent OS for your desktop: it runs your coding agents, browser and apps by voice or chat, on your own machine. Formerly Personal Jarvis.
Python agent-orchestrationai-agentai-coding-assistantclaude-codecoding-agentcomputer-usedesktop-applocal-firstmcppersonal-jarvisvoice-assistantvoice-coding
feat(agentic-ide): create new files in the selected folder, and document the editor
rubenluetke10-beep36e22987d8e9
diff --git a/docs/code-editor.md b/docs/code-editor.mdnew file mode 100644index 0000000000..65d9d5b1b0--- /dev/null+++ b/docs/code-editor.md@@ -0,0 +1,66 @@+# Code editor (Agentic IDE)++The Agentic IDE has a code editor for working by hand beside the coding+agents. It lies over the terminal grid; **Terminals** in its tab bar brings the+terminals back without closing a file.++## Using it++| Action | How |+| --- | --- |+| Open a file | Click it in the side panel's **Folder** tab, or **Ctrl+P** and type part of its name (`name:42` jumps to line 42) |+| Edit and save | Type, then **Ctrl+S** (**Ctrl+Shift+S** saves every open file). A dot on the tab means unsaved changes |+| New file / new folder | The buttons in the Folder tab's header, or right-click. The entry goes into the selected folder, next to the selected file, or into the workspace root when nothing is selected. A name with slashes (`src/new.py`) creates the folders on the way |+| Rename | **F2** or right-click |+| Delete | **Del** or right-click; the entry goes to the system trash |+| See what changed | 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 |+| Tabs | **Ctrl+W** closes, **Ctrl+Tab** switches, **Ctrl+Shift+T** reopens the last closed tab. A single click opens a preview tab (italic) that the next single click replaces; a double click or an edit keeps it |++Every file type opens:++- Text and code open in the editor (Monaco, bundled locally and loaded only+ when the first file opens).+- PDFs, images, audio and video open in built-in viewers.+- Word, Excel, PowerPoint and e-book files show the text read out of them.+- Binaries and files over 5 MB get a read-only look inside.++Non-text files also offer **Open on this computer** for editing them in their+own app.++## Working beside agents++- When an agent changes a file you have open, a clean buffer follows the disk+ by itself.+- When you have unsaved edits at that moment, a bar offers **Load their+ version** or **Keep mine**. A save never silently overwrites an agent's+ edit: every save names the version it was based on, and the server refuses+ a mismatch.+- Saves are atomic and keep the file's line endings, UTF-8 byte-order mark and+ file mode.+- Paths inside `.git` are refused, including through a symlink.++## Checklist++- [x] New File / New Folder create in the selected folder, or next to the+ selected file, or in the workspace root when nothing is selected+- [ ] Unsaved buffers survive closing or restarting the app (open tabs and+ unsaved text come back)+- [ ] Search in all files (Ctrl+Shift+F)+- [ ] Edit text files in encodings other than UTF-8 (Windows-1252, UTF-16)+- [ ] Explorer: drag to move, multi-select, copy and paste entries+- [ ] Warn before a save turns mixed line endings into one+- [ ] Verify the shortcuts on macOS (WKWebView may take Cmd+W / Cmd+Z) and+ Linux (WebKitGTK input)+- [ ] Optional: TypeScript/CSS/HTML language services, a Python language+ server, git change markers in the gutter++## Where it lives++- Backend: `jarvis/agentic_ide/file_editing.py` and the `/workspaces/{id}/`+ routes `text-file`, `text-file/version`, `head-text`, `file-list`,+ `entries`, `entries/move` and `entries/delete` in+ `jarvis/ui/web/agentic_ide_routes.py`.+- Frontend: `components/agentic/editor/`, `store/codeEditor.ts`, and the+ Folder and Changes tabs in+ `components/agentic/sidePanel/explorer/ExplorerPanel.tsx`.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.tsxindex 0f67fc07ca..c8ff52f991 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@@ -36,7 +36,12 @@ function respond(url: string): unknown {if (url.includes("/text-file/version")) return { version: url.includes("src") ? null : "v1" };if (url.includes("/entries")) return { path: "src/new.ts", trashed: true };if (url.includes("/files")) {- if (url.includes("?path=")) return { workspace_id: "w1", root_name: "app", path: "src", truncated: false, entries: [] };+ if (url.includes("?path=src")) {+ return { workspace_id: "w1", root_name: "app", path: "src", truncated: false, entries: [+ { name: "app.ts", path: "src/app.ts", is_directory: false, is_symlink: false },+ ] };+ }+ if (url.includes("?path=")) return { workspace_id: "w1", root_name: "app", path: "", truncated: false, entries: [] };return { workspace_id: "w1", root_name: "app", path: "", truncated: false, entries: [{ name: "src", path: "src", is_directory: true, is_symlink: false },{ name: "README.md", path: "README.md", is_directory: false, is_symlink: false },@@ -138,6 +143,30 @@ describe("ExplorerPanel", () => {expect(JSON.parse(create!.body)).toEqual({ path: "src/new.ts", kind: "file" });});+ it("creates a new entry in the selected folder, or beside the selected file", async () => {+ render(<ExplorerPanel view="files" />);+ await waitFor(() => expect(screen.getAllByTestId("explorer-tree-row")).toHaveLength(2));+ const row = (path: string) => screen.getAllByTestId("explorer-tree-row").find((entry) => entry.dataset.path === path)!;+ const createVia = async (button: string, name: string) => {+ fireEvent.click(screen.getByLabelText(button));+ const field = await screen.findByTestId("explorer-name-field");+ fireEvent.change(field, { target: { value: name } });+ fireEvent.keyDown(field, { key: "Enter" });+ await waitFor(() => expect(screen.queryByTestId("explorer-name-field")).toBeNull());+ };+ const sent = () => calls.filter((call) => call.url.endsWith("/entries")).map((call) => JSON.parse(call.body).path);++ fireEvent.click(row("src"));+ await waitFor(() => expect(row("src/app.ts")).toBeTruthy());+ await createVia("New file", "new.ts");+ fireEvent.click(row("src/app.ts"));+ await createVia("New folder", "lib");+ fireEvent.click(screen.getByTestId("explorer-tree"));+ await createVia("New file", "top.ts");++ await waitFor(() => expect(sent()).toEqual(["src/new.ts", "src/lib", "top.ts"]));+ });+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.tsxindex fc1f87bc8f..ec0b070dd0 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@@ -210,7 +210,8 @@ export function ExplorerPanel({ view }: { view: ExplorerView }) {const { changes, error: changesError, refresh } = useWorkspaceChanges(workspaceId);const [treeNonce, setTreeNonce] = useState(0);const [collapseNonce, setCollapseNonce] = useState(0);- const [creating, setCreating] = useState<{ folder: string; kind: "file" | "directory"; nonce: number } | null>(null);+ // `folder: null` = where the selection is, as the header's New File / New Folder do.+ const [creating, setCreating] = useState<CreateRequest | null>(null);const editorTabs = useCodeEditorStore((state) => (workspaceId ? state.tabs.filter((tab) => tab.workspaceId === workspaceId).length : 0));const editorVisible = useCodeEditorStore((state) => state.visible);@@ -273,10 +274,10 @@ export function ExplorerPanel({ view }: { view: ExplorerView }) {<span className="ml-auto flex shrink-0 items-center">{view === "files" && (<>- <HeaderButton label={t("ide_side_panel.explorer.new_file")} testId="explorer-new-file" onClick={() => setCreating({ folder: "", kind: "file", nonce: Date.now() })}>+ <HeaderButton label={t("ide_side_panel.explorer.new_file")} testId="explorer-new-file" onClick={() => setCreating({ folder: null, kind: "file", nonce: Date.now() })}><FilePlus className="h-3.5 w-3.5" aria-hidden /></HeaderButton>- <HeaderButton label={t("ide_side_panel.explorer.new_folder")} onClick={() => setCreating({ folder: "", kind: "directory", nonce: Date.now() })}>+ <HeaderButton label={t("ide_side_panel.explorer.new_folder")} onClick={() => setCreating({ folder: null, kind: "directory", nonce: Date.now() })}><FolderPlus className="h-3.5 w-3.5" aria-hidden /></HeaderButton><HeaderButton label={t("ide_side_panel.explorer.collapse_all")} onClick={() => setCollapseNonce((value) => value + 1)}>@@ -420,6 +421,13 @@ export function ExplorerPanel({ view }: { view: ExplorerView }) {);}+interface CreateRequest {+ /** The folder to create in; null = the selected folder, or the selected file's folder. */+ folder: string | null;+ kind: "file" | "directory";+ nonce: number;+}+interface TreeProps {workspaceId: string;filter: string;@@ -429,7 +437,7 @@ interface TreeProps {changesKey: string;reloadNonce: number;collapseNonce: number;- creating: { folder: string; kind: "file" | "directory"; nonce: number } | null;+ creating: CreateRequest | null;onCreatingDone: () => void;onCreate: (folder: string, kind: "file" | "directory") => void;absolute: (relative: string) => string;@@ -444,12 +452,15 @@ function NameField({initial,depth,icon,+ where,onSubmit,onCancel,}: {initial: string;depth: number;icon: ReactNode;+ /** The folder the name lands in, shown on hover. */+ where?: string;onSubmit: (name: string) => void;onCancel: () => void;}) {@@ -477,6 +488,7 @@ function NameField({ref={field}defaultValue={initial}data-testid="explorer-name-field"+ title={where}onKeyDown={(event) => {event.stopPropagation();if (event.key === "Enter") finish(true);@@ -612,9 +624,29 @@ function FileTree({setFocused(activePath);}, [activePath, expand]);- // A new entry is typed inside its folder, so that folder must be open.+ // Where a new entry goes, fixed when New File / New Folder is pressed: the+ // folder the request names, else the selected folder, else the selected+ // file's folder, else the workspace root. That folder opens for the name field.+ const [createAt, setCreateAt] = useState<string | null>(null);+ const focusedRef = useRef(focused);+ focusedRef.current = focused;+ const childrenRef = useRef(children);+ childrenRef.current = children;useEffect(() => {- if (creating?.folder) expand(creating.folder);+ if (!creating) {+ setCreateAt(null);+ return;+ }+ let folder = creating.folder;+ if (folder === null) {+ const selected = focusedRef.current;+ const item = selected+ ? Object.values(childrenRef.current).flat().find((entry) => entry.path === selected)+ : undefined;+ folder = !selected ? "" : item?.is_directory ? selected : parentPath(selected);+ }+ setCreateAt(folder);+ if (folder) expand(folder);}, [creating, expand]);const editor = useCodeEditorStore.getState();@@ -685,7 +717,7 @@ function FileTree({const rows: Row[] = [];const walk = (path: string, depth: number) => {- if (creating && creating.folder === path) rows.push({ kind: "create", folder: path, entry: creating.kind, depth });+ if (creating && createAt === path) rows.push({ kind: "create", folder: path, entry: creating.kind, depth });for (const item of sortEntries(children[path] ?? [])) {// Only entries that really sit inside this folder; a bad listing must not loop.if (path && !item.path.startsWith(`${path}/`)) continue;@@ -749,6 +781,11 @@ function FileTree({role="tree"aria-label={t("ide_side_panel.explorer.view_files")}className="min-h-full"+ // 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);+ }}onContextMenu={(event) => openMenu(event, "", true)}>{error && <li className="px-3 py-2 text-[11px] text-destructive">{error}</li>}@@ -759,6 +796,7 @@ function FileTree({<NameFieldinitial=""depth={row.depth}+ where={absolute(row.folder).replace(/[\\/]+$/, "")}icon={row.entry === "directory" ? <Folder className="h-4 w-4 shrink-0 text-muted-foreground" aria-hidden /> : <FilePlus className="h-4 w-4 shrink-0 text-muted-foreground" aria-hidden />}onSubmit={(name) => void create(row.folder, row.entry, name)}onCancel={onCreatingDone}