fix(discord): prevent stuck typing indicator

This commit is contained in:
Nimrod Gutman
2026-02-25 10:16:00 +02:00
committed by Nimrod Gutman
parent fb76e316fb
commit a0fa283839
3 changed files with 40 additions and 5 deletions

View File

@@ -85,4 +85,28 @@ describe("createTypingCallbacks", () => {
expect(stop).toHaveBeenCalledTimes(1);
});
it("does not restart keepalive after idle cleanup", async () => {
vi.useFakeTimers();
try {
const start = vi.fn().mockResolvedValue(undefined);
const stop = vi.fn().mockResolvedValue(undefined);
const onStartError = vi.fn();
const callbacks = createTypingCallbacks({ start, stop, onStartError });
await callbacks.onReplyStart();
expect(start).toHaveBeenCalledTimes(1);
callbacks.onIdle?.();
await flushMicrotasks();
await callbacks.onReplyStart();
await vi.advanceTimersByTimeAsync(9_000);
expect(start).toHaveBeenCalledTimes(1);
expect(stop).toHaveBeenCalledTimes(1);
} finally {
vi.useRealTimers();
}
});
});