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): add file type icons

rubenluetke10-beepd1f2760fc56c
diff --git a/jarvis/ui/web/frontend/package-lock.json b/jarvis/ui/web/frontend/package-lock.json
index ace0ea66eb..1923a97f3e 100644
--- a/jarvis/ui/web/frontend/package-lock.json
+++ b/jarvis/ui/web/frontend/package-lock.json
@@ -28,6 +28,7 @@
"framer-motion": "^12.38.0",
"html-to-image": "^1.11.13",
"lucide-react": "^0.445.0",
+ "material-icon-theme": "5.37.0",
"qrcode.react": "^4.2.0",
"react": "^18.3.1",
"react-arborist": "^3.5.0",
@@ -3250,6 +3251,12 @@
"node": ">= 6"
}
},
+ "node_modules/chroma-js": {
+ "version": "3.2.0",
+ "resolved": "https://registry.npmjs.org/chroma-js/-/chroma-js-3.2.0.tgz",
+ "integrity": "sha512-os/OippSlX1RlWWr+QDPcGUZs0uoqr32urfxESG9U93lhUfbnlyckte84Q8P1UQY/qth983AS1JONKmLS4T0nw==",
+ "license": "(BSD-3-Clause AND Apache-2.0)"
+ },
"node_modules/class-variance-authority": {
"version": "0.7.1",
"resolved": "https://registry.npmjs.org/class-variance-authority/-/class-variance-authority-0.7.1.tgz",
@@ -4891,6 +4898,22 @@
"url": "https://github.com/sponsors/wooorm"
}
},
+ "node_modules/material-icon-theme": {
+ "version": "5.37.0",
+ "resolved": "https://registry.npmjs.org/material-icon-theme/-/material-icon-theme-5.37.0.tgz",
+ "integrity": "sha512-/F5llOVU0DZ88V+wmPlEbBqi8FochPg5XaJ7zqVzGCTTygeFnpIpdVQQTRElEnHyxSWRMfF0wBbOqwFKnujFLA==",
+ "license": "MIT",
+ "dependencies": {
+ "chroma-js": "^3.2.0",
+ "fast-deep-equal": "^3.1.3"
+ },
+ "engines": {
+ "vscode": "^1.55.0"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/material-extensions"
+ }
+ },
"node_modules/math-intrinsics": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/math-intrinsics/-/math-intrinsics-1.1.0.tgz",
diff --git a/jarvis/ui/web/frontend/package.json b/jarvis/ui/web/frontend/package.json
index da9309fe92..abd754843d 100644
--- a/jarvis/ui/web/frontend/package.json
+++ b/jarvis/ui/web/frontend/package.json
@@ -30,6 +30,7 @@
"framer-motion": "^12.38.0",
"html-to-image": "^1.11.13",
"lucide-react": "^0.445.0",
+ "material-icon-theme": "5.37.0",
"qrcode.react": "^4.2.0",
"react": "^18.3.1",
"react-arborist": "^3.5.0",
diff --git a/jarvis/ui/web/frontend/public/THIRD_PARTY_NOTICES.txt b/jarvis/ui/web/frontend/public/THIRD_PARTY_NOTICES.txt
new file mode 100644
index 0000000000..e1bb23f470
--- /dev/null
+++ b/jarvis/ui/web/frontend/public/THIRD_PARTY_NOTICES.txt
@@ -0,0 +1,23 @@
+Material Icon Theme
+Copyright (c) 2025 Material Extensions
+https://github.com/material-extensions/vscode-material-icon-theme
+
+The MIT License (MIT)
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
diff --git a/jarvis/ui/web/frontend/src/components/agentic/WorkspaceExplorer.test.tsx b/jarvis/ui/web/frontend/src/components/agentic/WorkspaceExplorer.test.tsx
index e4f3ac4df8..2f9aa764fa 100644
--- a/jarvis/ui/web/frontend/src/components/agentic/WorkspaceExplorer.test.tsx
+++ b/jarvis/ui/web/frontend/src/components/agentic/WorkspaceExplorer.test.tsx
@@ -2,12 +2,19 @@ import { fireEvent, render, screen, waitFor } from "@testing-library/react";
import { beforeEach, describe, expect, it, vi } from "vitest";
const pushToast = vi.fn();
+let nativeFileActions = true;
vi.mock("@/store/events", () => ({
useEventStore: (selector: (state: { pushToast: typeof pushToast }) => unknown) =>
selector({ pushToast }),
}));
+vi.mock("@/hooks/useCapabilities", () => ({
+ useCapabilities: () => ({
+ data: { native_file_actions: nativeFileActions, platform: "win32" },
+ }),
+}));
+
vi.mock("@/i18n", () => ({
useT: () => (key: string) =>
({
@@ -19,6 +26,11 @@ vi.mock("@/i18n", () => ({
"agentic_grid.explorer.empty": "Empty folder",
"agentic_grid.explorer.load_failed": "The folder could not be loaded.",
"agentic_grid.explorer.open_failed": "The file could not be opened.",
+ "agentic_grid.explorer.open_file": "Open file",
+ "agentic_grid.explorer.open_unavailable": "File opening is available in the desktop app.",
+ "agentic_grid.explorer.file": "File",
+ "agentic_grid.explorer.folder": "Folder",
+ "agentic_grid.explorer.symlink": "Symbolic link",
"agentic_grid.explorer.open_hint":
"Double-click a file to open it in your system editor.",
"agentic_grid.explorer.truncated":
@@ -37,6 +49,7 @@ import { WorkspaceExplorer } from "./WorkspaceExplorer";
describe("WorkspaceExplorer", () => {
beforeEach(() => {
vi.clearAllMocks();
+ nativeFileActions = true;
vi.mocked(api.fetchWorkspaceFiles).mockImplementation(async (_workspace, path = "") => {
if (path === "src") {
return {
@@ -74,6 +87,20 @@ describe("WorkspaceExplorer", () => {
is_symlink: false,
size: 8,
},
+ {
+ name: "README.md",
+ path: "README.md",
+ is_directory: false,
+ is_symlink: false,
+ size: 20,
+ },
+ {
+ name: "LICENSE",
+ path: "LICENSE",
+ is_directory: false,
+ is_symlink: false,
+ size: 12,
+ },
],
};
});
@@ -98,6 +125,14 @@ describe("WorkspaceExplorer", () => {
expect(explorer.className).toContain("w-full");
expect(explorer.style.background).toContain("0.22");
expect(screen.getByText("project")).toBeTruthy();
+ expect(
+ screen
+ .getByRole("treeitem", { name: /README\.md, Markdown README/i })
+ .querySelector('[data-material-icon="readme"]'),
+ ).toBeTruthy();
+ expect(
+ screen.getByRole("treeitem", { name: /LICENSE, File/i }),
+ ).toBeTruthy();
fireEvent.click(screen.getByRole("treeitem", { name: /src/i }));
expect(await screen.findByText("main.ts")).toBeTruthy();
@@ -110,6 +145,11 @@ describe("WorkspaceExplorer", () => {
"src/main.ts",
),
);
+
+ fireEvent.click(screen.getByRole("button", { name: "Open file main.ts" }));
+ await waitFor(() =>
+ expect(api.openTerminalTarget).toHaveBeenCalledTimes(2),
+ );
});
it("keeps open failures visible and lets the close button collapse the panel", async () => {
@@ -148,4 +188,24 @@ describe("WorkspaceExplorer", () => {
"The folder could not be loaded.",
);
});
+
+ it("disables native file opening outside the desktop app", async () => {
+ nativeFileActions = false;
+ render(
+ <WorkspaceExplorer
+ workspaceId="workspace-1"
+ rootName="project"
+ onClose={vi.fn()}
+ />,
+ );
+
+ const file = await screen.findByRole("treeitem", { name: /\.gitignore/i });
+ const openButton = screen.getByRole("button", {
+ name: /File opening is available in the desktop app\. \.gitignore/i,
+ });
+ expect((openButton as HTMLButtonElement).disabled).toBe(true);
+
+ fireEvent.doubleClick(file);
+ expect(api.openTerminalTarget).not.toHaveBeenCalled();
+ });
});
diff --git a/jarvis/ui/web/frontend/src/components/agentic/WorkspaceExplorer.tsx b/jarvis/ui/web/frontend/src/components/agentic/WorkspaceExplorer.tsx
index 7a4fe52bce..f939904bd7 100644
--- a/jarvis/ui/web/frontend/src/components/agentic/WorkspaceExplorer.tsx
+++ b/jarvis/ui/web/frontend/src/components/agentic/WorkspaceExplorer.tsx
@@ -8,18 +8,15 @@
import { useCallback, useEffect, useRef, useState } from "react";
import {
ChevronRight,
- File,
- FileCode2,
- FileText,
- Folder,
- FolderOpen,
- Image as ImageIcon,
+ ExternalLink,
Link2,
Loader2,
RefreshCw,
X,
} from "lucide-react";
+import { useThemeValue } from "@/hooks/useTheme";
+import { useCapabilities } from "@/hooks/useCapabilities";
import { useT } from "@/i18n";
import {
fetchWorkspaceFiles,
@@ -29,6 +26,8 @@ import {
import { cn } from "@/lib/utils";
import { useEventStore } from "@/store/events";
+import { materialFileIcon, useMaterialFileIcons } from "./materialFileIcons";
+
interface DirectoryState {
entries: WorkspaceFileItem[];
loading: boolean;
@@ -48,12 +47,16 @@ export function WorkspaceExplorer({
onClose,
}: WorkspaceExplorerProps) {
const t = useT();
+ const theme = useThemeValue();
+ const capabilities = useCapabilities();
+ useMaterialFileIcons();
const tRef = useRef(t);
tRef.current = t;
const pushToast = useEventStore((state) => state.pushToast);
const [directories, setDirectories] = useState<Record<string, DirectoryState>>({});
const [openPaths, setOpenPaths] = useState<Set<string>>(() => new Set([""]));
const [selectedPath, setSelectedPath] = useState<string | null>(null);
+ const [openingPath, setOpeningPath] = useState<string | null>(null);
const [resolvedRootName, setResolvedRootName] = useState(rootName);
const loadDirectory = useCallback(
@@ -122,6 +125,8 @@ export function WorkspaceExplorer({
const openFile = useCallback(
async (path: string) => {
+ if (openingPath === path) return;
+ setOpeningPath(path);
try {
await openTerminalTarget(workspaceId, path);
} catch (error) {
@@ -130,9 +135,11 @@ export function WorkspaceExplorer({
"error",
detail || t("agentic_grid.explorer.open_failed"),
);
+ } finally {
+ setOpeningPath((current) => (current === path ? null : current));
}
},
- [pushToast, t, workspaceId],
+ [openingPath, pushToast, t, workspaceId],
);
const refresh = () => {
@@ -143,6 +150,7 @@ export function WorkspaceExplorer({
};
const rootOpen = openPaths.has("");
+ const nativeFileActions = capabilities.data?.native_file_actions === true;
return (
<aside
@@ -193,9 +201,26 @@ export function WorkspaceExplorer({
aria-hidden
/>
{rootOpen ? (
- <FolderOpen className="h-4 w-4 shrink-0 text-primary" aria-hidden />
+ <MaterialEntryIcon
+ icon={materialFileIcon({
+ name: resolvedRootName,
+ directory: true,
+ open: true,
+ root: true,
+ theme,
+ })}
+ className="h-4 w-4"
+ />
) : (
- <Folder className="h-4 w-4 shrink-0 text-primary" aria-hidden />
+ <MaterialEntryIcon
+ icon={materialFileIcon({
+ name: resolvedRootName,
+ directory: true,
+ root: true,
+ theme,
+ })}
+ className="h-4 w-4"
+ />
)}
<span className="truncate">{resolvedRootName}</span>
</button>
@@ -207,6 +232,9 @@ export function WorkspaceExplorer({
directories={directories}
openPaths={openPaths}
selectedPath={selectedPath}
+ openingPath={openingPath}
+ nativeFileActions={nativeFileActions}
+ theme={theme}
onToggle={toggleDirectory}
onSelect={setSelectedPath}
onOpenFile={(path) => void openFile(path)}
@@ -216,7 +244,11 @@ export function WorkspaceExplorer({
</div>
<footer className="shrink-0 border-t border-border/60 px-3 py-2 text-[10px] leading-relaxed text-muted-foreground">
- {t("agentic_grid.explorer.open_hint")}
+ {t(
+ nativeFileActions
+ ? "agentic_grid.explorer.open_hint"
+ : "agentic_grid.explorer.open_unavailable",
+ )}
</footer>
</aside>
);
@@ -228,6 +260,9 @@ function TreeLevel({
directories,
openPaths,
selectedPath,
+ openingPath,
+ nativeFileActions,
+ theme,
onToggle,
onSelect,
onOpenFile,
@@ -237,6 +272,9 @@ function TreeLevel({
directories: Record<string, DirectoryState>;
openPaths: Set<string>;
selectedPath: string | null;
+ openingPath: string | null;
+ nativeFileActions: boolean;
+ theme: "dark" | "light";
onToggle: (path: string) => void;
onSelect: (path: string) => void;
onOpenFile: (path: string) => void;
@@ -275,66 +313,103 @@ function TreeLevel({
const expandable = entry.is_directory && !entry.is_symlink;
const isOpen = expandable && openPaths.has(entry.path);
const selected = selectedPath === entry.path;
- const EntryIcon = iconFor(entry, isOpen);
+ const icon = materialFileIcon({
+ name: entry.name,
+ path: entry.path,
+ directory: expandable,
+ open: isOpen,
+ theme,
+ });
+ const isFile = !entry.is_directory && !entry.is_symlink;
+ const canOpen = isFile && nativeFileActions;
+ const typeName = entry.is_symlink
+ ? t("agentic_grid.explorer.symlink")
+ : entry.is_directory
+ ? t("agentic_grid.explorer.folder")
+ : fileTypeName(entry.name, icon.id, t("agentic_grid.explorer.file"));
return (
<div key={entry.path}>
- <button
- type="button"
- role="treeitem"
- aria-expanded={expandable ? isOpen : undefined}
- aria-selected={selected}
- title={entry.path}
- onClick={() => {
- onSelect(entry.path);
- if (expandable) onToggle(entry.path);
- }}
- onDoubleClick={() => {
- if (!entry.is_directory && !entry.is_symlink) onOpenFile(entry.path);
- }}
- onKeyDown={(event) => {
- if (
- event.key === "Enter" &&
- !entry.is_directory &&
- !entry.is_symlink
- ) {
- event.preventDefault();
- onOpenFile(entry.path);
- }
- }}
+ <div
className={cn(
- "group flex h-6 w-full items-center gap-1.5 rounded-control pr-2 text-left text-[12px] transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring/60",
+ "group flex h-7 w-full items-center rounded-control transition-colors",
selected
? "bg-primary/10 text-foreground shadow-[inset_2px_0_0_hsl(var(--primary))]"
: "text-muted-foreground hover:bg-secondary/65 hover:text-foreground",
)}
- style={{ paddingLeft: `${depth * 12}px` }}
>
- {expandable ? (
- <ChevronRight
- className={cn(
- "h-3 w-3 shrink-0 transition-transform",
- isOpen && "rotate-90",
+ <button
+ type="button"
+ role="treeitem"
+ aria-expanded={expandable ? isOpen : undefined}
+ aria-selected={selected}
+ aria-label={`${entry.name}, ${typeName}`}
+ title={`${typeName} · ${entry.path}`}
+ onClick={() => {
+ onSelect(entry.path);
+ if (expandable) onToggle(entry.path);
+ }}
+ onDoubleClick={() => {
+ if (canOpen) onOpenFile(entry.path);
+ }}
+ onKeyDown={(event) => {
+ if (event.key === "Enter" && canOpen) {
+ event.preventDefault();
+ onOpenFile(entry.path);
+ }
+ }}
+ className="flex h-full min-w-0 flex-1 items-center gap-1.5 text-left text-[12px] focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-ring/60"
+ style={{ paddingLeft: `${depth * 12}px` }}
+ >
+ {expandable ? (
+ <ChevronRight
+ className={cn(
+ "h-3 w-3 shrink-0 transition-transform",
+ isOpen && "rotate-90",
+ )}
+ aria-hidden
+ />
+ ) : (
+ <span className="w-3 shrink-0" aria-hidden />
+ )}
+ {entry.is_symlink ? (
+ <Link2
+ className="h-4 w-4 shrink-0 text-muted-foreground/70"
+ aria-hidden
+ />
+ ) : (
+ <MaterialEntryIcon icon={icon} className="h-4 w-4" />
+ )}
+ <span className="min-w-0 flex-1 truncate">{entry.name}</span>
+ </button>
+
+ {isFile && (
+ <button
+ type="button"
+ onClick={() => {
+ if (!canOpen) return;
+ onSelect(entry.path);
+ onOpenFile(entry.path);
+ }}
+ disabled={!canOpen || openingPath === entry.path}
+ aria-label={`${t(canOpen ? "agentic_grid.explorer.open_file" : "agentic_grid.explorer.open_unavailable")} ${entry.name}`}
+ title={t(
+ canOpen
+ ? "agentic_grid.explorer.open_file"
+ : "agentic_grid.explorer.open_unavailable",
)}
- aria-hidden
- />
- ) : (
- <span className="w-3 shrink-0" aria-hidden />
+ className="mr-0.5 flex h-6 w-6 shrink-0 items-center justify-center rounded-control text-muted-foreground/70 opacity-70 transition hover:bg-primary/10 hover:text-primary hover:opacity-100 focus-visible:opacity-100 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring/60 disabled:cursor-not-allowed disabled:opacity-30"
+ >
+ {openingPath === entry.path ? (
+ <Loader2
+ className="h-3 w-3 animate-spin motion-reduce:animate-none"
+ aria-hidden
+ />
+ ) : (
+ <ExternalLink className="h-3 w-3" aria-hidden />
+ )}
+ </button>
)}
- <EntryIcon
- className={cn(
- "h-3.5 w-3.5 shrink-0",
- expandable
- ? "text-primary/80"
- : entry.is_symlink
- ? "text-muted-foreground/70"
- : selected
- ? "text-primary"
- : "text-muted-foreground group-hover:text-foreground/80",
- )}
- aria-hidden
- />
- <span className="min-w-0 flex-1 truncate">{entry.name}</span>
- </button>
+ </div>
{isOpen && (
<TreeLevel
@@ -343,6 +418,9 @@ function TreeLevel({
directories={directories}
openPaths={openPaths}
selectedPath={selectedPath}
+ openingPath={openingPath}
+ nativeFileActions={nativeFileActions}
+ theme={theme}
onToggle={onToggle}
onSelect={onSelect}
onOpenFile={onOpenFile}
@@ -373,18 +451,43 @@ function TreeLevel({
);
}
-function iconFor(entry: WorkspaceFileItem, open: boolean) {
- if (entry.is_symlink) return Link2;
- if (entry.is_directory) return open ? FolderOpen : Folder;
- const name = entry.name.toLowerCase();
- if (/\.(png|jpe?g|gif|webp|svg|ico|bmp)$/.test(name)) return ImageIcon;
- if (/\.(md|mdx|txt|rst|log)$/.test(name)) return FileText;
- if (
- /\.(py|js|jsx|ts|tsx|css|scss|html|rs|go|java|c|cc|cpp|h|hpp|sh|ps1|toml|ya?ml|json)$/.test(
- name,
- )
- ) {
- return FileCode2;
+const TECHNICAL_FILE_TYPES: Record<string, string> = {
+ csharp: "C#",
+ cpp: "C++",
+ docker: "Docker",
+ javascript: "JavaScript",
+ markdown: "Markdown",
+ nodejs: "Node.js",
+ powershell: "PowerShell",
+ react_ts: "React TypeScript",
+ readme: "Markdown README",
+ typescript: "TypeScript",
+};
+
+function fileTypeName(name: string, iconId: string, genericLabel: string) {
+ if (TECHNICAL_FILE_TYPES[iconId]) return TECHNICAL_FILE_TYPES[iconId];
+ const dotIndex = name.lastIndexOf(".");
+ if (dotIndex > -1 && dotIndex < name.length - 1) {
+ return name.slice(dotIndex + 1).toUpperCase();
}
- return File;
+ return genericLabel;
+}
+
+function MaterialEntryIcon({
+ icon,
+ className,
+}: {
+ icon: ReturnType<typeof materialFileIcon>;
+ className?: string;
+}) {
+ return (
+ <img
+ src={icon.src}
+ alt=""
+ aria-hidden
+ draggable={false}
+ data-material-icon={icon.id}
+ className={cn("shrink-0 select-none", className)}
+ />
+ );
}
diff --git a/jarvis/ui/web/frontend/src/components/agentic/materialFileIcons.test.ts b/jarvis/ui/web/frontend/src/components/agentic/materialFileIcons.test.ts
new file mode 100644
index 0000000000..7ebb1ced8d
--- /dev/null
+++ b/jarvis/ui/web/frontend/src/components/agentic/materialFileIcons.test.ts
@@ -0,0 +1,41 @@
+import { describe, expect, it } from "vitest";
+import materialIconManifest from "material-icon-theme/dist/material-icons.json";
+
+import {
+ materialFileIcon,
+ type MaterialIconManifest,
+} from "./materialFileIcons";
+
+const manifest = materialIconManifest as MaterialIconManifest;
+
+describe("materialFileIcon", () => {
+ it.each([
+ ["README.md", "readme"],
+ ["App.tsx", "react_ts"],
+ ["package.json", "nodejs"],
+ [".gitignore", "git"],
+ ["Dockerfile", "docker"],
+ ["report.pdf", "pdf"],
+ ])("maps %s to the complete Material Icon Theme", (name, id) => {
+ const icon = materialFileIcon({ name }, manifest);
+ expect(icon).toEqual({
+ id,
+ src: expect.stringContaining("/assets/material-file-icons/"),
+ });
+ });
+
+ it("uses compound extensions before their shorter suffix", () => {
+ expect(materialFileIcon({ name: "Widget.test.tsx" }, manifest).id).toBe(
+ "test-jsx",
+ );
+ });
+
+ it("provides named folder icons and a safe fallback", () => {
+ expect(
+ materialFileIcon({ name: "src", directory: true }, manifest).id,
+ ).toBe("folder-src");
+ expect(
+ materialFileIcon({ name: "unknown.custom-extension" }, manifest).id,
+ ).toBe("file");
+ });
+});
diff --git a/jarvis/ui/web/frontend/src/components/agentic/materialFileIcons.ts b/jarvis/ui/web/frontend/src/components/agentic/materialFileIcons.ts
new file mode 100644
index 0000000000..ac4b5117fc
--- /dev/null
+++ b/jarvis/ui/web/frontend/src/components/agentic/materialFileIcons.ts
@@ -0,0 +1,259 @@
+import { useEffect, useState } from "react";
+import materialIconManifestUrl from "material-icon-theme/dist/material-icons.json?url&no-inline";
+
+import type { Theme } from "@/hooks/useTheme";
+
+interface IconDefinition {
+ iconPath: string;
+}
+
+interface ThemeOverrides {
+ fileExtensions?: Record<string, string>;
+ fileNames?: Record<string, string>;
+ folderNames?: Record<string, string>;
+ folderNamesExpanded?: Record<string, string>;
+ rootFolderNames?: Record<string, string>;
+ rootFolderNamesExpanded?: Record<string, string>;
+}
+
+export interface MaterialIconManifest {
+ iconDefinitions: Record<string, IconDefinition>;
+ fileExtensions: Record<string, string>;
+ fileNames: Record<string, string>;
+ folderNames: Record<string, string>;
+ folderNamesExpanded: Record<string, string>;
+ rootFolderNames: Record<string, string>;
+ rootFolderNamesExpanded: Record<string, string>;
+ light?: ThemeOverrides;
+ file: string;
+ folder: string;
+ folderExpanded: string;
+ rootFolder: string;
+ rootFolderExpanded: string;
+}
+
+export interface MaterialFileIcon {
+ id: string;
+ src: string;
+}
+
+interface MaterialFileIconOptions {
+ name: string;
+ path?: string;
+ directory?: boolean;
+ open?: boolean;
+ root?: boolean;
+ theme?: Theme;
+}
+
+const fallbackIconIds = [
+ "docker",
+ "file",
+ "folder",
+ "folder-open",
+ "folder-root",
+ "folder-root-open",
+ "folder-src",
+ "folder-src-open",
+ "git",
+ "markdown",
+ "nodejs",
+ "pdf",
+ "react_ts",
+ "readme",
+ "typescript",
+];
+
+const FALLBACK_MANIFEST: MaterialIconManifest = {
+ iconDefinitions: Object.fromEntries(
+ fallbackIconIds.map((id) => [id, { iconPath: `./../icons/${id}.svg` }]),
+ ),
+ fileExtensions: {
+ md: "markdown",
+ pdf: "pdf",
+ ts: "typescript",
+ tsx: "react_ts",
+ },
+ fileNames: {
+ ".gitignore": "git",
+ "package.json": "nodejs",
+ "readme.md": "readme",
+ dockerfile: "docker",
+ },
+ folderNames: { src: "folder-src" },
+ folderNamesExpanded: { src: "folder-src-open" },
+ rootFolderNames: {},
+ rootFolderNamesExpanded: {},
+ file: "file",
+ folder: "folder",
+ folderExpanded: "folder-open",
+ rootFolder: "folder-root",
+ rootFolderExpanded: "folder-root-open",
+};
+
+let activeManifest = FALLBACK_MANIFEST;
+let manifestRequest: Promise<MaterialIconManifest> | null = null;
+
+function isMaterialIconManifest(value: unknown): value is MaterialIconManifest {
+ if (!value || typeof value !== "object") return false;
+ const candidate = value as Partial<MaterialIconManifest>;
+ return Boolean(
+ candidate.iconDefinitions &&
+ candidate.fileExtensions &&
+ candidate.fileNames &&
+ candidate.folderNames &&
+ candidate.file &&
+ candidate.folder,
+ );
+}
+
+function loadMaterialIconManifest() {
+ if (import.meta.env.MODE === "test") return Promise.resolve(activeManifest);
+ if (manifestRequest) return manifestRequest;
+
+ manifestRequest = fetch(materialIconManifestUrl)
+ .then(async (response) => {
+ if (!response.ok) throw new Error(`HTTP ${response.status}`);
+ const candidate: unknown = await response.json();
+ if (!isMaterialIconManifest(candidate)) {
+ throw new Error("Invalid Material Icon Theme manifest");
+ }
+ activeManifest = candidate;
+ return candidate;
+ })
+ .catch((error: unknown) => {
+ console.warn(
+ "Material file icons could not be loaded; using fallbacks.",
+ error,
+ );
+ return FALLBACK_MANIFEST;
+ });
+ return manifestRequest;
+}
+
+/** Load the complete mapping only while the explorer is mounted. */
+export function useMaterialFileIcons() {
+ const [, setManifest] = useState(activeManifest);
+
+ useEffect(() => {
+ let mounted = true;
+ void loadMaterialIconManifest().then((manifest) => {
+ if (mounted) setManifest(manifest);
+ });
+ return () => {
+ mounted = false;
+ };
+ }, []);
+}
+
+function valueFor(map: Record<string, string> | undefined, key: string) {
+ return map?.[key] ?? map?.[key.toLowerCase()];
+}
+
+function themedValue(
+ base: Record<string, string>,
+ light: Record<string, string> | undefined,
+ key: string,
+ theme: Theme,
+) {
+ return theme === "light"
+ ? (valueFor(light, key) ?? valueFor(base, key))
+ : valueFor(base, key);
+}
+
+function resolveFileIconId(
+ manifest: MaterialIconManifest,
+ name: string,
+ path: string,
+ theme: Theme,
+) {
+ const normalizedPath = path.replaceAll("\\", "/").replace(/^\.\//, "");
+ const light = manifest.light;
+
+ for (const candidate of [normalizedPath, name]) {
+ const match = themedValue(
+ manifest.fileNames,
+ light?.fileNames,
+ candidate,
+ theme,
+ );
+ if (match) return match;
+ }
+
+ const extensionSource = name.startsWith(".") ? name.slice(1) : name;
+ const parts = extensionSource.split(".");
+ const firstExtensionPart = name.startsWith(".") ? 0 : 1;
+ for (let index = firstExtensionPart; index < parts.length; index += 1) {
+ const extension = parts.slice(index).join(".");
+ const match = themedValue(
+ manifest.fileExtensions,
+ light?.fileExtensions,
+ extension,
+ theme,
+ );
+ if (match) return match;
+ }
+
+ return manifest.file;
+}
+
+function resolveFolderIconId(
+ manifest: MaterialIconManifest,
+ name: string,
+ open: boolean,
+ root: boolean,
+ theme: Theme,
+) {
+ const light = manifest.light;
+ const baseNames = root
+ ? open
+ ? manifest.rootFolderNamesExpanded
+ : manifest.rootFolderNames
+ : open
+ ? manifest.folderNamesExpanded
+ : manifest.folderNames;
+ const lightNames = root
+ ? open
+ ? light?.rootFolderNamesExpanded
+ : light?.rootFolderNames
+ : open
+ ? light?.folderNamesExpanded
+ : light?.folderNames;
+
+ return (
+ themedValue(baseNames, lightNames, name, theme) ??
+ (root
+ ? open
+ ? manifest.rootFolderExpanded
+ : manifest.rootFolder
+ : open
+ ? manifest.folderExpanded
+ : manifest.folder)
+ );
+}
+
+function iconUrl(manifest: MaterialIconManifest, iconId: string) {
+ const definition =
+ manifest.iconDefinitions[iconId] ?? manifest.iconDefinitions[manifest.file];
+ const fileName = definition.iconPath.slice(
+ definition.iconPath.lastIndexOf("/") + 1,
+ );
+ return `/assets/material-file-icons/${fileName}`;
+}
+
+export function materialFileIcon(
+ {
+ name,
+ path = name,
+ directory = false,
+ open = false,
+ root = false,
+ theme = "dark",
+ }: MaterialFileIconOptions,
+ manifest: MaterialIconManifest = activeManifest,
+): MaterialFileIcon {
+ const id = directory
+ ? resolveFolderIconId(manifest, name, open, root, theme)
+ : resolveFileIconId(manifest, name, path, theme);
+ return { id, src: iconUrl(manifest, id) };
+}
diff --git a/jarvis/ui/web/frontend/src/i18n/locales/de.json b/jarvis/ui/web/frontend/src/i18n/locales/de.json
index c3472ce50d..b887981cc2 100644
--- a/jarvis/ui/web/frontend/src/i18n/locales/de.json
+++ b/jarvis/ui/web/frontend/src/i18n/locales/de.json
@@ -3932,7 +3932,12 @@
"empty": "Leerer Ordner",
"load_failed": "Der Ordner konnte nicht geladen werden.",
"open_failed": "Die Datei konnte nicht geöffnet werden.",
- "open_hint": "Doppelklick öffnet eine Datei im System-Editor.",
+ "open_file": "Datei öffnen",
+ "open_unavailable": "Dateien können in der Desktop-App geöffnet werden.",
+ "file": "Datei",
+ "folder": "Ordner",
+ "symlink": "Symbolische Verknüpfung",
+ "open_hint": "Doppelklick oder die Öffnen-Schaltfläche öffnet eine Datei.",
"truncated": "Dieser Ordner enthält mehr Einträge, als gleichzeitig angezeigt werden können."
},
"arrange": {
diff --git a/jarvis/ui/web/frontend/src/i18n/locales/en.json b/jarvis/ui/web/frontend/src/i18n/locales/en.json
index 8ce67d32b3..d2ae2cc6a2 100644
--- a/jarvis/ui/web/frontend/src/i18n/locales/en.json
+++ b/jarvis/ui/web/frontend/src/i18n/locales/en.json
@@ -3932,7 +3932,12 @@
"empty": "Empty folder",
"load_failed": "The folder could not be loaded.",
"open_failed": "The file could not be opened.",
- "open_hint": "Double-click a file to open it in your system editor.",
+ "open_file": "Open file",
+ "open_unavailable": "File opening is available in the desktop app.",
+ "file": "File",
+ "folder": "Folder",
+ "symlink": "Symbolic link",
+ "open_hint": "Double-click a file or use its open button.",
"truncated": "This folder has more entries than can be shown at once."
},
"arrange": {
diff --git a/jarvis/ui/web/frontend/src/i18n/locales/es.json b/jarvis/ui/web/frontend/src/i18n/locales/es.json
index ecf4c82fac..21378d0043 100644
--- a/jarvis/ui/web/frontend/src/i18n/locales/es.json
+++ b/jarvis/ui/web/frontend/src/i18n/locales/es.json
@@ -3932,7 +3932,12 @@
"empty": "Carpeta vacía",
"load_failed": "No se pudo cargar la carpeta.",
"open_failed": "No se pudo abrir el archivo.",
- "open_hint": "Haz doble clic en un archivo para abrirlo en el editor del sistema.",
+ "open_file": "Abrir archivo",
+ "open_unavailable": "Los archivos se pueden abrir en la aplicación de escritorio.",
+ "file": "Archivo",
+ "folder": "Carpeta",
+ "symlink": "Enlace simbólico",
+ "open_hint": "Haz doble clic en un archivo o usa su botón para abrirlo.",
"truncated": "Esta carpeta tiene más entradas de las que se pueden mostrar a la vez."
},
"arrange": {
diff --git a/jarvis/ui/web/frontend/vite.config.js b/jarvis/ui/web/frontend/vite.config.js
index f33e6943b2..7458401fff 100644
--- a/jarvis/ui/web/frontend/vite.config.js
+++ b/jarvis/ui/web/frontend/vite.config.js
@@ -1,9 +1,57 @@
/// <reference types="vitest" />
+import fs from "node:fs";
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
import path from "node:path";
+var MATERIAL_ICON_ROUTE = "/assets/material-file-icons";
+var materialIconSource = path.resolve(__dirname, "node_modules/material-icon-theme/icons");
+/**
+ * Keep the complete icon theme out of the Agentic IDE JavaScript chunk.
+ * Development serves the pinned package directly; production copies the same
+ * MIT-licensed SVGs beside the static assets for offline desktop use.
+ */
+function materialIconAssets() {
+ var outputDirectory = "";
+ return {
+ name: "material-file-icon-assets",
+ configResolved: function (config) {
+ outputDirectory = path.resolve(config.root, config.build.outDir);
+ },
+ configureServer: function (server) {
+ server.middlewares.use(MATERIAL_ICON_ROUTE, function (request, response, next) {
+ var _a;
+ var requestedFile = "";
+ try {
+ requestedFile = decodeURIComponent((_a = request.url) !== null && _a !== void 0 ? _a : "")
+ .split("?", 1)[0]
+ .replace(/^\/+/, "");
+ }
+ catch (_b) {
+ next();
+ return;
+ }
+ if (!/^[a-zA-Z0-9_.-]+\.svg$/.test(requestedFile)) {
+ next();
+ return;
+ }
+ var sourceFile = path.resolve(materialIconSource, requestedFile);
+ if (path.dirname(sourceFile) !== materialIconSource ||
+ !fs.existsSync(sourceFile)) {
+ next();
+ return;
+ }
+ response.setHeader("Content-Type", "image/svg+xml");
+ response.setHeader("Cache-Control", "public, max-age=3600");
+ fs.createReadStream(sourceFile).pipe(response);
+ });
+ },
+ writeBundle: function () {
+ fs.cpSync(materialIconSource, path.join(outputDirectory, "assets", "material-file-icons"), { recursive: true });
+ },
+ };
+}
export default defineConfig({
- plugins: [react()],
+ plugins: [react(), materialIconAssets()],
resolve: {
alias: {
"@": path.resolve(__dirname, "./src"),
diff --git a/jarvis/ui/web/frontend/vite.config.ts b/jarvis/ui/web/frontend/vite.config.ts
index fc079de05b..048ae596e6 100644
--- a/jarvis/ui/web/frontend/vite.config.ts
+++ b/jarvis/ui/web/frontend/vite.config.ts
@@ -1,10 +1,71 @@
/// <reference types="vitest" />
+import fs from "node:fs";
import { defineConfig } from "vite";
+import type { Plugin } from "vite";
import react from "@vitejs/plugin-react";
import path from "node:path";
+const MATERIAL_ICON_ROUTE = "/assets/material-file-icons";
+const materialIconSource = path.resolve(
+ __dirname,
+ "node_modules/material-icon-theme/icons",
+);
+
+/**
+ * Keep the complete icon theme out of the Agentic IDE JavaScript chunk.
+ * Development serves the pinned package directly; production copies the same
+ * MIT-licensed SVGs beside the static assets for offline desktop use.
+ */
+function materialIconAssets(): Plugin {
+ let outputDirectory = "";
+
+ return {
+ name: "material-file-icon-assets",
+ configResolved(config) {
+ outputDirectory = path.resolve(config.root, config.build.outDir);
+ },
+ configureServer(server) {
+ server.middlewares.use(MATERIAL_ICON_ROUTE, (request, response, next) => {
+ let requestedFile = "";
+ try {
+ requestedFile = decodeURIComponent(request.url ?? "")
+ .split("?", 1)[0]
+ .replace(/^\/+/, "");
+ } catch {
+ next();
+ return;
+ }
+ if (!/^[a-zA-Z0-9_.-]+\.svg$/.test(requestedFile)) {
+ next();
+ return;
+ }
+
+ const sourceFile = path.resolve(materialIconSource, requestedFile);
+ if (
+ path.dirname(sourceFile) !== materialIconSource ||
+ !fs.existsSync(sourceFile)
+ ) {
+ next();
+ return;
+ }
+
+ response.setHeader("Content-Type", "image/svg+xml");
+ response.setHeader("Cache-Control", "public, max-age=3600");
+ fs.createReadStream(sourceFile).pipe(response);
+ });
+ },
+ writeBundle() {
+ fs.cpSync(
+ materialIconSource,
+ path.join(outputDirectory, "assets", "material-file-icons"),
+ { recursive: true },
+ );
+ },
+ };
+}
+
export default defineConfig({
- plugins: [react()],
+ plugins: [react(), materialIconAssets()],
resolve: {
alias: {
"@": path.resolve(__dirname, "./src"),