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): the folder picker opens a typed path, makes a new folder, and shows hidden ones

rubenluetke10-beep3b824249883c
diff --git a/jarvis/agentic_ide/folders.py b/jarvis/agentic_ide/folders.py
index 4d14ae4e15..b7abeffdbc 100644
--- a/jarvis/agentic_ide/folders.py
+++ b/jarvis/agentic_ide/folders.py
@@ -426,7 +426,14 @@ def search_folders(
if budget <= 0:
break
name = item.name
- if name in _SKIP_DIRS or _is_hidden(name):
+ if name in _SKIP_DIRS:
+ continue
+ # Hidden folders are matched only when the query itself
+ # starts with a dot (".claude", ".config") — that is the
+ # one time a person means one — and are never walked into:
+ # ".cache" alone can hold more entries than the budget.
+ hidden = _is_hidden(name)
+ if hidden and not needle.startswith("."):
continue
try:
if not item.is_dir(follow_symlinks=False):
@@ -452,7 +459,7 @@ def search_folders(
),
)
)
- if depth < max_depth:
+ if depth < max_depth and not hidden:
queue.append((child, depth + 1))
except (PermissionError, OSError):
continue
@@ -461,6 +468,50 @@ def search_folders(
return [entry for _t, _k, _n, entry in hits[:limit]]
+def create_folder(parent: str | Path | None, name: str) -> tuple[FolderEntry | None, str | None]:
+ """Make one new folder called ``name`` inside ``parent``.
+
+ Returns ``(entry, error_message)``. Without a parent the folder goes into
+ the home directory — the one place that exists on every machine.
+
+ One segment only: a name carrying a separator would silently create a tree
+ the person never saw, so it is refused rather than honoured. The parent must
+ already exist for the same reason. A folder that is already there is handed
+ back as it is — the person wanted that folder, and it now exists; whether
+ it was made just now is not something they need to be told twice.
+ """
+ cleaned = name.strip()
+ if not cleaned or cleaned in {".", ".."}:
+ return None, "Give the new folder a name first."
+ if any(sep in cleaned for sep in ("/", "\\", "\x00")):
+ return None, "A folder name cannot contain slashes. Type just the name."
+
+ base = Path(parent).expanduser() if parent else Path.home()
+ try:
+ if not base.is_dir():
+ return None, (f"There is no folder called {base}, so nothing can be created inside it.")
+ except OSError as exc:
+ return None, f"Could not open {base}: {exc}"
+
+ target = base / cleaned
+ try:
+ if target.is_dir():
+ is_project, is_repo = _looks_like_project(target)
+ return (
+ FolderEntry(name=cleaned, path=str(target), is_project=is_project, is_repo=is_repo),
+ None,
+ )
+ if target.exists():
+ return None, f"{target} already exists and is a file, not a folder."
+ target.mkdir()
+ except PermissionError:
+ return None, f"Jarvis is not allowed to create folders inside {base}."
+ except OSError as exc:
+ return None, f"Could not create {target}: {exc}"
+
+ return FolderEntry(name=cleaned, path=str(target), is_project=False, is_repo=False), None
+
+
def _git_branch(root: Path) -> str | None:
"""Current branch from ``.git/HEAD`` — no subprocess, no git required."""
head = root / ".git" / "HEAD"
@@ -581,6 +632,7 @@ __all__ = [
"ProjectProfile",
"WorkspaceEntry",
"WorkspaceListing",
+ "create_folder",
"list_dir",
"list_workspace_dir",
"probe_project",
diff --git a/jarvis/ui/web/agentic_ide_routes.py b/jarvis/ui/web/agentic_ide_routes.py
index 2623029fb1..f263f0cc17 100644
--- a/jarvis/ui/web/agentic_ide_routes.py
+++ b/jarvis/ui/web/agentic_ide_routes.py
@@ -11,6 +11,7 @@ Endpoints (prefix ``/api/agentic-ide``):
* ``GET /folders`` → browse folders (no path = start points)
* ``GET /folders/native`` → can this machine show the OS folder window?
* ``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
* ``GET /workspaces`` → every open workspace, in tab order
* ``GET /workspaces/{id}/files`` → browse that workspace's file tree
@@ -98,6 +99,7 @@ from jarvis.agentic_ide.fleet_actions import (
wait_for_prompt_ready,
)
from jarvis.agentic_ide.folders import (
+ create_folder,
list_dir,
list_workspace_dir,
search_folders,
@@ -692,6 +694,25 @@ class SearchResponse(BaseModel):
truncated: bool = False
+class CreateFolderRequest(BaseModel):
+ parent: str | None = Field(
+ default=None,
+ description="Folder to create it in; the home folder when omitted.",
+ )
+ name: str = Field(
+ min_length=1,
+ max_length=255,
+ description="Name of the new folder — one segment, no slashes.",
+ )
+
+
+class CreateFolderResponse(BaseModel):
+ folder: FolderItem | None = Field(
+ default=None, description="The folder, whether made just now or already there."
+ )
+ error: str | None = Field(default=None, description="Why nothing was created.")
+
+
class RecentItem(BaseModel):
path: str
name: str
@@ -1349,6 +1370,27 @@ async def search(q: str, limit: int = 40) -> SearchResponse:
)
+ "/folders/create", response_model=CreateFolderResponse, summary="Create a new folder"
+)
+async def create_new_folder(req: CreateFolderRequest) -> CreateFolderResponse:
+ """Make one folder so a workspace can start in a place that did not exist yet.
+
+ A new project has no folder to pick; before this route the wizard could only
+ open what was already on disk, and "make it in Explorer first, then come
+ back" is the kind of detour nobody should need. One segment inside an
+ existing parent, never a whole tree — see ``folders.create_folder``. A
+ refusal comes back as ``error`` with the reason, not as a status code: the
+ picker shows it next to the name field the same way it shows a path that
+ does not exist.
+ """
+ entry, error = await asyncio.to_thread(create_folder, req.parent, req.name)
+ return CreateFolderResponse(
+ folder=FolderItem(**asdict(entry)) if entry else None,
+ error=error,
+ )
+
+
@router.get(
"/folders/native",
response_model=NativePickerSupport,
diff --git a/jarvis/ui/web/frontend/src/components/agentic/FolderPicker.test.tsx b/jarvis/ui/web/frontend/src/components/agentic/FolderPicker.test.tsx
index ba157e61e3..18f63a83cb 100644
--- a/jarvis/ui/web/frontend/src/components/agentic/FolderPicker.test.tsx
+++ b/jarvis/ui/web/frontend/src/components/agentic/FolderPicker.test.tsx
@@ -9,6 +9,7 @@ vi.mock("@/lib/agenticIdeApi", () => ({
resolveDroppedFolder: vi.fn(),
fetchNativePickerSupport: vi.fn(),
openNativePicker: vi.fn(),
+ createFolder: vi.fn(),
}));
import {
@@ -16,6 +17,7 @@ import {
extractDropPayload,
isAbsolutePath,
joinPath,
+ looksLikePath,
normalizeTypedPath,
resolveTypedPath,
separatorOf,
@@ -300,7 +302,7 @@ describe("the system folder window", () => {
await waitFor(() => expect(onSelect).toHaveBeenCalledWith("C:\\work\\shop"));
// And the in-page browser follows it there, so both views agree.
- expect(api.fetchFolders).toHaveBeenCalledWith("C:\\work\\shop");
+ expect(api.fetchFolders).toHaveBeenCalledWith("C:\\work\\shop", false);
});
it("says a window is waiting, because it can open behind the app", async () => {
@@ -498,3 +500,143 @@ describe("typing a path", () => {
expect(onSelect).not.toHaveBeenCalled();
});
});
+
+describe("a path in the search field", () => {
+ it("opens that folder instead of searching the machine for its name", async () => {
+ // Reported: `C:\Users\me\.claude` typed into the search found nothing —
+ // no folder is CALLED that — and the wizard looked broken.
+ vi.mocked(api.fetchFolders).mockImplementation(async (target) =>
+ target === "C:\\Users\\me\\.claude"
+ ? {
+ path: "C:\\Users\\me\\.claude",
+ parent: "C:\\Users\\me",
+ entries: [
+ {
+ name: "skills",
+ path: "C:\\Users\\me\\.claude\\skills",
+ is_project: false,
+ is_repo: false,
+ },
+ ],
+ device_name: "Box",
+ }
+ : LISTING,
+ );
+ const onSelect = vi.fn();
+ render(<FolderPicker selected={null} onSelect={onSelect} />);
+ await screen.findByText("webshop");
+
+ fireEvent.change(screen.getByTestId("folder-search"), {
+ target: { value: "C:\\Users\\me\\.claude" },
+ });
+
+ await waitFor(() => expect(onSelect).toHaveBeenCalledWith("C:\\Users\\me\\.claude"), {
+ timeout: 2000,
+ });
+ expect(api.searchFolders).not.toHaveBeenCalled();
+ // A dot-name asks for hidden folders by itself; nobody has to find the switch.
+ expect(api.fetchFolders).toHaveBeenCalledWith("C:\\Users\\me\\.claude", true);
+ expect(await screen.findByText("skills")).toBeTruthy();
+ });
+
+ it("reads a pasted prompt as the path inside it", () => {
+ expect(normalizeTypedPath("PS C:\\Users\\me\\.claude>")).toBe("C:\\Users\\me\\.claude");
+ expect(normalizeTypedPath("C:\\Users\\me\\.claude> ")).toBe("C:\\Users\\me\\.claude");
+ expect(looksLikePath("C:\\Users\\me")).toBe(true);
+ expect(looksLikePath("Desktop/shop")).toBe(true);
+ expect(looksLikePath("~")).toBe(true);
+ expect(looksLikePath("shop")).toBe(false);
+ });
+
+ it("offers to create the folder when the last segment does not exist yet", async () => {
+ vi.mocked(api.fetchFolders).mockImplementation(async (target) =>
+ target === "/home/ruben/newshop"
+ ? {
+ path: "/home/ruben/newshop",
+ parent: "/home/ruben",
+ entries: [],
+ error: "There is no folder called /home/ruben/newshop.",
+ device_name: "Box",
+ }
+ : { ...LISTING, path: "/home/ruben", parent: "/home" },
+ );
+ vi.mocked(api.createFolder).mockResolvedValue({
+ folder: { name: "newshop", path: "/home/ruben/newshop", is_project: false, is_repo: false },
+ error: null,
+ });
+ const onSelect = vi.fn();
+ render(<FolderPicker selected={null} onSelect={onSelect} />);
+ await screen.findByText("webshop");
+
+ fireEvent.change(screen.getByTestId("folder-search"), {
+ target: { value: "/home/ruben/newshop" },
+ });
+
+ const offer = await screen.findByTestId("create-offer", {}, { timeout: 2000 });
+ expect(offer.textContent).toContain("newshop");
+ // Nothing is chosen until the folder exists.
+ expect(onSelect).not.toHaveBeenCalled();
+
+ fireEvent.click(offer);
+ await waitFor(() =>
+ expect(api.createFolder).toHaveBeenCalledWith({ parent: "/home/ruben", name: "newshop" }),
+ );
+ await waitFor(() => expect(onSelect).toHaveBeenCalledWith("/home/ruben/newshop"));
+ });
+});
+
+describe("a new folder", () => {
+ it("is made in the folder on screen and becomes the selection", async () => {
+ vi.mocked(api.fetchFolders).mockResolvedValue({
+ ...LISTING,
+ path: "/home/ruben",
+ parent: "/home",
+ });
+ vi.mocked(api.createFolder).mockResolvedValue({
+ folder: { name: "shop2", path: "/home/ruben/shop2", is_project: false, is_repo: false },
+ error: null,
+ });
+ const onSelect = vi.fn();
+ render(<FolderPicker selected={null} onSelect={onSelect} />);
+ await screen.findByText("webshop");
+
+ fireEvent.click(screen.getByTestId("new-folder"));
+ fireEvent.change(screen.getByTestId("new-folder-name"), { target: { value: "shop2" } });
+ fireEvent.submit(screen.getByTestId("new-folder-form"));
+
+ await waitFor(() =>
+ expect(api.createFolder).toHaveBeenCalledWith({ parent: "/home/ruben", name: "shop2" }),
+ );
+ await waitFor(() => expect(onSelect).toHaveBeenCalledWith("/home/ruben/shop2"));
+ });
+
+ it("shows why it could not be made and keeps the name for correcting", async () => {
+ vi.mocked(api.createFolder).mockResolvedValue({
+ folder: null,
+ error: "A folder name cannot contain slashes. Type just the name.",
+ });
+ const onSelect = vi.fn();
+ render(<FolderPicker selected={null} onSelect={onSelect} />);
+ await screen.findByText("webshop");
+
+ fireEvent.click(screen.getByTestId("new-folder"));
+ fireEvent.change(screen.getByTestId("new-folder-name"), { target: { value: "a/b" } });
+ fireEvent.submit(screen.getByTestId("new-folder-form"));
+
+ expect(await screen.findByText(/cannot contain slashes/)).toBeTruthy();
+ expect((screen.getByTestId("new-folder-name") as HTMLInputElement).value).toBe("a/b");
+ expect(onSelect).not.toHaveBeenCalled();
+ });
+});
+
+describe("hidden folders", () => {
+ it("are listed only once the switch is on", async () => {
+ render(<FolderPicker selected={null} onSelect={vi.fn()} />);
+ await screen.findByText("webshop");
+ expect(api.fetchFolders).toHaveBeenLastCalledWith(null, false);
+
+ fireEvent.click(screen.getByTestId("toggle-hidden"));
+
+ await waitFor(() => expect(api.fetchFolders).toHaveBeenLastCalledWith(null, true));
+ });
+});
diff --git a/jarvis/ui/web/frontend/src/components/agentic/FolderPicker.tsx b/jarvis/ui/web/frontend/src/components/agentic/FolderPicker.tsx
index bc3e5b3faa..ac8ab20de4 100644
--- a/jarvis/ui/web/frontend/src/components/agentic/FolderPicker.tsx
+++ b/jarvis/ui/web/frontend/src/components/agentic/FolderPicker.tsx
@@ -9,13 +9,20 @@
* 2. **Recents** — the folders opened before, with their previous layout. One
* click and the launcher already knows how many terminals to open.
* 3. **Search** — type a name, get matches from anywhere under home and the
- * usual code directories. Faster than clicking down five levels.
- * 4. **Browsing** — the list, projects and repositories sorted first.
+ * usual code directories. Faster than clicking down five levels. The same
+ * field reads a PATH as a place, not a name: `C:\Users\me\.claude` opens
+ * that folder on the spot instead of searching the disk for a folder called
+ * that (which found nothing, and was reported as "search is broken").
+ * 4. **Browsing** — the list, projects and repositories sorted first. Hidden
+ * folders (`.claude`, `.config`) stay out of the way until asked for.
* 5. **Typing a path** — with completion, the way `cd` works in a terminal.
* 6. **Drag and drop** — drop a folder (or a file inside it) anywhere on the
* panel. Inside the desktop shell the host reports the real path
* (`waitForNativeDrop`); in a browser only the NAME is known, and the
* backend searches for it — see `extractDropPayload`.
+ * 7. **A new folder** — a project that does not exist yet has nothing to pick.
+ * "New folder" makes one inside the folder on screen, and a typed path that
+ * is not a folder yet is offered for creation rather than only refused.
*
* The in-page browser is not a fallback for the system window, it is the floor:
* the system window opens on the machine the BACKEND runs on, so it is useless
@@ -45,9 +52,12 @@ import { useCallback, useEffect, useMemo, useRef, useState } from "react";
import {
CornerDownLeft,
CornerLeftUp,
+ Eye,
+ EyeOff,
Folder,
FolderGit2,
FolderOpen,
+ FolderPlus,
Loader2,
RefreshCw,
Search,
@@ -59,6 +69,7 @@ import { waitForNativeDrop } from "@/lib/nativeDrop";
import { useDragSessionEnd } from "./dragSessionEnd";
import { Button, Field, IconButton, SectionLabel } from "./controls";
import {
+ createFolder,
fetchFolders,
fetchNativePickerSupport,
fetchRecents,
@@ -161,11 +172,37 @@ export function FolderPicker({
const [nativeOpen, setNativeOpen] = useState(false);
const [nativeNote, setNativeNote] = useState<string | null>(null);
- const load = useCallback(async (target: string | null) => {
+ // Dot-folders are noise in a project list and the one thing someone opening
+ // `.claude` needs — so they are a switch, off by default, and a typed name
+ // that starts with a dot turns them on for that lookup by itself.
+ const [showHidden, setShowHidden] = useState(false);
+ const showHiddenRef = useRef(showHidden);
+ showHiddenRef.current = showHidden;
+
+ // The search field holding a path whose last segment is not a folder (yet):
+ // the folder above it is on screen, filtered to names starting with this.
+ const [pathLeaf, setPathLeaf] = useState<string | null>(null);
+ // Where a folder that does not exist could be made, and what to call it.
+ const [createOffer, setCreateOffer] = useState<{
+ parent: string | null;
+ name: string;
+ } | null>(null);
+ const [naming, setNaming] = useState(false);
+ const [newName, setNewName] = useState("");
+ const [creating, setCreating] = useState(false);
+ const [createNote, setCreateNote] = useState<string | null>(null);
+
+ // Read through a ref by the search effect: the launcher may hand in a fresh
+ // callback every render, and an effect keyed on it would re-run — and
+ // re-fetch — on each of its own state updates.
+ const onSelectRef = useRef(onSelect);
+ onSelectRef.current = onSelect;
+
+ const load = useCallback(async (target: string | null, hidden?: boolean) => {
setLoading(true);
setError(null);
try {
- const res = await fetchFolders(target);
+ const res = await fetchFolders(target, hidden ?? showHiddenRef.current);
setPath(res.path);
setParent(res.parent);
setEntries(res.entries);
@@ -226,9 +263,69 @@ export function FolderPicker({
.finally(() => setNativeOpen(false));
};
+ /**
+ * A path typed into the search field is a place to go, not a name to find.
+ *
+ * The folder is listed and becomes the selection when it exists. When it does
+ * not, the folder ABOVE it is listed instead, narrowed to names starting with
+ * the last segment — so a half-typed name completes on screen — and, once
+ * nothing matches, creating it is offered. Nothing here is relative to the
+ * folder that happened to be open: a typed path means exactly what it says.
+ */
+ const goToTypedPath = useCallback((typed: string) => {
+ const { dir, leaf } = splitTypedPath(typed);
+ const hidden = showHiddenRef.current || leaf.startsWith(".");
+ return fetchFolders(typed, hidden).then(async (res) => {
+ if (res.device_name) setDeviceName(res.device_name);
+ if (!res.error) {
+ setPath(res.path);
+ setParent(res.parent);
+ setEntries(res.entries);
+ setPathLeaf(null);
+ setCreateOffer(null);
+ setError(null);
+ if (res.path) onSelectRef.current(res.path);
+ return;
+ }
+ if (!dir || !leaf) {
+ setError(res.error);
+ setPathLeaf(null);
+ setCreateOffer(null);
+ return;
+ }
+ const above = await fetchFolders(dir, hidden);
+ if (above.error) {
+ setError(above.error);
+ setPathLeaf(null);
+ setCreateOffer(null);
+ return;
+ }
+ setPath(above.path);
+ setParent(above.parent);
+ setEntries(above.entries);
+ setError(null);
+ setPathLeaf(leaf);
+ setCreateOffer({ parent: above.path, name: leaf });
+ });
+ }, []);
+
// Server-side search once the query is long enough; shorter input just filters
- // the folder list already on screen, which feels instant.
+ // the folder list already on screen, which feels instant. A path goes its own
+ // way (see `goToTypedPath`) and never reaches the name search.
useEffect(() => {
+ const typed = normalizeTypedPath(query);
+ if (looksLikePath(typed)) {
+ setSearchHits(null);
+ setSearching(true);
+ const handle = window.setTimeout(() => {
+ goToTypedPath(typed)
+ .catch((e) => setError((e as Error).message))
+ .finally(() => setSearching(false));
+ }, SEARCH_DEBOUNCE_MS);
+ return () => window.clearTimeout(handle);
+ }
+ setPathLeaf(null);
+ setCreateOffer(null);
const trimmed = query.trim();
if (trimmed.length < SEARCH_MIN) {
setSearchHits(null);
@@ -243,22 +340,59 @@ export function FolderPicker({
.finally(() => setSearching(false));
}, SEARCH_DEBOUNCE_MS);
return () => window.clearTimeout(handle);
- }, [query]);
+ }, [query, goToTypedPath]);
const visible = useMemo(() => {
if (searchHits !== null) return searchHits;
+ if (pathLeaf !== null) {
+ const needle = pathLeaf.toLowerCase();
+ return entries.filter((e) => e.name.toLowerCase().startsWith(needle));
+ }
+ const typed = normalizeTypedPath(query);
+ // A path on its way to being listed: the folder itself is what is shown,
+ // not the list filtered by a string no folder is called.
+ if (looksLikePath(typed)) return entries;
const needle = query.trim().toLowerCase();
if (!needle) return entries;
return entries.filter((e) => e.name.toLowerCase().includes(needle));
- }, [entries, query, searchHits]);
+ }, [entries, query, searchHits, pathLeaf]);
const open = (item: FolderItem) => {
onSelect(item.path);
setQuery("");
setSearchHits(null);
+ setPathLeaf(null);
+ setCreateOffer(null);
void load(item.path);
};
+ /** Make the folder, then treat it like any other folder that was clicked. */
+ const makeFolder = (parent: string | null, name: string) => {
+ if (creating) return;
+ setCreating(true);
+ setCreateNote(null);
+ createFolder({ parent, name })
+ .then((res) => {
+ if (res.error || !res.folder) {
+ setCreateNote(res.error || "Could not create that folder.");
+ return;
+ }
+ setNaming(false);
+ setNewName("");
+ setError(null);
+ open(res.folder);
+ })
+ .catch((e) => setCreateNote((e as Error).message))
+ .finally(() => setCreating(false));
+ };
+
+ const toggleHidden = () => {
+ const next = !showHidden;
+ setShowHidden(next);
+ showHiddenRef.current = next;
+ if (searchHits === null) void load(path, next);
+ };
+
/**
* A typed path is checked before it is chosen. The old order — select first,
* then list — let "cd haral\.personal-jarvis" (not a folder anywhere) reach
@@ -271,16 +405,22 @@ export function FolderPicker({
if (!value) return;
setLoading(true);
setError(null);
- fetchFolders(value)
+ const { dir, leaf } = splitTypedPath(value);
+ fetchFolders(value, showHiddenRef.current || leaf.startsWith("."))
.then((res) => {
if (res.device_name) setDeviceName(res.device_name);
if (res.error) {
setError(res.error);
+ // Not a folder — but it could be one. The offer sits next to the
+ // message, so a typo is corrected and a new project is created from
+ // the same line.
+ setCreateOffer(dir && leaf ? { parent: dir, name: leaf } : null);
return;
}
setPath(res.path);
setParent(res.parent);
setEntries(res.entries);
+ setCreateOffer(null);
onSelect(res.path ?? value);
})
.catch((e) => setError((e as Error).message))
@@ -385,8 +525,8 @@ export function FolderPicker({
<Field
value={query}
onChange={(e) => setQuery(e.target.value)}
- placeholder="Search folders by name…"
- aria-label="Search folders by name"
+ placeholder="Search folders by name, or type a path…"
+ aria-label="Search folders by name, or type a path"
data-testid="folder-search"
className="w-full pl-8 pr-7"
spellCheck={false}
@@ -417,6 +557,38 @@ export function FolderPicker({
{nativeOpen ? "Window open…" : "Browse"}
</Button>
)}
+ <Button
+ onClick={() => {
+ setNaming(true);
+ setNewName("");
+ setCreateNote(null);
+ }}
+ disabled={naming}
+ data-testid="new-folder"
+ title={`Make a new folder in ${path ?? "your home folder"}`}
+ >
+ <FolderPlus className="h-3.5 w-3.5" />
+ New folder
+ </Button>
+ <IconButton
+ label={showHidden ? "Hide hidden folders" : "Show hidden folders"}
+ title={
+ showHidden
+ ? "Hidden folders (names starting with a dot) are shown"
+ : "Also list hidden folders — names starting with a dot"
+ }
+ aria-pressed={showHidden}
+ onClick={toggleHidden}
+ disabled={loading}
+ data-testid="toggle-hidden"
+ className={cn(showHidden && "text-primary")}
+ >
+ {showHidden ? (
+ <Eye className="h-4 w-4" />
+ ) : (
+ <EyeOff className="h-4 w-4" />
+ )}
+ </IconButton>
<IconButton
label="Go up one folder"
onClick={() => void load(parent)}
@@ -470,6 +642,56 @@ export function FolderPicker({
</p>
)}
+ {/* --------------------------------------------------------- new folder */}
+ {naming && (
+ <form
+ data-testid="new-folder-form"
+ className="flex items-center gap-1.5 px-3 pb-2"
+ onSubmit={(e) => {
+ e.preventDefault();
+ if (newName.trim()) makeFolder(path, newName);
+ }}
+ >
+ <FolderPlus className="h-4 w-4 shrink-0 text-primary" />
+ <Field
+ autoFocus
+ value={newName}
+ onChange={(e) => setNewName(e.target.value)}
+ onKeyDown={(e) => {
+ if (e.key === "Escape") setNaming(false);
+ }}
+ placeholder={`Name of the new folder in ${path ?? "your home folder"}`}
+ aria-label="Name of the new folder"
+ data-testid="new-folder-name"
+ className="min-w-0 flex-1"
+ spellCheck={false}
+ autoComplete="off"
+ />
+ <Button
+ type="submit"
+ variant="primary"
+ disabled={creating || !newName.trim()}
+ data-testid="new-folder-create"
+ >
+ {creating ? (
+ <Loader2 className="h-3.5 w-3.5 animate-spin" />
+ ) : (
+ <FolderPlus className="h-3.5 w-3.5" />
+ )}
+ Create
+ </Button>
+ <IconButton
+ label="Cancel new folder"
+ onClick={() => {
+ setNaming(false);
+ setCreateNote(null);
+ }}
+ >
+ <X className="h-4 w-4" />
+ </IconButton>
+ </form>
+ )}
+
{/* --------------------------------------------------------------- list */}
<div className="min-h-[16rem] flex-1 overflow-y-auto scrollbar-jarvis border-y border-border/70">
{recents.length > 0 && !searchingMachine && (
@@ -537,11 +759,42 @@ export function FolderPicker({
</>
)}
+ {/*
+ The typed path's last segment is not a folder in the folder on
+ screen, and nothing there starts with it either: the one thing left
+ to do with that name is make it.
+ */}
+ {createOffer && pathLeaf !== null && visible.length === 0 && !searching && (
+ <button
+ type="button"
+ data-testid="create-offer"
+ onClick={() => makeFolder(createOffer.parent, createOffer.name)}
+ disabled={creating}
+ className="flex w-full items-center gap-2.5 px-3 py-2 text-left text-sm text-primary transition-colors hover:bg-secondary/60"
+ >
+ {creating ? (
+ <Loader2 className="h-4 w-4 shrink-0 animate-spin" />
+ ) : (
+ <FolderPlus className="h-4 w-4 shrink-0" />
+ )}
+ <span className="min-w-0 flex-1">
+ <span className="block truncate">
+ Create folder “{createOffer.name}”
+ </span>
+ <span className="block truncate font-mono text-[10px] text-muted-foreground">
+ in {createOffer.parent ?? "your home folder"}
+ </span>
+ </span>
+ </button>
+ )}
+
{visible.length === 0 && !loading && !searching ? (
<p className="px-3 py-4 text-sm text-muted-foreground">
{searchingMachine
? "No folder with that name was found."
- : "Nothing to list here — search above, drop a folder, or type its path below."}
+ : pathLeaf !== null
+ ? `No folder here starts with “${pathLeaf}”.`
+ : "Nothing to list here — search above, drop a folder, or type its path below."}
</p>
) : (
<ul>
@@ -603,16 +856,37 @@ export function FolderPicker({
</div>
{/* ------------------------------------------------------------- typing */}
- <PathInput base={path} onUse={usePath} />
+ <PathInput base={path} showHidden={showHidden} onUse={usePath} />
{/* ---------------------------------------------------------- reporting */}
- {(error || nativeNote || dropNote) && (
+ {(error || nativeNote || dropNote || createNote) && (
<div className="space-y-1 px-3 pb-3">
{error && (
<p className="text-xs text-destructive" role="alert">
{error}
</p>
)}
+ {/* The path field's "no such folder", answered: make it. */}
+ {error && createOffer && pathLeaf === null && (
+ <Button
+ onClick={() => makeFolder(createOffer.parent, createOffer.name)}
+ disabled={creating}
+ data-testid="create-offer"
+ className="h-7 text-xs"
+ >
+ {creating ? (
+ <Loader2 className="h-3.5 w-3.5 animate-spin" />
+ ) : (
+ <FolderPlus className="h-3.5 w-3.5" />
+ )}
+ Create folder “{createOffer.name}”
+ </Button>
+ )}
+ {createNote && (
+ <p className="text-xs text-destructive" role="alert">
+ {createNote}
+ </p>
+ )}
{nativeNote && !nativeOpen && (
<p className="text-xs text-muted-foreground" role="alert">
{nativeNote}
@@ -685,6 +959,9 @@ export function joinPath(base: string, name: string): string {
export function normalizeTypedPath(raw: string): string {
let value = raw.trim();
value = value.replace(/^cd(?:\s+\/d)?(?:\s+|$)/i, "").trim();
+ // A prompt copied whole — `PS C:\Users\me>` — is the path with a shell's
+ // decoration on both ends; the decoration is not part of the folder.
+ value = value.replace(/^PS\s+/, "").replace(/\s*>$/, "").trim();
const quoted = value.match(/^(["'])(.*)\1$/);
if (quoted) value = quoted[2].trim();
return value;
@@ -695,6 +972,17 @@ export function isAbsolutePath(value: string): boolean {
return /^(?:[a-zA-Z]:[\\/]|[\\/]|~)/.test(value);
}
+/**
+ * Text that names a PLACE rather than a folder to look for.
+ *
+ * A root or a separator anywhere is the tell: nobody searches for a folder
+ * called `Desktop\shop`, they mean the one at that path. A bare name stays a
+ * search, which is what a search field is for.
+ */
+export function looksLikePath(value: string): boolean {
+ return isAbsolutePath(value) || /[\\/]/.test(value);
+}
+
/**
* The folder a typed path means, given the folder on screen.
*
@@ -725,9 +1013,11 @@ export function resolveTypedPath(raw: string, base: string | null): string {
*/
function PathInput({
base,
+ showHidden,
onUse,
}: {
base: string | null;
+ showHidden: boolean;
onUse: (value: string) => void;
}) {
const [value, setValue] = useState("");
@@ -752,7 +1042,9 @@ function PathInput({
}
let cancelled = false;
const handle = window.setTimeout(() => {
- fetchFolders(lookupDir || null)
+ // A dot-name completes against hidden folders whether or not they are
+ // switched on: typing `.cl` is the request to see `.claude`.
+ fetchFolders(lookupDir || null, showHidden || leaf.startsWith("."))
.then((res) => {
if (cancelled) return;
const needle = leaf.toLowerCase();
@@ -771,7 +1063,7 @@ function PathInput({
cancelled = true;
window.clearTimeout(handle);
};
- }, [lookupDir, leaf, value, base]);
+ }, [lookupDir, leaf, value, base, showHidden]);
/** Take a suggestion and leave the cursor ready for the next segment. */
const complete = (item: FolderItem) => {
diff --git a/jarvis/ui/web/frontend/src/lib/agenticIdeApi.ts b/jarvis/ui/web/frontend/src/lib/agenticIdeApi.ts
index 6976ec2aef..5627feea30 100644
--- a/jarvis/ui/web/frontend/src/lib/agenticIdeApi.ts
+++ b/jarvis/ui/web/frontend/src/lib/agenticIdeApi.ts
@@ -859,9 +859,40 @@ export function refreshTerminalRecap(
return recapCall(recapUrl(name, workspaceId, "/refresh"), { method: "POST" });
}
-export function fetchFolders(path?: string | null): Promise<FoldersResponse> {
- const query = path ? `?path=${encodeURIComponent(path)}` : "";
- return getJson<FoldersResponse>(`/api/agentic-ide/folders${query}`);
+export function fetchFolders(
+ path?: string | null,
+ includeHidden = false,
+): Promise<FoldersResponse> {
+ const qs = new URLSearchParams();
+ if (path) qs.set("path", path);
+ if (includeHidden) qs.set("include_hidden", "true");
+ const query = qs.toString();
+ return getJson<FoldersResponse>(
+ `/api/agentic-ide/folders${query ? `?${query}` : ""}`,
+ );
+}
+
+export interface CreateFolderResponse {
+ folder: FolderItem | null;
+ error: string | null;
+}
+
+/**
+ * Make one new folder inside an existing one (the home folder when `parent`
+ * is null). A refusal — bad name, missing parent, no permission — comes back
+ * as `error`, never as a thrown exception, so the picker can show it in place.
+ */
+export async function createFolder(payload: {
+ parent: string | null;
+ name: string;
+}): Promise<CreateFolderResponse> {
+ const res = await fetch("/api/agentic-ide/folders/create", {
+ method: "POST",
+ headers: { "Content-Type": "application/json" },
+ body: JSON.stringify(payload),
+ });
+ if (!res.ok) throw new Error(await detail(res));
+ return (await res.json()) as CreateFolderResponse;
}
/** Load one level of an open workspace's file tree. */
diff --git a/tests/unit/agentic_ide/test_folders_create.py b/tests/unit/agentic_ide/test_folders_create.py
new file mode 100644
index 0000000000..77663fa2cf
--- /dev/null
+++ b/tests/unit/agentic_ide/test_folders_create.py
@@ -0,0 +1,104 @@
+"""Making a folder from the picker, and finding a hidden one by name.
+
+A new project has no folder to pick; a `.claude` folder is hidden from the
+search. Both left the wizard with "go make it in Explorer first", which is the
+detour the picker exists to remove.
+"""
+
+from __future__ import annotations
+
+from pathlib import Path
+
+import pytest
+
+from jarvis.agentic_ide.folders import create_folder, search_folders
+
+
+# ------------------------------------------------------------------- create
+def test_creates_one_folder_inside_an_existing_one(tmp_path: Path) -> None:
+ entry, error = create_folder(tmp_path, "shop")
+
+ assert error is None
+ assert entry is not None
+ assert entry.name == "shop"
+ assert Path(entry.path) == tmp_path / "shop"
+ assert (tmp_path / "shop").is_dir()
+ assert entry.is_project is False
+
+
+def test_surrounding_whitespace_is_not_part_of_the_name(tmp_path: Path) -> None:
+ entry, error = create_folder(tmp_path, " shop ")
+
+ assert error is None
+ assert entry is not None and entry.name == "shop"
+
+
+def test_a_folder_already_there_is_handed_back_not_refused(tmp_path: Path) -> None:
+ (tmp_path / "shop").mkdir()
+ (tmp_path / "shop" / ".git").mkdir()
+
+ entry, error = create_folder(tmp_path, "shop")
+
+ assert error is None
+ assert entry is not None
+ assert entry.is_repo is True
+
+
+def test_a_file_of_that_name_is_an_error(tmp_path: Path) -> None:
+ (tmp_path / "shop").write_text("", encoding="utf-8")
+
+ entry, error = create_folder(tmp_path, "shop")
+
+ assert entry is None
+ assert error is not None and "file" in error
+
+
[email protected]("name", ["", " ", ".", "..", "a/b", "a\\b"])
+def test_refuses_names_that_are_not_one_plain_segment(tmp_path: Path, name: str) -> None:
+ entry, error = create_folder(tmp_path, name)
+
+ assert entry is None
+ assert error
+ assert not any(p.is_dir() for p in tmp_path.iterdir())
+
+
+def test_a_missing_parent_is_reported_not_created(tmp_path: Path) -> None:
+ entry, error = create_folder(tmp_path / "nowhere", "shop")
+
+ assert entry is None
+ assert error is not None and "nowhere" in error
+ assert not (tmp_path / "nowhere").exists()
+
+
+def test_no_parent_means_home(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> None:
+ monkeypatch.setattr(Path, "home", classmethod(lambda cls: tmp_path))
+
+ entry, error = create_folder(None, "shop")
+
+ assert error is None
+ assert entry is not None and Path(entry.path) == tmp_path / "shop"
+
+
+# ------------------------------------------------------------------- hidden
+def test_search_finds_a_hidden_folder_when_asked_for_by_its_dot_name(tmp_path: Path) -> None:
+ (tmp_path / ".claude").mkdir()
+ (tmp_path / "claude-notes").mkdir()
+
+ names = [e.name for e in search_folders(".claude", roots=[tmp_path])]
+
+ assert names == [".claude"]
+
+
+def test_search_still_hides_dot_folders_for_an_ordinary_query(tmp_path: Path) -> None:
+ (tmp_path / ".claude").mkdir()
+ (tmp_path / "claude-notes").mkdir()
+
+ names = [e.name for e in search_folders("claude", roots=[tmp_path])]
+
+ assert names == ["claude-notes"]
+
+
+def test_search_never_walks_into_a_hidden_folder(tmp_path: Path) -> None:
+ (tmp_path / ".cache" / ".claude").mkdir(parents=True)
+
+ assert search_folders(".claude", roots=[tmp_path]) == []
diff --git a/tests/unit/web/test_agentic_ide_create_folder.py b/tests/unit/web/test_agentic_ide_create_folder.py
new file mode 100644
index 0000000000..bb99752b93
--- /dev/null
+++ b/tests/unit/web/test_agentic_ide_create_folder.py
@@ -0,0 +1,34 @@
+"""``POST /folders/create`` — a refusal is an answer, not a status code.
+
+The picker shows the reason next to the name field, the same way it shows a
+typed path that does not exist, so the route reports through ``error`` and
+never raises for an ordinary "no".
+"""
+
+from __future__ import annotations
+
+from pathlib import Path
+
+from jarvis.ui.web import agentic_ide_routes as routes
+
+
+async def test_makes_the_folder_and_describes_it(tmp_path: Path) -> None:
+ res = await routes.create_new_folder(
+ routes.CreateFolderRequest(parent=str(tmp_path), name="shop")
+ )
+
+ assert res.error is None
+ assert res.folder is not None
+ assert res.folder.name == "shop"
+ assert Path(res.folder.path) == tmp_path / "shop"
+ assert (tmp_path / "shop").is_dir()
+
+
+async def test_a_bad_name_comes_back_as_a_reason(tmp_path: Path) -> None:
+ res = await routes.create_new_folder(
+ routes.CreateFolderRequest(parent=str(tmp_path), name="a/b")
+ )
+
+ assert res.folder is None
+ assert res.error is not None and "slashes" in res.error
+ assert list(tmp_path.iterdir()) == [] # noqa: ASYNC240