fix: preserve sender-keyed plugin command bindings

This commit is contained in:
Tak Hoffman
2026-04-10 17:59:41 -05:00
parent c28900f509
commit 1c0e444f56
2 changed files with 32 additions and 0 deletions

View File

@@ -186,6 +186,22 @@ beforeEach(() => {
},
},
},
{
pluginId: "signal",
source: "test",
plugin: {
...createChannelTestPluginBase({ id: "signal", label: "Signal" }),
commands: {
nativeCommandsAutoEnabled: true,
},
bindings: {
resolveCommandConversation: ({ senderId }: { senderId?: string }) => {
const normalizedSenderId = senderId?.trim();
return normalizedSenderId ? { conversationId: `dm:${normalizedSenderId}` } : null;
},
},
},
},
]),
);
});
@@ -446,6 +462,19 @@ describe("registerPluginCommand", () => {
},
expected: null,
},
{
name: "resolves sender-keyed command bindings when only senderId is available",
params: {
channel: "signal",
senderId: "signal-user-42",
accountId: "default",
},
expected: {
channel: "signal",
accountId: "default",
conversationId: "dm:signal-user-42",
},
},
] as const)("$name", ({ params, expected }) => {
expectBindingConversationCase(params, expected);
});

View File

@@ -116,6 +116,7 @@ function sanitizeArgs(args: string | undefined): string | undefined {
function resolveBindingConversationFromCommand(params: {
config?: OpenClawConfig;
channel: string;
senderId?: string;
from?: string;
to?: string;
accountId?: string;
@@ -140,6 +141,7 @@ function resolveBindingConversationFromCommand(params: {
accountId: params.accountId,
threadId: params.messageThreadId,
threadParentId: params.threadParentId,
senderId: params.senderId,
originatingTo: params.from,
commandTo: params.to,
fallbackTo: params.to ?? params.from,
@@ -187,6 +189,7 @@ export async function executePluginCommand(params: {
const bindingConversation = resolveBindingConversationFromCommand({
config,
channel,
senderId,
from: params.from,
to: params.to,
accountId: params.accountId,