Skip to content

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

fix(preview): a standalone Show in folder is a ui-button, paths keep their spaces, and a relative link gets no find-it hint

laijsg1d88509e3c67b
diff --git a/src/components/AttachmentPreview.tsx b/src/components/AttachmentPreview.tsx
index d0ba477a01..626098b07d 100644
--- a/src/components/AttachmentPreview.tsx
+++ b/src/components/AttachmentPreview.tsx
@@ -427,7 +427,7 @@ export function OutsideWorkspaceFile({ filePath, standalone = false }: { filePat
const reveal = revealBridge();
if (!reveal || !REVEALABLE_PATH.test(filePath)) {
return (
- <code title={t("attach.outsideWorkspacePath")} className="select-all break-all text-ink">
+ <code title={t("attach.outsideWorkspacePath")} className="select-all whitespace-pre-wrap break-all text-ink">
{filePath}
</code>
);
@@ -448,9 +448,9 @@ export function OutsideWorkspaceFile({ filePath, standalone = false }: { filePat
type="button"
onClick={() => void show()}
title={filePath}
- className={`${standalone ? "min-h-8 touch:min-h-10 " : ""}inline-flex items-center gap-1 text-accent underline decoration-accent/40 hover:decoration-accent`}
+ className={standalone ? "ui-button touch:min-h-10" : "inline-flex items-center gap-1 text-accent underline decoration-accent/40 hover:decoration-accent"}
>
- <FolderOpen size={12} className="shrink-0" aria-hidden="true" />
+ <FolderOpen size={standalone ? 14 : 12} className="shrink-0" aria-hidden="true" />
{t("attach.showInFolder")}
</button>
{problem && <span role="alert" className="text-danger">{problem}</span>}
diff --git a/src/components/FilePreviewContent.outside.dom.test.ts b/src/components/FilePreviewContent.outside.dom.test.ts
index ef253598b2..7812b4ba0d 100644
--- a/src/components/FilePreviewContent.outside.dom.test.ts
+++ b/src/components/FilePreviewContent.outside.dom.test.ts
@@ -64,6 +64,14 @@ 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 () => {
+ 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(buttons()).toEqual([]);
+ });
+
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 79d53f88d9..e1b5490643 100644
--- a/src/components/OutsideWorkspacePreview.tsx
+++ b/src/components/OutsideWorkspacePreview.tsx
@@ -4,14 +4,15 @@ 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 revealable = Boolean(revealBridge()) && REVEALABLE_PATH.test(filePath);
return (
<div className="p-8 text-center text-sm">
<p role="alert" className="mb-3 text-ink-secondary">{t("attach.previewOutsideWorkspace")}</p>
- {!revealable && <p className="mb-1 text-[12px] text-ink-secondary">{t("attach.outsideWorkspacePath")}</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 break-all text-ink-secondary">{filePath}</code>}
+ {revealable && <code className="select-all whitespace-pre-wrap break-all text-ink-secondary">{filePath}</code>}
</div>
</div>
);