diff --git a/extensions/slack/src/message-action-dispatch.test.ts b/extensions/slack/src/message-action-dispatch.test.ts index 9f2182d14e84..4069cc22a805 100644 --- a/extensions/slack/src/message-action-dispatch.test.ts +++ b/extensions/slack/src/message-action-dispatch.test.ts @@ -738,6 +738,32 @@ describe("handleSlackMessageAction", () => { initialComment: "path alias", }, }, + { + name: "maps an upload-file caption to the upload's initial comment", + params: { + channelId: "C1", + media: "/tmp/chart.png", + caption: "chart attached", + }, + expected: { + filePath: "/tmp/chart.png", + initialComment: "chart attached", + }, + }, + { + name: "prefers an explicit upload-file initial comment over message and caption", + params: { + channelId: "C1", + media: "/tmp/chart.png", + initialComment: "", + message: "message text", + caption: "caption text", + }, + expected: { + filePath: "/tmp/chart.png", + initialComment: "", + }, + }, ])("$name", async ({ params, expected }) => { const invoke = createInvokeSpy(); const cfg = slackConfig(); diff --git a/extensions/slack/src/message-action-dispatch.ts b/extensions/slack/src/message-action-dispatch.ts index 6e04d82d132c..086aff2e343d 100644 --- a/extensions/slack/src/message-action-dispatch.ts +++ b/extensions/slack/src/message-action-dispatch.ts @@ -358,6 +358,10 @@ export async function handleSlackMessageAction(params: { initialComment: readStringParam(actionParams, "initialComment", { allowEmpty: true }) ?? readStringParam(actionParams, "message", { allowEmpty: true }) ?? + // `media` is accepted as an alias for the file, so a send-shaped call + // arrives with its text in `caption`; without this alias that text is + // silently dropped instead of becoming the upload's first comment. + readStringParam(actionParams, "caption", { allowEmpty: true }) ?? "", filename: readStringParam(actionParams, "filename"), title: readStringParam(actionParams, "title"),