Skip to content

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

Leave a folder where its other threads put it when it holds the main thread

luishron12326c0bfc1120d
diff --git a/src/components/Sidebar.pinned-show-all.dom.test.ts b/src/components/Sidebar.pinned-show-all.dom.test.ts
index 178d471c62..66f5a20e71 100644
--- a/src/components/Sidebar.pinned-show-all.dom.test.ts
+++ b/src/components/Sidebar.pinned-show-all.dom.test.ts
@@ -129,6 +129,19 @@ describe("a bot's main thread", () => {
delete bot.mainThreadId;
});
+ it("leaves its folder where the folder's other threads put it", async () => {
+ const folders = () => [...host.querySelectorAll("[data-sidebar-folder-row]")].map((row) => row.getAttribute("data-sidebar-folder-row"));
+ const before = { projects: bot.projects, tasks: bot.tasks };
+ bot.projects = [...bot.projects!, { id: "later", name: "Later" }];
+ bot.tasks = [...bot.tasks!, { threadId: "later-pinned", title: "Later pinned", createdAt: 2_000, projectId: "later", pinned: true }];
+ bot.mainThreadId = "later-pinned";
+ await mount();
+ expect(folders()).toEqual(["folder", "later"]);
+ await unmount();
+ Object.assign(bot, before);
+ delete bot.mainThreadId;
+ });
+
it("is marked on a collapsed bot's row for it", () => {
const html = renderToStaticMarkup(createElement(SidebarBotActivity, {
bot: { ...bot, mainThreadId: "filed-pinned" }, rowThreadId: bot.threadId, density: "comfortable", pendingQueued: {}, dispatch: vi.fn(),
diff --git a/src/components/Sidebar.tsx b/src/components/Sidebar.tsx
index 799e580d6a..31f40560ea 100644
--- a/src/components/Sidebar.tsx
+++ b/src/components/Sidebar.tsx
@@ -483,7 +483,7 @@ export function BotThreadList({ bot, selected, drafting, query, pendingQueued, r
const bulk = useBulkSelect();
const { own: ownTasks, helpers } = bulk.active ? { own: tasks, helpers: [] } : partitionHelperThreads(tasks, bot.threadId, query, projects, bot.mainThreadId);
const visibleTasks = orderedThreadList(visibleSidebarThreads(ownTasks, bot.threadId, query, projects, showAll || bulk.active, routineRuns, bot.mainThreadId)), mainTask = visibleTasks.find((task) => task.threadId === bot.mainThreadId);
- const visibleProjectIndex = (projectId: string) => visibleTasks.findIndex((task) => task.projectId === projectId);
+ const visibleProjectIndex = (projectId: string) => visibleTasks.findIndex((task) => task !== mainTask && task.projectId === projectId);
const folderRank = (projectId: string) => {
const index = visibleProjectIndex(projectId);
return index < 0 ? Number.POSITIVE_INFINITY : index;