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.

fix(ui): strip preview comments with a plain scan instead of a regex

rubenluetke10-beep620d6069fa14
diff --git a/jarvis/ui/web/frontend/src/views/assistant/FilesSection.tsx b/jarvis/ui/web/frontend/src/views/assistant/FilesSection.tsx
index 3129f3a557..d8e55af78f 100644
--- a/jarvis/ui/web/frontend/src/views/assistant/FilesSection.tsx
+++ b/jarvis/ui/web/frontend/src/views/assistant/FilesSection.tsx
@@ -30,14 +30,21 @@ export function useFileMeta(): (file: SoulFile) => string {
};
}
-/** Drops HTML comments, including nested leftovers and an unclosed opener. */
+/**
+ * Drops HTML comments. The preview renders as plain text, so this is about
+ * readability, not safety; an unclosed comment hides the rest of the line.
+ */
function withoutComments(text: string): string {
- let previous: string;
- do {
- previous = text;
- text = text.replace(/<!--[\s\S]*?-->/g, "");
- } while (text !== previous);
- return text.replace(/<!--|-->/g, "");
+ let out = "";
+ let at = 0;
+ for (;;) {
+ const start = text.indexOf("<!--", at);
+ if (start < 0) return out + text.slice(at);
+ out += text.slice(at, start);
+ const end = text.indexOf("-->", start + 4);
+ if (end < 0) return out;
+ at = end + 3;
+ }
}
/** Inline Markdown made readable: emphasis markers and comments dropped. */