From 1fb8a8cdff3d8307df21bd2803e898135fa2a9a4 Mon Sep 17 00:00:00 2001 From: Tak Hoffman <781889+Takhoffman@users.noreply.github.com> Date: Fri, 10 Apr 2026 21:22:53 -0500 Subject: [PATCH] fix: prefer target entry for inline command dispatch --- ...ine-actions.skip-when-config-empty.test.ts | 47 +++++++++++++++++++ .../reply/get-reply-inline-actions.ts | 2 +- 2 files changed, 48 insertions(+), 1 deletion(-) 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,