Skip to content

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

fix(preview): keep the path in view beside Show in folder, at touch size

laijsg1a001e22753db
diff --git a/src/components/AttachmentPreview.tsx b/src/components/AttachmentPreview.tsx
index c9ada6dab4..d0ba477a01 100644
--- a/src/components/AttachmentPreview.tsx
+++ b/src/components/AttachmentPreview.tsx
@@ -448,7 +448,7 @@ export function OutsideWorkspaceFile({ filePath, standalone = false }: { filePat
type="button"
onClick={() => void show()}
title={filePath}
- className={`${standalone ? "min-h-8 " : ""}inline-flex items-center gap-1 text-accent underline decoration-accent/40 hover:decoration-accent`}
+ className={`${standalone ? "min-h-8 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" />
{t("attach.showInFolder")}
diff --git a/src/components/FilePreviewContent.outside.dom.test.ts b/src/components/FilePreviewContent.outside.dom.test.ts
index 70c626d9ec..ef253598b2 100644
--- a/src/components/FilePreviewContent.outside.dom.test.ts
+++ b/src/components/FilePreviewContent.outside.dom.test.ts
@@ -3,7 +3,8 @@ import { act, createElement } from "react";
import { createRoot, type Root } from "react-dom/client";
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
import { setLocale } from "@/lib/i18n";
-import { MessageAttachmentGallery } from "./AttachmentGallery";
+import { collectMessageFiles } from "./AttachmentGallery";
+import { AttachedFileChip } from "./AttachmentPreview";
import { ChatMarkdown } from "./ChatMarkdown";
import { FilePreviewContent } from "./HtmlFilePreview";
@@ -57,6 +58,7 @@ describe("a previewed file outside the chat's folders", () => {
await show(kind, extension, outside);
expect(buttons()).toEqual(["Show in folder"]);
expect(host.textContent).not.toContain("Find this file at this path");
+ expect(host.querySelector("code")?.textContent).toBe(`${onDisk}${extension}`);
await act(async () => host.querySelector("button")!.click());
expect(revealInFolder).toHaveBeenCalledWith(`${onDisk}${extension}`);
});
@@ -99,8 +101,9 @@ describe("a linked file outside the chat's folders, opened from the chat", () =>
expect(opened.revealed).toEqual([`${onDisk}.csv`]);
});
- it("shows a file:// link from the files under a reply in its folder by its real path", async () => {
- const opened = await openFrom(createElement(MessageAttachmentGallery, { text: `Report: [Q3](file://${linked}.md)`, message }), "Preview: Q3 report.md");
+ it("shows a file:// link listed as a file chip, as the Library lists a message's links, in its folder by its real path", async () => {
+ const [file] = collectMessageFiles(`Report: [Q3](file://${linked}.md)`);
+ const opened = await openFrom(createElement(AttachedFileChip, { file: file!, linked: true, message }), "Preview: Q3 report.md");
expect(opened.asked).toBe(`file://${linked}.md`);
expect(opened.revealed).toEqual([`${onDisk}.md`]);
});
diff --git a/src/components/OutsideWorkspacePreview.tsx b/src/components/OutsideWorkspacePreview.tsx
index af2fffd9ad..79d53f88d9 100644
--- a/src/components/OutsideWorkspacePreview.tsx
+++ b/src/components/OutsideWorkspacePreview.tsx
@@ -9,7 +9,10 @@ export function OutsideWorkspacePreview({ filePath }: { filePath: string }) {
<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>}
- <div className="flex flex-wrap items-center justify-center gap-x-1.5 text-[12px]"><OutsideWorkspaceFile filePath={filePath} standalone /></div>
+ <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>}
+ </div>
</div>
);
}