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(extensions): the file card shows the folder, not a dropdown
rubenluetke10-beep9b12ed627293
diff --git a/jarvis/ui/web/frontend/src/components/extensions/FileCard.tsx b/jarvis/ui/web/frontend/src/components/extensions/FileCard.tsxindex 7325dd1fca..9af0ee6ead 100644--- a/jarvis/ui/web/frontend/src/components/extensions/FileCard.tsx+++ b/jarvis/ui/web/frontend/src/components/extensions/FileCard.tsx@@ -1,7 +1,8 @@/**- * The read-only file card of a detail page: a file picker ("plugin.json ▾ ·- * 3 files"), a preview/source toggle and the file itself. Markdown renders as- * prose in preview, JSON and everything else as monospace text; source is+ * The read-only file card of a detail page: a folder tree on the left (the+ * plugin's or server's pieces, laid out the way a folder would hold them),+ * the chosen file on the right, and a preview/source toggle. Markdown renders+ * as prose in preview, JSON and everything else as monospace text; source is* always the raw text.** Plugins and MCP servers have no folder on disk, so the backend writes their@@ -12,10 +13,20 @@import { useEffect, useMemo, useState, type ReactNode } from "react";import ReactMarkdown from "react-markdown";import remarkGfm from "remark-gfm";-import { ChevronDown, Code2, Eye, FileCode, FileJson, FileText } from "lucide-react";+import {+ ChevronDown,+ ChevronRight,+ Code2,+ Eye,+ FileCode,+ FileJson,+ FileText,+ Folder,+ FolderOpen,+} from "lucide-react";import { cn } from "@/lib/utils";import { fill, useT } from "@/i18n";-import { ActionMenu, Panel } from "@/components/extensions/primitives";+import { Panel } from "@/components/extensions/primitives";export interface CardFile {path: string;@@ -26,7 +37,7 @@ export interface CardFile {type ViewMode = "preview" | "source";-function iconFor(path: string) {+export function fileIconFor(path: string) {if (/\.(md|markdown)$/i.test(path)) return FileText;if (/\.json$/i.test(path)) return FileJson;return FileCode;@@ -81,13 +92,147 @@ export function ModeButton({);}+// ---------------------------------------------------------------------------+// Folder tree+// ---------------------------------------------------------------------------++interface TreeNode {+ name: string;+ path: string;+ children?: TreeNode[];+}++/** Folders first (sorted), then files in the order they were given. */+function buildTree(paths: string[]): TreeNode[] {+ const root: TreeNode[] = [];+ for (const path of paths) {+ const parts = path.split("/").filter(Boolean);+ let level = root;+ let prefix = "";+ parts.forEach((part, i) => {+ prefix = prefix ? `${prefix}/${part}` : part;+ const leaf = i === parts.length - 1;+ let node = level.find((n) => n.name === part && Boolean(n.children) !== leaf);+ if (!node) {+ node = leaf ? { name: part, path } : { name: part, path: prefix, children: [] };+ level.push(node);+ }+ if (!leaf) level = node.children!;+ });+ }+ const sort = (nodes: TreeNode[]): TreeNode[] => {+ const folders = nodes.filter((n) => n.children).sort((a, b) => a.name.localeCompare(b.name));+ const files = nodes.filter((n) => !n.children);+ folders.forEach((f) => (f.children = sort(f.children!)));+ return [...folders, ...files];+ };+ return sort(root);+}++/**+ * The folder column: a root folder named after the thing, its files beneath,+ * sub-folders collapsible. One click opens a file; the open one is marked.+ */+export function FileTree({+ rootLabel,+ paths,+ openPath,+ onOpen,+ className,+}: {+ rootLabel: string;+ paths: string[];+ openPath: string | null;+ onOpen: (path: string) => void;+ className?: string;+}) {+ const t = useT();+ const tree = useMemo(() => buildTree(paths), [paths]);+ const [collapsed, setCollapsed] = useState<Set<string>>(new Set());+ const toggle = (p: string) =>+ setCollapsed((prev) => {+ const next = new Set(prev);+ if (next.has(p)) next.delete(p);+ else next.add(p);+ return next;+ });++ const renderNodes = (nodes: TreeNode[], depth: number): ReactNode =>+ nodes.map((node) => {+ const pad = { paddingLeft: `${12 + depth * 14}px` };+ if (node.children) {+ const closed = collapsed.has(node.path);+ const Icon = closed ? Folder : FolderOpen;+ return (+ <li key={`d:${node.path}`}>+ <button+ type="button"+ onClick={() => toggle(node.path)}+ aria-expanded={!closed}+ style={pad}+ className="flex h-8 w-full items-center gap-1.5 pr-2 text-left text-[13px] text-foreground/85 hover:bg-sheen/[0.05]"+ >+ {closed ? (+ <ChevronRight className="h-3.5 w-3.5 shrink-0 text-muted-foreground" />+ ) : (+ <ChevronDown className="h-3.5 w-3.5 shrink-0 text-muted-foreground" />+ )}+ <Icon className="h-4 w-4 shrink-0 text-muted-foreground" />+ <span className="truncate">{node.name}</span>+ </button>+ {!closed && <ul>{renderNodes(node.children, depth + 1)}</ul>}+ </li>+ );+ }+ const Icon = fileIconFor(node.name);+ const active = node.path === openPath;+ return (+ <li key={`f:${node.path}`}>+ <button+ type="button"+ onClick={() => onOpen(node.path)}+ aria-current={active ? "true" : undefined}+ title={node.path}+ style={{ paddingLeft: `${12 + depth * 14 + 20}px` }}+ className={cn(+ "flex h-8 w-full items-center gap-2 pr-2 text-left font-mono text-[13px] transition-colors",+ active+ ? "bg-sheen/[0.08] text-foreground"+ : "text-foreground/80 hover:bg-sheen/[0.05] hover:text-foreground",+ )}+ >+ <Icon className={cn("h-4 w-4 shrink-0", active ? "text-foreground" : "text-muted-foreground")} />+ <span className="truncate">{node.name}</span>+ </button>+ </li>+ );+ });++ return (+ <nav aria-label={t("extensions.files_menu")} className={cn("min-w-0", className)}>+ <div className="flex h-8 items-center gap-1.5 px-3 text-[13px] font-medium text-foreground">+ <FolderOpen className="h-4 w-4 shrink-0 text-primary" />+ <span className="truncate">{rootLabel}</span>+ </div>+ <ul>{renderNodes(tree, 0)}</ul>+ </nav>+ );+}++// ---------------------------------------------------------------------------+// Card+// ---------------------------------------------------------------------------+export function FileCard({+ rootLabel,files,loading,error,emptyLabel,className,}: {+ /** The folder's name — the plugin id or the server name. */+ rootLabel: string;files: CardFile[];loading?: boolean;error?: string | null;@@ -110,40 +255,15 @@ export function FileCard({const open = useMemo(() => files.find((f) => f.path === openPath) ?? null, [files, openPath]);const isMarkdown = open ? /\.(md|markdown)$/i.test(open.path) : false;- const OpenIcon = open ? iconFor(open.path) : FileText;+ const OpenIcon = open ? fileIconFor(open.path) : FileText;return (<Panel className={className}><div className="flex items-center gap-3 border-b border-border/70 px-3 py-2">- <ActionMenu- label={t("extensions.files_menu")}- align="start"- actions={files.map((f) => {- const Icon = iconFor(f.path);- return {- id: f.path,- label: f.path,- icon: <Icon className="h-3.5 w-3.5" />,- onSelect: () => setOpenPath(f.path),- };- })}- trigger={({ open: menuOpen, toggle }) => (- <button- type="button"- onClick={toggle}- disabled={files.length === 0}- aria-expanded={menuOpen}- aria-haspopup="menu"- className="inline-flex h-8 max-w-[360px] items-center gap-2 rounded-md bg-sheen/[0.07] px-3 font-mono text-[13px] text-foreground hover:bg-sheen/[0.12] disabled:opacity-60"- >- <OpenIcon className="h-3.5 w-3.5 shrink-0 text-muted-foreground" />- <span className="truncate">{open?.path ?? "—"}</span>- <ChevronDown- className={cn("h-3.5 w-3.5 shrink-0 transition-transform", menuOpen && "rotate-180")}- />- </button>- )}- />+ <span className="inline-flex h-8 min-w-0 items-center gap-2 px-1 font-mono text-[13px] text-foreground">+ <OpenIcon className="h-3.5 w-3.5 shrink-0 text-muted-foreground" />+ <span className="truncate">{open?.path ?? "—"}</span>+ </span><span className="text-sm text-muted-foreground">{files.length === 1? t("extensions.file_one")@@ -171,29 +291,40 @@ export function FileCard({</div></div>- {loading && (- <div className="px-6 py-6 text-sm text-muted-foreground">{t("common.loading")}</div>- )}- {!loading && error && (- <div className="px-6 py-6 text-sm text-destructive">{error}</div>- )}- {!loading && !error && !open && (- <div className="px-6 py-6 text-sm text-muted-foreground">- {emptyLabel ?? t("extensions.no_files")}+ <div className="flex min-h-[160px]">+ <FileTree+ className="w-56 shrink-0 border-r border-border/70 py-2"+ rootLabel={rootLabel}+ paths={files.map((f) => f.path)}+ openPath={openPath}+ onOpen={setOpenPath}+ />+ <div className="min-w-0 flex-1">+ {loading && (+ <div className="px-6 py-6 text-sm text-muted-foreground">{t("common.loading")}</div>+ )}+ {!loading && error && (+ <div className="px-6 py-6 text-sm text-destructive">{error}</div>+ )}+ {!loading && !error && !open && (+ <div className="px-6 py-6 text-sm text-muted-foreground">+ {emptyLabel ?? t("extensions.no_files")}+ </div>+ )}+ {!loading && !error && open && (+ mode === "preview" && isMarkdown ? (+ <div className="max-h-[60vh] overflow-auto px-6 py-5">+ <MarkdownBody text={open.text} />+ </div>+ ) : (+ <pre className="max-h-[60vh] overflow-auto whitespace-pre-wrap break-words px-6 py-5 font-mono text-[13px] leading-relaxed">+ {open.text}+ {open.truncated ? "\n…" : ""}+ </pre>+ )+ )}</div>- )}- {!loading && !error && open && (- mode === "preview" && isMarkdown ? (- <div className="max-h-[60vh] overflow-auto px-6 py-5">- <MarkdownBody text={open.text} />- </div>- ) : (- <pre className="max-h-[60vh] overflow-auto whitespace-pre-wrap break-words px-6 py-5 font-mono text-[13px] leading-relaxed">- {open.text}- {open.truncated ? "\n…" : ""}- </pre>- )- )}+ </div></Panel>);}diff --git a/jarvis/ui/web/frontend/src/views/McpsView.test.tsx b/jarvis/ui/web/frontend/src/views/McpsView.test.tsxindex f09e5017aa..bdd780aa0c 100644--- a/jarvis/ui/web/frontend/src/views/McpsView.test.tsx+++ b/jarvis/ui/web/frontend/src/views/McpsView.test.tsx@@ -155,8 +155,12 @@ describe("McpsView — detail page", () => {expect(screen.getByText("notebook_list")).toBeTruthy();expect(screen.getByText("notebook_get")).toBeTruthy();expect(screen.getByText("python -m notebooklm_mcp.server")).toBeTruthy();- // The file card opens on the server's own mcp.json block.- await screen.findByText("mcp.json");+ // The file card lists the server's files in its folder tree and opens on+ // the server's own mcp.json block.+ await waitFor(() => {+ expect(screen.getAllByText("mcp.json").length).toBeGreaterThan(0);+ });+ expect(screen.getByText("definition.json")).toBeTruthy();expect(screen.getByText("2 files")).toBeTruthy();// The overflow menu carries the connection check.diff --git a/jarvis/ui/web/frontend/src/views/McpsView.tsx b/jarvis/ui/web/frontend/src/views/McpsView.tsxindex a8efc4b3b0..15d6490588 100644--- a/jarvis/ui/web/frontend/src/views/McpsView.tsx+++ b/jarvis/ui/web/frontend/src/views/McpsView.tsx@@ -564,6 +564,7 @@ function McpDetail({<FileCardclassName="mt-4"+ rootLabel={server.name}files={filesQuery.data?.files ?? []}loading={filesQuery.isPending}error={filesQuery.error ? (filesQuery.error as Error).message : null}diff --git a/jarvis/ui/web/frontend/src/views/PluginsView.tsx b/jarvis/ui/web/frontend/src/views/PluginsView.tsxindex d91a77a7be..e293dcbe90 100644--- a/jarvis/ui/web/frontend/src/views/PluginsView.tsx+++ b/jarvis/ui/web/frontend/src/views/PluginsView.tsx@@ -1403,6 +1403,7 @@ function PluginDetail({ plugin, onConnect, onDisconnect }: { plugin: Plugin } &<FileCardclassName="mt-4"+ rootLabel={plugin.id}files={filesQuery.data?.files ?? []}loading={filesQuery.isPending}error={filesQuery.error ? (filesQuery.error as Error).message : null}diff --git a/jarvis/ui/web/frontend/src/views/SkillsView.tsx b/jarvis/ui/web/frontend/src/views/SkillsView.tsxindex 1abb90f28d..bab8a85192 100644--- a/jarvis/ui/web/frontend/src/views/SkillsView.tsx+++ b/jarvis/ui/web/frontend/src/views/SkillsView.tsx@@ -26,7 +26,6 @@ import {Link2,Eye,Code2,- ChevronDown,MoreHorizontal,Info,Copy,@@ -60,7 +59,7 @@ import {formatShortDate,type Column,} from "@/components/extensions/primitives";-import { MarkdownBody, ModeButton } from "@/components/extensions/FileCard";+import { FileTree, MarkdownBody, ModeButton } from "@/components/extensions/FileCard";import { cn } from "@/lib/utils";import { robustCopy } from "@/lib/clipboard";import { fill, translate, useT, useUiLanguage } from "@/i18n";@@ -77,7 +76,6 @@ import {useDeleteSkill,useBulkDeleteSkills,RESOURCE_KINDS,- RESOURCE_LABELS,type SkillSummary,type SkillState,type SkillTrigger,@@ -1002,6 +1000,8 @@ function SkillDetailPage({const fileCount = 1 + resourceFiles.length;const openLabel =openFile.kind === "skill" ? "SKILL.md" : `${openFile.kind}/${openFile.filename}`;+ const treePaths = ["SKILL.md", ...resourceFiles.map((f) => `${f.kind}/${f.filename}`)];+ const OpenFileIcon = openFile.kind === "skill" ? FileText : KIND_ICON[openFile.kind];const menuActions = [{@@ -1131,40 +1131,10 @@ function SkillDetailPage({<Panel className="mt-4"><div className="flex items-center gap-3 border-b border-border/70 px-3 py-2">- <ActionMenu- label={t("skills_view.files_menu")}- align="start"- actions={[- {- id: "skill-md",- label: "SKILL.md",- icon: <FileText className="h-3.5 w-3.5" />,- onSelect: () => setOpenFile({ kind: "skill" }),- },- ...resourceFiles.map((f, i) => {- const Icon = KIND_ICON[f.kind];- return {- id: `${f.kind}/${f.filename}`,- label: `${RESOURCE_LABELS[f.kind]} / ${f.filename}`,- icon: <Icon className="h-3.5 w-3.5" />,- separatorAbove: i === 0,- onSelect: () => setOpenFile({ kind: f.kind, filename: f.filename }),- };- }),- ]}- trigger={({ open, toggle }) => (- <button- type="button"- onClick={toggle}- aria-expanded={open}- aria-haspopup="menu"- className="inline-flex h-8 max-w-[360px] items-center gap-2 rounded-md bg-sheen/[0.07] px-3 font-mono text-[13px] text-foreground hover:bg-sheen/[0.12]"- >- <span className="truncate">{openLabel}</span>- <ChevronDown className={cn("h-3.5 w-3.5 shrink-0 transition-transform", open && "rotate-180")} />- </button>- )}- />+ <span className="inline-flex h-8 min-w-0 items-center gap-2 px-1 font-mono text-[13px] text-foreground">+ <OpenFileIcon className="h-3.5 w-3.5 shrink-0 text-muted-foreground" />+ <span className="truncate">{openLabel}</span>+ </span><span className="text-sm text-muted-foreground">{fileCount === 1 ? t("skills_view.file_one") : fill(t("skills_view.files"), { n: fileCount })}</span>@@ -1204,6 +1174,22 @@ function SkillDetailPage({</div></div>+ <div className="flex min-h-[160px]">+ <FileTree+ className="w-56 shrink-0 border-r border-border/70 py-2"+ rootLabel={data.name}+ paths={treePaths}+ openPath={openLabel}+ onOpen={(path) => {+ if (path === "SKILL.md") {+ setOpenFile({ kind: "skill" });+ return;+ }+ const hit = resourceFiles.find((f) => `${f.kind}/${f.filename}` === path);+ if (hit) setOpenFile({ kind: hit.kind, filename: hit.filename });+ }}+ />+ <div className="min-w-0 flex-1">{openFile.kind === "skill" ? (mode === "preview" ? (<div className="max-h-[60vh] overflow-auto px-6 py-5">@@ -1261,6 +1247,8 @@ function SkillDetailPage({mode={mode}/>)}+ </div>+ </div></Panel></div>