Skip to content

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

fix(files): keep Save this file shown when revealOnClick is true

jonathanwxh-cell16fa9d7cc9ad
diff --git a/src/components/ChatMarkdown.test.ts b/src/components/ChatMarkdown.test.ts
index 9dbec7c775..99ad33d004 100644
--- a/src/components/ChatMarkdown.test.ts
+++ b/src/components/ChatMarkdown.test.ts
@@ -1090,6 +1090,32 @@ describe("ChatMarkdown attachments", () => {
probe.mockRestore();
}
});
+
+ it("keeps Save this file available when revealOnClick is true and the server sets canOpenOutside", () => {
+ vi.stubGlobal("window", { ogb: { revealInFolder, remoteClient: { active: false } } });
+ const probe = vi.spyOn(OutsideWorkspaceProbe, "useMessageFileOutsideWorkspace").mockReturnValue(true);
+ const save = vi.spyOn(AttachmentPreview, "useLocalFileSave").mockReturnValue({
+ state: "failed",
+ reason: "the linked file is outside this conversation's workspace",
+ savedTo: "",
+ outsideWorkspace: true,
+ canOpenOutside: true,
+ retryable: false,
+ folder: null,
+ save: vi.fn(async () => undefined),
+ });
+ try {
+ const html = renderToStaticMarkup(createElement(ChatMarkdown, {
+ text: "[report.html](C:\\Users\\Maus\\_draft\\report.html)", message: { threadId: "thread-1", messageId: "message-1" },
+ }));
+ expect(html).toContain("Save this file");
+ expect(html).toContain("This file is outside this chat's working folder, so it can't be saved from here");
+ } finally {
+ vi.unstubAllGlobals();
+ save.mockRestore();
+ probe.mockRestore();
+ }
+ });
});
it("makes a message-authorized file link downloadable", () => {
diff --git a/src/components/ChatMarkdown.tsx b/src/components/ChatMarkdown.tsx
index e74ea593fc..8a1745d3a5 100644
--- a/src/components/ChatMarkdown.tsx
+++ b/src/components/ChatMarkdown.tsx
@@ -393,7 +393,7 @@ function LocalFileLink({ filePath, shownPath, shownName, name, source, children,
? t("common.saving")
: save.state === "saved"
? t("common.saved")
- : save.state === "failed" && !revealOnClick
+ : save.state === "failed" && (!revealOnClick || save.canOpenOutside)
? t("chat.retry")
: null;
const pathTitle = preview.opens ? preview.label : revealOnClick ? t("attach.showInFolder") : t("chat.file.saveCopy");
@@ -438,7 +438,7 @@ function LocalFileLink({ filePath, shownPath, shownName, name, source, children,
{save.state === "failed" ? saveFailureText(save) : label}
</span>
)}
- {save.state === "failed" && save.outsideWorkspace && !revealOnClick && (
+ {save.state === "failed" && save.outsideWorkspace && (!revealOnClick || save.canOpenOutside) && (
<span className="inline-flex flex-wrap items-center gap-x-1.5 text-[12px]">
<OutsideWorkspaceFile
filePath={shownPath}