GeezerVison is showing github.com — fix(server): PR watch wakes call an edited comment edited, not new · pingdotgg/t3code@9dcd148
File treeExpand file treeCollapse file tree Open diff view settings apps/server/src/orchestration-v2
Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: apps/server/src/orchestration-v2/pullRequestWatch.test.ts +21-6Lines changed: 21 additions & 6 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -273,15 +273,30 @@ describe("evaluatePullRequestWatch", () => { | 273 | 273 | assert.deepEqual(evaluatePullRequestWatch(watching, detail(), [old]).changes, []); | 274 | 274 | const edited = { ...old, editedAt: "2026-10-02T12:06:00Z" }; | 275 | 275 | const report = evaluatePullRequestWatch(watching, detail(), [edited]); | 276 | | - assert.deepEqual(report.changes, [{ kind: "remarks", remarks: [edited] }]); | | 276 | + assert.deepEqual(report.changes, [{ kind: "edits", remarks: [edited] }]); | 277 | 277 | assert.equal(report.next.remarksThrough, edited.editedAt); | 278 | 278 | assert.deepEqual(report.next.remarkIds, [old.id]); | 279 | 279 | assert.isTrue(report.exhausted); | | 280 | + const { text, notification } = pullRequestWatchMessage({ | | 281 | + number: 1, | | 282 | + url: "https://github.com/o/r/pull/1", | | 283 | + baseBranch: "main", | | 284 | + headSha: null, | | 285 | + report, | | 286 | + }); | | 287 | + assert.include(text, "- 1 edited comment:"); | | 288 | + assert.notInclude(text, "new comment"); | | 289 | + assert.equal(notification.summary, "#1: edited comments, stopped watching"); | 280 | 290 | assert.deepEqual(evaluatePullRequestWatch(report.next, detail(), [edited]).changes, []); | 281 | 291 | const late = { ...edited, id: "late" }; | 282 | | - assert.deepEqual(evaluatePullRequestWatch(report.next, detail(), [edited, late]).changes, [ | 283 | | - { kind: "remarks", remarks: [late] }, | 284 | | - ]); | | 292 | + const added = { ...remark("bot", "2026-10-02T12:07:00Z"), editedAt: "2026-10-02T12:08:00Z" }; | | 293 | + assert.deepEqual( | | 294 | + evaluatePullRequestWatch(report.next, detail(), [edited, late, added]).changes, | | 295 | + [ | | 296 | + { kind: "remarks", remarks: [added] }, | | 297 | + { kind: "edits", remarks: [late] }, | | 298 | + ], | | 299 | + ); | 285 | 300 | }); | 286 | 301 |
| 287 | 302 | it("wakes once per edit of a remark seen at the watermark, never for the agent's own", () => { | @@ -295,12 +310,12 @@ describe("evaluatePullRequestWatch", () => { | 295 | 310 | assert.deepEqual(evaluatePullRequestWatch(watching, detail(), [seen]).changes, []); | 296 | 311 | const edited = { ...seen, editedAt: "2026-10-10T20:04:50.000Z" }; | 297 | 312 | const first = evaluatePullRequestWatch(watching, detail(), [edited]); | 298 | | - assert.deepEqual(first.changes, [{ kind: "remarks", remarks: [edited] }]); | | 313 | + assert.deepEqual(first.changes, [{ kind: "edits", remarks: [edited] }]); | 299 | 314 | assert.strictEqual(first.next.remarksThrough, edited.editedAt); | 300 | 315 | assert.deepEqual(evaluatePullRequestWatch(first.next, detail(), [edited]).changes, []); | 301 | 316 | const again = { ...seen, editedAt: "2026-10-10T20:05:50.000Z" }; | 302 | 317 | const second = evaluatePullRequestWatch(first.next, detail(), [again]); | 303 | | - assert.deepEqual(second.changes, [{ kind: "remarks", remarks: [again] }]); | | 318 | + assert.deepEqual(second.changes, [{ kind: "edits", remarks: [again] }]); | 304 | 319 | assert.deepEqual(evaluatePullRequestWatch(second.next, detail(), [again]).changes, []); | 305 | 320 | const own = { ...edited, author: { login: "agent-user", name: null, avatarUrl: null } }; | 306 | 321 | assert.deepEqual(evaluatePullRequestWatch(watching, detail(), [own]).changes, []); | |
Collapse file Copy file name to clipboardExpand all lines: apps/server/src/orchestration-v2/pullRequestWatch.ts +19-10Lines changed: 19 additions & 10 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -18,6 +18,7 @@ export type PullRequestWatchChange = | 18 | 18 | | { readonly kind: "checks-failed"; readonly failed: ReadonlyArray<PullRequestCheck> } | 19 | 19 | | { readonly kind: "checks-passed"; readonly count: number; readonly required: boolean } | 20 | 20 | | { readonly kind: "remarks"; readonly remarks: ReadonlyArray<PullRequestComment> } | | 21 | + | { readonly kind: "edits"; readonly remarks: ReadonlyArray<PullRequestComment> } | 21 | 22 | | { readonly kind: "no-checks"; readonly minutes: number } | 22 | 23 | | { readonly kind: "conflicting" }; | 23 | 24 |
| @@ -111,14 +112,18 @@ export function evaluatePullRequestWatch( | 111 | 112 | const through = Date.parse(watch.remarksThrough); | 112 | 113 | const activeAt = (remark: PullRequestComment) => remark.editedAt ?? remark.createdAt; | 113 | 114 | // Hosts can stamp remarks to the second, so remarks at the boundary time are told apart by ID. | 114 | | - const fresh = (remarks ?? []).filter((remark) => { | 115 | | - const at = Date.parse(activeAt(remark)); | 116 | | - return ( | 117 | | - (at > through || (at === through && !watch.remarkIds.includes(remark.id))) && | 118 | | - remark.author?.login.toLowerCase() !== own | 119 | | - ); | 120 | | - }); | 121 | | - if (fresh.length > 0) changes.push({ kind: "remarks", remarks: fresh }); | | 115 | + const past = (at: string, id: string) => { | | 116 | + const time = Date.parse(at); | | 117 | + return time < through || (time === through && watch.remarkIds.includes(id)); | | 118 | + }; | | 119 | + const fresh = (remarks ?? []).filter( | | 120 | + (remark) => !past(activeAt(remark), remark.id) && remark.author?.login.toLowerCase() !== own, | | 121 | + ); | | 122 | + // A remark that already existed at the watermark is news only as an edit, not a new comment. | | 123 | + const edits = fresh.filter((remark) => past(remark.createdAt, remark.id)); | | 124 | + const added = fresh.filter((remark) => !edits.includes(remark)); | | 125 | + if (added.length > 0) changes.push({ kind: "remarks", remarks: added }); | | 126 | + if (edits.length > 0) changes.push({ kind: "edits", remarks: edits }); | 122 | 127 | const latest = Math.max(through, ...fresh.map((remark) => Date.parse(activeAt(remark)))); | 123 | 128 | const atLatest = fresh.filter((remark) => Date.parse(activeAt(remark)) === latest); | 124 | 129 | const remarksThrough = latest === through ? watch.remarksThrough : activeAt(atLatest[0]!); | @@ -136,7 +141,9 @@ export function evaluatePullRequestWatch( | 136 | 141 | const conflicting = | 137 | 142 | detail.mergeability === "unknown" ? toldConflict : detail.mergeability === "conflicting"; | 138 | 143 |
| 139 | | - const commentsOnly = changes.length > 0 && changes.every((change) => change.kind === "remarks"); | | 144 | + const commentsOnly = | | 145 | + changes.length > 0 && | | 146 | + changes.every((change) => change.kind === "remarks" || change.kind === "edits"); | 140 | 147 | const progress = headMoved || (changes.length > 0 && !commentsOnly); | 141 | 148 | const wakes = (progress ? 0 : watch.wakes) + (commentsOnly ? 1 : 0); | 142 | 149 | return { | @@ -195,8 +202,9 @@ function changeLines( | 195 | 202 | `- All ${change.count} ${change.required ? "required " : ""}${change.count === 1 ? "check" : "checks"} passed${context.commit}.`, | 196 | 203 | ]; | 197 | 204 | case "remarks": | | 205 | + case "edits": | 198 | 206 | return [ | 199 | | - `- ${change.remarks.length} new ${change.remarks.length === 1 ? "comment" : "comments"}:`, | | 207 | + `- ${change.remarks.length} ${change.kind === "remarks" ? "new" : "edited"} ${change.remarks.length === 1 ? "comment" : "comments"}:`, | 200 | 208 | ...listed(change.remarks, (remark) => { | 201 | 209 | const where = remark.path === null ? "" : ` on ${remark.path}`; | 202 | 210 | const body = snippet(remark.body); | @@ -217,6 +225,7 @@ const SUMMARY: Record<PullRequestWatchChange["kind"], string> = { | 217 | 225 | "checks-failed": "checks failed", | 218 | 226 | "checks-passed": "checks passed", | 219 | 227 | remarks: "new comments", | | 228 | + edits: "edited comments", | 220 | 229 | "no-checks": "no checks reported", | 221 | 230 | conflicting: "merge conflict", | 222 | 231 | }; | |
|