Turbocharge Claude Code, Cursor, Codex, Gemini & every coding agent: faster, cheaper, with contextual understanding specific to your codebase.
TypeScript ai-agentsanthropicclaude-codeclicode-graphcodexcontext-engineeringcursordeveloper-toolsgeminiknowledge-graphllmmcpmcp-serveropen-sourceopenaitree-sitter
fix(app): review closed PRs too, so a merged PR keeps a working graph link (#280)
anirudhkumar-nanonets6fa2baedb7cb
diff --git a/src/app/events.ts b/src/app/events.tsindex 7d641a9e..4f12db9c 100644--- a/src/app/events.ts+++ b/src/app/events.ts@@ -45,6 +45,13 @@ const ACTIONS = new Set(["opened", "synchronize", "reopened", "ready_for_review"* a bot commenting on every push to one is the fastest way to be uninstalled.* `ready_for_review` is in the accepted set so the comment appears the moment the* author asks for eyes.+ *+ * A CLOSED pull request is not skipped. The graph is most useful to whoever reads+ * the PR later, and a merged PR is exactly what gets read — so the comment has to+ * keep working after the merge. This costs nothing on live traffic: none of the+ * four accepted actions fire on an already-merged PR, so in practice this only+ * admits a `synchronize` that raced a merge, and a deliberate re-delivery. The+ * accepted-action set, not the PR state, is what bounds the work.*/export function reviewJobFor(event: string, payload: unknown): { job: ReviewJob } | { skip: string } {if (event === "ping") return { skip: "ping" };@@ -66,7 +73,6 @@ export function reviewJobFor(event: string, payload: unknown): { job: ReviewJobreturn { skip: "payload missing installation, repository or pull request fields" };}if (pr?.draft === true && action !== "ready_for_review") return { skip: "draft" };- if (pr?.state === "closed") return { skip: "closed" };const base = pr?.base?.repo?.full_name;const head = pr?.head?.repo?.full_name;diff --git a/test/app-events.test.ts b/test/app-events.test.tsindex f0b6d3b5..f2406079 100644--- a/test/app-events.test.ts+++ b/test/app-events.test.ts@@ -46,12 +46,20 @@ test("events: a pull request that changed its diff becomes a job", () => {assert.equal(fork.job.owner, "NanoNets", "the comment belongs on the BASE repo, not the contributor's copy");});+test("events: a merged pull request is still reviewed, so the link survives the merge", () => {+ // The graph is read most often after the fact, on a PR that already landed.+ // Skipping closed PRs left every merged comment pointing at a page that could+ // never be regenerated.+ const merged = reviewJobFor("pull_request", delivery({ action: "synchronize" }, { state: "closed" }));+ assert.ok("job" in merged, `a closed PR must still produce a job, got ${JSON.stringify(merged)}`);+ assert.equal(merged.job.number, 180);+});+test("events: noise is skipped with a reason", () => {const skipped = [reviewJobFor("pull_request", delivery({ action: "labeled" })),reviewJobFor("pull_request", delivery({ action: "edited" })),reviewJobFor("pull_request", delivery({}, { draft: true })),- reviewJobFor("pull_request", delivery({}, { state: "closed" })),reviewJobFor("issue_comment", delivery()),reviewJobFor("ping", {}),reviewJobFor("pull_request", delivery({ installation: undefined })),