diff --git a/actions/setup/js/route_slash_command.cjs b/actions/setup/js/route_slash_command.cjs index cd1ddf59918..b89c6daf977 100644 --- a/actions/setup/js/route_slash_command.cjs +++ b/actions/setup/js/route_slash_command.cjs @@ -24,11 +24,14 @@ async function appendRoutingSummary(existingCommands, selectedCommand) { .map(command => `/${command.trim()}`) .sort(); - const existingCommandsText = normalizedCommands.length ? normalizedCommands.join(", ") : ""; - const selectedCommandText = selectedCommand ? `/${selectedCommand}` : ""; + const selectedCommandText = selectedCommand ? `\`/${selectedCommand}\`` : "``"; + const existingCommandsList = normalizedCommands.map(command => `- \`${command}\``).join("\n"); try { - summary.addHeading("Agentic Commands Router", 3).addRaw(`- Existing commands: ${existingCommandsText}`, true).addEOL().addRaw(`- Selected command: ${selectedCommandText}`, true).addEOL(); + summary.addHeading("Agentic Commands Router", 3).addRaw(`- Selected command: ${selectedCommandText}`, true).addEOL().addRaw(`- Configured commands: ${normalizedCommands.length}`, true).addEOL(); + if (existingCommandsList) { + summary.addEOL().addRaw(`
Configured commands\n\n${existingCommandsList}\n\n
`, true).addEOL(); + } await summary.write({ overwrite: false }); } catch (error) { core.warning(`Failed to write centralized routing details to step summary: ${String(error)}`); @@ -286,7 +289,7 @@ function isDisabledWorkflowDispatchError(error) { return false; } - return message.includes("workflow is disabled") || message.includes("workflow was disabled"); + return message.includes("workflow is disabled") || message.includes("workflow was disabled") || message.includes("disabled workflow"); } async function main() { diff --git a/actions/setup/js/route_slash_command.test.cjs b/actions/setup/js/route_slash_command.test.cjs index 23ad16adaaf..caa22ffcb73 100644 --- a/actions/setup/js/route_slash_command.test.cjs +++ b/actions/setup/js/route_slash_command.test.cjs @@ -160,8 +160,9 @@ describe("route_slash_command", () => { const awContext = JSON.parse(dispatchCalls[0].inputs.aw_context); expect(awContext.command_name).toBe("archie"); expect(awContext.desired_ai_reaction).toBe("eyes"); - expect(summaryMock.addRaw).toHaveBeenCalledWith("- Existing commands: /archie", true); - expect(summaryMock.addRaw).toHaveBeenCalledWith("- Selected command: /archie", true); + expect(summaryMock.addRaw).toHaveBeenCalledWith("- Selected command: `/archie`", true); + expect(summaryMock.addRaw).toHaveBeenCalledWith("- Configured commands: 1", true); + expect(summaryMock.addRaw).toHaveBeenCalledWith("
Configured commands\n\n- `/archie`\n\n
", true); expect(summaryMock.write).toHaveBeenCalledWith({ overwrite: false }); }); @@ -170,8 +171,9 @@ describe("route_slash_command", () => { await main(); - expect(summaryMock.addRaw).toHaveBeenCalledWith("- Existing commands: /archie", true); - expect(summaryMock.addRaw).toHaveBeenCalledWith("- Selected command: ", true); + expect(summaryMock.addRaw).toHaveBeenCalledWith("- Selected command: ``", true); + expect(summaryMock.addRaw).toHaveBeenCalledWith("- Configured commands: 1", true); + expect(summaryMock.addRaw).toHaveBeenCalledWith("
Configured commands\n\n- `/archie`\n\n
", true); expect(summaryMock.write).toHaveBeenCalledWith({ overwrite: false }); }); @@ -347,6 +349,37 @@ describe("route_slash_command", () => { expect(globals.core.info).toHaveBeenCalledWith(expect.stringContaining("Skipping workflow 'ci-doctor.lock.yml' because it is disabled.")); }); + it("ignores disabled workflow_dispatch failures for disabled label routes", async () => { + globals.github.rest.actions.createWorkflowDispatch = vi.fn(async params => { + if (params.workflow_id === "smoke-otel-backends.lock.yml") { + throw Object.assign(new Error("Cannot trigger a 'workflow_dispatch' on a disabled workflow"), { + status: 422, + response: { status: 422, data: { message: "Cannot trigger a 'workflow_dispatch' on a disabled workflow" } }, + }); + } + dispatchCalls.push(params); + }); + globals.context.eventName = "pull_request"; + globals.context.payload = { + action: "labeled", + label: { name: "smoke" }, + pull_request: { number: 23 }, + }; + process.env.GH_AW_LABEL_ROUTING = JSON.stringify({ + smoke: [ + { workflow: "smoke-copilot", events: ["pull_request"] }, + { workflow: "smoke-otel-backends", events: ["pull_request"] }, + ], + }); + + await main(); + + expect(dispatchCalls).toHaveLength(1); + expect(dispatchCalls[0].workflow_id).toBe("smoke-copilot.lock.yml"); + expect(globals.core.info).toHaveBeenCalledWith(expect.stringContaining("Skipping workflow 'smoke-otel-backends.lock.yml' because it is disabled.")); + expect(globals.core.info).toHaveBeenCalledWith(expect.stringContaining("Completed decentralized label routing for 'smoke'.")); + }); + it("skips centralized routing when PR is closed at workflow start", async () => { globals.context.eventName = "pull_request"; globals.context.payload = { action: "ready_for_review", pull_request: { number: 12, state: "closed" } };