Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
Grok move: name the part that is too large or can't be opened
AdityaUmale3ded1b150ebf
diff --git a/src/components/GrokMoveDialog.test.ts b/src/components/GrokMoveDialog.test.tsindex eb1f70049b..7a7bff0c0b 100644--- a/src/components/GrokMoveDialog.test.ts+++ b/src/components/GrokMoveDialog.test.ts@@ -8,7 +8,7 @@ vi.mock("@/state/store", () => ({ useStore: () => ({ state: f.state, dispatch: fvi.mock("@/lib/analytics", () => ({ track: f.track }));import { setLocale } from "@/lib/i18n";-import { GROK_EXPORT_FORMAT, GROK_EXPORT_PROMPT } from "../../shared/grok-import";+import { GROK_EXPORT_FORMAT, GROK_EXPORT_MAX_CHARS, GROK_EXPORT_PROMPT } from "../../shared/grok-import";import { ComposerAttachments } from "./ComposerAttachments";import { GROK_BOT_MARK_PATH } from "./GrokBotMark";import { GrokMoveDialog } from "./GrokMoveDialog";@@ -483,6 +483,29 @@ describe("a file dragged over the dialog, with the chat box behind it", () => {expect(host.querySelector('[role="alert"]')?.textContent).toMatch(/^part-2\.json: /);});+ it("names the part that is too large, and brings none of them", async () => {+ await render(true);+ await tick();+ const big = fileOf(PARTS[1]!, "part-2.json");+ Object.defineProperty(big, "size", { value: GROK_EXPORT_MAX_CHARS + 1 });+ const files = [fileOf(PARTS[0]!, "part-1.json"), big];+ await drag("drop", files);+ expect(step()).toBe("start");+ expect(host.querySelector('[role="alert"]')?.textContent).toBe("part-2.json: That's larger than 4 MB. Ask your Bot to split it into several messages.");+ for (const file of files) expect(file.text).not.toHaveBeenCalled();+ });++ it("says which part could not be opened when reading it fails, and brings none of them", async () => {+ await render(true);+ await tick();+ const gone = fileOf(PARTS[1]!, "part-2.json");+ vi.mocked(gone.text).mockRejectedValue(new DOMException("The file could not be read.", "NotReadableError"));+ await drag("drop", [fileOf(PARTS[0]!, "part-1.json"), gone]);+ await tick();+ expect(step()).toBe("start");+ expect(host.querySelector('[role="alert"]')?.textContent).toBe("part-2.json: The file could not be read.");+ });+it("hands drags back to the chat box once it closes", async () => {await render(true);await tick();diff --git a/src/components/GrokMoveDialog.tsx b/src/components/GrokMoveDialog.tsxindex 33ebb70399..5abc7b8ca3 100644--- a/src/components/GrokMoveDialog.tsx+++ b/src/components/GrokMoveDialog.tsx@@ -244,12 +244,18 @@ export function GrokMoveDialog({ onClose, inline = false }: { onClose: () => voiconst readFiles = useRef<(files: readonly File[]) => void>(() => {});readFiles.current = (files) => {if (!files.length) return;- if (files.some((file) => file.size > GROK_EXPORT_MAX_CHARS)) return setError(t("grokMove.error.tooLarge"));- void Promise.all(files.map(async (file, order) => ({ name: file.name, modifiedAt: order, text: await file.text() }))).then((parts) => show(() => {+ const refusal = (file: string, reason: string) => (files.length > 1 ? t("grokMove.refused", { file, reason }) : reason);+ const tooLarge = files.find((file) => file.size > GROK_EXPORT_MAX_CHARS);+ if (tooLarge) return setError(refusal(tooLarge.name, t("grokMove.error.tooLarge")));+ const read = (file: File, order: number) => file.text().then(+ (text) => ({ name: file.name, modifiedAt: order, text }),+ (cause: unknown) => { throw new Error(refusal(file.name, grokErrorText(cause))); },+ );+ void Promise.all(files.map(read)).then((parts) => show(() => {const { bots, refused: [first] } = foundExports(parts);- if (first) throw new Error(parts.length > 1 ? t("grokMove.refused", { file: first.file, reason: first.error }) : first.error);+ if (first) throw new Error(refusal(first.file, first.error));return bots;- }));+ }), (cause: unknown) => setError(grokErrorText(cause)));};// The chat box behind this dialog attaches any file dropped on the window, and one Send would hand a private export to its// model. So nothing behind the dialog sees a drag, on any step, and only the first step reads what was dropped.