Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
Train fix for #6115: the bot row's threads menu opens on click only
milind-soni1c6828b16619
diff --git a/DESIGN.md b/DESIGN.mdindex aaa0707837..d9a38b5a22 100644--- a/DESIGN.md+++ b/DESIGN.md@@ -301,7 +301,8 @@ on. Simple is the default for new installs.place in both modes. Advanced may show more rows or more detail.One exception: where Advanced already shows something in place (a bot'sthreads as a tree under its row), Simple may offer a shortcut to the same- thing there instead of a second copy of it.+ thing there instead of a second copy of it: a menu that opens on a click+ of a small chevron, never on hover.- **Switching modes never loses data.**## 14. Accessibilitydiff --git a/src/components/SidebarBotThreadsPeek.dom.test.ts b/src/components/SidebarBotThreadsPeek.dom.test.tsindex 3483dace93..6ab68f328f 100644--- a/src/components/SidebarBotThreadsPeek.dom.test.ts+++ b/src/components/SidebarBotThreadsPeek.dom.test.ts@@ -4,7 +4,7 @@ import { createRoot, type Root } from "react-dom/client";import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";import { TYPEAHEAD_RESET_MS } from "@/lib/menu-keys";import type { Action, Task } from "@/state/store";-import { PEEK_CLOSE_MS, SidebarBotThreadsPeek } from "./SidebarBotThreadsPeek";+import { SidebarBotThreadsPeek } from "./SidebarBotThreadsPeek";(globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean }).IS_REACT_ACT_ENVIRONMENT = true;@@ -49,33 +49,21 @@ afterEach(async () => {vi.useRealTimers();});-describe("the hover sheet of a bot's other conversations", () => {- it("stays open while the pointer goes from the row onto it", async () => {+describe("the sheet of a bot's other conversations", () => {+ it("opens on a click of the chevron only, never on hover, and stays open when the pointer moves away", async () => {await mount([task("a")]);- await open();- await cross(row, sheet()!);- await wait(PEEK_CLOSE_MS * 5);- expect(chevron().getAttribute("aria-expanded")).toBe("true");- expect(sheet()).not.toBeNull();- });+ await cross(chat, row);+ await wait(5_000);+ expect(chevron().getAttribute("aria-expanded")).toBe("false");+ expect(sheet()).toBeNull();- it("stays open when the pointer crosses something else on the way, and closes shortly after leaving both", async () => {- await mount([task("a")]);await open();- await cross(row, chat);- await wait(PEEK_CLOSE_MS / 2);- await cross(chat, sheet()!);- await wait(PEEK_CLOSE_MS * 5);expect(chevron().getAttribute("aria-expanded")).toBe("true");-- await cross(sheet()!, row);- await wait(PEEK_CLOSE_MS * 5);- expect(chevron().getAttribute("aria-expanded")).toBe("true");-await cross(row, chat);- await wait(PEEK_CLOSE_MS - 1);+ await wait(5_000);expect(chevron().getAttribute("aria-expanded")).toBe("true");- await wait(1);++ await open();expect(chevron().getAttribute("aria-expanded")).toBe("false");});diff --git a/src/components/SidebarBotThreadsPeek.test.ts b/src/components/SidebarBotThreadsPeek.test.tsindex 00b0da7e7a..320fa83824 100644--- a/src/components/SidebarBotThreadsPeek.test.ts+++ b/src/components/SidebarBotThreadsPeek.test.ts@@ -63,7 +63,7 @@ describe("SidebarBotThreadsPeek", () => {expect(markup).not.toContain("aria-expanded");});- it("discloses the other open conversations, closed until hovered or pressed", () => {+ it("discloses the other open conversations, closed until pressed", () => {const markup = render([task("a")]);expect(markup).toContain('data-bot-threads-peek="atlas" aria-haspopup="menu" aria-expanded="false" aria-label="Expand Atlas threads"');expect(markup).not.toContain('role="menu"');diff --git a/src/components/SidebarBotThreadsPeek.tsx b/src/components/SidebarBotThreadsPeek.tsxindex 33beaa2b79..b4bcc7b7c6 100644--- a/src/components/SidebarBotThreadsPeek.tsx+++ b/src/components/SidebarBotThreadsPeek.tsx@@ -14,9 +14,6 @@ import { useHeldMenuMotion } from "./MenuMotion";import { isArchived, isSnoozed, isWorking, threadRecency, threadRowActions, threadUpdatedLabel } from "./SidebarThreadRow";export const PEEK_LIMIT = 3;-/** Long enough that sweeping the pointer down the list opens nothing. */-export const PEEK_OPEN_MS = 350;-export const PEEK_CLOSE_MS = 200;const SHEET_WIDTH = 240;const EDGE = 8;@@ -53,7 +50,6 @@ export function SidebarBotThreadsPeek({ bot, dispatch }: { bot: PeekBot; dispatcconst motion = useHeldMenuMotion(place);const anchor = useRef<HTMLButtonElement>(null);const sheet = useRef<HTMLDivElement>(null);- const timer = useRef<number | undefined>(undefined);const focusSheet = useRef(false);const focusAnchor = useRef(false);const typed = useRef<Typeahead | null>(null);@@ -63,35 +59,20 @@ export function SidebarBotThreadsPeek({ bot, dispatch }: { bot: PeekBot; dispatcconst has = threads.length > 0;const open = place !== null;- const cancel = () => window.clearTimeout(timer.current);- const close = () => { cancel(); setPlace(null); };+ // Opened by a click on the chevron only: resting the pointer on a row opens nothing.+ const close = () => setPlace(null);const show = () => {- cancel();const row = anchor.current?.parentElement;if (!row) return;setPlace(peekPlace(row.getBoundingClientRect(), threads.length + 1, { width: window.innerWidth, height: window.innerHeight }, getComputedStyle(row).direction === "rtl"));};- const later = (run: () => void, ms: number) => { cancel(); timer.current = window.setTimeout(run, ms); };- useEffect(() => cancel, []);useEffect(() => {if (has) return;close();if (focusAnchor.current) anchor.current?.focus();focusAnchor.current = false;}, [has]);- // React reports entering the sheet while the pointer is still leaving the row, so each side checks where the pointer went.- const within = (target: EventTarget | null) => target instanceof Node && Boolean(sheet.current?.contains(target) || anchor.current?.parentElement?.contains(target));- const leave = (event: Pick<PointerEvent, "pointerType" | "relatedTarget">) => { if (event.pointerType === "mouse" && !within(event.relatedTarget)) later(() => setPlace(null), PEEK_CLOSE_MS); };- useEffect(() => {- const row = anchor.current?.parentElement;- if (!row || !has) return;- // offsetParent is null while the disclosure is hidden, which it is on a phone-width window.- const enter = (event: PointerEvent) => { if (event.pointerType === "mouse" && event.buttons === 0 && anchor.current?.offsetParent) later(show, PEEK_OPEN_MS); };- row.addEventListener("pointerenter", enter);- row.addEventListener("pointerleave", leave);- return () => { row.removeEventListener("pointerenter", enter); row.removeEventListener("pointerleave", leave); };- }, [has, threads.length]);// Rows are taller on a touch screen, so the sheet's own height decides how far up it has to sit.useLayoutEffect(() => {const height = sheet.current?.offsetHeight;@@ -169,7 +150,7 @@ export function SidebarBotThreadsPeek({ bot, dispatch }: { bot: PeekBot; dispatc</button>{motion.shown && shown && createPortal(<div ref={sheet} role="menu" aria-label={bot.name} data-bot-threads-sheet={bot.id} style={{ left: shown.left, top: shown.top, width: SHEET_WIDTH }}- onPointerEnter={cancel} onPointerLeave={leave} onKeyDown={onKeyDown}+ onKeyDown={onKeyDown}className={cn(MENU_SHEET, "fixed z-[60] gap-0", motion.className)} {...motion.exitProps}><button type="button" role="menuitem" className={MENU_ROW} onClick={() => pick({ type: "newTask", botId: bot.id })}><span className={MENU_GUTTER}><Plus size={14} className={MENU_ICON} /></span>