[Fix] simplify message splitting logic and cleanup voice renderers#712
[Fix] simplify message splitting logic and cleanup voice renderers#712dingyi222666 merged 2 commits intov1-devfrom
Conversation
- Replace manual text parsing and token rendering with message.toString() - Improve reliability and consistency of message splitting in VoiceRenderer and MixedVoiceRenderer
- Bump version to 1.3.18 - Remove unused marked imports and helper functions in voice renderers - Minor formatting improvements in text and voice renderers
Summary of ChangesHello @dingyi222666, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request focuses on refining the internal message processing within the voice rendering components, leading to more robust and maintainable code. It streamlines how messages are prepared for voice output and removes unnecessary external dependencies, contributing to a leaner and more efficient codebase. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
|
Caution Review failedThe pull request is closed. 功能概述本次变更从 变更详情
估算代码审查工作量🎯 2 (简单) | ⏱️ ~10 分钟 相关的拉取请求
诗歌
✨ Finishing touches
🧪 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 does a great job of simplifying the message splitting logic in the voice renderers and cleaning up the code by removing unused dependencies. The changes make the code more concise and easier to understand.
However, I've identified a critical issue in the new implementation of _splitMessage in both VoiceRenderer and MixedVoiceRenderer. The use of Array.prototype.flatMap() with a callback that returns a string will cause the string to be treated as an array of characters, which is not the intended behavior. This would lead to the voice renderer receiving individual characters instead of whole sentences. I've left comments with suggestions to fix this by using map() instead.
Once this is addressed, the PR will be in great shape.
| return tokens | ||
| }) | ||
| .filter(Boolean) | ||
| return messages.flatMap((message) => message.toString()).filter(Boolean) |
There was a problem hiding this comment.
Using flatMap with a function that returns a string will iterate over the characters of the string, effectively splitting the message strings into individual characters. This is likely not the intended behavior, as it will cause the voice renderer to process single characters instead of full strings. You should use map instead to transform each message element into a string.
| return messages.flatMap((message) => message.toString()).filter(Boolean) | |
| return messages.map((message) => message.toString()).filter(Boolean) |
| return tokens | ||
| }) | ||
| .filter(Boolean) | ||
| return messages.flatMap((message) => message.toString()).filter(Boolean) |
There was a problem hiding this comment.
Using flatMap with a function that returns a string will iterate over the characters of the string, effectively splitting the message strings into individual characters. This is likely not the intended behavior, as it will cause the voice renderer to process single characters instead of full strings. You should use map instead to transform each message element into a string.
| return messages.flatMap((message) => message.toString()).filter(Boolean) | |
| return messages.map((message) => message.toString()).filter(Boolean) |
This pr simplifies the message splitting logic in voice renderers by using
message.toString()and removes unused dependencies and helper functions.New Features
None
Bug fixes
VoiceRendererandMixedVoiceRenderer.Other Changes
markedandTokenimports and related helper functions (renderToken,renderTokens).TextRenderer,VoiceRenderer, andMixedVoiceRenderer.koishi-plugin-chatluna(core) version to 1.3.18.