@devries-cameron20 / t3code-1 / commits / 74e5bd22a9
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

fix(forgejo): wake PR watches for edited comments (#18120)

Signed-off-by: Marc Went <marc@went.io>

Marc Went committed Oct 18, 2026 at 22:05 UTC 74e5bd22a96bc233a6eb9b7601d7a1a16ef6ea3a
2 files changed +85 -1
apps/server/src/orchestration-v2/pullRequestWatch.forgejoComments.test.ts new
+80
@@ -0,0 +1,80 @@
1 +import type { ThreadPullRequestWatch } from "@t3tools/contracts";
2 +import { assert, describe, it } from "@effect/vitest";
3 +import * as Schema from "effect/Schema";
4 +import {
5 + ForgejoComment,
6 + forgejoComment,
7 +} from "@t3tools/source-control-forgejo/server/forgejoPullRequestJson";
8 +
9 +import { evaluatePullRequestWatch } from "./pullRequestWatch.ts";
10 +
11 +const decodeForgejoComment = Schema.decodeSync(ForgejoComment);
12 +
13 +describe("Forgejo comment watch boundary", () => {
14 + const createdAt = "2026-10-10T19:52:40Z";
15 + const editedAt = "2026-10-10T20:04:50Z";
16 + const seen = {
17 + startedAt: "2026-10-02T12:00:00.000Z",
18 + headSha: "aaaaaaaaaa",
19 + failedChecks: [],
20 + passed: false,
21 + passedChecks: [],
22 + remarksThrough: "2026-10-10T19:52:40.000Z",
23 + remarkIds: ["29061"],
24 + conflicting: false,
25 + wakes: 2,
26 + } satisfies ThreadPullRequestWatch;
27 + const finalDetail = {
28 + headSha: seen.headSha,
29 + checks: [],
30 + mergeability: "mergeable",
31 + viewer: "agent-user",
32 + author: { login: "agent-user", name: null, avatarUrl: null },
33 + } satisfies Parameters<typeof evaluatePullRequestWatch>[1];
34 + const decodedComment = (updatedAt: string | null | undefined) =>
35 + forgejoComment(
36 + decodeForgejoComment({
37 + id: 29061,
38 + body: "Performance: five rounds complete",
39 + user: { login: "forgejo-actions" },
40 + created_at: createdAt,
41 + ...(updatedAt === undefined ? {} : { updated_at: updatedAt }),
42 + }),
43 + );
44 +
45 + it.each([undefined, null, createdAt, "2026-10-10T19:52:40.000Z"])(
46 + "does not wake for an unchanged comment with updated_at %s",
47 + (updatedAt) => {
48 + const comment = decodedComment(updatedAt);
49 + assert.isUndefined(comment.editedAt);
50 + assert.deepEqual(evaluatePullRequestWatch(seen, finalDetail, [comment]).changes, []);
51 + },
52 + );
53 +
54 + it("wakes once for the edit of an already-seen benchmark comment", () => {
55 + const finalComment = decodedComment(editedAt);
56 + assert.strictEqual(finalComment.editedAt, "2026-10-10T20:04:50.000Z");
57 + assert.isUndefined(decodedComment(createdAt).editedAt);
58 + const completed = evaluatePullRequestWatch(seen, finalDetail, [finalComment]);
59 + assert.deepEqual(completed.changes, [{ kind: "remarks", remarks: [finalComment] }]);
60 + assert.strictEqual(completed.next.remarksThrough, "2026-10-10T20:04:50.000Z");
61 + assert.deepEqual(
62 + evaluatePullRequestWatch(completed.next, finalDetail, [finalComment]).changes,
63 + [],
64 + );
65 + assert.deepEqual(
66 + evaluatePullRequestWatch(seen, finalDetail, [decodedComment(createdAt)]).changes,
67 + [],
68 + );
69 + const secondEdit = decodedComment("2026-10-10T20:05:50Z");
70 + const second = evaluatePullRequestWatch(completed.next, finalDetail, [secondEdit]);
71 + assert.deepEqual(second.changes, [{ kind: "remarks", remarks: [secondEdit] }]);
72 + assert.deepEqual(evaluatePullRequestWatch(second.next, finalDetail, [secondEdit]).changes, []);
73 + assert.deepEqual(
74 + evaluatePullRequestWatch(seen, finalDetail, [
75 + { ...finalComment, author: { login: "agent-user", name: null, avatarUrl: null } },
76 + ]).changes,
77 + [],
78 + );
79 + });
80 +});
packages/source-control-forgejo/src/server/forgejoPullRequestJson.ts
+5 -1
@@ -68,6 +68,7 @@ export const ForgejoComment = Schema.Struct({
68 body: Schema.String,
69 user: Schema.NullOr(ForgejoUser),
70 created_at: Schema.String,
71 + updated_at: Schema.optional(Schema.NullOr(Schema.String)),
72 html_url: Schema.optional(Schema.String),
73 });
74 export const ForgejoReview = Schema.Struct({
@@ -149,12 +150,15 @@ export function forgejoChangeRequest(pr: typeof ForgejoPullRequest.Type) {
150 }
151
152 export function forgejoComment(comment: typeof ForgejoComment.Type): PullRequestComment {
153 + const createdAt = toIsoUtc(comment.created_at);
154 + const editedAt = comment.updated_at == null ? undefined : toIsoUtc(comment.updated_at);
155 return {
156 id: String(comment.id),
157 kind: "issue-comment",
158 author: forgejoActor(comment.user),
159 body: comment.body,
157 - createdAt: toIsoUtc(comment.created_at),
160 + createdAt,
161 + ...(editedAt === undefined || editedAt === createdAt ? {} : { editedAt }),
162 url: comment.html_url || null,
163 path: null,
164 reviewState: null,