Skip to content

Commit 96e3bc8

Browse files
fix(whatsapp): always record per-contact last-route regardless of pin guard
The pin guard (pinnedMainDmRecipient) applies only to main session updates. Per-contact sessions should always record their last-route since they are independent of the main session pin state. Updated test to use pinnedMainDmRecipient that differs from dmRouteTarget to verify the per-contact session is updated even when not the pinned owner.
1 parent 9b75bb6 commit 96e3bc8

2 files changed

Lines changed: 5 additions & 7 deletions

File tree

extensions/whatsapp/src/auto-reply/monitor/inbound-dispatch.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -824,7 +824,7 @@ describe("whatsapp inbound dispatch", () => {
824824
cfg: {} as never,
825825
ctx: { Body: "hello" },
826826
dmRouteTarget: "+3000",
827-
pinnedMainDmRecipient: null,
827+
pinnedMainDmRecipient: "+1000", // owner different from dmRouteTarget
828828
route: makeRoute({
829829
sessionKey: "agent:main:whatsapp:direct:+3000",
830830
mainSessionKey: "agent:main:main",

extensions/whatsapp/src/auto-reply/monitor/inbound-dispatch.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -256,12 +256,10 @@ export function updateWhatsAppMainLastRoute(params: {
256256
return;
257257
}
258258

259-
// Record last-route for per-contact session when using scoped dmScope
260-
if (
261-
params.dmRouteTarget &&
262-
params.route.sessionKey !== params.route.mainSessionKey &&
263-
shouldUpdateMainLastRoute
264-
) {
259+
// Record last-route for per-contact session when using scoped dmScope.
260+
// Always record per-contact sessions regardless of pinnedMainDmRecipient,
261+
// since the pin guard only applies to main session updates.
262+
if (params.dmRouteTarget && params.route.sessionKey !== params.route.mainSessionKey) {
265263
params.updateLastRoute({
266264
cfg: params.cfg,
267265
backgroundTasks: params.backgroundTasks,

0 commit comments

Comments
 (0)