Skip to content

Commit 833b709

Browse files
committed
feat: clean review mail on merge and filter task noise
1 parent a40ac84 commit 833b709

2 files changed

Lines changed: 17 additions & 2 deletions

File tree

packages/cli/src/commands/pulse.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
1010
import { homedir } from "node:os";
1111
import { join } from "node:path";
1212
import { createFlairClient } from "../utils/flair-client.js";
13+
import { gcMessages } from "../utils/mail.js";
1314

1415
// ---------------------------------------------------------------------------
1516
// Types
@@ -289,6 +290,12 @@ export function handleTransition(
289290
config,
290291
sender,
291292
);
293+
for (const reviewer of config.reviewers) {
294+
const removed = gcMessages(reviewer, "24h", instance.prNumber);
295+
if (removed > 0) {
296+
console.log(`[pulse] gc → ${reviewer}: removed ${removed} mail item(s) for PR #${instance.prNumber}`);
297+
}
298+
}
292299
break;
293300
}
294301
}

packages/cli/src/utils/codex-runtime.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ import { formatTaskCompleteMailBody } from "./task-result-mail.js";
3636
/** Real git binary path — bypasses codex-tools wrapper that blocks commit/push */
3737
const GIT_BIN = process.env.TPS_GIT_BIN ?? "/usr/bin/git";
3838

39+
function shouldSendTaskCompletion(recipient: string, reviewNotify?: string[]): boolean {
40+
return !(reviewNotify?.includes(recipient));
41+
}
42+
3943
/** Read OpenAI OAuth creds from ~/.tps/auth/openai.json (written by tps auth login openai). */
4044
function readStoredOpenAICreds(): StoredCredentials | null {
4145
const credPath = join(homedir(), ".tps", "auth", "openai.json");
@@ -713,7 +717,9 @@ export async function runCodexRuntime(config: CodexRuntimeConfig): Promise<void>
713717
});
714718
const summary = result.length > 500 ? result.slice(0, 500) + "..." : result;
715719
console.log(`[${agentId}] Flair task complete. Result: ${result.length} chars`);
716-
sendMail(mailDir, agentId, event.authorId, formatTaskCompleteMailBody(summary, "Task complete (via Flair)"));
720+
if (shouldSendTaskCompletion(event.authorId, config.autoCommit?.reviewNotify)) {
721+
sendMail(mailDir, agentId, event.authorId, formatTaskCompleteMailBody(summary, "Task complete (via Flair)"));
722+
}
717723
try {
718724
await (flair as any).request("POST", "/OrgEvent", {
719725
kind: "task.completed", authorId: agentId, targetIds: [event.authorId],
@@ -814,7 +820,9 @@ export async function runCodexRuntime(config: CodexRuntimeConfig): Promise<void>
814820
});
815821
const summary = result.length > 500 ? result.slice(0, 500) + "..." : result;
816822
console.log(`[${agentId}] Task complete. Result length: ${result.length}`);
817-
sendMail(mailDir, agentId, msg.from, formatTaskCompleteMailBody(summary));
823+
if (shouldSendTaskCompletion(msg.from, config.autoCommit?.reviewNotify)) {
824+
sendMail(mailDir, agentId, msg.from, formatTaskCompleteMailBody(summary));
825+
}
818826
await publishTaskOutcomeEvent(flair, agentId, {
819827
kind: "task.completed",
820828
summary: `Task ${msg.id} completed by ${agentId}`,

0 commit comments

Comments
 (0)