Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
Move from Grok Bot opens in place in Settings (#5125)
Milind Sonie4b0882de2e1
diff --git a/src/components/GrokMoveDialog.test.ts b/src/components/GrokMoveDialog.test.tsindex 61a2092452..198fb436fc 100644--- a/src/components/GrokMoveDialog.test.ts+++ b/src/components/GrokMoveDialog.test.ts@@ -11,6 +11,7 @@ import { setLocale } from "@/lib/i18n";import { GROK_EXPORT_FORMAT, GROK_EXPORT_PROMPT } from "../../shared/grok-import";import { ComposerAttachments } from "./ComposerAttachments";import { GrokMoveDialog } from "./GrokMoveDialog";+import { GrokImportSection } from "./ImportSettings";const MEMORY = "The door sticks in the rain";const WHEN = "Weekdays around 9:00 AM Asia/Calcutta (may run up to 15 min early or 15 min late)";@@ -175,6 +176,38 @@ describe("Move from Grok Bot", () => {expect(host.querySelector('[data-grok-move="preview"]')).not.toBeNull();});+ it("inside Settings it opens in place, with no overlay to end up behind the Settings window", async () => {+ await act(async () => root.render(createElement(GrokMoveDialog, { onClose: vi.fn(), inline: true })));+ await tick();+ expect(host.querySelector("[data-grok-move]")).not.toBeNull();+ expect(host.querySelector("textarea")).not.toBeNull();+ expect(host.querySelector(".ui-scrim")).toBeNull();+ expect(host.querySelector('[role="dialog"]')).toBeNull();+ });++ it("Settings leaves Escape to its own window while the move is open in place", async () => {+ const onClose = vi.fn();+ await act(async () => root.render(createElement(GrokMoveDialog, { onClose, inline: true })));+ await tick();+ await act(async () => { host.querySelector("[data-grok-move]")!.dispatchEvent(new KeyboardEvent("keydown", { key: "Escape", bubbles: true })); });+ expect(onClose).not.toHaveBeenCalled();+ });++ it("the Settings row expands the move, and folding it away keeps what's in progress", async () => {+ await act(async () => root.render(createElement(GrokImportSection)));+ const row = host.querySelector<HTMLButtonElement>("[data-grok-move-open]")!;+ expect(row.getAttribute("aria-expanded")).toBe("false");+ expect(host.querySelector("[data-grok-move]")).toBeNull();+ await act(async () => { row.click(); });+ await vi.waitFor(() => expect(host.querySelector("[data-grok-move]")).not.toBeNull());+ expect(row.getAttribute("aria-expanded")).toBe("true");+ await paste(EXPORT);+ await act(async () => { row.click(); });+ expect(row.getAttribute("aria-expanded")).toBe("false");+ expect(host.querySelector("[data-grok-move]")!.parentElement!.className).toContain("hidden");+ expect(host.querySelector("[data-grok-move]")!.getAttribute("data-grok-move")).toBe("preview");+ });+it("scrolls inside the dialog, with its buttons always in view", async () => {await open();expect(host.querySelector("[data-grok-move-body]")!.className).toContain("overflow-y-auto");diff --git a/src/components/GrokMoveDialog.tsx b/src/components/GrokMoveDialog.tsxindex 7b0e4f93de..64abdad937 100644--- a/src/components/GrokMoveDialog.tsx+++ b/src/components/GrokMoveDialog.tsx@@ -98,7 +98,7 @@ function BringBack({ local, look, found, reply, error, onReply, onFile, onFound/** Settings → Import → Move from Grok Bot: the message, what the Bot wrote, the preview, the import, the report. Nothing on* this computer is read until this dialog is open. */-export function GrokMoveDialog({ onClose }: { onClose: () => void }) {+export function GrokMoveDialog({ onClose, inline = false }: { onClose: () => void; inline?: boolean }) {const { state, dispatch } = useStore();const local = localSetupImport(state.config?.cloudHome === true);const [look, setLook] = useState<GrokLook>(NOTHING_FOUND);@@ -173,27 +173,26 @@ export function GrokMoveDialog({ onClose }: { onClose: () => void }) {refresh();};- return (- <div className="ui-scrim fixed inset-0 z-[60] flex items-center justify-center p-4" onMouseDown={(event) => { if (event.target === event.currentTarget && !importing) onClose(); }}>- <div ref={root} tabIndex={-1} role="dialog" aria-modal="true" aria-labelledby="grok-move-title" data-grok-move={report ? "report" : preview ? "preview" : "start"}+ const panel = (+ <div ref={root} tabIndex={-1} {...(inline ? {} : { role: "dialog", "aria-modal": true, "aria-labelledby": "grok-move-title" })} data-grok-move={report ? "report" : preview ? "preview" : "start"}onKeyDown={(event) => {- if (event.key !== "Escape" || importing) return;+ if (inline || event.key !== "Escape" || importing) return;event.preventDefault();event.stopPropagation();if (preview) setPreview(null);else onClose();}}- className="ui-modal animate-pop-in flex max-h-[min(720px,calc(100dvh-32px))] w-[560px] max-w-full flex-col overflow-hidden text-left outline-none">- <div className="flex h-[52px] shrink-0 items-center justify-between pl-4 pr-3">+ className={inline ? "mt-3 flex flex-col rounded-lg border border-hairline/40 text-left outline-none" : "ui-modal animate-pop-in flex max-h-[min(720px,calc(100dvh-32px))] w-[560px] max-w-full flex-col overflow-hidden text-left outline-none"}>+ {(!inline || preview) && <><div className="flex h-[52px] shrink-0 items-center justify-between pl-4 pr-3"><h2 id="grok-move-title" className="text-[14px] font-semibold leading-[22px] text-ink">{preview ? t("grokMove.previewTitle") : t("settings.import.grokTitle")}</h2>- <button type="button" disabled={importing} onClick={onClose} aria-label={t("common.close")} title={t("common.close")}+ {!inline && <button type="button" disabled={importing} onClick={onClose} aria-label={t("common.close")} title={t("common.close")}className="flex size-7 items-center justify-center rounded-full text-ink-secondary transition-colors hover:bg-ink/[0.06] hover:text-ink disabled:opacity-40"><X size={16} />- </button>+ </button>}</div>- <div className="ui-modal-divider shrink-0" />+ <div className="ui-modal-divider shrink-0" /></>}<div key={report ? "report" : preview ? "preview" : "start"} data-grok-move-body className="flex min-h-0 flex-1 flex-col gap-4 overflow-y-auto p-4 [scrollbar-width:thin]">{report ? (<>@@ -235,6 +234,11 @@ export function GrokMoveDialog({ onClose }: { onClose: () => void }) {)}</div></div>+ );+ if (inline) return panel;+ return (+ <div className="ui-scrim fixed inset-0 z-[60] flex items-center justify-center p-4" onMouseDown={(event) => { if (event.target === event.currentTarget && !importing) onClose(); }}>+ {panel}</div>);}diff --git a/src/components/ImportSettings.tsx b/src/components/ImportSettings.tsxindex 38eec5801a..d4797bb36b 100644--- a/src/components/ImportSettings.tsx+++ b/src/components/ImportSettings.tsx@@ -1,6 +1,6 @@// Settings → Import: everything that brings work in from elsewhere, in one place. "From your AI apps" brings the skills// and MCP servers another AI tool keeps on this computer.-import { BookOpen, Check, Info, Loader2, Plug } from "lucide-react";+import { BookOpen, Check, ChevronDown, Info, Loader2, Plug } from "lucide-react";import { useEffect, useState, type ReactNode } from "react";import { track } from "@/lib/analytics";@@ -161,13 +161,17 @@ function AiAppsImport({ client, local }: { client: SetupImportClient; local: boo}export function GrokImportSection() {+ const [started, setStarted] = useState(false);const [open, setOpen] = useState(false);return (<section data-import-section="grok" className="rounded-xl bg-card p-4"><div className="flex items-center gap-2 text-[15px] font-medium text-ink"><GrokBotMark size={16} />{t("settings.import.grokTitle")}</div><div className="mt-0.5 text-[13px] leading-relaxed text-ink-secondary">{t("settings.import.grokSubtitle")}</div>- <button type="button" data-grok-move-open onClick={() => setOpen(true)} className={cn(buttonClass, "mt-3")}>{t("settings.import.grokTitle")}</button>- {open && <GrokMoveDialog onClose={() => setOpen(false)} />}+ <button type="button" data-grok-move-open aria-expanded={open} onClick={() => { setStarted(true); setOpen(!open); }} className={cn(buttonClass, "mt-3")}>+ {t("settings.import.grokTitle")}+ <ChevronDown size={14} aria-hidden="true" className={cn("transition-transform", open && "rotate-180")} />+ </button>+ {started && <div className={open ? undefined : "hidden"}><GrokMoveDialog inline onClose={() => { setStarted(false); setOpen(false); }} /></div>}</section>);}