Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
Sidebar: show only each automation's newest run in the default thread list
AdityaUmalee6fc5f1dd328
diff --git a/src/components/Sidebar.tsx b/src/components/Sidebar.tsxindex a765f8edb8..7df9377bb2 100644--- a/src/components/Sidebar.tsx+++ b/src/components/Sidebar.tsx@@ -449,7 +449,7 @@ export function currentArchivableBot(bots: readonly Bot[], id: string): Bot | unconst NO_FOLDERS: BotProject[] = [];-export function BotThreadList({ bot, selected, query, pendingQueued, reveal, locale, generatedTitles, dispatch, activityLabel, hidden = false }: BotRowProps & {+export function BotThreadList({ bot, selected, query, pendingQueued, routineRuns, reveal, locale, generatedTitles, dispatch, activityLabel, hidden = false }: BotRowProps & {activityLabel?: string;hidden?: boolean;}) {@@ -483,7 +483,7 @@ export function BotThreadList({ bot, selected, query, pendingQueued, reveal, locuseSnoozeExpiry(tasks);const bulk = useBulkSelect();const { own: ownTasks, helpers } = bulk.active ? { own: tasks, helpers: [] } : partitionHelperThreads(tasks, bot.threadId, query, projects);- const visibleTasks = orderedThreadList(visibleSidebarThreads(ownTasks, bot.threadId, query, projects, showAll || bulk.active));+ const visibleTasks = orderedThreadList(visibleSidebarThreads(ownTasks, bot.threadId, query, projects, showAll || bulk.active, routineRuns));const visibleProjectIndex = (projectId: string) => visibleTasks.findIndex((task) => task.projectId === projectId);const folderRank = (projectId: string) => {const index = visibleProjectIndex(projectId);@@ -650,6 +650,7 @@ export interface BotRowProps {mascotMotion: AppState["mascotMotion"];reveal: AppState["revealThread"];pendingQueued: AppState["pendingQueued"];+ routineRuns?: AppState["routineRuns"];instances: InstanceInfo[];liveCall: AppState["liveCall"];locale: string;@@ -680,6 +681,7 @@ export function botRowProps(mascotMotion: selected && state.mascotMotion?.botId === bot.id ? state.mascotMotion : null,reveal: reveal && (bot.threadId === reveal.threadId || bot.tasks?.some((task) => task.threadId === reveal.threadId)) ? reveal : null,pendingQueued: state.pendingQueued,+ routineRuns: state.routineRuns,instances: state.instances,liveCall: state.liveCall,locale: activeLocale(),diff --git a/src/components/SidebarThreadRow.test.ts b/src/components/SidebarThreadRow.test.tsindex 3975d4171c..f3f6ef300f 100644--- a/src/components/SidebarThreadRow.test.ts+++ b/src/components/SidebarThreadRow.test.ts@@ -59,6 +59,20 @@ describe("sidebar thread visibility", () => {expect(visibleSidebarThreads(tasks, "0", "thread 9").map((task) => task.threadId)).toEqual(["9"]);expect(visibleSidebarThreads(tasks, "0", "missing")).toEqual([]);});+ it("shows only each routine's newest run by default; older runs stay under Show all", () => {+ const rows = [+ { threadId: "chat", title: "Chat", createdAt: 50 },+ ...[40, 30, 20].map((at) => ({ threadId: `daily-${at}`, title: "Daily brief", createdAt: at })),+ { threadId: "weekly-10", title: "Weekly", createdAt: 10 },+ { threadId: "daily-5", title: "Daily brief", createdAt: 5, unread: true },+ ];+ const runs = [...["daily-40", "daily-30", "daily-20", "daily-5"].map((threadId) => ({ routineId: "daily", threadId })), { routineId: "weekly", threadId: "weekly-10" }, { routineId: "room" }];+ expect(visibleSidebarThreads(rows, "chat", "", [], false, runs).map((task) => task.threadId)).toEqual(["chat", "daily-40", "weekly-10", "daily-5"]);+ expect(visibleSidebarThreads(rows, "daily-20", "", [], false, runs).map((task) => task.threadId)).toEqual(["chat", "daily-40", "daily-20", "weekly-10", "daily-5"]);+ expect(visibleSidebarThreads(rows, "chat", "", [], true, runs)).toEqual(rows);+ expect(visibleSidebarThreads(rows, "chat", "daily", [], false, runs)).toHaveLength(4);+ expect(visibleSidebarThreads(rows, "chat").map((task) => task.threadId)).toEqual(rows.map((task) => task.threadId));+ });it("keeps queued older threads visible", () => {const rows = tasks.map((task) => ({ ...task, queued: task.threadId === "9" }));expect(visibleSidebarThreads(rows, "0").map((task) => task.threadId)).toEqual(["0", "1", "2", "3", "4", "5", "9"]);diff --git a/src/components/SidebarThreadRow.tsx b/src/components/SidebarThreadRow.tsxindex 820ea68726..55e0d3c94c 100644--- a/src/components/SidebarThreadRow.tsx+++ b/src/components/SidebarThreadRow.tsx@@ -2,6 +2,7 @@ import { memo, useEffect, useRef, useState, type Dispatch, type ReactNode } fromimport { createPortal } from "react-dom";import { Archive, ArchiveRestore, BellOff, Check, ChevronRight, Clock, Clock3, FolderInput, Link2, Link2Off, Loader2, MoreHorizontal, Pencil, Pin, PinOff, RefreshCw, Trash2 } from "lucide-react";import type { Action, AppState, BotProject, Task } from "@/state/store";+import type { RoutineRun } from "@/lib/routines";import { cn } from "@/lib/cn";import { MENU_SHEET } from "./menu-recipe";import { useHeldMenuMotion } from "./MenuMotion";@@ -122,17 +123,25 @@ export function HelperThreadGroup<T>({ tasks, renderThread }: { tasks: T[]; rend</div>;}-export function visibleSidebarThreads<T extends ThreadRowTask>(tasks: T[], activeId: string, query = "", folders: BotProject[] = [], showAll = false): T[] {+/** Default list shows each routine's newest run only; older runs stay under "Show all". */+export function visibleSidebarThreads<T extends ThreadRowTask>(tasks: T[], activeId: string, query = "", folders: BotProject[] = [], showAll = false, routineRuns: readonly Pick<RoutineRun, "routineId" | "threadId">[] = []): T[] {const needle = query.trim().toLowerCase();if (needle) {return tasks.filter((task) => task.title.toLowerCase().includes(needle) || folders.some((folder) => folder.id === task.projectId && folder.name.toLowerCase().includes(needle)));}if (showAll) return tasks;let open = 0;+ const routineOf = new Map(routineRuns.flatMap((run) => run.threadId ? [[run.threadId, run.routineId] as const] : []));+ const shownRoutines = new Set<string>();return orderedThreadList(tasks).filter((task) => {if (task.pinned === true) return true;if (task.openedBy?.burstId) return task.threadId === activeId || demandsAttention(task, activeId);if (isArchived(task)) return task.threadId === activeId;+ const routineId = routineOf.get(task.threadId);+ if (routineId !== undefined) {+ if (shownRoutines.has(routineId)) return demandsAttention(task, activeId);+ shownRoutines.add(routineId);+ }return task.closedBy || isSnoozed(task)? demandsAttention(task, activeId): open++ < 6 || demandsAttention(task, activeId);