Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
fix(chat): show and reveal a linked folder by its real path, not its %20 spelling
AdityaUmale18432b5da337
diff --git a/src/components/AttachmentGallery.tsx b/src/components/AttachmentGallery.tsxindex fd09ef209a..c5b71b4efc 100644--- a/src/components/AttachmentGallery.tsx+++ b/src/components/AttachmentGallery.tsx@@ -7,7 +7,7 @@ import { attachmentBasename, PREVIEW_MAX_BYTES, type TranscriptFileAttachment, timport { cn } from "@/lib/cn";import { t } from "@/lib/i18n";import { windowsPathDestinations } from "../../shared/markdown-windows-paths";-import { localFilePath } from "./ChatMarkdown";+import { decodedLinkPath, localFilePath } from "./ChatMarkdown";import {AttachedFileChip,AttachmentPreviewDialog,@@ -34,8 +34,7 @@ type MarkdownNode = {export function fileIdentity(path: string): string {// Presentation deduplication only, never an authorization check.if (/^file:\/\//i.test(path)) return localFilePath(path) ?? path;- try { return decodeURIComponent(path.split(/[?#]/, 1)[0]!); }- catch { return path; }+ return decodedLinkPath(path);}export function collectMessageFiles(text: string, existingPaths: readonly string[] = []): GalleryFile[] {diff --git a/src/components/ChatMarkdown.test.ts b/src/components/ChatMarkdown.test.tsindex 405d82650d..ac2f003b26 100644--- a/src/components/ChatMarkdown.test.ts+++ b/src/components/ChatMarkdown.test.ts@@ -956,6 +956,47 @@ describe("ChatMarkdown attachments", () => {expect(render(true)).toContain(`>${filePath}</code>`);});+ describe("a backticked folder path with a space", () => {+ const folder = "D:\\Claude Works\\v3\\";+ const text = `The videos are in \`${folder}\``;+ const outsideSave = () => vi.spyOn(AttachmentPreview, "useLocalFileSave").mockReturnValue({+ state: "failed", reason: "", savedTo: "", outsideWorkspace: true, retryable: false, folder: null,+ save: vi.fn(async () => undefined),+ });++ it("shows the real path in a browser, not the link's %20 spelling", () => {+ const save = outsideSave();+ try {+ const html = renderToStaticMarkup(createElement(ChatMarkdown, { text, message: { threadId: "thread-1", messageId: "message-1" } }));+ expect(html).toContain(`>${folder}</code>`);+ expect(html).not.toContain("%20");+ } finally {+ save.mockRestore();+ }+ });++ it("asks the desktop app to show the real folder", async () => {+ const save = outsideSave();+ const ogb = (window as { ogb?: unknown }).ogb;+ const reveal = vi.fn(async () => "shown" as const);+ (window as { ogb?: unknown }).ogb = { revealInFolder: reveal, remoteClient: { active: false } };+ const host = document.createElement("div");+ document.body.append(host);+ const root = createRoot(host);+ try {+ await act(async () => root.render(createElement(ChatMarkdown, { text, message: { threadId: "thread-1", messageId: "message-1" } })));+ const show = [...host.querySelectorAll("button")].find((button) => button.textContent === "Show in folder")!;+ await act(async () => show.click());+ expect(reveal).toHaveBeenCalledWith(folder);+ } finally {+ await act(async () => root.unmount());+ host.remove();+ (window as { ogb?: unknown }).ogb = ogb;+ save.mockRestore();+ }+ });+ });+it("leaves other failures alone", () => {vi.stubGlobal("window", { ogb: { revealInFolder, remoteClient: { active: false } } });try {diff --git a/src/components/ChatMarkdown.tsx b/src/components/ChatMarkdown.tsxindex 3db4b0dea8..b1112e845a 100644--- a/src/components/ChatMarkdown.tsx+++ b/src/components/ChatMarkdown.tsx@@ -69,6 +69,12 @@ export const localFilePath = (href?: string): string | null => {return href;};+// A plain-path link as the server reads it: cut at ? or #, then percent-decoded once.+export const decodedLinkPath = (href: string): string => {+ try { return decodeURIComponent(href.split(/[?#]/, 1)[0]!); }+ catch { return href; }+};+export function chatUrlTransform(value: string, key = "href"): string {if (looksLikeThreadRefUrl(value) || isUseMyComputerUrl(value)) return value;// Markdown-to-HTML percent-encodes a destination's backslashes (C:%5CUsers…); restore them and leave other escapes@@ -385,7 +391,7 @@ function LocalFileLink({ filePath, name, source, children, message }: { filePath)}{save.state === "failed" && save.outsideWorkspace && (<span className="inline-flex flex-wrap items-center gap-x-1.5 text-[12px]">- <OutsideWorkspaceFile filePath={filePath} />+ <OutsideWorkspaceFile filePath={decodedLinkPath(filePath)} /></span>)}{save.folder && <MessageFolderFiles folderPath={filePath} listing={save.folder} message={message} />}