Skip to content

Commit 9b44929

Browse files
committed
fix(gateway): preserve restart sentinel account routing
1 parent 527601d commit 9b44929

2 files changed

Lines changed: 15 additions & 4 deletions

File tree

src/gateway/server-restart-sentinel.test.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ describe("scheduleRestartSentinelWake", () => {
316316
expect(mocks.resolveOutboundTarget).not.toHaveBeenCalled();
317317
});
318318

319-
it("falls back to the base session when the thread entry only has partial route metadata", async () => {
319+
it("merges base session routing into partial thread metadata", async () => {
320320
mocks.consumeRestartSentinel.mockResolvedValue({
321321
payload: {
322322
sessionKey: "agent:main:matrix:channel:!lowercased:example.org:thread:$thread-event",
@@ -329,14 +329,20 @@ describe("scheduleRestartSentinelWake", () => {
329329
mocks.loadSessionEntry
330330
.mockReturnValueOnce({
331331
cfg: {},
332-
entry: { origin: { provider: "matrix", threadId: "$thread-event" } },
332+
entry: {
333+
origin: { provider: "matrix", accountId: "acct-thread", threadId: "$thread-event" },
334+
},
333335
})
334336
.mockReturnValueOnce({
335337
cfg: {},
336338
entry: { lastChannel: "matrix", lastTo: "room:!MixedCase:example.org" },
337339
});
338340
mocks.deliveryContextFromSession
339-
.mockReturnValueOnce({ channel: "matrix", threadId: "$thread-event" })
341+
.mockReturnValueOnce({
342+
channel: "matrix",
343+
accountId: "acct-thread",
344+
threadId: "$thread-event",
345+
})
340346
.mockReturnValueOnce({ channel: "matrix", to: "room:!MixedCase:example.org" });
341347
mocks.resolveOutboundTarget.mockReturnValue({
342348
ok: true as const,
@@ -349,12 +355,14 @@ describe("scheduleRestartSentinelWake", () => {
349355
expect.objectContaining({
350356
channel: "matrix",
351357
to: "room:!MixedCase:example.org",
358+
accountId: "acct-thread",
352359
}),
353360
);
354361
expect(mocks.deliverOutboundPayloads).toHaveBeenCalledWith(
355362
expect.objectContaining({
356363
channel: "matrix",
357364
to: "room:!MixedCase:example.org",
365+
accountId: "acct-thread",
358366
threadId: "$thread-event",
359367
}),
360368
);

src/gateway/server-restart-sentinel.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,10 @@ export async function scheduleRestartSentinelWake(params: { deps: CliDeps }) {
161161
baseSessionKey !== sessionKey
162162
) {
163163
const { entry: baseEntry } = loadSessionEntry(baseSessionKey);
164-
sessionDeliveryContext = deliveryContextFromSession(baseEntry);
164+
sessionDeliveryContext = mergeDeliveryContext(
165+
sessionDeliveryContext,
166+
deliveryContextFromSession(baseEntry),
167+
);
165168
}
166169

167170
const origin = mergeDeliveryContext(sentinelContext, sessionDeliveryContext);

0 commit comments

Comments
 (0)