diff --git a/src/auto-reply/reply/get-reply-inline-actions.skip-when-config-empty.test.ts b/src/auto-reply/reply/get-reply-inline-actions.skip-when-config-empty.test.ts index 680ec99620e..de79cba27f7 100644 --- a/src/auto-reply/reply/get-reply-inline-actions.skip-when-config-empty.test.ts +++ b/src/auto-reply/reply/get-reply-inline-actions.skip-when-config-empty.test.ts @@ -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({ diff --git a/src/auto-reply/reply/get-reply-inline-actions.ts b/src/auto-reply/reply/get-reply-inline-actions.ts index 7fc55b04f82..c36c152fbc7 100644 --- a/src/auto-reply/reply/get-reply-inline-actions.ts +++ b/src/auto-reply/reply/get-reply-inline-actions.ts @@ -390,7 +390,7 @@ export async function handleInlineActions(params: { allowed: elevatedAllowed, failures: elevatedFailures, }, - sessionEntry, + sessionEntry: targetSessionEntry, previousSessionEntry, sessionStore, sessionKey,