Skip to content

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

fix(brief): follow up waiting rows first, keep checking Gmail when Outlook fails, drop a row picked again once read

AdityaUmale973fbef87adb
diff --git a/server/host/brief.test.ts b/server/host/brief.test.ts
index 033554e2e5..ac1160007b 100644
--- a/server/host/brief.test.ts
+++ b/server/host/brief.test.ts
@@ -467,6 +467,16 @@ describe("the brief's email rows", () => {
expect(s.shown()).not.toContain("Waiting on your reply");
});
+ it("still follows up Gmail rows when Outlook can't be read", async () => {
+ const session: ReadSession = { ...mailSession({ t1: [{ id: "m1", at: 0, from: "[email protected]", unread: false }] }), outlookMessage: async () => { throw new Error("signed out"); } };
+ const s = setup();
+ await s.brief.active("desktop", "UTC");
+ await s.brief.report({ routine: {} as never, at: s.now(), trouble: [], picked: [{ email: bob, why: "Due Friday.", needsReply: true }, { email: ada, why: "Ada needs the numbers.", needsReply: true }] });
+ await s.brief.report({ routine: {} as never, at: s.now(), trouble: [], session });
+ expect(s.shown()).toContain("Invoice");
+ expect(s.shown()).not.toContain("Q3 numbers");
+ });
+
it("checks a watch run's picks the same way before showing them", async () => {
const at = Date.parse("2026-10-22T07:00:00Z");
const s = setup({ session: mailSession({ t1: [{ id: "m0", at: at - 60 * MINUTE, from: "[email protected]" }, { id: "m1", at, from: "[email protected]" }] }) });
diff --git a/server/host/brief.ts b/server/host/brief.ts
index 1acb22eea7..be884add9e 100644
--- a/server/host/brief.ts
+++ b/server/host/brief.ts
@@ -419,11 +419,16 @@ export function createBrief(deps: BriefDeps) {
return { bot, threadId, messageId };
}
- /** An email picked for the brief, by a watch run or by the helper models: its row, with the why kept for this process. */
+ /** An email picked for the brief, by a watch run or by the helper models: its row, with the why kept for this process.
+ * Mail already read, or from a no-reply address, is not one to list. */
function keepImportant(email: EmailHeader, why: string, needsReply: boolean, at: number, whyText?: ServerText): void {
- if (email.unread === false || automatedSender(email.from)) return;
+ const others = state.important.filter((row) => row.messageId !== email.id);
+ if (email.unread === false || automatedSender(email.from)) {
+ state.important = others;
+ return;
+ }
headers.set(email.id, { ...email, why, ...(whyText ? { whyText } : {}) });
- state.important = [...state.important.filter((row) => row.messageId !== email.id), { messageId: email.id, threadId: email.threadId, at: email.at, judgedAt: at, needsReply, ...(email.app === "outlook" ? { app: "outlook" as const } : {}) }].slice(-MAX_ROWS);
+ state.important = [...others, { messageId: email.id, threadId: email.threadId, at: email.at, judgedAt: at, needsReply, ...(email.app === "outlook" ? { app: "outlook" as const } : {}) }].slice(-MAX_ROWS);
}
/** What the checks found that needs no AI: today's meetings, clashes, reminders, other routines, trouble, and the
@@ -448,16 +453,19 @@ export function createBrief(deps: BriefDeps) {
* already written in is not waiting on their reply. */
async function followUp(session: ReadSession | null | undefined): Promise<void> {
const address = deps.address();
- const open = liveImportant(now());
+ const open = liveImportant(now()).sort((a, b) => Number(b.needsReply) - Number(a.needsReply));
if (!session || !open.length) return;
+ const unreadable = new Set<string>();
let changed = false;
const drop = (row: Important) => {
state.important = state.important.filter((one) => one.messageId !== row.messageId);
changed = true;
};
for (const row of open.slice(0, 10)) {
+ const app = row.app ?? "gmail";
+ if (unreadable.has(app)) continue;
try {
- if (row.app === "outlook") {
+ if (app === "outlook") {
const header = await session.outlookMessage?.(row.messageId);
if (header === null || header?.unread === false) drop(row);
continue;
@@ -469,7 +477,7 @@ export function createBrief(deps: BriefDeps) {
changed = true;
}
} catch {
- break;
+ unreadable.add(app);
}
}
if (changed) save();
diff --git a/server/host/check-plan.test.ts b/server/host/check-plan.test.ts
index 4120700a3b..8a5b5ec31f 100644
--- a/server/host/check-plan.test.ts
+++ b/server/host/check-plan.test.ts
@@ -79,7 +79,7 @@ describe("mail", () => {
describe("mail senders and threads", () => {
it("knows no-reply and bounce senders, and only those", () => {
expect(automatedSender(from), from).toBe(true);
}
for (const from of ["Ada <[email protected]>", "[email protected]", "[email protected]", "[email protected]", "Noreply Team <[email protected]>"]) {
diff --git a/server/host/check-plan.ts b/server/host/check-plan.ts
index f4dada20f7..c4a302a68f 100644
--- a/server/host/check-plan.ts
+++ b/server/host/check-plan.ts
@@ -160,7 +160,7 @@ export function planMail(input: { now: number; emails: readonly EmailHeader[]; j
/** Mail from an address nobody reads replies at (no-reply, do-not-reply, bounce notices): never one to list. */
export function automatedSender(from: string): boolean {
- return /^(?:no[-_.]?reply|do[-_.]?not[-_.]?reply|mailer-daemon)(?![a-z0-9])/.test(addressIn(from));
+ return /^(?:no[-_.]?reply|do[-_.]?not[-_.]?reply|mailer-daemon|postmaster)(?![a-z0-9])/.test(addressIn(from));
}
/** The person already wrote in the thread before this email arrived. */