From 9449aa2fbfaa4bc444c2c9b69ba2f90a63434707 Mon Sep 17 00:00:00 2001 From: xiao Date: Fri, 19 Jun 2026 21:23:16 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=A4=84=E7=90=86=E4=BB=BB=E5=8A=A1?= =?UTF-8?q?=E6=97=B6=E7=BB=99=E6=8E=92=E9=98=9F=E6=B6=88=E6=81=AF=E4=B8=80?= =?UTF-8?q?=E4=B8=AA=E5=8F=8D=E9=A6=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 用户在 Claude 处理任务期间发的消息会进入串行队列等待,但此前没有任何反馈, 用户对着空白聊天框干等、容易误以为消息丢了。 - onMessage 入队时,若已有任务在处理,立刻回一句排队提示 - 一波忙碌期内只提示一次(queueNoticeSent 标志),避免连发刷屏 - drainQueue 清空队列后复位标志,下一波忙碌可再次提示 - 仅对用户消息提示,不影响 /stop /clear 优先命令的即时处理 --- src/main.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/main.ts b/src/main.ts index e0bb69b..6c4202f 100644 --- a/src/main.ts +++ b/src/main.ts @@ -270,6 +270,8 @@ async function runDaemon(): Promise { // -- Message queue for serial processing -- const messageQueue: WeixinMessage[] = []; let processingQueue = false; + // 一波忙碌期内只发一次排队提示,避免用户连发消息时被刷屏 + let queueNoticeSent = false; async function drainQueue(): Promise { if (processingQueue) return; @@ -279,6 +281,7 @@ async function runDaemon(): Promise { await handleMessage(msg, account!, session, sessionStore, sender, config, sharedCtx, activeControllers, messageQueue); } processingQueue = false; + queueNoticeSent = false; // 队列已清空,下一波忙碌可再次提示 } // -- Wire the monitor callbacks -- @@ -305,6 +308,16 @@ async function runDaemon(): Promise { const callbacks: MonitorCallbacks = { onMessage: async (msg: WeixinMessage) => { if (handlePriorityCommand(msg)) return; + // 已有任务在处理时,新消息会进队列等待——立刻给一个排队反馈, + // 避免用户对着空白聊天框干等、误以为消息丢了。一波忙碌期只提示一次。 + if (processingQueue && !queueNoticeSent && msg.message_type === MessageType.USER && msg.from_user_id) { + queueNoticeSent = true; + sender.sendText( + msg.from_user_id, + msg.context_token ?? '', + '⏳ 正在处理上一条消息,你后面发的我都收到了,会处理完依次回复。', + ).catch(() => {}); + } messageQueue.push(msg); drainQueue(); },