From ef103a92f85da82a6276eff8ca234195060e8b8a Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 24 Feb 2026 20:25:56 +0000 Subject: [PATCH 1/2] Initial plan From e3ffbe35ef7b27e4b2c6b14245250808a0759006 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 24 Feb 2026 20:37:30 +0000 Subject: [PATCH 2/2] Fix hide-older-comments to match combined XML marker workflow_id format Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com> --- actions/setup/js/add_comment.cjs | 22 +++++++-- actions/setup/js/add_comment.test.cjs | 65 +++++++++++++++++++++++++++ 2 files changed, 84 insertions(+), 3 deletions(-) diff --git a/actions/setup/js/add_comment.cjs b/actions/setup/js/add_comment.cjs index 56c7690f081..e9d17ebaabc 100644 --- a/actions/setup/js/add_comment.cjs +++ b/actions/setup/js/add_comment.cjs @@ -72,9 +72,18 @@ async function findCommentsWithTrackerId(github, owner, repo, issueNumber, workf break; } - // Filter comments that contain the workflow-id and are NOT reaction comments + // Filter comments that contain the workflow-id and are NOT reaction comments. + // Supports both the standalone marker format () + // and the combined XML marker format (). const filteredComments = data - .filter(comment => comment.body?.includes(``) && !comment.body.includes(``)) + .filter(comment => { + if (!comment.body || comment.body.includes(``)) return false; + // Standalone marker: + if (comment.body.includes(``)) return true; + // Combined XML marker: + if (comment.body.includes(``))) return true; + return false; + }) .map(({ id, node_id, body }) => ({ id, node_id, body })); comments.push(...filteredComments); @@ -129,7 +138,14 @@ async function findDiscussionCommentsWithTrackerId(github, owner, repo, discussi } const filteredComments = result.repository.discussion.comments.nodes - .filter(comment => comment.body?.includes(``) && !comment.body.includes(``)) + .filter(comment => { + if (!comment.body || comment.body.includes(``)) return false; + // Standalone marker: + if (comment.body.includes(``)) return true; + // Combined XML marker: + if (comment.body.includes(``))) return true; + return false; + }) .map(({ id, body }) => ({ id, body })); comments.push(...filteredComments); diff --git a/actions/setup/js/add_comment.test.cjs b/actions/setup/js/add_comment.test.cjs index 60eee79aa9b..6b8d252ea51 100644 --- a/actions/setup/js/add_comment.test.cjs +++ b/actions/setup/js/add_comment.test.cjs @@ -527,6 +527,71 @@ describe("add_comment", () => { // Clean up delete process.env.GH_AW_WORKFLOW_ID; }); + + it("should hide older comments with combined XML marker format (workflow_id inside gh-aw-agentic-workflow)", async () => { + const addCommentScript = fs.readFileSync(path.join(__dirname, "add_comment.cjs"), "utf8"); + + delete process.env.GH_AW_SAFE_OUTPUT_MESSAGES; + process.env.GH_AW_WORKFLOW_ID = "test-workflow"; + + let hideCommentsWasCalled = false; + let listCommentsCalls = 0; + + mockGithub.rest.issues.listComments = async () => { + listCommentsCalls++; + return { + data: [ + { + id: 999, + node_id: "IC_kwDOTest999", + body: "Old comment\n\n", + }, + ], + }; + }; + + mockGithub.graphql = async (query, variables) => { + if (query.includes("minimizeComment")) { + hideCommentsWasCalled = true; + } + return { + minimizeComment: { + minimizedComment: { + isMinimized: true, + }, + }, + }; + }; + + let capturedComment = null; + mockGithub.rest.issues.createComment = async params => { + capturedComment = params; + return { + data: { + id: 12346, + html_url: `https://github.com/owner/repo/issues/${params.issue_number}#issuecomment-12346`, + }, + }; + }; + + const handler = await eval(`(async () => { ${addCommentScript}; return await main({ hide_older_comments: true }); })()`); + + const message = { + type: "add_comment", + body: "New comment - should hide combined-marker old ones", + }; + + const result = await handler(message, {}); + + expect(result.success).toBe(true); + expect(hideCommentsWasCalled).toBe(true); + expect(listCommentsCalls).toBeGreaterThan(0); + expect(capturedComment).toBeTruthy(); + expect(capturedComment.body).toContain("New comment - should hide combined-marker old ones"); + + // Clean up + delete process.env.GH_AW_WORKFLOW_ID; + }); }); describe("404 error handling", () => {