Skip to content

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

Test: marking unread falls back to the main thread kept for the bot

milind-soni0a8a463e0229
diff --git a/server/patch-bot-unread.test.ts b/server/patch-bot-unread.test.ts
index 0d95fecdd3..762f178097 100644
--- a/server/patch-bot-unread.test.ts
+++ b/server/patch-bot-unread.test.ts
@@ -62,6 +62,21 @@ describe("patchBot unread targeting", () => {
expect(store.taskByThread(bot.id, chosenOpen.threadId)!.unread).toBe(true);
});
+ it("marks the main conversation kept for the bot unread when the active one is archived and no choice was made", async () => {
+ const { store } = await freshStore();
+ const bot = store.createBot();
+ const first = bot.threadId;
+ const kept = store.createTask(bot.id, "Kept main", false)!;
+ expect(store.keepMainThread(bot.id, () => kept.threadId)).toBe(kept.threadId);
+ const oldTask = store.createTask(bot.id, "Closed chat", true)!;
+ store.patchTask(bot.id, oldTask.threadId, { archivedAt: 1_000, unread: false });
+
+ expect(store.patchBot(bot.id, { unread: true })!.unread).toBe(true);
+ expect(store.taskByThread(bot.id, kept.threadId)!.unread).toBe(true);
+ expect(store.taskByThread(bot.id, first)!.unread).toBe(false);
+ expect(store.taskByThread(bot.id, oldTask.threadId)!.unread).toBe(false);
+ });
+
it("leaves bot.unread false when every non-routine conversation is archived", async () => {
const { store } = await freshStore();
const bot = store.createBot();