Skip to content

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

Merge remote-tracking branch 'origin/main' into train/nov8-e

milind-sonic19868b02514
diff --cc src/components/app/AppMessage.tsx
index 9ea5c927bd,e03cfcc3c4..52c08eae1c
--- a/src/components/app/AppMessage.tsx
+++ b/src/components/app/AppMessage.tsx
@@@ -9,7 -9,8 +9,8 @@@ import { AppDocumentError, fetchAppDocu
import { APP_POOL_LIMITS, useAppPoolSlot, type AppPool } from "./app-pool";
import { AppDone, AppHeader, AppInfo, AppOpenButton, AppPlaceholder, AppStrip, APP_SURFACE } from "./AppChrome";
import { AppFrame, type AppFrameHandle, type AppFrameProblem } from "./AppFrame";
- import { PAGE_HEIGHT, PageFullScreen, PageNotes, PageToolbar, usePagePoint, usePageSave, usePageShare, usePageVersion } from "./PageTools";
+ import { closePage, onPageOpened, openPage, openPageFor } from "@/lib/open-page";
-import { PAGE_HEIGHT, PAGE_PREVIEW_HEIGHT, PageFullScreen, PageNotes, PagePaneContext, PageToolbar, usePagePoint, usePageShare, usePageVersion } from "./PageTools";
++import { PAGE_HEIGHT, PAGE_PREVIEW_HEIGHT, PageFullScreen, PageNotes, PagePaneContext, PageToolbar, usePagePoint, usePageSave, usePageShare, usePageVersion } from "./PageTools";
const WIDTH = "max-w-[760px]";
const DOC_REUSE_MS = 60_000;
@@@ -151,11 -156,17 +156,18 @@@ function AppRow({ botId, botName, threa
const current = slot.live ? loaded?.doc : undefined;
const point = usePagePoint({
frame: () => (fullScreen ? wide.current : frame.current)?.iframe,
- threadId, appId: message.id, rev, title: payload.title, picked: () => setFullScreen(false),
+ // In the pane the message box stays usable, so the page stays open while the person writes about what they picked.
+ threadId, appId: message.id, rev, title: payload.title, picked: () => { if (!pane) setFullScreen(false); },
});
+ useEffect(() => {
+ if (!paneOpen) return;
+ openPage(threadId, { appId: message.id, rev });
+ const off = onPageOpened(() => { if (openPageFor(threadId)?.appId !== message.id) setFullScreen(false); });
+ return () => { off(); closePage(threadId, message.id); };
+ }, [paneOpen, threadId, message.id, rev]);
const share = usePageShare(threadId, message.id, message.publishedPage);
- const tools = { version, point, share, room, ready: Boolean(current), fullScreen: { open: fullScreen, pane: Boolean(pane), toggle: () => { point.stop(); setFullScreen((open) => !open); } } };
+ const save = usePageSave(threadId, message.id, payload.title);
- const tools = { version, point, share, save, room, ready: Boolean(current), fullScreen: { open: fullScreen, toggle: () => { point.stop(); setFullScreen((open) => !open); } } };
++ const tools = { version, point, share, save, room, ready: Boolean(current), fullScreen: { open: fullScreen, pane: Boolean(pane), toggle: () => { point.stop(); setFullScreen((open) => !open); } } };
const reloadNow = () => {
setProblem(null);
diff --cc src/components/app/PageTools.tsx
index d292913b62,f0991cdc7f..b8a98766f2
--- a/src/components/app/PageTools.tsx
+++ b/src/components/app/PageTools.tsx
@@@ -1,7 -1,7 +1,7 @@@
// A bot's page in the chat, artifact-style: its version stepper, Point, Share, Open in new tab and Full screen.
- import { useCallback, useEffect, useRef, useState, type MutableRefObject, type ReactNode } from "react";
+ import { createContext, useCallback, useEffect, useRef, useState, type MutableRefObject, type ReactNode } from "react";
import { createPortal } from "react-dom";
-import { ArrowUpRight, Check, ChevronLeft, ChevronRight, Copy, Crosshair, Globe, Loader2, Maximize2, Share2, Trash2, X } from "lucide-react";
+import { ArrowUpRight, Check, ChevronLeft, ChevronRight, Copy, Crosshair, Download, Globe, Loader2, Maximize2, Share2, Trash2, X } from "lucide-react";
import { useStore } from "@/state/store";
import { openExternalLink } from "@/lib/app-links";
import { cn } from "@/lib/cn";
@@@ -169,9 -121,9 +169,10 @@@ export interface PageToolsProps
version: ReturnType<typeof usePageVersion>;
point: ReturnType<typeof usePagePoint>;
share: ReturnType<typeof usePageShare>;
+ save: ReturnType<typeof usePageSave>;
ready: boolean;
- fullScreen: { open: boolean; toggle(): void };
+ /** pane: the page opens in the chat's page pane, beside a usable message box, instead of covering the window. */
+ fullScreen: { open: boolean; toggle(): void; pane?: boolean };
/** Shown in a room: view-only, so no Point and no Share. */
room?: boolean;
}