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): open every file type in the code editor
rubenluetke10-beep74f511a297ca
diff --git a/jarvis/ui/web/frontend/src/components/agentic/editor/CodeEditorStage.tsx b/jarvis/ui/web/frontend/src/components/agentic/editor/CodeEditorStage.tsxindex bde3fc58e5..23e40be9f9 100644--- a/jarvis/ui/web/frontend/src/components/agentic/editor/CodeEditorStage.tsx+++ b/jarvis/ui/web/frontend/src/components/agentic/editor/CodeEditorStage.tsx@@ -3,7 +3,9 @@ import { useShallow } from "zustand/react/shallow";import {AlertTriangle,ChevronRight,+ Code2,Copy,+ Eye,ExternalLink,FileDiff,FileText,@@ -25,6 +27,7 @@ import { absoluteWorkspacePath } from "@/components/agentic/sidePanel/explorer/eimport { ThreadMenuItem, ThreadMenuSeparator, ThreadPopover } from "@/components/agentic/threads/ThreadPopover";import { checkDisk, discardFile, languageName, revertFile, saveAll, saveFile } from "./editorModels";import { QuickOpen } from "./QuickOpen";+import { renderKindOf } from "./fileKinds";const EditorSurface = lazy(() => import("./EditorSurface"));@@ -71,6 +74,17 @@ export function CodeEditorStage({const files = useCodeEditorStore((state) => state.files);const [pending, setPending] = useState<PendingClose | null>(null);const [menu, setMenu] = useState<EditorTab | null>(null);+ // Tabs whose Markdown, HTML or SVG is shown rendered (Ctrl+Shift+V).+ const [rendered, setRendered] = useState<ReadonlySet<string>>(() => new Set());+ const toggleRendered = (key: string) =>+ setRendered((current) => {+ const next = new Set(current);+ if (next.has(key)) next.delete(key);+ else next.add(key);+ return next;+ });+ const toggleRenderedRef = useRef(toggleRendered);+ toggleRenderedRef.current = toggleRendered;const menuAnchor = useRef<HTMLElement | null>(null);const pushToast = useEventStore((state) => state.pushToast);@@ -144,6 +158,9 @@ export function CodeEditorStage({} else if (key === "t" && event.shiftKey) {handled();state.reopenClosed(workspaceId);+ } else if (key === "v" && event.shiftKey && current.mode === "edit" && renderKindOf(current.path)) {+ handled();+ toggleRenderedRef.current(current.key);}};window.addEventListener("keydown", onKey, true);@@ -293,11 +310,23 @@ export function CodeEditorStage({))}{activeTab.mode === "diff" && <span className="ml-1.5 shrink-0 rounded bg-secondary px-1.5 py-px text-[11px]">{t("code_editor.diff_badge")}</span>}</nav>- <ActionButton- onClick={() => store.openFile(workspaceId, activeTab.path, { mode: activeTab.mode === "diff" ? "edit" : "diff", preview: false })}- icon={activeTab.mode === "diff" ? <FileText className="h-3.5 w-3.5" aria-hidden /> : <FileDiff className="h-3.5 w-3.5" aria-hidden />}- label={activeTab.mode === "diff" ? t("code_editor.open_file") : t("code_editor.open_changes")}- />+ {activeTab.mode === "edit" && activeFile?.status === "ready" && renderKindOf(activeTab.path) && (+ <ActionButton+ onClick={() => toggleRendered(activeTab.key)}+ icon={rendered.has(activeTab.key) ? <Code2 className="h-3.5 w-3.5" aria-hidden /> : <Eye className="h-3.5 w-3.5" aria-hidden />}+ label={rendered.has(activeTab.key) ? t("code_editor.show_source") : t("code_editor.preview")}+ hint="Ctrl+Shift+V"+ wide+ />+ )}+ {/* A text comparison only means something for a text file. */}+ {(activeTab.mode === "diff" || activeFile?.status === "ready") && (+ <ActionButton+ onClick={() => store.openFile(workspaceId, activeTab.path, { mode: activeTab.mode === "diff" ? "edit" : "diff", preview: false })}+ icon={activeTab.mode === "diff" ? <FileText className="h-3.5 w-3.5" aria-hidden /> : <FileDiff className="h-3.5 w-3.5" aria-hidden />}+ label={activeTab.mode === "diff" ? t("code_editor.open_file") : t("code_editor.open_changes")}+ />+ )}{stagedPane && (<ActionButtononClick={() =>@@ -336,7 +365,7 @@ export function CodeEditorStage({</p>}>- <EditorSurface tab={activeTab} onOpenExternally={openExternally} />+ <EditorSurface tab={activeTab} rendered={rendered.has(activeTab.key)} onOpenExternally={openExternally} /></Suspense></div>@@ -380,17 +409,32 @@ export function CodeEditorStage({);}-function ActionButton({ onClick, icon, label, iconOnly = false }: { onClick: () => void; icon: ReactNode; label: string; iconOnly?: boolean }) {+function ActionButton({+ onClick,+ icon,+ label,+ hint,+ iconOnly = false,+ wide = false,+}: {+ onClick: () => void;+ icon: ReactNode;+ label: string;+ hint?: string;+ iconOnly?: boolean;+ /** Keep the label visible at every window width. */+ wide?: boolean;+}) {return (<buttontype="button"onClick={onClick}- title={label}+ title={hint ? `${label} (${hint})` : label}aria-label={label}className="inline-flex h-6 shrink-0 items-center gap-1.5 rounded px-1.5 text-xs text-muted-foreground hover:bg-secondary hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring">{icon}- {!iconOnly && <span className="hidden xl:inline">{label}</span>}+ {!iconOnly && <span className={wide ? "inline" : "hidden xl:inline"}>{label}</span>}</button>);}diff --git a/jarvis/ui/web/frontend/src/components/agentic/editor/EditorSurface.tsx b/jarvis/ui/web/frontend/src/components/agentic/editor/EditorSurface.tsxindex 284ba7db04..a77137fbca 100644--- a/jarvis/ui/web/frontend/src/components/agentic/editor/EditorSurface.tsx+++ b/jarvis/ui/web/frontend/src/components/agentic/editor/EditorSurface.tsx@@ -1,12 +1,13 @@import { useEffect, useRef, type MouseEvent } from "react";-import { ExternalLink, FileWarning, Loader2 } from "lucide-react";+import { Loader2 } from "lucide-react";import { fill, useT } from "@/i18n";-import { workspaceFileUrl } from "@/lib/agenticIdeApi";import { cn } from "@/lib/utils";import { useCodeEditorStore, type EditorTab } from "@/store/codeEditor";import { languageFor, loadFile, loadHead, modelOf, rememberViewState, viewStateOf } from "./editorModels";import { EDITOR_OPTIONS, applyTheme, monaco } from "./monacoRuntime";+import { renderKindOf } from "./fileKinds";+import { ExtractedPreview, MediaViewer, Notice, RenderedPreview } from "./FileViewers";type CodeEditor = monaco.editor.ICodeEditor;@@ -48,9 +49,12 @@ const keepContextMenu = (event: MouseEvent) => event.stopPropagation();*/export default function EditorSurface({tab,+ rendered,onOpenExternally,}: {tab: EditorTab;+ /** Show a Markdown, HTML or SVG file rendered instead of its source. */+ rendered: boolean;onOpenExternally: (path: string) => void;}) {const t = useT();@@ -64,6 +68,7 @@ export default function EditorSurface({const reveal = useCodeEditorStore((state) => state.reveal);const status = file?.status ?? "loading";const ready = status === "ready";+ const renderKind = renderKindOf(tab.path);// Follow the app's light/dark switch. Watching the class on <html> (not a// prop) matters: the theme provider repaints the document in its own effect,@@ -158,47 +163,30 @@ export default function EditorSurface({editor.focus();}, [reveal, ready, tab.fileKey, tab.mode, tab.key]);- const notice = (() => {+ const external = () => onOpenExternally(tab.path);+ const overlay = (() => {if (status === "loading") {return (- <p className="flex items-center gap-2 text-sm text-muted-foreground">+ <p className="flex h-full items-center justify-center gap-2 text-sm text-muted-foreground"><Loader2 className="h-4 w-4 animate-spin" aria-hidden />{t("code_editor.loading")}</p>);}- if (status === "image") {- return (- <img- src={workspaceFileUrl(tab.workspaceId, tab.path)}- alt={tab.path.split("/").pop() ?? tab.path}- className="max-h-full max-w-full rounded-md border border-border/60 object-contain"- />- );+ if (status === "ready") {+ return rendered && renderKind && tab.mode === "edit" ? (+ <RenderedPreview kind={renderKind} fileKey={tab.fileKey} workspaceId={tab.workspaceId} path={tab.path} />+ ) : null;+ }+ if (status === "image" || status === "pdf" || status === "audio" || status === "video") {+ return <MediaViewer kind={status} workspaceId={tab.workspaceId} path={tab.path} onOpenExternally={external} />;+ }+ if (status === "document" || status === "binary" || status === "too_large") {+ const note =+ status === "document" ? t("code_editor.document_note") : status === "binary" ? t("code_editor.binary") : t("code_editor.too_large");+ return <ExtractedPreview workspaceId={tab.workspaceId} path={tab.path} note={note} onOpenExternally={external} />;}- if (status === "ready") return null;- const message =- status === "binary"- ? t("code_editor.binary")- : status === "too_large"- ? t("code_editor.too_large")- : fill(t("code_editor.load_failed"), { error: file?.error ?? "" });- return (- <div className="flex max-w-sm flex-col items-center gap-3 text-center">- <FileWarning className="h-8 w-8 text-muted-foreground/70" aria-hidden />- <p className="text-sm text-muted-foreground">{message}</p>- {status !== "error" && (- <button- type="button"- onClick={() => onOpenExternally(tab.path)}- className="inline-flex h-8 items-center gap-1.5 rounded-md border border-border px-3 text-xs text-foreground hover:bg-secondary focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"- >- <ExternalLink className="h-3.5 w-3.5" aria-hidden />- {t("code_editor.open_externally")}- </button>- )}- </div>- );+ return <Notice message={fill(t("code_editor.load_failed"), { error: file?.error ?? "" })} />;})();const showCode = ready && tab.mode === "edit";@@ -210,7 +198,7 @@ export default function EditorSurface({onContextMenu={keepContextMenu}className={cn("absolute inset-0", tab.mode !== "diff" && "invisible", !ready && "invisible")}/>- {notice && <div className="absolute inset-0 flex items-center justify-center p-6">{notice}</div>}+ {overlay && <div className="absolute inset-0 bg-background">{overlay}</div>}</div>);}diff --git a/jarvis/ui/web/frontend/src/components/agentic/editor/FileViewers.tsx b/jarvis/ui/web/frontend/src/components/agentic/editor/FileViewers.tsxnew file mode 100644index 0000000000..24cea96d0f--- /dev/null+++ b/jarvis/ui/web/frontend/src/components/agentic/editor/FileViewers.tsx@@ -0,0 +1,256 @@+import { useEffect, useMemo, useState, type AnchorHTMLAttributes, type ImgHTMLAttributes, type ReactNode } from "react";+import ReactMarkdown from "react-markdown";+import remarkGfm from "remark-gfm";+import { ExternalLink, FileWarning, Loader2 } from "lucide-react";++import { useT } from "@/i18n";+import { fetchWorkspaceFilePreview, workspaceFileUrl, type WorkspaceFilePreviewResponse } from "@/lib/agenticIdeApi";+import { useCodeEditorStore } from "@/store/codeEditor";+import type { ViewKind, RenderKind } from "./fileKinds";+import { modelOf } from "./editorModels";++const baseName = (path: string) => path.split("/").pop() ?? path;+const folderOf = (path: string) => (path.includes("/") ? path.slice(0, path.lastIndexOf("/") + 1) : "");++/** `../img/a.png` relative to `docs/guide.md`, as a workspace path; null outside it. */+function resolveRelative(fromFile: string, href: string): string | null {+ let target = href.split("#", 1)[0].split("?", 1)[0];+ try {+ target = decodeURIComponent(target);+ } catch {+ return null;+ }+ if (!target) return null;+ const parts = target.startsWith("/") ? target.slice(1).split("/") : `${folderOf(fromFile)}${target}`.split("/");+ const resolved: string[] = [];+ for (const part of parts) {+ if (!part || part === ".") continue;+ if (part === "..") {+ if (!resolved.length) return null;+ resolved.pop();+ } else resolved.push(part);+ }+ return resolved.length ? resolved.join("/") : null;+}++export function OpenExternallyButton({ onClick }: { onClick: () => void }) {+ const t = useT();+ return (+ <button+ type="button"+ onClick={onClick}+ className="inline-flex h-8 items-center gap-1.5 rounded-md border border-border px-3 text-xs text-foreground hover:bg-secondary focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"+ >+ <ExternalLink className="h-3.5 w-3.5" aria-hidden />+ {t("code_editor.open_externally")}+ </button>+ );+}++/** Images, PDFs, audio and video, straight from the workspace file. */+export function MediaViewer({+ kind,+ workspaceId,+ path,+ onOpenExternally,+}: {+ kind: Exclude<ViewKind, "document">;+ workspaceId: string;+ path: string;+ onOpenExternally: () => void;+}) {+ const t = useT();+ const [failed, setFailed] = useState(false);+ // A changed file on disk shows up when the tab is opened again.+ const url = useMemo(() => `${workspaceFileUrl(workspaceId, path)}&v=${Date.now()}`, [workspaceId, path]);+ useEffect(() => setFailed(false), [url]);+ if (failed) {+ return (+ <Notice message={t("code_editor.media_failed")}>+ <OpenExternallyButton onClick={onOpenExternally} />+ </Notice>+ );+ }+ if (kind === "pdf") {+ return <iframe data-testid="code-editor-pdf" title={baseName(path)} src={url} className="h-full w-full border-0 bg-white" />;+ }+ return (+ <div className="flex h-full w-full items-center justify-center overflow-auto p-6">+ {kind === "image" && (+ <img src={url} alt={baseName(path)} onError={() => setFailed(true)} className="max-h-full max-w-full rounded-md border border-border/60 object-contain" />+ )}+ {kind === "audio" && <audio src={url} controls onError={() => setFailed(true)} className="w-full max-w-xl" />}+ {kind === "video" && <video src={url} controls onError={() => setFailed(true)} className="max-h-full max-w-full bg-black" />}+ </div>+ );+}++/**+ * The text the server can read out of a file that is not editable here: an+ * Office document, a file too large to edit, or a binary (shown as hex).+ */+export function ExtractedPreview({+ workspaceId,+ path,+ note,+ onOpenExternally,+}: {+ workspaceId: string;+ path: string;+ note: string;+ onOpenExternally: () => void;+}) {+ const t = useT();+ const [preview, setPreview] = useState<WorkspaceFilePreviewResponse | null>(null);+ const [error, setError] = useState("");+ useEffect(() => {+ let alive = true;+ setPreview(null);+ setError("");+ fetchWorkspaceFilePreview(workspaceId, path)+ .then((answer) => alive && setPreview(answer))+ .catch((err: unknown) => alive && setError((err as Error).message));+ return () => {+ alive = false;+ };+ }, [workspaceId, path]);++ return (+ <div className="scrollbar-jarvis h-full overflow-auto">+ <div className="sticky top-0 z-[1] flex flex-wrap items-center gap-2 border-b border-border/60 bg-background/95 px-4 py-2 text-xs text-muted-foreground backdrop-blur-sm">+ <FileWarning className="h-3.5 w-3.5 shrink-0" aria-hidden />+ <span className="min-w-0 flex-1">{note}</span>+ <OpenExternallyButton onClick={onOpenExternally} />+ </div>+ {error ? (+ <p className="px-4 py-3 text-xs text-destructive">{error}</p>+ ) : !preview ? (+ <p className="flex items-center gap-2 px-4 py-3 text-xs text-muted-foreground">+ <Loader2 className="h-3.5 w-3.5 animate-spin" aria-hidden />+ {t("code_editor.loading")}+ </p>+ ) : preview.text ? (+ <>+ {preview.truncated && <p className="px-4 pt-3 text-xs text-muted-foreground">{t("code_editor.truncated")}</p>}+ <pre data-testid="code-editor-extracted" className="whitespace-pre-wrap break-words px-4 py-3 font-mono text-[12.5px] leading-relaxed text-foreground">+ {preview.text}+ </pre>+ </>+ ) : preview.hex_preview ? (+ <pre data-testid="code-editor-extracted" className="whitespace-pre-wrap break-words px-4 py-3 font-mono text-[12.5px] leading-relaxed text-muted-foreground">+ {preview.hex_preview}+ </pre>+ ) : (+ <p className="px-4 py-3 text-xs text-muted-foreground">{t("code_editor.empty")}</p>+ )}+ </div>+ );+}++/** The live buffer's text, re-read on every edit. */+function useModelText(fileKey: string): string {+ const [text, setText] = useState(() => modelOf(fileKey)?.getValue() ?? "");+ useEffect(() => {+ const model = modelOf(fileKey);+ if (!model) return;+ setText(model.getValue());+ const listener = model.onDidChangeContent(() => setText(model.getValue()));+ return () => listener.dispose();+ }, [fileKey]);+ return text;+}++/**+ * Markdown, HTML or SVG shown rendered from the live buffer (Ctrl+Shift+V).+ * HTML runs in a sandbox without scripts; SVG is drawn as an image, which+ * never runs script either.+ */+export function RenderedPreview({+ kind,+ fileKey,+ workspaceId,+ path,+}: {+ kind: RenderKind;+ fileKey: string;+ workspaceId: string;+ path: string;+}) {+ const t = useT();+ const text = useModelText(fileKey);+ const svgUrl = useMemo(+ () => (kind === "svg" ? URL.createObjectURL(new Blob([text], { type: "image/svg+xml" })) : ""),+ [kind, text],+ );+ useEffect(() => () => {+ if (svgUrl) URL.revokeObjectURL(svgUrl);+ }, [svgUrl]);++ const components = useMemo(+ () => ({+ a: ({ href, children, ...props }: AnchorHTMLAttributes<HTMLAnchorElement>) => {+ if (!href || /^(https?:|mailto:)/i.test(href)) {+ return <a href={href} target="_blank" rel="noreferrer noopener" {...props}>{children}</a>;+ }+ if (href.startsWith("#")) return <a href={href} {...props}>{children}</a>;+ return (+ <a+ href={href}+ {...props}+ onClick={(event) => {+ event.preventDefault();+ const target = resolveRelative(path, href);+ if (target) useCodeEditorStore.getState().openFile(workspaceId, target, { preview: false });+ }}+ >+ {children}+ </a>+ );+ },+ img: ({ src, alt, ...props }: ImgHTMLAttributes<HTMLImageElement>) => {+ // Remote images stay off: a document must not call out to the web.+ if (!src || /^[a-z][a-z0-9+.-]*:/i.test(src) || src.startsWith("//")) {+ return <span className="text-xs text-muted-foreground">[{alt || src}]</span>;+ }+ const target = resolveRelative(path, src);+ return target ? <img src={workspaceFileUrl(workspaceId, target)} alt={alt ?? ""} loading="lazy" {...props} /> : null;+ },+ }),+ [path, workspaceId],+ );++ if (kind === "html") {+ return <iframe data-testid="code-editor-rendered" title={t("code_editor.preview")} sandbox="" srcDoc={text} className="h-full w-full border-0 bg-white" />;+ }+ if (kind === "svg") {+ return (+ <div data-testid="code-editor-rendered" className="flex h-full w-full items-center justify-center overflow-auto p-6">+ <img src={svgUrl} alt={baseName(path)} className="max-h-full max-w-full" />+ </div>+ );+ }+ return (+ <div className="scrollbar-jarvis h-full overflow-auto">+ <article+ data-testid="code-editor-rendered"+ className="prose prose-neutral mx-auto max-w-3xl px-8 py-6 text-sm dark:prose-invert prose-code:text-foreground prose-pre:border prose-pre:border-border prose-pre:bg-card"+ >+ <ReactMarkdown remarkPlugins={[remarkGfm]} components={components}>+ {text}+ </ReactMarkdown>+ </article>+ </div>+ );+}++export function Notice({ message, children }: { message: string; children?: ReactNode }) {+ return (+ <div className="flex h-full w-full items-center justify-center p-6">+ <div className="flex max-w-sm flex-col items-center gap-3 text-center">+ <FileWarning className="h-8 w-8 text-muted-foreground/70" aria-hidden />+ <p className="text-sm text-muted-foreground">{message}</p>+ {children}+ </div>+ </div>+ );+}diff --git a/jarvis/ui/web/frontend/src/components/agentic/editor/editorModels.ts b/jarvis/ui/web/frontend/src/components/agentic/editor/editorModels.tsindex b26c20bfd4..9c37c602e7 100644--- a/jarvis/ui/web/frontend/src/components/agentic/editor/editorModels.ts+++ b/jarvis/ui/web/frontend/src/components/agentic/editor/editorModels.ts@@ -2,6 +2,7 @@ import type * as Monaco from "monaco-editor/editor/editor.api";import { useEventStore } from "@/store/events";import { useCodeEditorStore, type EditorFile } from "@/store/codeEditor";+import { viewKindOf } from "./fileKinds";import {SaveConflictError,fetchFileVersion,@@ -55,9 +56,6 @@ export function monacoApi(): MonacoApi | null {const store = () => useCodeEditorStore.getState();-const IMAGE_FILE = /\.(png|jpe?g|gif|webp|svg|bmp|ico|avif)$/i;--export const isImagePath = (path: string) => IMAGE_FILE.test(path);/** The engine's language id for a file name, `plaintext` when nothing claims it. */export function languageFor(path: string): string {@@ -165,8 +163,9 @@ function toast(message: string): void {export async function loadFile(fileKey: string): Promise<void> {const file = store().files[fileKey];if (!file || !api) return;- if (isImagePath(file.path)) {- store().patchFile(fileKey, { status: "image" });+ const kind = viewKindOf(file.path);+ if (kind) {+ store().patchFile(fileKey, { status: kind });return;}try {diff --git a/jarvis/ui/web/frontend/src/components/agentic/editor/fileKinds.test.ts b/jarvis/ui/web/frontend/src/components/agentic/editor/fileKinds.test.tsnew file mode 100644index 0000000000..78fcbafc9f--- /dev/null+++ b/jarvis/ui/web/frontend/src/components/agentic/editor/fileKinds.test.ts@@ -0,0 +1,27 @@+import { describe, expect, it } from "vitest";++import { renderKindOf, viewKindOf } from "./fileKinds";++describe("editor file kinds", () => {+ it("shows media and documents with a viewer, case-insensitively", () => {+ expect(viewKindOf("docs/Guide.PDF")).toBe("pdf");+ expect(viewKindOf("a/b/logo.png")).toBe("image");+ expect(viewKindOf("clip.webm")).toBe("video");+ expect(viewKindOf("voice.mp3")).toBe("audio");+ expect(viewKindOf("report.docx")).toBe("document");+ });++ it("opens everything else as text", () => {+ expect(viewKindOf("src/main.py")).toBeNull();+ expect(viewKindOf("Makefile")).toBeNull();+ expect(viewKindOf(".env.example")).toBeNull();+ expect(viewKindOf("icon.svg")).toBeNull();+ });++ it("offers a rendered view for Markdown, HTML and SVG", () => {+ expect(renderKindOf("README.md")).toBe("markdown");+ expect(renderKindOf("site/index.HTML")).toBe("html");+ expect(renderKindOf("icon.svg")).toBe("svg");+ expect(renderKindOf("main.py")).toBeNull();+ });+});diff --git a/jarvis/ui/web/frontend/src/components/agentic/editor/fileKinds.ts b/jarvis/ui/web/frontend/src/components/agentic/editor/fileKinds.tsnew file mode 100644index 0000000000..a4930ea23d--- /dev/null+++ b/jarvis/ui/web/frontend/src/components/agentic/editor/fileKinds.ts@@ -0,0 +1,39 @@+/**+ * Which files the editor shows with a viewer instead of as text.+ *+ * Everything not listed here is opened as text first; the server says whether+ * it really is text, and a file that is not falls back to a read-only peek.+ */+export type ViewKind = "image" | "pdf" | "audio" | "video" | "document";++const KINDS: Record<ViewKind, ReadonlySet<string>> = {+ image: new Set(["png", "jpg", "jpeg", "gif", "webp", "bmp", "ico", "avif"]),+ pdf: new Set(["pdf"]),+ audio: new Set(["mp3", "wav", "ogg", "oga", "m4a", "aac", "flac", "weba", "opus"]),+ video: new Set(["mp4", "m4v", "webm", "ogv", "mov"]),+ // Office and e-book formats: the server extracts their text for reading.+ document: new Set(["docx", "doc", "odt", "rtf", "xlsx", "xls", "ods", "pptx", "ppt", "odp", "epub"]),+};++const extensionOf = (path: string): string => {+ const name = (path.split("/").pop() ?? path).toLowerCase();+ const dot = name.lastIndexOf(".");+ return dot > 0 ? name.slice(dot + 1) : "";+};++export function viewKindOf(path: string): ViewKind | null {+ const extension = extensionOf(path);+ for (const kind of Object.keys(KINDS) as ViewKind[]) if (KINDS[kind].has(extension)) return kind;+ return null;+}++/** Text files that can also be shown rendered (Ctrl+Shift+V). */+export type RenderKind = "markdown" | "html" | "svg";++export function renderKindOf(path: string): RenderKind | null {+ const extension = extensionOf(path);+ if (["md", "markdown", "mdx", "mdown", "mkd"].includes(extension)) return "markdown";+ if (["html", "htm"].includes(extension)) return "html";+ if (extension === "svg") return "svg";+ return null;+}diff --git a/jarvis/ui/web/frontend/src/i18n/locales/de.json b/jarvis/ui/web/frontend/src/i18n/locales/de.jsonindex 981ce79283..c547722770 100644--- a/jarvis/ui/web/frontend/src/i18n/locales/de.json+++ b/jarvis/ui/web/frontend/src/i18n/locales/de.json@@ -6182,6 +6182,12 @@"conflict_load_disk": "Seine Version laden","conflict_keep_mine": "Meine behalten","deleted": "Diese Datei wurde auf der Festplatte gelöscht. Speichern legt sie neu an.",+ "preview": "Vorschau",+ "show_source": "Quelltext zeigen",+ "media_failed": "Diese Datei lässt sich hier nicht anzeigen.",+ "document_note": "Aus diesem Dokument gelesener Text. Zum Bearbeiten auf diesem Computer öffnen.",+ "truncated": "Nur der Anfang der Datei wird gezeigt.",+ "empty": "Diese Datei hat keinen lesbaren Inhalt.","tab_menu": "Tab-Aktionen","menu": {"close": "Schließen",diff --git a/jarvis/ui/web/frontend/src/i18n/locales/en.json b/jarvis/ui/web/frontend/src/i18n/locales/en.jsonindex ebfeeff522..edf07804ec 100644--- a/jarvis/ui/web/frontend/src/i18n/locales/en.json+++ b/jarvis/ui/web/frontend/src/i18n/locales/en.json@@ -6182,6 +6182,12 @@"conflict_load_disk": "Load their version","conflict_keep_mine": "Keep mine","deleted": "This file was deleted on disk. Saving creates it again.",+ "preview": "Preview",+ "show_source": "Show source",+ "media_failed": "This file cannot be shown here.",+ "document_note": "Text read out of this document. Open it on this computer to edit it.",+ "truncated": "Only the beginning of the file is shown.",+ "empty": "This file has no readable content.","tab_menu": "Tab actions","menu": {"close": "Close",diff --git a/jarvis/ui/web/frontend/src/i18n/locales/es.json b/jarvis/ui/web/frontend/src/i18n/locales/es.jsonindex 04b08b6597..178cf0c073 100644--- a/jarvis/ui/web/frontend/src/i18n/locales/es.json+++ b/jarvis/ui/web/frontend/src/i18n/locales/es.json@@ -6182,6 +6182,12 @@"conflict_load_disk": "Cargar su versión","conflict_keep_mine": "Mantener la mía","deleted": "Este archivo se eliminó del disco. Al guardar se vuelve a crear.",+ "preview": "Vista previa",+ "show_source": "Ver código",+ "media_failed": "Este archivo no se puede mostrar aquí.",+ "document_note": "Texto leído de este documento. Ábrelo en este equipo para editarlo.",+ "truncated": "Solo se muestra el comienzo del archivo.",+ "empty": "Este archivo no tiene contenido legible.","tab_menu": "Acciones de pestaña","menu": {"close": "Cerrar",diff --git a/jarvis/ui/web/frontend/src/store/codeEditor.ts b/jarvis/ui/web/frontend/src/store/codeEditor.tsindex 52162b2674..925144cd6e 100644--- a/jarvis/ui/web/frontend/src/store/codeEditor.ts+++ b/jarvis/ui/web/frontend/src/store/codeEditor.ts@@ -2,6 +2,7 @@ import { create } from "zustand";import { setReloadHold } from "@/lib/reloadHold";import type { LineEnding, TextEncoding } from "@/components/agentic/editor/editorApi";+import type { ViewKind } from "@/components/agentic/editor/fileKinds";/*** The Agentic IDE's code editor: which files are open as tabs, and what is@@ -28,7 +29,8 @@ export interface EditorTab {preview: boolean;}-export type FileStatus = "loading" | "ready" | "binary" | "too_large" | "image" | "error";+/** `ready` = editable text; a ViewKind = shown with a viewer; the rest are read-only notices. */+export type FileStatus = "loading" | "ready" | "binary" | "too_large" | "error" | ViewKind;export interface EditorFile {workspaceId: string;