Skip to content

Open-source Grok Bot alternative with a virtual machine that bots can use

fix(sidebar): show ungrouped thread disclosure

skygunnered672494bd05
diff --git a/src/components/Sidebar.pinned-show-all.dom.test.ts b/src/components/Sidebar.pinned-show-all.dom.test.ts
index 0631611b34..ac387af122 100644
--- a/src/components/Sidebar.pinned-show-all.dom.test.ts
+++ b/src/components/Sidebar.pinned-show-all.dom.test.ts
@@ -102,6 +102,19 @@ describe("a bot's Show all threads", () => {
describe("a bot's ungrouped threads", () => {
const looseRows = () => [...host.querySelectorAll('[data-sidebar-thread-row^="loose-"]')];
+ it("shows ten ordinary ungrouped threads before the whole-bot Show all action", async () => {
+ const ordinary: Bot = {
+ ...bot,
+ threadId: "loose-14",
+ tasks: Array.from({ length: 15 }, (_, index) => ({ threadId: `loose-${index}`, title: `Loose chat ${index}`, createdAt: 100 + index })),
+ };
+ await mount(ordinary);
+ expect(looseRows()).toHaveLength(10);
+ expect(button("Show all 15 threads")).toBeTruthy();
+ await click("Show all 15 threads");
+ expect(looseRows()).toHaveLength(15);
+ });
+
it("bounds a long list while keeping show all, search and bulk selection available", async () => {
await mount(crowded);
expect(looseRows()).toHaveLength(10);
diff --git a/src/components/Sidebar.tsx b/src/components/Sidebar.tsx
index 873046db61..6733ba154a 100644
--- a/src/components/Sidebar.tsx
+++ b/src/components/Sidebar.tsx
@@ -516,7 +516,9 @@ export function BotThreadList({ bot, selected, drafting, query, pendingQueued, r
activityLabel={task.threadId === bot.threadId ? activityLabel : undefined} now={stampClock(threadRecency(task), now)} locale={locale} {...actions}
selectMode={bulk.active} checked={selection.has(task.threadId)} onToggleSelect={bulk.toggle} />;
};
- const ungrouped = visibleTasks.filter((task) => task !== mainTask && !projects.some((project) => project.id === task.projectId));
+ const ungroupedTasks = ownTasks.filter((task) => !projects.some((project) => project.id === task.projectId));
+ const ungrouped = visibleSidebarThreads(ungroupedTasks, bot.threadId, query, [], showAll || bulk.active, routineRuns, bot.mainThreadId, ungroupedTasks.length > 10 ? 10 : 6)
+ .filter((task) => task !== mainTask);
const shownRows = [...(mainTask ? [mainTask] : []), ...orderedProjects.filter((project) => query || bulk.active || !collapsed.has(project.id)).flatMap((project) => visibleTasks.filter((task) => task !== mainTask && task.projectId === project.id)), ...ungrouped]
.map((task) => { const thread = currentTaskBot(bot, task.threadId); return { ...task, busy: thread.busy, activity: thread.activity }; });
const selection = bulk.forRows(shownRows);
diff --git a/src/components/SidebarThreadRow.tsx b/src/components/SidebarThreadRow.tsx
index 3473c12d84..4f06b00849 100644
--- a/src/components/SidebarThreadRow.tsx
+++ b/src/components/SidebarThreadRow.tsx
@@ -168,7 +168,7 @@ export function mainThreadFirst<T extends { threadId: string }>(tasks: T[], main
}
/** 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" | "createdAt">[] = [], mainId?: string): T[] {
+export function visibleSidebarThreads<T extends ThreadRowTask>(tasks: T[], activeId: string, query = "", folders: BotProject[] = [], showAll = false, routineRuns: readonly Pick<RoutineRun, "routineId" | "threadId" | "createdAt">[] = [], mainId?: string, openLimit = 6): 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)));
@@ -193,7 +193,7 @@ export function visibleSidebarThreads<T extends ThreadRowTask>(tasks: T[], activ
if (run && newestRun.get(run.routineId) !== run) return demandsAttention(task, activeId);
return task.closedBy || isSnoozed(task)
? demandsAttention(task, activeId)
- : open++ < 6 || demandsAttention(task, activeId);
+ : open++ < openLimit || demandsAttention(task, activeId);
});
}