Skip to content

fix(core): merge messages correctly in message_delay debounce - #1061

Merged
dingyi222666 merged 1 commit into
v1-devfrom
fix/message-delay-merge
Oct 18, 2026
Merged

dingyi222666 merged 1 commit into
v1-devfrom
fix/message-delay-merge

Conversation

@dingyi222666

Copy link
Copy Markdown
Member

Fixes #1057.

Defect 1 — cooldown_time intercepts messages mid-collection

cooldown_time was ordered only .after('allow_reply'), so it ran before message_delay. With msgCooldown > 0, a second message inside the window was STOPped with a cooldown notice before it could join the collecting turn — the debounce merged nothing.

Fix: cooldown_time is now also .after('message_delay'), so it gates the merged turn rather than each raw message. Since message_delay's joined members resolve STOP at their own chain step, only the merged turn's starter reaches the cooldown check — cooldown now means "between replies" instead of "between keystrokes".

Also: lastChatTime was a module-global shared by every user and channel — one active channel could throttle unrelated ones. It's now a Map keyed by session.channelId.

Defect 2 — strict userName equality blocks guild merges

The tail-turn join check required tailTurn.userName === userName. In guilds, a second message from a different member inside the window could never merge — it spawned a serial waiting turn instead, defeating the debounce.

The check is dropped entirely: turns are already scoped per conversationId, and a DM conversation has exactly one sender, so the equality was either a no-op or wrong.

mergeMessages now prepends ${msg.name}: to each message's content parts when the batch has more than one distinct sender, so the model can attribute multi-user content. Single-user batches keep the existing newline-join shape.

Net: +14 / −9 in 2 files. Verified yarn fast-build core (exit 0), ESLint clean.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ⚠️ Failed 2026-10-17T19:51:57.005436Z 3cdacda PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@coderabbitai

coderabbitai Bot commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 24 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 2 included reviews currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: c7c36389-78b6-4196-b610-e990f1fa4cdd
📥 Commits

Reviewing files that changed from the base of the PR and between 315d488 and 8867806.

📒 Files selected for processing: 2
  • packages/core/src/middlewares/chat/cooldown_time.ts
  • packages/core/src/middlewares/chat/message_delay.ts
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Two defects kept the debounce queue from merging messages:

1. cooldown_time ran before message_delay, so a second message sent
   inside the cooldown window was STOPped with a cooldown notice
   instead of joining the collecting turn. cooldown_time is now
   declared .after('message_delay') so it gates the merged turn,
   and its lastChatTime is scoped per session.channelId rather
   than one global timestamp shared across all users/channels.

2. In guild conversations, tailTurn.userName === userName meant a
   message from a different member could never join the collecting
   turn — multi-member debounce silently degraded to serial turns.
   The equality check is dropped (turns are already per
   conversationId; a DM has exactly one sender anyway), and
   mergeMessages now prefixes each message with its sender name
   when the batch contains more than one distinct name, so the
   model can attribute speakers.

Fixes #1057.

Co-Authored-By: Claude <noreply@anthropic.com>
@dingyi222666
dingyi222666 force-pushed the fix/message-delay-merge branch from 3cdacda to 8867806 Compare October 17, 2026 19:55
@dingyi222666
dingyi222666 merged commit 4c45a85 into v1-dev Oct 18, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] message_delay 防抖队列两处缺陷:cooldown_time 拦截收集窗口、userName 强校验导致群聊消息无法合并

1 participant