fix(markdown): strengthen streaming tail fade#7303
Open
c121914yu wants to merge 1 commit into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adjusts the “streaming tail” animation for Markdown rendering so that newly appended streamed text fades in from fully transparent to fully visible, matching the intended streaming UX and aligning timing/easing with the referenced LobeHub approach.
Changes:
- Updated the Web Animations API keyframes to fade from
opacity: 0to1and aligned duration/easing via shared constants. - Added a CSS keyframes-based fade-in under the streaming “waiting” state as a fallback when WAAPI isn’t available.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| projects/app/src/components/Markdown/index.tsx | Aligns stream-tail WAAPI fade-in keyframes and timing/easing constants. |
| projects/app/src/components/Markdown/index.module.scss | Adds CSS fade-in keyframes and applies it to .stream-tail during waitingAnimation. |
Comments suppressed due to low confidence (1)
projects/app/src/components/Markdown/index.tsx:94
- MarkdownStreamTailRenderer’s JSDoc says CSS is only a fallback when Web Animations API is unavailable, but
.waitingAnimation .stream-tailnow always runs a CSS animation. In browsers that support WAAPI, this means the fade may run twice (CSS on initial paint, then WAAPI on layout effect), which can cause a visible restart/flicker and makes the behavior harder to reason about.
/** 仅让最新流式文本批次执行淡入;CSS 会为不支持 Web Animations API 的浏览器兜底。 */
function MarkdownStreamTailRenderer({ children }: any) {
const ref = useRef<HTMLSpanElement>(null);
useBrowserLayoutEffect(() => {
const element = ref.current;
if (!element?.animate) return;
const animation = element.animate(
[
{ opacity: 0, transform: 'translateY(1px)' },
{ opacity: 1, transform: 'translateY(0)' }
],
{
duration: STREAM_TAIL_FADE_DURATION_MS,
easing: STREAM_TAIL_FADE_EASING,
fill: 'both'
}
);
return () => animation.cancel();
}, [children]);
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
1
to
20
| .waitingAnimation { | ||
| :global(.stream-tail) { | ||
| display: inline; | ||
| will-change: opacity, filter, transform; | ||
| opacity: 0; | ||
| will-change: opacity, transform; | ||
| animation: streamTailFadeIn 280ms cubic-bezier(0.33, 0, 0.67, 1) both; | ||
| } | ||
| } | ||
|
|
||
| @keyframes streamTailFadeIn { | ||
| from { | ||
| opacity: 0; | ||
| transform: translateY(1px); | ||
| } | ||
|
|
||
| to { | ||
| opacity: 1; | ||
| transform: translateY(0); | ||
| } | ||
| } |
|
✅ Build Successful - Preview fastgpt Image for this PR: 🕒 Time: 2026-07-14 18:09:18 (UTC+8) |
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
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.
Summary
Verification
Reference: https://github.com/lobehub/lobehub