Skip to content

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

fix(preview): show no path for a relative link, which names no folder to start from

laijsg1a5ef6a5a9730
diff --git a/src/components/FilePreviewContent.outside.dom.test.ts b/src/components/FilePreviewContent.outside.dom.test.ts
index dca0aa5973..35cabf516d 100644
--- a/src/components/FilePreviewContent.outside.dom.test.ts
+++ b/src/components/FilePreviewContent.outside.dom.test.ts
@@ -64,11 +64,13 @@ describe("a previewed file outside the chat's folders", () => {
});
}
- it("leaves out the find-it-at-this-path hint for a relative link, which names no folder to start from", async () => {
+ it("shows no path for a relative link, which names no folder to start from", async () => {
vi.stubGlobal("fetch", vi.fn(async () => outside()));
await act(async () => root.render(createElement(FilePreviewContent, { kind: "markdown", path: "../finance-head/report.md", shownPath: "../finance-head/report.md", name: "report.md", message })));
await vi.waitFor(() => expect(host.textContent).toContain("Ask the bot that saved it to attach a copy."), { timeout: 5_000 });
expect(host.textContent).not.toContain("Find this file at this path");
+ expect(host.querySelector("[title]")).toBeNull();
+ expect(host.textContent).not.toContain("../finance-head/report.md");
expect(buttons()).toEqual([]);
});
diff --git a/src/components/OutsideWorkspacePreview.tsx b/src/components/OutsideWorkspacePreview.tsx
index 9419959645..30c1e77c9a 100644
--- a/src/components/OutsideWorkspacePreview.tsx
+++ b/src/components/OutsideWorkspacePreview.tsx
@@ -9,11 +9,13 @@ export function OutsideWorkspacePreview({ filePath }: { filePath: string }) {
return (
<div className="p-8 text-center text-sm">
<p role="alert" className="mb-3 text-ink-secondary">{t("attach.previewOutsideWorkspace")}</p>
- {!revealable && absolute && <p className="mb-1 text-[12px] text-ink-secondary">{t("attach.outsideWorkspacePath")}</p>}
- <div className="flex flex-col items-center gap-1 text-[12px]">
- <OutsideWorkspaceFile filePath={filePath} standalone />
- {revealable && <code className="select-all whitespace-pre-wrap break-all text-ink-secondary">{filePath}</code>}
- </div>
+ {absolute && <>
+ {!revealable && <p className="mb-1 text-[12px] text-ink-secondary">{t("attach.outsideWorkspacePath")}</p>}
+ <div className="flex flex-col items-center gap-1 text-[12px]">
+ <OutsideWorkspaceFile filePath={filePath} standalone />
+ {revealable && <code className="select-all whitespace-pre-wrap break-all text-ink-secondary">{filePath}</code>}
+ </div>
+ </>}
</div>
);
}