Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
Merge pull request #6115 from luishron123/feat/sidebar-hover-threads (follow-up commits)
milind-soni10239128b72d
diff --cc src/components/SidebarBotThreadsPeek.tsxindex b0a366adaa,872ed0e197..54090a8935--- a/src/components/SidebarBotThreadsPeek.tsx+++ b/src/components/SidebarBotThreadsPeek.tsx@@@ -11,9 -11,12 +11,9 @@@ import { botOpensTo } from "@/state/thrimport { ConfirmDialog } from "./ConfirmDialog";import { MENU_GUTTER, MENU_ICON, MENU_META, MENU_ROW, MENU_SEPARATOR, MENU_SHEET } from "./menu-recipe";import { useHeldMenuMotion } from "./MenuMotion";- import { isArchived, isSnoozed, isWorking, threadRecency, threadRowActions, threadUpdatedLabel } from "./SidebarThreadRow";+ import { isArchived, isSnoozed, isWorking, nextSnoozeExpiry, threadRecency, threadRowActions, threadUpdatedLabel, useSnoozeExpiry } 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;@@@ -56,12 -70,13 +66,12 @@@ export function SidebarBotThreadsPeek(const [deletingId, setDeletingId] = useState<string | null>(null);const deleting = deletingId ? bot.tasks?.find((task) => task.threadId === deletingId) : undefined;const labels = useId();- const has = threads.length > 0;+ const has = others > 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"));@@@ -73,12 -90,32 +83,20 @@@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;- 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;