Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
fix(preview): keep a delivered copy's literal file name
AdityaUmaleeec13c45dc2e
diff --git a/src/components/ChatMarkdown.test.ts b/src/components/ChatMarkdown.test.tsindex d1101b80af..ff0fd53487 100644--- a/src/components/ChatMarkdown.test.ts+++ b/src/components/ChatMarkdown.test.ts@@ -839,6 +839,15 @@ describe("ChatMarkdown attachments", () => {expect(html).toContain('title="Preview page: 100%41 report.html"');});+ it("names a delivered copy by its literal file name, without decoding it", () => {+ const html = renderToStaticMarkup(createElement(ChatMarkdown, {+ text: "[Report](/old/100%41.html)", message: { threadId: "thread-1", messageId: "message-1" },+ delivered: { "100%41.html": "/store/delivered-100.html" },+ }));+ expect(html).toContain('title="Preview page: 100%41.html"');+ expect(html).not.toContain("100A.html");+ });+it("preserves dollar signs in Windows file destinations", () => {const save = vi.spyOn(AttachmentPreview, "useLocalFileSave");const filePath = "C:\\Users\\Maus\\R$5\\receipt.pdf";diff --git a/src/components/ChatMarkdown.tsx b/src/components/ChatMarkdown.tsxindex 2318bb5ab2..7d813e9271 100644--- a/src/components/ChatMarkdown.tsx+++ b/src/components/ChatMarkdown.tsx@@ -659,8 +659,8 @@ function MarkdownLink({ href, children, ...rest }: { href?: string; children?: Rif (localPath) {const copy = delivered && Object.hasOwn(delivered, fileName(localPath)) ? delivered[fileName(localPath)] : undefined;const source = copy && originals && Object.hasOwn(originals, copy) ? originals[copy] : undefined;- // localFilePath already decodes a file:// URL; a plain path link is still encoded and gets the server's single decode.- const shownName = fileName(/^file:\/\//i.test(href) ? localPath : decodedLinkPath(localPath));+ // A delivered copy keeps its literal name; localFilePath already decodes a file:// URL; a plain path link is still encoded and gets the server's single decode.+ const shownName = copy || /^file:\/\//i.test(href) ? fileName(localPath) : fileName(decodedLinkPath(localPath));return <LocalFileLink filePath={copy ?? localPath} shownName={shownName} name={copy ? fileName(localPath) : undefined} source={source} message={message}>{children}</LocalFileLink>;}if (!/^https?:\/\//i.test(href)) {