Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
Folder link: show Opening while it opens, hide an old save failure once opened
AdityaUmale777134b0bff0
diff --git a/src/components/ChatMarkdown.test.ts b/src/components/ChatMarkdown.test.tsindex 2d2886b60b..dc51350f19 100644--- a/src/components/ChatMarkdown.test.ts+++ b/src/components/ChatMarkdown.test.ts@@ -900,6 +900,43 @@ describe("ChatMarkdown attachments", () => {}});+ it("shows Opening while a folder link opens, then stops showing an earlier save failure", async () => {+ let finish: (result: "opened") => void = () => {};+ const openFolder = vi.fn(() => new Promise<"opened">((resolve) => { finish = resolve; }));+ const save = vi.spyOn(AttachmentPreview, "useLocalFileSave").mockReturnValue({+ state: "failed",+ reason: "Couldn't save",+ savedTo: "",+ outsideWorkspace: false,+ retryable: true,+ folder: null,+ save: vi.fn(async () => undefined),+ });+ vi.stubGlobal("ogb", { openFolder, remoteClient: { active: false } });+ const host = document.createElement("div");+ document.body.append(host);+ const root = createRoot(host);+ try {+ await act(async () => {+ root.render(createElement(ChatMarkdown, { text: "[post](/work/Instagram/04_post/)", message: { threadId: "thread-1", messageId: "message-1" } }));+ });+ const link = [...host.querySelectorAll("button")].find((button) => button.textContent?.includes("post"))!;+ await act(async () => { link.click(); });+ expect(openFolder).toHaveBeenCalledWith("/work/Instagram/04_post/");+ expect(host.querySelector('[role="status"]')?.textContent).toBe("Opening…");+ expect(host.querySelector('[role="alert"]')).toBeNull();+ expect(link.querySelector(".animate-spin")).not.toBeNull();+ await act(async () => { finish("opened"); });+ expect(host.querySelector('[role="alert"]')).toBeNull();+ expect(host.textContent).not.toContain("Couldn't save");+ } finally {+ act(() => root.unmount());+ host.remove();+ vi.unstubAllGlobals();+ save.mockRestore();+ }+ });+describe("a file link outside the conversation's workspace", () => {const filePath = "C:\\Users\\Maus\\_draft\\ollama-gen.js";const render = (outsideWorkspace: boolean, href = filePath) => {@@ -911,7 +948,7 @@ describe("ChatMarkdown attachments", () => {retryable: !outsideWorkspace,folder: null,save: vi.fn(async () => undefined),- });+ });try {return renderToStaticMarkup(createElement(ChatMarkdown, {text: `[ollama-gen.js](${href})`, message: { threadId: "thread-1", messageId: "message-1" },diff --git a/src/components/ChatMarkdown.tsx b/src/components/ChatMarkdown.tsxindex 5ef2d7e9c1..c578f1fcca 100644--- a/src/components/ChatMarkdown.tsx+++ b/src/components/ChatMarkdown.tsx@@ -334,14 +334,19 @@ function LocalFileLink({ filePath, name, source, children, message }: { filePathconst preview = useHtmlPreview(filePath, name ?? fileName(filePath), message);const revealMenu = useRevealOriginalMenu();const [opening, setOpening] = useState(false);+ const [opened, setOpened] = useState(false);if (!message) {return <span title={t("chat.file.legacy")} className="break-words text-ink-secondary">{children}</span>;}- const label = save.state === "saving"+ // While a folder link opens, and after it opened, an earlier failed save is no longer what the link shows.+ const shown = opening ? "opening" : opened && save.state === "failed" ? "idle" : save.state;+ const label = shown === "opening"+ ? t("settings.updates.opening")+ : shown === "saving"? t("common.saving")- : save.state === "saved"+ : shown === "saved"? t("common.saved")- : save.state === "failed"+ : shown === "failed"? t("chat.retry"): null;@@ -355,7 +360,8 @@ function LocalFileLink({ filePath, name, source, children, message }: { filePathtype="button"onClick={preview.html ? preview.show : () => {setOpening(true);- void openLinkedFolder(filePath).then((opened) => opened ? undefined : save.save()).finally(() => setOpening(false));+ setOpened(false);+ void openLinkedFolder(filePath).then((done) => done ? setOpened(true) : save.save()).finally(() => setOpening(false));}}disabled={!preview.html && (opening || save.state === "saving")}title={preview.html ? t("html.preview", { name: name ?? fileName(filePath) }) : t("chat.file.saveCopy")}@@ -364,11 +370,11 @@ function LocalFileLink({ filePath, name, source, children, message }: { filePath{children}{preview.html ? (<Eye size={12} className="shrink-0" aria-hidden="true" />- ) : save.state === "saving" ? (+ ) : shown === "opening" || shown === "saving" ? (<LoaderCircle size={12} className="shrink-0 animate-spin" aria-hidden="true" />- ) : save.state === "saved" ? (+ ) : shown === "saved" ? (<Check size={12} className="shrink-0 text-success" aria-hidden="true" />- ) : save.state === "failed" ? (+ ) : shown === "failed" ? (save.retryable && <RotateCcw size={12} className="shrink-0" aria-hidden="true" />) : (<Download size={12} className="shrink-0" aria-hidden="true" />@@ -376,14 +382,14 @@ function LocalFileLink({ filePath, name, source, children, message }: { filePath</button>{label && (<span- role={save.state === "failed" ? "alert" : "status"}- title={save.state === "saved" ? save.savedTo : undefined}- className={`text-[12px] ${save.state === "saved" ? "text-success" : save.state === "failed" ? "text-danger" : "text-ink-secondary"}`}+ role={shown === "failed" ? "alert" : "status"}+ title={shown === "saved" ? save.savedTo : undefined}+ className={`text-[12px] ${shown === "saved" ? "text-success" : shown === "failed" ? "text-danger" : "text-ink-secondary"}`}>- {save.state === "failed" ? saveFailureText(save) : label}+ {shown === "failed" ? saveFailureText(save) : label}</span>)}- {save.state === "failed" && save.outsideWorkspace && (+ {shown === "failed" && save.outsideWorkspace && (<span className="inline-flex flex-wrap items-center gap-x-1.5 text-[12px]"><OutsideWorkspaceFile filePath={filePath} /></span>