Skip to content

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

fix(inbox): drop an assistant answer once the inbox task is archived

Sebastian B2c4eaa8ad1e1
diff --git a/server/host/person-inbox.test.ts b/server/host/person-inbox.test.ts
index 04581ca9a4..769797096e 100644
--- a/server/host/person-inbox.test.ts
+++ b/server/host/person-inbox.test.ts
@@ -64,7 +64,7 @@ describe("pending assistant answers", () => {
expect(f.lines(inbox)[0]!.inbox!.answers).toEqual([expect.objectContaining({ by: "person", text: "I am busy tomorrow." })]);
});
- it.each(["done", "answered at origin", "forgotten", "deleted", "reassigned", "new starter", "stopped"])("silently drops a result when its inbox item is %s", async (change) => {
+ it.each(["done", "answered at origin", "forgotten", "deleted", "reassigned", "new starter", "archived", "stopped"])("silently drops a result when its inbox item is %s", async (change) => {
const { f, inbox, complete } = await pending();
const row = f.lines(inbox)[0]!;
if (change === "done") expect(f.team.inbox.markDone(key(MARCO.email), row.id)).toBe("done");
@@ -73,6 +73,7 @@ describe("pending assistant answers", () => {
else if (change === "deleted") f.deleteThread(inbox);
else if (change === "reassigned") f.bots.find((bot) => bot.id === "marcos-chief")!.reportsTo = PHILIPP.email;
else if (change === "new starter") f.starters.set(inbox, key(PHILIPP.email));
+ else if (change === "archived") Object.assign(f.bots.find((bot) => bot.id === "marcos-chief")!.tasks.find((task) => task.threadId === inbox)!, { archivedAt: Date.now() });
else f.team.stop();
await complete();
expect(f.continued).toEqual([]);
diff --git a/server/host/person-inbox.ts b/server/host/person-inbox.ts
index 52d4021dd4..228bb52255 100644
--- a/server/host/person-inbox.ts
+++ b/server/host/person-inbox.ts
@@ -318,7 +318,8 @@ export function createPersonInbox(deps: PersonInboxDeps) {
console.warn(`person inbox: the assistant could not answer: ${error instanceof Error ? error.message : String(error)}`);
}
if (stopped || !items.includes(item) || item.answered || item.done || settled(item)
- || !deps.person(item.person) || personOf(item.threadId) !== item.person || deps.starters.get(item.threadId) !== item.person) return;
+ || !deps.person(item.person) || personOf(item.threadId) !== item.person || !isHomeOf(item.threadId, item.person)
+ || deps.starters.get(item.threadId) !== item.person) return;
if (answer && answerItem(item, answer, "assistant").status === 200) {
if (line(item)?.inbox?.answers?.at(-1)?.by !== "assistant") return;
notifyItem(item, `${delivery.title} · your assistant answered`, delivery.notify, `${delivery.text} → ${answer}`);