The open-source app everyone uses to manage agents at work
TypeScript acpxagent-orchestrationagent-skillsagentic-aiai-agentsai-engineeringai-governanceai-toolsautonomous-agentsclaudeclaude-codeclaude-skillscodexhermesllmmcpmulti-agentopenclawproject-managementworkflow-automation
fix(issues): coerce anchor.createdAt to Date before postgres binding (PRO-3144) (#5220)
aperim-agentd58a86254952
diff --git a/server/src/__tests__/issues-service.test.ts b/server/src/__tests__/issues-service.test.tsindex 9b22974411..07f5717bc2 100644--- a/server/src/__tests__/issues-service.test.ts+++ b/server/src/__tests__/issues-service.test.ts@@ -1243,6 +1243,64 @@ describeEmbeddedPostgres("issueService.list participantAgentId", () => {expect(comments.map((comment) => comment.id)).toEqual([firstCommentId]);});+ it("paginates later comments in ascending order from an anchor comment", async () => {+ const companyId = randomUUID();+ const issueId = randomUUID();+ const firstCommentId = randomUUID();+ const anchorCommentId = randomUUID();+ const latestCommentId = randomUUID();++ await db.insert(companies).values({+ id: companyId,+ name: "Paperclip",+ issuePrefix: `T${companyId.replace(/-/g, "").slice(0, 6).toUpperCase()}`,+ requireBoardApprovalForNewAgents: false,+ });++ await db.insert(issues).values({+ id: issueId,+ companyId,+ title: "Paged comments issue",+ status: "todo",+ priority: "medium",+ });++ await db.insert(issueComments).values([+ {+ id: firstCommentId,+ companyId,+ issueId,+ body: "First comment",+ createdAt: new Date("2026-03-26T10:00:00.000Z"),+ updatedAt: new Date("2026-03-26T10:00:00.000Z"),+ },+ {+ id: anchorCommentId,+ companyId,+ issueId,+ body: "Anchor comment",+ createdAt: new Date("2026-03-26T11:00:00.000Z"),+ updatedAt: new Date("2026-03-26T11:00:00.000Z"),+ },+ {+ id: latestCommentId,+ companyId,+ issueId,+ body: "Latest comment",+ createdAt: new Date("2026-03-26T12:00:00.000Z"),+ updatedAt: new Date("2026-03-26T12:00:00.000Z"),+ },+ ]);++ const comments = await svc.listComments(issueId, {+ afterCommentId: anchorCommentId,+ order: "asc",+ limit: 50,+ });++ expect(comments.map((comment) => comment.id)).toEqual([latestCommentId]);+ });+it("lists user comments when derived run attribution scans a timestamp window", async () => {const companyId = randomUUID();const agentId = randomUUID();diff --git a/server/src/services/issues.ts b/server/src/services/issues.tsindex 1a20f62b88..32472bcf26 100644--- a/server/src/services/issues.ts+++ b/server/src/services/issues.ts@@ -5589,15 +5589,25 @@ export function issueService(db: Db) {.then((rows) => rows[0] ?? null);if (!anchor) return [];+ const anchorCreatedAt =+ anchor.createdAt instanceof Date+ ? anchor.createdAt+ : new Date(String(anchor.createdAt));conditions.push(order === "asc"? or(- gt(issueComments.createdAt, anchor.createdAt),- and(eq(issueComments.createdAt, anchor.createdAt), gt(issueComments.id, anchor.id)),+ gt(issueComments.createdAt, anchorCreatedAt),+ and(+ eq(issueComments.createdAt, anchorCreatedAt),+ gt(issueComments.id, anchor.id),+ ),)!: or(- lt(issueComments.createdAt, anchor.createdAt),- and(eq(issueComments.createdAt, anchor.createdAt), lt(issueComments.id, anchor.id)),+ lt(issueComments.createdAt, anchorCreatedAt),+ and(+ eq(issueComments.createdAt, anchorCreatedAt),+ lt(issueComments.id, anchor.id),+ ),)!,);}