Skip to content

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

fix(sidebar): in Simple mode, show threads that wait on the person under their bot

AdityaUmale1f35a3449721
diff --git a/src/components/Sidebar.simple-mode.test.ts b/src/components/Sidebar.simple-mode.test.ts
index 28b3259745..f0214ecdb7 100644
--- a/src/components/Sidebar.simple-mode.test.ts
+++ b/src/components/Sidebar.simple-mode.test.ts
@@ -443,7 +443,7 @@ describe("bot-first sidebar", () => {
]);
});
- it.each(densities)("lists the bot alone in Simple mode, with no thread or activity rows under it, keeping its dots, in %s density", (density) => {
+ it.each(densities)("lists the bot with no thread tree in Simple mode, only a row for each thread that waits on the person, keeping its dots, in %s density", (density) => {
// Its threads were left expanded in Advanced mode.
fixture.advanced = true;
let tree: ReactNode;
@@ -458,13 +458,18 @@ describe("bot-first sidebar", () => {
expect(markup).toContain(`data-sidebar-bot-row="${bot.id}"`);
expect(markup).not.toContain("data-sidebar-thread-row");
expect(markup).not.toContain("data-sidebar-folder-row");
- expect(markup).not.toContain("data-sidebar-activity-row");
- expect(markup).not.toContain("data-sidebar-bot-activity");
expect(markup).not.toContain('aria-label="Atlas threads"');
+ if (density === "icons") expect(markup).not.toContain("data-sidebar-bot-activity");
+ else {
+ // It asks the person something, or has a reply they have not read; running, queued and idle threads stay out.
+ expect([...markup.matchAll(/data-sidebar-activity-row="([^"]+)"/g)].map((match) => match[1]).sort()).toEqual(["approval", "unread"]);
+ }
expect(markup).toContain('data-testid="waiting-dot"');
}
const unread = renderToStaticMarkup(createElement(BotListItem, rowProps(density, { ...bot, tasks: [bot.tasks![0]!, bot.tasks![5]!] })));
- expect(unread).not.toContain("data-sidebar-activity-row");
+ expect(unread.includes('data-sidebar-activity-row="unread"')).toBe(density !== "icons");
+ const read = renderToStaticMarkup(createElement(BotListItem, rowProps(density, { ...bot, unread: false, tasks: [bot.tasks![0]!, bot.tasks![1]!, bot.tasks![3]!] })));
+ expect(read).not.toContain("data-sidebar-activity-row");
expect(unread).toContain(density === "icons" ? "rounded-full border border-panel bg-accent" : density === "comfortable" ? 'data-testid="unread-dot"' : 'aria-label="Unread threads"');
forgetSearchDisclosuresForTests();
});
diff --git a/src/components/Sidebar.tsx b/src/components/Sidebar.tsx
index 243ad53027..b8b77ca109 100644
--- a/src/components/Sidebar.tsx
+++ b/src/components/Sidebar.tsx
@@ -914,7 +914,7 @@ export const BotListItem = memo(function BotListItem(props: BotRowProps) {
{advanced && !iconOnly && threadsOpen && hasThreadList && <BotThreadList {...props} hidden={!showThreads}
activityLabel={liveActivityLabel(last)}
query={bot.name.toLowerCase().includes(query.toLowerCase()) || bot.title.toLowerCase().includes(query.toLowerCase()) ? "" : query} />}
- {advanced && !expanded && <SidebarBotActivity bot={bot} rowThreadId={selected ? bot.threadId : botOpensTo(bot, showThreads)} density={density} pendingQueued={pendingQueued} dispatch={dispatch} />}
+ {(advanced || (!iconOnly && (waiting || unread))) && !expanded && <SidebarBotActivity bot={bot} rowThreadId={selected ? bot.threadId : botOpensTo(bot, showThreads)} density={density} pendingQueued={pendingQueued} dispatch={dispatch} waitingOnly={!advanced} />}
{showThreads && creatingProject && <BotProjectDialog bot={bot} onClose={() => setCreatingProject(false)} />}
</>
);
diff --git a/src/components/SidebarBotActivity.test.ts b/src/components/SidebarBotActivity.test.ts
index 15d8e2814f..18d84b8c87 100644
--- a/src/components/SidebarBotActivity.test.ts
+++ b/src/components/SidebarBotActivity.test.ts
@@ -3,7 +3,7 @@ import { describe, expect, it } from "vitest";
import type { Bot, Group, GroupTask, Task } from "@/state/store";
import { botShowsUnread } from "@/lib/bot-unread";
import { t } from "@/lib/i18n";
-import { attentionHasRunningWork, attentionJumpAction, attentionOwnerName, attentionRowStatus, attentionTriggerLabel, attentionUnpinAction, crossBotAttentionThreads, crossBotPinnedThreads, sidebarBotActivityTasks, sidebarGroupActivityTasks, threadsWhenTreeHidden } from "./SidebarBotActivity";
+import { attentionHasRunningWork, attentionJumpAction, attentionOwnerName, attentionRowStatus, attentionTriggerLabel, attentionUnpinAction, crossBotAttentionThreads, crossBotPinnedThreads, sidebarBotActivityTasks, sidebarGroupActivityTasks, threadsWaitingOnPerson, threadsWhenTreeHidden } from "./SidebarBotActivity";
const task = (threadId: string, title: string, extra: Partial<Task>): Task =>
({ threadId, title, createdAt: 0, ...extra }) as Task;
@@ -294,3 +294,21 @@ describe("attentionUnpinAction", () => {
expect(attentionUnpinAction(entry)).toEqual({ type: "pinGroupTask", groupId: "g", threadId: "g0", pinned: false, title: "Crew" });
});
});
+
+describe("threadsWaitingOnPerson", () => {
+ it("keeps only threads that ask the person something or hold a reply they have not read", () => {
+ const ivy = bot("ivy", "Ivy", "i0", [
+ task("i0", "Main chat", {}),
+ task("i1", "Opened by the Chief, ended on a card", { unread: true, openedBy: { botId: "chief", name: "Chief", at: 1 } }),
+ task("i2", "Needs approval", { busy: true, activity: "waiting-on-you" }),
+ task("i3", "Still running", { busy: true, activity: "working" }),
+ task("i4", "Waits on a teammate", { waitingForTeammates: true }),
+ task("i5", "Queued", {}),
+ task("i6", "Pinned", { pinned: true }),
+ task("i7", "Put away", { archivedAt: 5, unread: true }),
+ task("i8", "Routine run", { routineRunId: "run-1", unread: true }),
+ ]);
+ expect(threadsWaitingOnPerson(ivy, { i5: [{}] }).map((one) => one.threadId).sort()).toEqual(["i1", "i2"]);
+ expect(threadsWaitingOnPerson(bot("q", "Quiet", "q0", [task("q0", "Read", {}), task("q1", "Read too", {})]), {})).toEqual([]);
+ });
+});
diff --git a/src/components/SidebarBotActivity.tsx b/src/components/SidebarBotActivity.tsx
index ab467554af..a97e2f4e9c 100644
--- a/src/components/SidebarBotActivity.tsx
+++ b/src/components/SidebarBotActivity.tsx
@@ -37,6 +37,13 @@ export function threadsWhenTreeHidden(bot: Bot, queued: Record<string, unknown[]
return orderedThreadList([...attention, ...pinned]);
}
+/** Simple mode has no thread list, so a thread gets a row under its bot only while it waits on the person:
+ * it asks them something, or has a reply they have not read. A teammate's thread that ended on a card for them
+ * reaches the app only as unread, so unread is the signal. */
+export function threadsWaitingOnPerson(bot: Bot, queued: Record<string, unknown[]>) {
+ return orderedThreadList(sidebarBotActivityTasks(bot, queued).filter((task) => task.activity === "waiting-on-you" || task.unread));
+}
+
/** Must derive each thread's state exactly as GroupThreadList's sidebar rows do. */
export function sidebarGroupActivityTasks(group: Group, bots: Bot[], queued: Record<string, unknown[]>): Array<Task & { queued: boolean }> {
if (group.dm) return [];
@@ -189,8 +196,8 @@ export function PinnedThreadRows({ entries, now, onJump, onUnpin }: { entries: A
</>;
}
-export function SidebarBotActivity({ bot, rowThreadId, density, pendingQueued, dispatch }: { bot: Bot; rowThreadId: string; density: SidebarDensity; pendingQueued: AppState["pendingQueued"]; dispatch: Dispatch<Action> }) {
- const tasks = threadsWhenTreeHidden(bot, pendingQueued).filter((task) => task.threadId !== rowThreadId);
+export function SidebarBotActivity({ bot, rowThreadId, density, pendingQueued, dispatch, waitingOnly = false }: { bot: Bot; rowThreadId: string; density: SidebarDensity; pendingQueued: AppState["pendingQueued"]; dispatch: Dispatch<Action>; waitingOnly?: boolean }) {
+ const tasks = (waitingOnly ? threadsWaitingOnPerson : threadsWhenTreeHidden)(bot, pendingQueued).filter((task) => task.threadId !== rowThreadId);
if (!tasks.length) return null;
const iconOnly = density === "icons";
return <div data-sidebar-bot-activity={bot.id} className={cn("mb-1 space-y-0.5", !iconOnly && "ml-6")}>