fix: prefer target entry for inline command dispatch

This commit is contained in:
Tak Hoffman
2026-04-10 21:22:53 -05:00
parent 3b6fac85ea
commit 1fb8a8cdff
2 changed files with 48 additions and 1 deletions

View File

@@ -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({

View File

@@ -390,7 +390,7 @@ export async function handleInlineActions(params: {
allowed: elevatedAllowed,
failures: elevatedFailures,
},
sessionEntry,
sessionEntry: targetSessionEntry,
previousSessionEntry,
sessionStore,
sessionKey,