Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
Pages Point: redraw outlines on the frame a reload puts in place
AdityaUmale690758ad8851
diff --git a/src/components/app/AppMessage.tsx b/src/components/app/AppMessage.tsxindex e9752bb8a2..6c096b5b1b 100644--- a/src/components/app/AppMessage.tsx+++ b/src/components/app/AppMessage.tsx@@ -155,7 +155,7 @@ function AppRow({ botId, botName, threadId, message, payload, pool, room }: {const current = slot.live ? loaded?.doc : undefined;const point = usePagePoint({- frame: () => (fullScreen ? wide.current : frame.current)?.iframe, view: fullScreen ? "full" : "inline",+ frame: () => (fullScreen ? wide.current : frame.current)?.iframe, view: fullScreen ? "full" : "inline", frameKey: loaded?.key,// 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); },});diff --git a/src/components/app/PageTools.test.ts b/src/components/app/PageTools.test.tsindex 61837f1d7c..b6dde1cc22 100644--- a/src/components/app/PageTools.test.ts+++ b/src/components/app/PageTools.test.ts@@ -149,6 +149,18 @@ describe("a bot's page in the chat", () => {expect(posted).toHaveBeenCalledWith({ jsonrpc: "2.0", method: "mausbot/point", params: { on: false } }, "*");});+ it("sends the numbered outlines again to the frame a reload puts in place", async () => {+ await render(row(payload()));+ await click("Point", card());+ await fromFrame(PICK, inlineFrame().contentWindow);+ const before = inlineFrame();+ await click("Reload app", card());+ expect(inlineFrame()).not.toBe(before);+ const posted = vi.spyOn(inlineFrame().contentWindow!, "postMessage").mockImplementation(() => {});+ await act(async () => { inlineFrame().dispatchEvent(new Event("load")); });+ expect(posted).toHaveBeenCalledWith(marksMessage(["main > section:nth-of-type(2) > button"]), "*");+ });+it("shares the version on screen; the card the server patches shows the link with Copy, opens it, and unpublishes it", async () => {await render(row(payload()));await click("Share", card());diff --git a/src/components/app/PageTools.tsx b/src/components/app/PageTools.tsxindex e754588b43..c07d82d9bc 100644--- a/src/components/app/PageTools.tsx+++ b/src/components/app/PageTools.tsx@@ -129,7 +129,7 @@ export function usePageSave(threadId: string, messageId: string, title: string)/** Point mode on whichever frame shows the page. Security: a pick counts only from that frame's own window and only* while the person has Point on, so a page cannot fill the composer by itself. Point stays on after a pick so several* parts can be marked in one pass; once it ends after any pick, `picked` runs and the composer takes focus. */-export function usePagePoint(args: { frame(): HTMLIFrameElement | null | undefined; view?: string; threadId: string; appId: string; rev: number; title: string; picked(): void }) {+export function usePagePoint(args: { frame(): HTMLIFrameElement | null | undefined; view?: string; frameKey?: string; threadId: string; appId: string; rev: number; title: string; picked(): void }) {const [pointing, setPointing] = useState(false);const on = useRef(false);on.current = pointing;@@ -173,10 +173,10 @@ export function usePagePoint(args: { frame(): HTMLIFrameElement | null | undefinconst iframe = latest.current.frame();const send = () => iframe?.contentWindow?.postMessage(marksMessage(JSON.parse(marks) as string[]), "*");send();- // A new frame (full screen, a reload) gets them again once its page has loaded.+ // A new frame (full screen, a reload) gets them again once its page has loaded; `frameKey` changes with each frame.iframe?.addEventListener("load", send);return () => iframe?.removeEventListener("load", send);- }, [marks, pointing, args.view]);+ }, [marks, pointing, args.view, args.frameKey]);return { pointing, toggle: () => set(!on.current), stop: () => { if (on.current) set(false); } };}