Skip to content

✨ feat: Transition animation switch #7981

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
wants to merge 22 commits into
base: main
Choose a base branch
from

Conversation

Wxh16144
Copy link
Contributor

@Wxh16144 Wxh16144 commented May 26, 2025

💻 变更类型 | Change Type

  • ✨ feat
  • 🐛 fix
  • ♻️ refactor
  • 💄 style
  • 👷 build
  • ⚡️ perf
  • 📝 docs
  • 🔨 chore

🔀 变更说明 | Description of Change

背景: #7885

📝 补充信息 | Additional Information

Kapture.2025-05-27.at.13.39.15.mp4

Copy link

vercel bot commented May 26, 2025

@Wxh16144 is attempting to deploy a commit to the LobeHub OSS Team on Vercel.

A member of the Team first needs to authorize it.

@dosubot dosubot bot added the size:L This PR changes 100-499 lines, ignoring generated files. label May 26, 2025
@lobehubbot
Copy link
Member

👍 @Wxh16144

Thank you for raising your pull request and contributing to our Community
Please make sure you have followed our contributing guidelines. We will review it as soon as possible.
If you encounter any problems, please feel free to connect with us.
非常感谢您提出拉取请求并为我们的社区做出贡献,请确保您已经遵循了我们的贡献指南,我们会尽快审查它。
如果您遇到任何问题,请随时与我们联系。

@dosubot dosubot bot added the 🌠 Feature Request New feature or request | 特性与建议 label May 26, 2025
Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Summary

This PR implements a user-configurable animation toggle for chat messages, allowing users to switch between smooth transitions and typing effects.

  • Added bubbleTransition setting in UserGeneralConfig with options 'smooth' (default) and 'typing'
  • Implemented visual selector in ChatAppearance settings with preview images for both animation modes
  • Modified Thinking and ChatItem components to respect the animation preference
  • Updated SSE fetch logic to properly handle text smoothing based on selected animation mode
  • Integrated animation toggle across markdown elements and reasoning components for consistent behavior

💡 (2/5) Greptile learns from your feedback when you react with 👍/👎!

11 file(s) reviewed, 7 comment(s)
Edit PR Review Bot Settings | Greptile

Comment on lines 149 to 152
transition={{
duration: 0.2,
ease: [0.4, 0, 0.2, 1], // 使用 ease-out 缓动函数
}}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: Chinese comment in English codebase. Keep comments consistent in English.

@@ -23,9 +25,18 @@ const Render = memo<MarkdownElementProps>(({ children, id }) => {
return message?.search?.citations;
});

const bubbleTransition = useUserStore(userGeneralSettingsSelectors.bubbleTransition);

if (!isGenerating && !children) return;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: missing explicit return type (undefined) - could cause unexpected rendering behavior

Copy link

codecov bot commented May 26, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.67%. Comparing base (585e386) to head (6dee9b3).
Report is 3 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7981      +/-   ##
==========================================
+ Coverage   88.45%   95.67%   +7.21%     
==========================================
  Files         822       14     -808     
  Lines       60394     2519   -57875     
  Branches     4008      444    -3564     
==========================================
- Hits        53424     2410   -51014     
+ Misses       6970      109    -6861     
Flag Coverage Δ
app ?
server 95.67% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@Wxh16144
Copy link
Contributor Author

先 review 一下吧,看看字段名和逻辑是否符合要求。之后再进行翻译,否则太阻碍 review 了

@lobehubbot
Copy link
Member

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


Review first and see if the field name and logic meet the requirements. Translate it later, otherwise it will be too hindered from review

@Wxh16144 Wxh16144 changed the title WIP feat: Transition animation switch ✨ feat: Transition animation switch May 27, 2025
Copy link

vercel bot commented May 27, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
lobe-chat-preview ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 27, 2025 4:12am

@arvinxx
Copy link
Contributor

arvinxx commented May 27, 2025

感觉可以考虑加一个 无动画 选项做个对比?🤔

@lobehubbot
Copy link
Member

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


I feel like you can consider adding an animation-free option to compare it? 🤔

@Wxh16144
Copy link
Contributor Author

感觉可以考虑加一个 无动画 选项做个对比?🤔

怎么理解这句话呢?无动画是一个啥状态,在旁边再加一个选项么?

@lobehubbot
Copy link
Member

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


I feel like you can consider adding an animation-free option to compare it? 🤔

How do you understand this sentence? What is the state of no animation? Will there be another option next to it?

Wxh16144 and others added 3 commits May 28, 2025 17:11
- branch: wuxh/feat-bubble-2
- date: 2025-05-28 18:13:36
- commit: 06abda1

---------- original commit message ----------

fix: update transitionMode type and refactor fetchSSE handling
@entelligence-ai-reviews

Review Summary

Skipped posting 1 drafted comments based on your review threshold. Feel free to update them here.

Draft Comments
src/utils/fetch/__tests__/fetchSSE.test.ts:125-338
The test expects individual character messages for smoothing, but the test implementation might not be correctly validating the smoothing behavior since the test was previously skipped.

Scores:

  • Production Impact: 3
  • Fix Specificity: 2
  • Urgency Impact: 3
  • Total Score: 8

Reason for filtering: The comment identifies a potential correctness issue in a test that was previously skipped and may not be correctly validating smoothing behavior

