Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
Train fix (#7847): a stable toggle, so unchanged circles skip their render
milind-sonidbbbb830f852
diff --git a/src/components/PinnedCircleThreads.tsx b/src/components/PinnedCircleThreads.tsxindex 3b0605da55..a6a97e5fcc 100644--- a/src/components/PinnedCircleThreads.tsx+++ b/src/components/PinnedCircleThreads.tsx@@ -1,4 +1,4 @@-import { memo, useEffect, useLayoutEffect, useMemo, useRef, useState, type ComponentType, type DragEvent, type KeyboardEvent } from "react";+import { memo, useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState, type ComponentType, type DragEvent, type KeyboardEvent } from "react";import { ChevronRight, FolderPlus, Plus } from "lucide-react";import { openBotRow, visibleMessages, type Bot, type Message } from "@/state/store";import { avatarCropRadius, botAvatarProfile } from "../../shared/bot-avatar";@@ -175,7 +175,7 @@ export const PinnedBotCircle = memo(function PinnedBotCircle({prevId,nextId,...props-}: BotRowProps & PinnedCircleDragProps & { threadsOpen?: boolean; onToggleThreads?: () => void }) {+}: BotRowProps & PinnedCircleDragProps & { threadsOpen?: boolean; onToggleThreads?: (botId: string) => void }) {const { bot, selected, mascotMotion, pendingQueued, density, query, dispatch, onMenu } = props;const showThreads = useShowThreads();const visible = useVisibleMessages(bot);@@ -252,7 +252,7 @@ export const PinnedBotCircle = memo(function PinnedBotCircle({aria-label={t(threadsOpen ? "task.collapseNamed" : "task.expandNamed", { name: bot.name })}aria-expanded={threadsOpen}aria-controls={pinnedCircleThreadPanelId(bot.id)}- onClick={onToggleThreads}+ onClick={() => onToggleThreads?.(bot.id)}className="flex size-4 items-center justify-center rounded text-ink-secondary outline-none hover:text-ink focus-visible:ring-1 focus-visible:ring-accent/60"><ChevronRight aria-hidden="true" size={13} className={cn("transition-transform", threadsOpen && "rotate-90")} /></button>}</div>}@@ -264,14 +264,15 @@ function PinnedCircleGridRow({items,columns,openId,- choose,+ toggle,circleDrag,}: {items: BotRowProps[];/** 0 until the grid has been measured: one auto-fill row is enough. */columns: number;openId: string | null;- choose: (id: string | null) => void;+ /** Stable across renders, so a circle whose own props did not change skips its render. */+ toggle: (botId: string) => void;circleDrag: (bot: Bot) => PinnedCircleDragProps;}) {const active = items.find(({ bot, query }) => bot.id === openId && botHasThreadList(bot, query));@@ -282,7 +283,7 @@ function PinnedCircleGridRow({style={{ gridTemplateColumns: columns > 0 ? `repeat(${columns}, minmax(84px, 1fr))` : "repeat(auto-fill, minmax(84px, 1fr))" }}>{items.map((item) => <PinnedBotCircle key={item.bot.id} {...item} {...circleDrag(item.bot)}- threadsOpen={item.bot.id === openId} onToggleThreads={() => choose(item.bot.id === openId ? null : item.bot.id)} />)}+ threadsOpen={item.bot.id === openId} onToggleThreads={toggle} />)}</div>{active && <PinnedCircleThreadPanel key={active.bot.id} {...active} />}</div>@@ -341,6 +342,8 @@ export function PinnedBotRoster({const [searchChoice, setSearchChoice] = useState<{ id: string | null } | null>(null);useEffect(() => setSearchChoice(null), [query]);const choose = (id: string | null) => query ? setSearchChoice({ id }) : setOpenId(id);+ const toggleNow = useRef<(id: string) => void>(() => {});+ const toggle = useCallback((id: string) => toggleNow.current(id), []);const reveal = items.find((item) => item.reveal);useEffect(() => {if (circleLayout && showThreads && reveal) choose(reveal.bot.id);@@ -367,11 +370,12 @@ export function PinnedBotRoster({const expandedId = query? searchChoice ? searchChoice.id : items.find(({ bot }) => searchMatchesThreads(query, bot.tasks, bot.projects))?.bot.id ?? null: openId;+ toggleNow.current = (id) => choose(id === expandedId ? null : id);return (<div className="px-1 pb-1"><div ref={frame} data-sidebar-pinned-circles="" className="flex flex-col gap-1" {...frameProps}>{circleRows.map((group) => (- <PinnedCircleGridRow key={group[0]?.bot.id ?? ""} items={group} columns={columns} openId={expandedId} choose={choose} circleDrag={circleDrag} />+ <PinnedCircleGridRow key={group[0]?.bot.id ?? ""} items={group} columns={columns} openId={expandedId} toggle={toggle} circleDrag={circleDrag} />))}</div><span role="status" className="sr-only">{moved}</span>