Skip to content

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

Merge pull request #6746 from guylfe/feat/message-file-containing-folder

milind-sonid02672f56e21
diff --cc src/components/ChatMarkdown.test.ts
index cdb2f146c3,d96df1b0bf..543a34e54c
--- a/src/components/ChatMarkdown.test.ts
+++ b/src/components/ChatMarkdown.test.ts
@@@ -956,14 -948,13 +956,14 @@@ describe("ChatMarkdown attachments", (
};
const revealInFolder = vi.fn(async () => "shown" as const);
- it("offers Open containing folder in the local desktop app, without printing the path", () => {
+ it("reveals the host path on the first click in the local desktop app when the probe already refused it", () => {
vi.stubGlobal("window", { ogb: { revealInFolder, remoteClient: { active: false } } });
try {
- const html = render(true);
- expect(html).toContain("This file is outside this chat's working folder, so it can't be saved from here");
+ const html = render(false, filePath, true);
+ expect(html).not.toContain("This file is outside this chat's working folder, so it can't be saved from here");
expect(html).not.toContain("the linked file is outside");
- expect(html).toContain('title="Show in folder"');
- expect(html).toContain("Open containing folder");
++ expect(html).toContain('title="Open containing folder"');
+ expect(html).toContain("lucide-folder-open");
expect(html).not.toContain("<code");
} finally {
vi.unstubAllGlobals();
@@@ -973,8 -964,8 +973,8 @@@
it("shows the full path as selectable text to a remote client instead", () => {
vi.stubGlobal("window", { ogb: { revealInFolder, remoteClient: { active: true } } });
try {
- const html = render(true);
- expect(html).not.toContain("Open containing folder");
+ const html = render(true, filePath, null);
- expect(html).not.toContain('title="Show in folder"');
++ expect(html).not.toContain('title="Open containing folder"');
expect(html).toMatch(/<code[^>]*select-all[^>]*>C:\\Users\\Maus\\_draft\\ollama-gen\.js<\/code>/);
} finally {
vi.unstubAllGlobals();
@@@ -1049,7 -1021,7 +1049,7 @@@
const root = createRoot(host);
try {
await act(async () => root.render(createElement(ChatMarkdown, { text, message: { threadId: "thread-1", messageId: "message-1" } })));
- const show = host.querySelector('button[title="Show in folder"]') as HTMLButtonElement;
- const show = [...host.querySelectorAll("button")].find((button) => button.textContent === "Open containing folder")!;
++ const show = host.querySelector('button[title="Open containing folder"]') as HTMLButtonElement;
await act(async () => show.click());
expect(reveal).toHaveBeenCalledWith(folder);
} finally {
@@@ -1064,22 -1035,10 +1064,22 @@@
it("leaves other failures alone", () => {
vi.stubGlobal("window", { ogb: { revealInFolder, remoteClient: { active: false } } });
+ const probe = vi.spyOn(OutsideWorkspaceProbe, "useMessageFileOutsideWorkspace").mockReturnValue(false);
+ const save = vi.spyOn(AttachmentPreview, "useLocalFileSave").mockReturnValue({
+ state: "failed",
+ reason: "the linked file is outside this conversation's workspace",
+ savedTo: "",
+ outsideWorkspace: false,
+ retryable: true,
+ folder: null,
+ save: vi.fn(async () => undefined),
+ });
try {
- const html = render(false);
+ const html = renderToStaticMarkup(createElement(ChatMarkdown, {
+ text: `[ollama-gen.js](${filePath})`, message: { threadId: "thread-1", messageId: "message-1" },
+ }));
expect(html).toContain("the linked file is outside this conversation&#x27;s workspace");
- expect(html).not.toContain('title="Show in folder"');
- expect(html).not.toContain("Open containing folder");
++ expect(html).not.toContain('title="Open containing folder"');
expect(html).not.toContain(filePath);
} finally {
vi.unstubAllGlobals();