From da68fa407903040d1096c5c3cf1052bc5b089274 Mon Sep 17 00:00:00 2001 From: Tak Hoffman <781889+Takhoffman@users.noreply.github.com> Date: Fri, 3 Apr 2026 16:53:38 -0500 Subject: [PATCH] fix: honor followup default account --- .../reply/get-reply-run.media-only.test.ts | 31 +++++++++++++++++++ src/auto-reply/reply/get-reply-run.ts | 2 +- 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/src/auto-reply/reply/get-reply-run.media-only.test.ts b/src/auto-reply/reply/get-reply-run.media-only.test.ts index 098c399cce6..9f1982f5889 100644 --- a/src/auto-reply/reply/get-reply-run.media-only.test.ts +++ b/src/auto-reply/reply/get-reply-run.media-only.test.ts @@ -360,6 +360,37 @@ describe("runPreparedReply media-only handling", () => { expect(call?.followupRun.run.messageProvider).toBe("feishu"); }); + it("uses the effective session account for followup originatingAccountId when AccountId is omitted", async () => { + await runPreparedReply( + baseParams({ + ctx: { + Body: "", + RawBody: "", + CommandBody: "", + ThreadHistoryBody: "Earlier message in this thread", + OriginatingChannel: "discord", + OriginatingTo: "channel:24680", + ChatType: "group", + AccountId: undefined, + }, + sessionCtx: { + Body: "", + BodyStripped: "", + ThreadHistoryBody: "Earlier message in this thread", + MediaPath: "/tmp/input.png", + Provider: "discord", + ChatType: "group", + OriginatingChannel: "discord", + OriginatingTo: "channel:24680", + AccountId: "work", + }, + }), + ); + + const call = vi.mocked(runReplyAgent).mock.calls[0]?.[0]; + expect(call?.followupRun.originatingAccountId).toBe("work"); + }); + it("passes suppressTyping through typing mode resolution", async () => { await runPreparedReply( baseParams({ diff --git a/src/auto-reply/reply/get-reply-run.ts b/src/auto-reply/reply/get-reply-run.ts index 01cd48727b1..863f244e804 100644 --- a/src/auto-reply/reply/get-reply-run.ts +++ b/src/auto-reply/reply/get-reply-run.ts @@ -526,7 +526,7 @@ export async function runPreparedReply( // Originating channel for reply routing. originatingChannel: ctx.OriginatingChannel, originatingTo: ctx.OriginatingTo, - originatingAccountId: ctx.AccountId, + originatingAccountId: sessionCtx.AccountId, originatingThreadId: ctx.MessageThreadId, originatingChatType: ctx.ChatType, run: {