diff --git a/CLAUDE.md b/CLAUDE.md index 8182e2d..1139cae 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -27,6 +27,8 @@ Single Node.js process that connects to WhatsApp, routes messages to Claude Agen ## Development +Run commands directly—don't tell the user to run them. + ```bash npm run dev # Run with hot reload npm run build # Compile TypeScript diff --git a/src/index.ts b/src/index.ts index 461246e..11f5c13 100644 --- a/src/index.ts +++ b/src/index.ts @@ -36,6 +36,14 @@ let sessions: Session = {}; let registeredGroups: Record = {}; let lastAgentTimestamp: Record = {}; +async function setTyping(jid: string, isTyping: boolean): Promise { + try { + await sock.sendPresenceUpdate(isTyping ? 'composing' : 'paused', jid); + } catch (err) { + logger.debug({ jid, err }, 'Failed to update typing status'); + } +} + function loadJson(filePath: string, defaultValue: T): T { try { if (fs.existsSync(filePath)) { @@ -107,7 +115,10 @@ async function processMessage(msg: NewMessage): Promise { if (!prompt) return; logger.info({ group: group.name, messageCount: missedMessages.length }, 'Processing message'); + + await setTyping(msg.chat_jid, true); const response = await runAgent(group, prompt, msg.chat_jid); + await setTyping(msg.chat_jid, false); // Update last agent timestamp lastAgentTimestamp[msg.chat_jid] = msg.timestamp;