From 305e591ec2af83ea3481845c8178187f6b3712bb Mon Sep 17 00:00:00 2001 From: Timothy Jaeryang Baek Date: Fri, 6 Mar 2026 15:03:23 -0600 Subject: [PATCH] feat: use CodeMirror for always-editable code file preview - Add FileCodeEditor.svelte: CodeMirror wrapper with auto language detection, dark mode, Ctrl+S save, reactive to value/filePath changes - Replace Shiki read-only highlighting + textarea editing with always-editable CodeMirror for code files in FileNav preview - Show persistent Save button for code files in toolbar - Non-code text files keep existing Edit/Save/Cancel textarea flow - SVG retains Shiki highlighting for visual preview mode --- src/lib/components/chat/FileNav.svelte | 21 ++- .../chat/FileNav/FileCodeEditor.svelte | 139 ++++++++++++++++++ .../chat/FileNav/FilePreview.svelte | 49 ++++-- 3 files changed, 191 insertions(+), 18 deletions(-) create mode 100644 src/lib/components/chat/FileNav/FileCodeEditor.svelte diff --git a/src/lib/components/chat/FileNav.svelte b/src/lib/components/chat/FileNav.svelte index 12d0c9daf3..fbc7568f80 100644 --- a/src/lib/components/chat/FileNav.svelte +++ b/src/lib/components/chat/FileNav.svelte @@ -659,7 +659,7 @@ {/if} - {#if (isMarkdown || isCsv || isHtml || isCode || isJson || isSvg || isNotebook) && fileContent !== null && !editing} + {#if (isMarkdown || isCsv || isHtml || isJson || isSvg || isNotebook) && fileContent !== null && !editing} + + {:else if editing}