Skip to content

Commit 1fb8a8c

Browse files
committed
fix: prefer target entry for inline command dispatch
1 parent 3b6fac8 commit 1fb8a8c

2 files changed

Lines changed: 48 additions & 1 deletion

File tree

src/auto-reply/reply/get-reply-inline-actions.skip-when-config-empty.test.ts

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,53 @@ describe("handleInlineActions", () => {
190190
);
191191
});
192192

193+
it("prefers the target session entry when routing inline commands into handleCommands", async () => {
194+
const typing = createTypingController();
195+
196+
handleCommandsMock.mockResolvedValue({ shouldContinue: false, reply: { text: "done" } });
197+
198+
const ctx = buildTestCtx({
199+
Body: "/status",
200+
CommandBody: "/status",
201+
});
202+
203+
const result = await handleInlineActions(
204+
createHandleInlineActionsInput({
205+
ctx,
206+
typing,
207+
cleanedBody: "/status",
208+
command: {
209+
isAuthorizedSender: true,
210+
rawBodyNormalized: "/status",
211+
commandBodyNormalized: "/status",
212+
},
213+
overrides: {
214+
allowTextCommands: true,
215+
cfg: { commands: { text: true } },
216+
sessionEntry: {
217+
sessionId: "wrapper-session",
218+
updatedAt: Date.now(),
219+
} as SessionEntry,
220+
sessionStore: {
221+
"s:main": {
222+
sessionId: "target-session",
223+
updatedAt: Date.now(),
224+
} as SessionEntry,
225+
},
226+
},
227+
}),
228+
);
229+
230+
expect(result).toEqual({ kind: "reply", reply: { text: "done" } });
231+
expect(handleCommandsMock).toHaveBeenCalledWith(
232+
expect.objectContaining({
233+
sessionEntry: expect.objectContaining({
234+
sessionId: "target-session",
235+
}),
236+
}),
237+
);
238+
});
239+
193240
it("does not run command handlers after replying to an inline status-only turn", async () => {
194241
const typing = createTypingController();
195242
const ctx = buildTestCtx({

src/auto-reply/reply/get-reply-inline-actions.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ export async function handleInlineActions(params: {
390390
allowed: elevatedAllowed,
391391
failures: elevatedFailures,
392392
},
393-
sessionEntry,
393+
sessionEntry: targetSessionEntry,
394394
previousSessionEntry,
395395
sessionStore,
396396
sessionKey,

0 commit comments

Comments
 (0)