fix(core): wrap split render parts as messages#976
Conversation
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: ⛔ Files ignored due to path filters (27)
📒 Files selected for processing (3)
Walkthrough本次变更统一 split 模式下流式渲染元素的包装形式,并将 Changes流式渲染输出
Estimated code review effort: 3 (Moderate) | ~15–30 minutes Possibly related PRs
Poem
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Code Review
This pull request bumps the version of koishi-plugin-chatluna to 1.4.0-alpha.41 across multiple packages and updates the core rendering logic to support message splitting. The review feedback correctly identifies a critical issue where mapping individual elements to separate message elements when splitting is enabled will break rendering for inline formatting (such as bold text, links, or images) by fragmenting them into multiple messages. The reviewer's suggestions to wrap the entire array of elements in a single message element instead are highly appropriate and should be implemented to preserve message integrity.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| result.push( | ||
| ...(this.options.split && this.options.split !== 'none' | ||
| ? elements.map((el) => | ||
| el.type === 'message' ? el : h('message', el) | ||
| ) | ||
| : elements) | ||
| ) |
There was a problem hiding this comment.
When split mode is enabled, mapping each individual element to a message element causes formatting elements (such as bold text, links, or images) within a single sentence/paragraph to be split into separate messages. This results in broken rendering and multiple fragmented messages in the chat client.
Instead, the entire array of elements for a single part should be wrapped in a single message element (unless it already contains message elements).
if (elements.length > 0) {
result.push(
...(this.options.split && this.options.split !== 'none'
? elements.some((el) => el.type === 'message')
? elements
: [h('message', ...elements)]
: elements)
)
}| let elements = this.splitter.writeText(text) | ||
| if (this.options.split && this.options.split !== 'none') { | ||
| elements = elements.map((el) => | ||
| el.type === 'message' ? el : h('message', el) | ||
| ) | ||
| } |
There was a problem hiding this comment.
When split mode is enabled, mapping each individual element to a message element causes elements that are part of the same text block to be split into separate messages. Wrapping the entire array of elements in a single message element (unless it already contains message elements) preserves the integrity of the message structure.
| let elements = this.splitter.writeText(text) | |
| if (this.options.split && this.options.split !== 'none') { | |
| elements = elements.map((el) => | |
| el.type === 'message' ? el : h('message', el) | |
| ) | |
| } | |
| let elements = this.splitter.writeText(text) | |
| if (this.options.split && this.options.split !== 'none' && elements.length > 0) { | |
| elements = elements.some((el) => el.type === 'message') | |
| ? elements | |
| : [h('message', ...elements)] | |
| } |
| let elements = this.splitter.flush() | ||
| if (this.options.split && this.options.split !== 'none') { | ||
| elements = elements.map((el) => | ||
| el.type === 'message' ? el : h('message', el) | ||
| ) | ||
| } |
There was a problem hiding this comment.
When split mode is enabled, mapping each individual element to a message element causes elements that are part of the same text block to be split into separate messages. Wrapping the entire array of elements in a single message element (unless it already contains message elements) preserves the integrity of the message structure.
| let elements = this.splitter.flush() | |
| if (this.options.split && this.options.split !== 'none') { | |
| elements = elements.map((el) => | |
| el.type === 'message' ? el : h('message', el) | |
| ) | |
| } | |
| let elements = this.splitter.flush() | |
| if (this.options.split && this.options.split !== 'none' && elements.length > 0) { | |
| elements = elements.some((el) => el.type === 'message') | |
| ? elements | |
| : [h('message', ...elements)] | |
| } |
This pr fixes split markdown/element rendering so each split part is sent as a separate message.
New Features
Bug Fixes
h('message')when split mode is enabled for text and koishi-element renderersOther Changes
koishi-plugin-chatlunato1.4.0-alpha.41and sync peer dependency rangesValidation