Skip to content

Commit 8578b8f

Browse files
steipeteampagent
andauthored
fix(gateway): retain idle manual channel stops (#128237)
Co-authored-by: Amp <[email protected]>
1 parent a7d30b9 commit 8578b8f

2 files changed

Lines changed: 20 additions & 12 deletions

File tree

‎src/gateway/server-channels.test.ts‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1016,6 +1016,19 @@ describe("server-channels auto restart", () => {
10161016
expect(stopAccount).not.toHaveBeenCalled();
10171017
});
10181018

1019+
it("records explicit manual stop intent for an idle account without a stop hook", async () => {
1020+
const startAccount = vi.fn(async () => undefined);
1021+
installTestRegistry(createTestPlugin({ startAccount }));
1022+
const manager = createManager();
1023+
1024+
await manager.stopChannel("discord", "automatic", { manual: false });
1025+
await manager.stopChannel("discord", "operator");
1026+
1027+
expect(manager.isManuallyStopped("discord", "automatic")).toBe(false);
1028+
expect(manager.isManuallyStopped("discord", "operator")).toBe(true);
1029+
expect(startAccount).not.toHaveBeenCalled();
1030+
});
1031+
10191032
it("does not auto-restart after manual stop during backoff", async () => {
10201033
const startAccount = vi.fn(async () => {});
10211034
installTestRegistry(

‎src/gateway/server-channels.ts‎

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1108,22 +1108,17 @@ export function createChannelManager(opts: ChannelManagerOptions): ChannelManage
11081108
...store.stops.keys(),
11091109
...store.tasks.keys(),
11101110
]);
1111+
// Preserve no-enumeration channel-wide idle stops. An explicit account stop
1112+
// must still commit manual intent before health monitoring can restart it.
11111113
if (!accountId && lifecycleIds.size === 0) {
11121114
return;
11131115
}
1114-
// Fast path: nothing running and no explicit plugin shutdown hook to run.
1115-
if (!plugin?.gateway?.stopAccount && lifecycleIds.size === 0) {
1116-
return;
1117-
}
11181116
const cfg = getRuntimeConfig();
1119-
const knownIds = new Set<string>([
1120-
...lifecycleIds,
1121-
...(plugin ? plugin.config.listAccountIds(cfg) : []),
1122-
]);
1123-
if (accountId) {
1124-
knownIds.clear();
1125-
knownIds.add(accountId);
1126-
}
1117+
const knownIds = new Set<string>(
1118+
accountId
1119+
? [accountId]
1120+
: [...lifecycleIds, ...(plugin ? plugin.config.listAccountIds(cfg) : [])],
1121+
);
11271122

11281123
// Gate replacement starts before teardown begins. Failures still reject only
11291124
// after every sibling account has finished its independent lifecycle cleanup.

0 commit comments

Comments
 (0)