mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-12 17:51:22 +00:00
fix: prefer target entry for inline command dispatch
This commit is contained in:
@@ -190,6 +190,53 @@ describe("handleInlineActions", () => {
|
||||
);
|
||||
});
|
||||
|
||||
it("prefers the target session entry when routing inline commands into handleCommands", async () => {
|
||||
const typing = createTypingController();
|
||||
|
||||
handleCommandsMock.mockResolvedValue({ shouldContinue: false, reply: { text: "done" } });
|
||||
|
||||
const ctx = buildTestCtx({
|
||||
Body: "/status",
|
||||
CommandBody: "/status",
|
||||
});
|
||||
|
||||
const result = await handleInlineActions(
|
||||
createHandleInlineActionsInput({
|
||||
ctx,
|
||||
typing,
|
||||
cleanedBody: "/status",
|
||||
command: {
|
||||
isAuthorizedSender: true,
|
||||
rawBodyNormalized: "/status",
|
||||
commandBodyNormalized: "/status",
|
||||
},
|
||||
overrides: {
|
||||
allowTextCommands: true,
|
||||
cfg: { commands: { text: true } },
|
||||
sessionEntry: {
|
||||
sessionId: "wrapper-session",
|
||||
updatedAt: Date.now(),
|
||||
} as SessionEntry,
|
||||
sessionStore: {
|
||||
"s:main": {
|
||||
sessionId: "target-session",
|
||||
updatedAt: Date.now(),
|
||||
} as SessionEntry,
|
||||
},
|
||||
},
|
||||
}),
|
||||
);
|
||||
|
||||
expect(result).toEqual({ kind: "reply", reply: { text: "done" } });
|
||||
expect(handleCommandsMock).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
sessionEntry: expect.objectContaining({
|
||||
sessionId: "target-session",
|
||||
}),
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
it("does not run command handlers after replying to an inline status-only turn", async () => {
|
||||
const typing = createTypingController();
|
||||
const ctx = buildTestCtx({
|
||||
|
||||
@@ -390,7 +390,7 @@ export async function handleInlineActions(params: {
|
||||
allowed: elevatedAllowed,
|
||||
failures: elevatedFailures,
|
||||
},
|
||||
sessionEntry,
|
||||
sessionEntry: targetSessionEntry,
|
||||
previousSessionEntry,
|
||||
sessionStore,
|
||||
sessionKey,
|
||||
|
||||
Reference in New Issue
Block a user