Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
fix(sidebar): fall back to a routine's next run when its newest is closed or snoozed
AdityaUmale0cf319b58f7f
diff --git a/src/components/SidebarThreadRow.test.ts b/src/components/SidebarThreadRow.test.tsindex 604dcef14d..6de1ba6e44 100644--- a/src/components/SidebarThreadRow.test.ts+++ b/src/components/SidebarThreadRow.test.ts@@ -80,6 +80,14 @@ describe("sidebar thread visibility", () => {expect(visibleSidebarThreads(rows, "", "", [], false, runs).map((task) => task.threadId)).toEqual(["run-b"]);expect(visibleSidebarThreads([{ ...rows[0] }, { ...rows[1], archivedAt: 40 }], "", "", [], false, runs).map((task) => task.threadId)).toEqual(["run-a"]);});+ it("falls back to the next run when the newest run is closed or snoozed and needs nothing", () => {+ const rows = [{ threadId: "run-a", title: "Daily brief", createdAt: 10 }, { threadId: "run-b", title: "Daily brief", createdAt: 30 }];+ const runs = [{ routineId: "daily", threadId: "run-a", createdAt: 10 }, { routineId: "daily", threadId: "run-b", createdAt: 30 }];+ const ids = (newest: Partial<Parameters<typeof visibleSidebarThreads>[0][number]>) => visibleSidebarThreads([rows[0], { ...rows[1], ...newest }], "", "", [], false, runs).map((task) => task.threadId);+ expect(ids({ closedBy: { botId: "bot-a", name: "Ada", at: 1 } })).toEqual(["run-a"]);+ expect(ids({ snoozedUntil: Date.now() + 60_000 })).toEqual(["run-a"]);+ expect(ids({ closedBy: { botId: "bot-a", name: "Ada", at: 1 }, unread: true })).toEqual(["run-b"]);+ });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 c2130ba109..0ccfe93396 100644--- a/src/components/SidebarThreadRow.tsx+++ b/src/components/SidebarThreadRow.tsx@@ -133,11 +133,12 @@ export function visibleSidebarThreads<T extends ThreadRowTask>(tasks: T[], activif (showAll) return tasks;let open = 0;const runOf = new Map(routineRuns.flatMap((run) => run.threadId ? [[run.threadId, run] as const] : []));- // Newest by the run's start, not sidebar order: an older run that finished later sorts first.+ // Newest by the run's start, not sidebar order (an older run that finished later sorts first), among runs the list can show.const newestRun = new Map<string, Pick<RoutineRun, "routineId" | "createdAt">>();for (const task of tasks) {const run = runOf.get(task.threadId);if (!run || task.pinned === true || task.openedBy?.burstId || isArchived(task)) continue;+ if ((task.closedBy || isSnoozed(task)) && !demandsAttention(task, activeId)) continue;const seen = newestRun.get(run.routineId);if (!seen || run.createdAt > seen.createdAt) newestRun.set(run.routineId, run);}