Analysis: This comment identifies a test that might not be correctly validating smoothing behavior. While this is a test issue rather than production code, incorrect tests can allow bugs to slip through. The fix direction is somewhat vague, requiring investigation into how smoothing should be properly tested. The urgency is medium as incorrect tests can lead to future issues but won't immediately break anything.

@entelligence-ai-reviews

Walkthrough

This PR introduces user-configurable chat message transition modes ('smooth' and 'stream') to enhance chat appearance customization. It adds an animated chat preview component, updates settings and localization to support the new feature, and refactors chat rendering logic to respect user preferences for animation. Smoothing options are now more flexible and integrated into the chat completion flow, with corresponding updates to selectors, types, and tests to ensure consistency and coverage.

Changes

File(s) Summary
src/app/[variants]/(main)/settings/common/features/ChatAppearance/AnimatedChatPreview.tsx Added new AnimatedChatPreview component for animated markdown chat previews.
src/app/[variants]/(main)/settings/common/features/ChatAppearance/index.tsx Integrated AnimatedChatPreview and transition mode selector into ChatAppearance settings.
src/locales/default/setting.ts Added localization for transitionMode settings and options.
src/const/settings/common.ts
src/types/user/settings/general.ts Added 'transitionMode' property to default settings and user config types.
src/store/user/slices/settings/selectors/general.ts Added transitionMode selector and exported it.
src/store/user/slices/settings/selectors/general.test.ts Updated tests to include transitionMode in expected settings.
src/features/Conversation/Messages/Assistant/Reasoning/index.tsx
src/features/Conversation/components/ChatItem/index.tsx
src/features/Conversation/components/MarkdownElements/LobeThinking/Render.tsx
src/features/Conversation/components/MarkdownElements/Thinking/Render.tsx Updated components to use transitionMode for controlling animation (via thinkingAnimated/animated props).
src/components/Thinking/index.tsx Refactored to accept thinkingAnimated prop for granular animation control.
src/services/chat.ts Added support for smoothing parameter, merging user, provider, and option configs; added normalizeSmoothing utility.
src/utils/fetch/fetchSSE.ts Made textSmoothing configurable based on smoothing option.
src/utils/fetch/tests/fetchSSE.test.ts Enabled and updated smoothing test to expect granular message output.

Sequence Diagram

This diagram shows the interactions between components:

sequenceDiagram
    title AnimatedChatPreview Component Interactions
    
    participant User
    participant AnimatedChatPreview
    participant useState
    participant useEffect
    participant ChatItem
    participant ActionIconGroup
    
    User->>AnimatedChatPreview: Render component
    AnimatedChatPreview->>useState: Initialize streamedContent (empty string)
    AnimatedChatPreview->>useState: Initialize isStreaming (true)
    AnimatedChatPreview->>useEffect: Setup streaming effect
    
    Note over useEffect: Effect runs when component mounts<br/>or when isStreaming changes
    
    alt isStreaming is true
        useEffect->>useEffect: Set up interval timer (25ms)
        
        loop Until text is fully streamed
            useEffect->>useEffect: Calculate next chunk size
            useEffect->>useState: Update streamedContent
            useState-->>ChatItem: Render updated content
            
            alt Current position >= data length
                useEffect->>useEffect: Clear interval
                useEffect->>useState: Set isStreaming to false
            end
        end
    end
    
    AnimatedChatPreview->>ChatItem: Render with current streamedContent
    AnimatedChatPreview->>ActionIconGroup: Create reset button
    
    User->>ActionIconGroup: Click reset button
    ActionIconGroup->>AnimatedChatPreview: Call handleReset()
    AnimatedChatPreview->>useState: Set streamedContent to empty string
    AnimatedChatPreview->>useState: Set isStreaming to true
    Note over useEffect: Effect re-triggers due to<br/>isStreaming dependency change
    
    useState-->>ChatItem: Re-render with empty content
    useEffect-->>ChatItem: Begin streaming text again
Loading

▶️AI Code Reviews for VS Code, Cursor, Windsurf
Install the extension

Note for Windsurf Please change the default marketplace provider to the following in the windsurf settings:

Marketplace Extension Gallery Service URL: https://marketplace.visualstudio.com/_apis/public/gallery

Marketplace Gallery Item URL: https://marketplace.visualstudio.com/items

Entelligence.ai can learn from your feedback. Simply add 👍 / 👎 emojis to teach it your preferences. More shortcuts below

Emoji Descriptions:

  • ⚠️ Potential Issue - May require further investigation.
  • 🔒 Security Vulnerability - Fix to ensure system safety.
  • 💻 Code Improvement - Suggestions to enhance code quality.
  • 🔨 Refactor Suggestion - Recommendations for restructuring code.
  • ℹ️ Others - General comments and information.

Interact with the Bot:

  • Send a message or request using the format:
    @entelligenceai + *your message*
Example: @entelligenceai Can you suggest improvements for this code?
  • Help the Bot learn by providing feedback on its responses.
    @entelligenceai + *feedback*
Example: @entelligenceai Do not comment on `save_auth` function !

Also you can trigger various commands with the bot by doing
@entelligenceai command

The current supported commands are

  1. config - shows the current config
  2. retrigger_review - retriggers the review

More commands to be added soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🌠 Feature Request New feature or request | 特性与建议 size:L This PR changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants