Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
Sidebar threads peek: stay on screen when the open menu grows taller
luishron123c749703d1045
diff --git a/src/components/SidebarBotThreadsPeek.dom.test.ts b/src/components/SidebarBotThreadsPeek.dom.test.tsindex 06f8f29456..db4b3fd09e 100644--- a/src/components/SidebarBotThreadsPeek.dom.test.ts+++ b/src/components/SidebarBotThreadsPeek.dom.test.ts@@ -167,6 +167,33 @@ describe("the hover sheet of a bot's other conversations", () => {expect(sheet()!.style.top).toBe(`${window.innerHeight - 185 - 8}px`);});+ it("moves up when it grows taller while open, and stops watching its height once closed", async () => {+ const watchers: { resized: () => void; target?: Element; live: boolean }[] = [];+ vi.stubGlobal("ResizeObserver", class {+ private entry: (typeof watchers)[number];+ constructor(resized: () => void) { this.entry = { resized, live: true }; watchers.push(this.entry); }+ observe(target: Element) { this.entry.target = target; }+ disconnect() { this.entry.live = false; }+ });+ await mount([task("a"), task("b"), task("c")]);+ row.getBoundingClientRect = () => ({ left: 8, right: 300, top: window.innerHeight - 20 }) as DOMRect;+ const height = vi.spyOn(HTMLElement.prototype, "offsetHeight", "get").mockReturnValue(180);+ await open();+ expect(sheet()!.style.top).toBe(`${window.innerHeight - 180 - 8}px`);++ height.mockReturnValue(225);+ const watching = watchers.filter((entry) => entry.live);+ expect(watching.map((entry) => entry.target)).toEqual([sheet()]);+ await act(async () => { watching[0].resized(); });+ expect(sheet()!.style.top).toBe(`${window.innerHeight - 225 - 8}px`);++ await open();+ height.mockRestore();+ vi.unstubAllGlobals();+ expect(chevron().getAttribute("aria-expanded")).toBe("false");+ expect(watchers.filter((entry) => entry.live)).toEqual([]);+ });+it("offers neither action for a conversation that is working", async () => {await mount([task("a", { busy: true })]);await open();diff --git a/src/components/SidebarBotThreadsPeek.tsx b/src/components/SidebarBotThreadsPeek.tsxindex 96fd4ceb90..24c9086d65 100644--- a/src/components/SidebarBotThreadsPeek.tsx+++ b/src/components/SidebarBotThreadsPeek.tsx@@ -100,10 +100,18 @@ export function SidebarBotThreadsPeek({ bot, onScreen = false, dispatch }: { bot}, [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;- if (!place || !height) return;- const top = Math.max(EDGE, Math.min(place.top, window.innerHeight - height - EDGE));- if (top !== place.top) setPlace({ ...place, top });+ const menu = sheet.current;+ if (!place || !menu) return;+ const fit = () => {+ const height = menu.offsetHeight;+ if (!height) return;+ const top = Math.max(EDGE, Math.min(place.top, window.innerHeight - height - EDGE));+ if (top !== place.top) setPlace({ ...place, top });+ };+ fit();+ const observer = typeof ResizeObserver === "undefined" ? null : new ResizeObserver(fit);+ observer?.observe(menu);+ return () => observer?.disconnect();}, [place, threads.length]);useEffect(() => {if (!open) return;