fix(discord): harden component sends

This commit is contained in:
Peter Steinberger
2026-05-01 04:07:14 +01:00
committed by clawsweeper
parent e6925886d4
commit 07a07b4cb0
2 changed files with 31 additions and 0 deletions

View File

@@ -216,6 +216,36 @@ describe("handleDiscordMessageAction", () => {
expect(handleDiscordActionMock).not.toHaveBeenCalled();
});
it("forwards top-level components on sends", async () => {
const components = { blocks: [{ type: "text", text: "Pick one" }] };
await handleDiscordMessageAction({
action: "send",
params: {
message: "hello",
components,
},
cfg: {
channels: { discord: { token: "tok" } },
} as OpenClawConfig,
toolContext: {
currentChannelProvider: "discord",
currentChannelId: "channel:123",
},
});
expect(handleDiscordActionMock).toHaveBeenCalledWith(
expect.objectContaining({
action: "sendMessage",
to: "channel:123",
content: "hello",
components,
}),
expect.any(Object),
expect.any(Object),
);
});
it("does not use another provider's current target for Discord sends", async () => {
await expect(
handleDiscordMessageAction({

View File

@@ -81,6 +81,7 @@ export async function handleDiscordMessageAction(
const to = readSendTarget();
const asVoice = readBooleanParam(params, "asVoice") === true;
const rawComponents =
params.components ??
buildDiscordPresentationComponents(normalizeMessagePresentation(params.presentation)) ??
buildDiscordInteractiveComponents(normalizeInteractiveReply(params.interactive));
const hasComponents =