Skip to content

Open-source Grok Bot alternative with a virtual machine that bots can use

fix(preview): a network share path keeps the find-it hint

laijsg13041e8082ded
diff --git a/src/components/FilePreviewContent.outside.dom.test.ts b/src/components/FilePreviewContent.outside.dom.test.ts
index 7812b4ba0d..dca0aa5973 100644
--- a/src/components/FilePreviewContent.outside.dom.test.ts
+++ b/src/components/FilePreviewContent.outside.dom.test.ts
@@ -72,6 +72,13 @@ describe("a previewed file outside the chat's folders", () => {
expect(buttons()).toEqual([]);
});
+ it("keeps the find-it hint for a network share path", async () => {
+ vi.stubGlobal("fetch", vi.fn(async () => outside()));
+ await act(async () => root.render(createElement(FilePreviewContent, { kind: "markdown", path: "file://server/share/report.md", shownPath: "//server/share/report.md", name: "report.md", message })));
+ await vi.waitFor(() => expect(host.textContent).toContain("Find this file at this path on the computer running"), { timeout: 5_000 });
+ expect(host.querySelector("code")?.textContent).toBe("//server/share/report.md");
+ });
+
it("keeps Retry for a refusal that may pass next time", async () => {
await show("markdown", ".md", () => new Response(JSON.stringify({ error: "the linked file changed while it was being opened" }), { status: 409, headers: { "content-type": "application/json" } }));
expect(host.querySelector("[role=alert]")!.textContent).toContain("the linked file changed while it was being opened");
diff --git a/src/components/OutsideWorkspacePreview.tsx b/src/components/OutsideWorkspacePreview.tsx
index e1b5490643..9419959645 100644
--- a/src/components/OutsideWorkspacePreview.tsx
+++ b/src/components/OutsideWorkspacePreview.tsx
@@ -4,7 +4,7 @@ import { t } from "@/lib/i18n";
export const refusedAsOutsideWorkspace = (error: unknown): boolean => (error as { code?: unknown } | null)?.code === "outside_workspace";
export function OutsideWorkspacePreview({ filePath }: { filePath: string }) {
- const absolute = REVEALABLE_PATH.test(filePath) || filePath.startsWith("\\\\");
+ const absolute = REVEALABLE_PATH.test(filePath) || /^(?:\\\\|\/\/)/.test(filePath);
const revealable = Boolean(revealBridge()) && REVEALABLE_PATH.test(filePath);
return (
<div className="p-8 text-center text-sm">