Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
Folder links: one open at a time, shorter comments
AdityaUmaled9bb2afaec8b
diff --git a/electron/save-file.mjs b/electron/save-file.mjsindex 9d4f233838..1b96104b20 100644--- a/electron/save-file.mjs+++ b/electron/save-file.mjs@@ -137,11 +137,8 @@ export async function revealInFolder(rawPath, { reveal, fsp = fs.promises, pathAreturn "shown";}-// A folder a chat links to, opened in Explorer or Finder. Same untrusted-path rules as revealInFolder, and only a plain-// folder is ever handed to `open` (shell.openPath), since opening anything else runs it: never a file, and never a-// folder that is really a program, as a Mac app (Name.app, or any folder with Contents/Info.plist) or a link to one is.-// Links are resolved first and any folder name with an extension is left alone. Anything refused answers "not-folder"-// so the page keeps today's save-a-copy. `open` answers "" or why it failed.+// shell.openPath runs whatever it is given, so only a plain folder may reach it: never a file, a Mac app bundle+// (Name.app, or a folder with Contents/Info.plist), or a link to either.export async function openFolder(rawPath, { open, fsp = fs.promises, pathApi = path }) {const target = localTarget(rawPath, pathApi);if (!target) return "invalid";diff --git a/src/components/ChatMarkdown.tsx b/src/components/ChatMarkdown.tsxindex 216f100f2c..0988bb0dab 100644--- a/src/components/ChatMarkdown.tsx+++ b/src/components/ChatMarkdown.tsx@@ -326,6 +326,7 @@ function LocalFileLink({ filePath, name, source, children, message }: { filePathconst save = useLocalFileSave(filePath, name, message);const preview = useHtmlPreview(filePath, name ?? fileName(filePath), message);const revealMenu = useRevealOriginalMenu();+ const [opening, setOpening] = useState(false);if (!message) {return <span title={t("chat.file.legacy")} className="break-words text-ink-secondary">{children}</span>;}@@ -345,8 +346,11 @@ function LocalFileLink({ filePath, name, source, children, message }: { filePath: <FilePreviewButton path={filePath} name={name ?? fileName(filePath)} message={message} />}<buttontype="button"- onClick={preview.html ? preview.show : () => void openLinkedFolder(filePath).then((opened) => { if (!opened) return save.save(); })}- disabled={!preview.html && save.state === "saving"}+ onClick={preview.html ? preview.show : () => {+ setOpening(true);+ void openLinkedFolder(filePath).then((opened) => opened ? undefined : 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")}className="inline-flex items-center gap-1 break-words text-start text-accent underline decoration-accent/40 hover:decoration-accent disabled:cursor-wait">diff --git a/src/components/RevealOriginalMenu.tsx b/src/components/RevealOriginalMenu.tsxindex f1aa009d29..6a42de4bcd 100644--- a/src/components/RevealOriginalMenu.tsx+++ b/src/components/RevealOriginalMenu.tsx@@ -20,8 +20,7 @@ function revealBridge(): Reveal | undefined {type OpenFolder = NonNullable<NonNullable<Window["ogb"]>["openFolder"]>;-/** Desktop app on the computer that holds the path: a folder a chat links to opens in Finder or Explorer. True only when- * it opened; a file, a missing path, a phone, the web or a connected window answer false and keep their own handling. */+/** Opens a linked folder in Finder or Explorer on the desktop app that holds it; false lets the caller fall back. */export async function openLinkedFolder(folderPath: string, open: OpenFolder | undefined = openFolderBridge()): Promise<boolean> {if (!open || !REVEALABLE_PATH.test(folderPath)) return false;try {