Repository navigation
fix(core): wrap split render parts as messages #976
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -74,7 +74,12 @@ class KoishiElementStreamSession implements RenderStreamSession { | |||||||||||||||||||||||||
| return transformAndEscape([h.text(this.text + '●')]) | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| const elements = this.splitter.writeText(text) | ||||||||||||||||||||||||||
| 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) | ||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
|
Comment on lines
+77
to
+82
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When
Suggested change
|
||||||||||||||||||||||||||
| return elements.length > 0 ? elements : null | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
|
|
@@ -84,7 +89,12 @@ class KoishiElementStreamSession implements RenderStreamSession { | |||||||||||||||||||||||||
| return transformAndEscape([h.text(this.text)]) | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| const elements = this.splitter.flush() | ||||||||||||||||||||||||||
| let elements = this.splitter.flush() | ||||||||||||||||||||||||||
| if (this.options.split && this.options.split !== 'none') { | ||||||||||||||||||||||||||
| elements = elements.map((el) => | ||||||||||||||||||||||||||
| el.type === 'message' ? el : h('message', el) | ||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
|
Comment on lines
+92
to
+97
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When
Suggested change
|
||||||||||||||||||||||||||
| return elements.length > 0 ? elements : null | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When
splitmode is enabled, mapping each individual element to amessageelement 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
messageelement (unless it already containsmessageelements).