-
Notifications
You must be signed in to change notification settings - Fork 2.7k
feat: implement useSmoothStream hook for dynamic text rendering #8070
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
Open
MyPrototypeWhat
wants to merge
6
commits into
main
Choose a base branch
from
feat/smooth-stream
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+182
−22
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- Added a new custom hook `useSmoothStream` to manage smooth text streaming with adjustable delays. - Integrated `useSmoothStream` into the Markdown component to enhance content display during streaming. - Implemented logic to handle content updates and reset conditions based on block status.
- Updated the `addChunk` function to split text into characters for Chinese and words for English using a regular expression. - Improved text rendering logic to support mixed language content more effectively.
录屏帧率有限 可以切到分支体验一下 |
模型是 gemini 2.5 flash lite preview 06-14
|
看起来像是换行符被吞掉了一样 |
…hStream hook - Updated the regular expression to enhance text splitting capabilities, allowing for better handling of mixed language content, including Chinese characters and alphanumeric sequences.
正则的问题,改了一下 再看看 |
- Replaced the regular expression for character extraction with a direct conversion of the chunk to an array of characters. - This change streamlines the chunk processing logic, enhancing performance and readability.
@alephpiece 改成Array.from了 我试了下没问题了 |
开启网络搜索的时候,好像偶尔会出现链接标签闪烁 CherryStudio-PR8070.mp4 |
- Enhanced the Markdown component to accept an optional post-processing function for text manipulation during streaming. - Updated MainTextBlock to utilize the new postProcess prop, allowing for dynamic content adjustments based on citation references.
Fix cs0715.mp4 |
测试没过 |
- Modified the mock implementation of the Markdown component to accept and apply an optional postProcess function, ensuring that the test environment accurately reflects the updated functionality introduced in the previous commit.
ok了 |
DeJeune
approved these changes
Jul 16, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Smooth流功能:
hook
+markdown
接入即可smooth
流的同时自适应输出速度,与接口请求几乎同时完成,避免用户点击暂停时接口已完成smooth-stream.mp4