fix(discord): ignore gateway frames after stop, hold the typed hint while a choice is pending, name the Discord group in the settings reference

This commit is contained in:
Devvyn committed 2026-10-30 15:42:48 +08:00
1 parent 9f18b78857
commit 97c698b249
3 files changed
+32 -3

No files matched your search

+23
View File
@@ -247,6 +247,15 @@ describe('DiscordGateway', () => {
gw.stop();
});
it('ignores a frame that arrives after stop(): no heartbeat timer, nothing sent', () => {
const { gw, sockets } = setup();
gw.start();
gw.stop();
sockets[0].recv({ op: 10, d: { heartbeat_interval: 1000 } });
expect(vi.getTimerCount()).toBe(0);
expect(sockets[0].sent).toHaveLength(0);
});
it('stops for good on a close code that retrying cannot fix', () => {
const { gw, sockets } = setup();
gw.start();
@@ -920,6 +929,20 @@ describe('DiscordBridge files and startup hint', () => {
b.stop();
});
it('holds the startup hint while a choice is pending and sends it at the next idle', async () => {
let choice = true;
const b = await make({}, undefined, () => choice);
await b.sessionCreated('s6', 'w6', t - 1000);
await b.sessionIdle('s6', true);
expect(sent).toHaveLength(0);
choice = false;
await b.sessionIdle('s6', true);
expect(sent).toHaveLength(1);
await b.sessionIdle('s6', true);
expect(sent).toHaveLength(1);
b.stop();
});
it('says the agent has exited and types nothing when the tab reports it', async () => {
const b = await make({}, undefined, undefined, () => true);
await b.onGatewayMessage(reply({ content: 'hello', attachments: [] }));