fix: use available instead of paused when stopping typing indicator

Sending 'paused' after the first response caused WhatsApp to stop
relaying subsequent 'composing' presence updates. Using 'available'
keeps the bot in a state where typing indicators work consistently.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
gavrielc
2026-02-13 23:05:36 +02:00
parent 658f6b02d3
commit ae474fd344
2 changed files with 3 additions and 3 deletions

View File

@@ -820,14 +820,14 @@ describe('WhatsAppChannel', () => {
expect(fakeSocket.sendPresenceUpdate).toHaveBeenCalledWith('composing', 'test@g.us'); expect(fakeSocket.sendPresenceUpdate).toHaveBeenCalledWith('composing', 'test@g.us');
}); });
it('sends paused presence when stopping', async () => { it('sends available presence when stopping', async () => {
const opts = createTestOpts(); const opts = createTestOpts();
const channel = new WhatsAppChannel(opts); const channel = new WhatsAppChannel(opts);
await connectChannel(channel); await connectChannel(channel);
await channel.setTyping('test@g.us', false); await channel.setTyping('test@g.us', false);
expect(fakeSocket.sendPresenceUpdate).toHaveBeenCalledWith('paused', 'test@g.us'); expect(fakeSocket.sendPresenceUpdate).toHaveBeenCalledWith('available', 'test@g.us');
}); });
it('handles typing indicator failure gracefully', async () => { it('handles typing indicator failure gracefully', async () => {

View File

@@ -218,7 +218,7 @@ export class WhatsAppChannel implements Channel {
async setTyping(jid: string, isTyping: boolean): Promise<void> { async setTyping(jid: string, isTyping: boolean): Promise<void> {
try { try {
await this.sock.sendPresenceUpdate(isTyping ? 'composing' : 'paused', jid); await this.sock.sendPresenceUpdate(isTyping ? 'composing' : 'available', jid);
} catch (err) { } catch (err) {
logger.debug({ jid, err }, 'Failed to update typing status'); logger.debug({ jid, err }, 'Failed to update typing status');
} }