Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
fix(preview): a Markdown file over 2 MB stays in its text view
milind-sonid7946ad9b830
diff --git a/src/components/MarkdownFilePreview.dom.test.ts b/src/components/MarkdownFilePreview.dom.test.tsindex 9b3c4bf554..5aeabdb6e2 100644--- a/src/components/MarkdownFilePreview.dom.test.ts+++ b/src/components/MarkdownFilePreview.dom.test.ts@@ -36,6 +36,7 @@ describe("Markdown file preview errors and encodings", () => {await open(async () => new Response(source));expect(host.querySelector("pre")?.textContent).toBe(source);expect(host.querySelector('[aria-pressed="true"]')).toBeTruthy();+ expect((host.querySelector('[aria-pressed="true"]') as HTMLButtonElement).disabled).toBe(true);});it("still opens UTF-8 files as UTF-8", async () => {diff --git a/src/components/MarkdownFilePreview.tsx b/src/components/MarkdownFilePreview.tsxindex 016cca562e..aa504450bf 100644--- a/src/components/MarkdownFilePreview.tsx+++ b/src/components/MarkdownFilePreview.tsx@@ -9,6 +9,7 @@ import { cn } from "@/lib/cn";import { t } from "@/lib/i18n";import { PREVIEW_MAX_BYTES } from "../../shared/upload-limits";+// Drawing a file this long as Markdown would hold up the window, so it stays as text.const AUTO_RENDER_MAX_CHARS = 2 * 1024 * 1024;/** A Markdown file in a message, drawn the way the chat draws a reply. Security: no message context is passed on, so@@ -51,7 +52,7 @@ export default function MarkdownFileContent({ path, shownPath = path, name, messif (source === null) return <div className="p-12 text-center text-sm text-ink-secondary"><span role="status" className="inline-flex items-center gap-2"><LoaderCircle size={16} className="animate-spin" />{t("markdown.loading")}</span>{recovery}</div>;return <div className={cn("flex flex-col gap-2", fill && "min-h-0 flex-1")}><div className="flex items-center justify-end gap-1">- <button type="button" className="table-action" aria-pressed={showSource} aria-label={t(showSource ? "markdown.rendered" : "html.source")} title={t(showSource ? "markdown.rendered" : "html.source")} onClick={() => setShowSource(!showSource)}>{showSource ? <Eye size={14} /> : <Code2 size={14} />}</button>+ <button type="button" className="table-action" aria-pressed={showSource} aria-label={t(showSource ? "markdown.rendered" : "html.source")} title={t(showSource ? "markdown.rendered" : "html.source")} disabled={source.length > AUTO_RENDER_MAX_CHARS} onClick={() => setShowSource(!showSource)}>{showSource ? <Eye size={14} /> : <Code2 size={14} />}</button><button type="button" className="table-action" aria-label={t("html.reload")} title={t("html.reload")} onClick={() => setAttempt(attempt + 1)}><RotateCcw size={14} /></button><button type="button" className="table-action" aria-label={t("attach.saveAria", { name })} title={t("attach.saveAria", { name })} disabled={save.state === "saving"} onClick={() => void save.save()}><Download size={14} /></button></div>