diff --git a/actions/setup/js/gateway_difc_filtered.cjs b/actions/setup/js/gateway_difc_filtered.cjs index 56a7285feda..d7ba5fbccd6 100644 --- a/actions/setup/js/gateway_difc_filtered.cjs +++ b/actions/setup/js/gateway_difc_filtered.cjs @@ -94,7 +94,7 @@ function generateDifcFilteredSection(filteredEvents) { let section = "\n\n> [!NOTE]\n"; section += `>
\n`; - section += `> **🔒 Integrity filter blocked ${count} ${itemWord}**\n`; + section += `> 🔒 Integrity filter blocked ${count} ${itemWord}\n`; section += `>\n`; section += `> The following ${itemWord} were blocked because they don't meet the GitHub integrity level.\n`; section += `>\n`; @@ -110,7 +110,8 @@ function generateDifcFilteredSection(filteredEvents) { reference = `[${label}](${event.html_url})`; } else { const desc = event.description ? event.description.replace(/^[a-z-]+:(?!\/\/)/i, "") : null; - reference = desc || (event.tool_name ? `\`${event.tool_name}\`` : "-"); + const validDesc = desc && desc !== "#unknown" ? desc : null; + reference = validDesc || (event.tool_name ? `\`${event.tool_name}\`` : "-"); } const tool = event.tool_name ? `\`${event.tool_name}\`` : "-"; const reason = (event.reason || "-").replace(/^Resource '[^']*' /, "").replace(/\n/g, " "); diff --git a/actions/setup/js/gateway_difc_filtered.test.cjs b/actions/setup/js/gateway_difc_filtered.test.cjs index 414e8b689ab..9f4ba9cda0c 100644 --- a/actions/setup/js/gateway_difc_filtered.test.cjs +++ b/actions/setup/js/gateway_difc_filtered.test.cjs @@ -175,7 +175,7 @@ describe("gateway_difc_filtered.cjs", () => { expect(result).toContain("> [!NOTE]"); expect(result).toContain(">
"); expect(result).toContain(">
"); - expect(result).toContain("> **🔒 Integrity filter blocked 1 item**"); + expect(result).toContain("> 🔒 Integrity filter blocked 1 item"); expect(result).toContain("[#42](https://github.com/org/repo/issues/42)"); expect(result).toContain("`list_issues`"); expect(result).toContain("Integrity check failed"); @@ -202,7 +202,7 @@ describe("gateway_difc_filtered.cjs", () => { const result = generateDifcFilteredSection(events); expect(result).toContain("> [!NOTE]"); - expect(result).toContain("> **🔒 Integrity filter blocked 2 items**"); + expect(result).toContain("> 🔒 Integrity filter blocked 2 items"); expect(result).toContain("[#42](https://github.com/org/repo/issues/42)"); expect(result).toContain("[#99](https://github.com/org/repo/issues/99)"); }); @@ -318,7 +318,7 @@ describe("gateway_difc_filtered.cjs", () => { const result = generateDifcFilteredSection(events); - expect(result).toContain("> **🔒 Integrity filter blocked 2 items**"); + expect(result).toContain("> 🔒 Integrity filter blocked 2 items"); expect(result).toContain("[#42](https://github.com/org/repo/issues/42)"); expect(result).toContain("[#99](https://github.com/org/repo/issues/99)"); }); @@ -363,7 +363,7 @@ describe("gateway_difc_filtered.cjs", () => { const result = generateDifcFilteredSection(events); // Summary still shows the total count - expect(result).toContain("> **🔒 Integrity filter blocked 20 items**"); + expect(result).toContain("> 🔒 Integrity filter blocked 20 items"); // First 16 items rendered expect(result).toContain("[#1](https://github.com/org/repo/issues/1)"); expect(result).toContain("[#16](https://github.com/org/repo/issues/16)"); @@ -397,5 +397,48 @@ describe("gateway_difc_filtered.cjs", () => { expect(result).toContain("... and 1 more item"); expect(result).not.toContain("... and 1 more items"); }); + + it("should show events with #unknown description using tool_name instead", () => { + const events = [ + { + type: "DIFC_FILTERED", + tool_name: "search_issues", + description: "github:#unknown", + reason: "has lower integrity than agent requires.", + }, + { + type: "DIFC_FILTERED", + tool_name: "list_issues", + reason: "Integrity check failed", + html_url: "https://github.com/org/repo/issues/42", + number: "42", + }, + ]; + + const result = generateDifcFilteredSection(events); + + // Both entries should be shown; #unknown text hidden, tool_name used instead + expect(result).toContain("> 🔒 Integrity filter blocked 2 items"); + expect(result).not.toContain("#unknown"); + expect(result).toContain("`search_issues`"); + expect(result).toContain("[#42](https://github.com/org/repo/issues/42)"); + }); + + it("should show entry using tool_name when description is #unknown", () => { + const events = [ + { + type: "DIFC_FILTERED", + tool_name: "search_issues", + description: "github:#unknown", + reason: "has lower integrity", + }, + ]; + + const result = generateDifcFilteredSection(events); + + expect(result).toContain("> 🔒 Integrity filter blocked 1 item"); + expect(result).toContain("`search_issues`"); + expect(result).not.toContain("#unknown"); + }); }); });