From d69664e10731dada4eb276fc5f9fe0068b8b2879 Mon Sep 17 00:00:00 2001 From: Tak Hoffman <781889+Takhoffman@users.noreply.github.com> Date: Fri, 27 Mar 2026 23:24:50 -0500 Subject: [PATCH] fix(regression): preserve googlechat pairing account context --- extensions/googlechat/src/channel.test.ts | 45 +++++++++++++++++++++++ extensions/googlechat/src/channel.ts | 4 +- 2 files changed, 47 insertions(+), 2 deletions(-) diff --git a/extensions/googlechat/src/channel.test.ts b/extensions/googlechat/src/channel.test.ts index 7b623956bc0..46d1cd75f13 100644 --- a/extensions/googlechat/src/channel.test.ts +++ b/extensions/googlechat/src/channel.test.ts @@ -290,6 +290,51 @@ describe("googlechatPlugin outbound resolveTarget", () => { }); describe("googlechatPlugin outbound cfg threading", () => { + it("preserves accountId when sending pairing approvals", async () => { + const cfg = { + channels: { + googlechat: { + enabled: true, + accounts: { + work: { + serviceAccount: { + type: "service_account", + }, + }, + }, + }, + }, + }; + const account = { + accountId: "work", + config: {}, + credentialSource: "inline", + }; + resolveGoogleChatAccountMock.mockReturnValue(account); + resolveGoogleChatOutboundSpaceMock.mockResolvedValue("spaces/WORK"); + sendGoogleChatMessageMock.mockResolvedValue({ + messageName: "spaces/WORK/messages/msg-1", + }); + + await googlechatPlugin.pairing?.notifyApproval?.({ + cfg: cfg as never, + id: "user@example.com", + accountId: "work", + }); + + expect(resolveGoogleChatAccountMock).toHaveBeenCalledWith({ + cfg, + accountId: "work", + }); + expect(sendGoogleChatMessageMock).toHaveBeenCalledWith( + expect.objectContaining({ + account, + space: "spaces/WORK", + text: expect.any(String), + }), + ); + }); + it("threads resolved cfg into sendText account resolution", async () => { const cfg = { channels: { diff --git a/extensions/googlechat/src/channel.ts b/extensions/googlechat/src/channel.ts index 04257101575..03c0c00ffd5 100644 --- a/extensions/googlechat/src/channel.ts +++ b/extensions/googlechat/src/channel.ts @@ -317,8 +317,8 @@ export const googlechatPlugin = createChatChannelPlugin({ idLabel: "googlechatUserId", message: PAIRING_APPROVED_MESSAGE, normalizeAllowEntry: (entry) => formatAllowFromEntry(entry), - notify: async ({ cfg, id, message }) => { - const account = resolveGoogleChatAccount({ cfg: cfg }); + notify: async ({ cfg, id, message, accountId }) => { + const account = resolveGoogleChatAccount({ cfg: cfg, accountId }); if (account.credentialSource === "none") { return; }