Skip to content

Conversation

@yyhhyyyyyy
Copy link
Collaborator

@yyhhyyyyyy yyhhyyyyyy commented Aug 26, 2025

add loading animation to scroll-to-bottom button during generation

CleanShot 2025-08-26 at 11 12 55

Summary by CodeRabbit

  • New Features

    • Added New Chat button when not generating; Cancel remains during generation.
    • Unified bottom action bar to show context-appropriate controls.
    • Scroll-to-bottom button now also appears while generating.
    • Added loading ring/animation to indicate active generation.
  • Style

    • Updated button styling and labels, including Chinese translations for clarity.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Aug 26, 2025

Walkthrough

UI logic in MessageList.vue was revised to use a persistent bottom action container that shows either Cancel (while generating) or New Chat (when idle). The scroll-to-bottom button now appears when aboveThreshold or generating, gains a loading style during generation, and includes new CSS with spin animation for a visual loading ring.

Changes

Cohort / File(s) Summary of changes
Message list UI and controls
src/renderer/src/components/message/MessageList.vue
Replaced conditional single-div with a persistent flex container hosting Cancel or New Chat based on generation state; broadened scroll-to-bottom visibility to also show during generation; added conditional loading class and CSS (pseudo-elements + spin keyframes); updated labels/comments; no public API signature changes.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor User
  participant MessageList
  participant ScrollObserver as Scroll State
  participant Generation as Generation State

  rect rgb(245,248,255)
    note over MessageList: Idle state
    ScrollObserver->>MessageList: aboveThreshold = true/false
    alt aboveThreshold == true
      MessageList->>User: Show "Scroll to bottom" button
    else aboveThreshold == false
      MessageList->>User: Hide button
    end
    User->>MessageList: Click "New Chat"
    MessageList->>Generation: startNewChat()
  end

  rect rgb(255,248,240)
    note over MessageList: Generating state
    Generation-->>MessageList: showCancelButton = true
    MessageList->>User: Show Cancel + loading-ring on bottom button
    User->>MessageList: Click "Cancel"
    MessageList->>Generation: cancelGeneration()
    Generation-->>MessageList: showCancelButton = false
    MessageList->>User: Switch to "New Chat", remove loading-ring
  end

  User->>MessageList: Click bottom button
  MessageList->>MessageList: scrollToBottom()
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

I thump my foot—new chats appear,
A spinning ring says “wait right here.”
If thoughts run long, I scroll below,
If plans go wrong, I cancel flow.
Two buttons dance in tidy sync—
Hop, tap, create, as quick as a wink. 🐇✨

Tip

🔌 Remote MCP (Model Context Protocol) integration is now available!

Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats.

✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/scroll-to-bottom-loading-animation

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.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (4)
src/renderer/src/components/message/MessageList.vue (4)

34-41: Use English comments and add type="button" to avoid implicit form submits

  • Per repo guidelines, comments/logs should be in English. Please translate the inline comment.
  • Add type="button" on the Button to prevent accidental form submissions if this component is ever nested inside a form.
-        <!-- 取消按钮 -->
+        <!-- Cancel button -->
         <Button
           v-if="showCancelButton"
           variant="outline"
           size="sm"
-          class="rounded-lg"
+          class="rounded-lg"
+          type="button"
           @click="handleCancel"
         >

50-57: Translate comment to English and add type="button"

  • Keep comments in English to meet the codebase guideline.
  • Explicitly set type="button" on the Button.
-        <!-- 新聊天按钮 (仅在非生成状态显示) -->
+        <!-- New chat button (only when not generating) -->
         <Button
           v-if="!showCancelButton"
           variant="outline"
           size="sm"
           class="rounded-lg shrink-0"
+          type="button"
           @click="createNewThread"
         >

420-474: Loading ring CSS: support reduced motion and remove duplicate positioning

  • Respect users with reduced motion preferences by disabling the spin animation.
  • position: relative is already applied via the template class; remove duplication here.
  • Optionally keep the ring behind content with an explicit z-index on ::after.
 .scroll-to-bottom-loading {
-  position: relative;
   overflow: visible;
 }
@@
 .scroll-to-bottom-loading::after {
   content: '';
   position: absolute;
@@
   animation: spin 1.2s linear infinite;
   pointer-events: none;
   will-change: transform;
+  z-index: 0;
 }
 
 @keyframes spin {
   to {
     transform: rotate(360deg);
   }
 }
+
+@media (prefers-reduced-motion: reduce) {
+  .scroll-to-bottom-loading::after {
+    animation: none;
+  }
+}

368-371: Optional: Enhance clarity of the showCancelButton computed

I verified that generatingThreadIds is initialized as a reactive Set<string> and is consistently mutated via .add()/.delete() in src/renderer/src/stores/chat.ts, so Vue will correctly track Set.has calls. The existing code works as intended; the suggested change is purely a readability nit.

• Location: src/renderer/src/components/message/MessageList.vue lines 368–371
• Current implementation reacts to generatingThreadIds.has(activeThreadId || ''), which safely handles undefined but embeds the default here.
• Proposed tweak pulls out the ID and uses an explicit truthiness check, making the intent more obvious.

-const showCancelButton = computed(() => {
-  return chatStore.generatingThreadIds.has(chatStore.getActiveThreadId() ?? '')
-})
+const showCancelButton = computed(() => {
+  const id = chatStore.getActiveThreadId()
+  return !!id && chatStore.generatingThreadIds.has(id)
+})
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 80768f6 and c72cc2e.

📒 Files selected for processing (1)
  • src/renderer/src/components/message/MessageList.vue (3 hunks)
🧰 Additional context used
📓 Path-based instructions (9)
**/*.{ts,tsx,js,jsx,vue}

📄 CodeRabbit inference engine (CLAUDE.md)

Use English for logs and comments

Files:

  • src/renderer/src/components/message/MessageList.vue
src/renderer/src/**/*.vue

📄 CodeRabbit inference engine (CLAUDE.md)

src/renderer/src/**/*.vue: Use Composition API for all Vue 3 components
Use Tailwind CSS with scoped styles for styling
Organize components by feature in src/renderer/src/
Follow existing component patterns in src/renderer/src/ when creating new UI components
Use Composition API with proper TypeScript typing for new UI components
Implement responsive design with Tailwind CSS for new UI components
Add proper error handling and loading states for new UI components

Use scoped styles to prevent CSS conflicts between components

Files:

  • src/renderer/src/components/message/MessageList.vue
src/renderer/src/**/*.{ts,tsx,vue}

📄 CodeRabbit inference engine (CLAUDE.md)

src/renderer/src/**/*.{ts,tsx,vue}: Use Pinia for frontend state management
Renderer to Main: Use usePresenter.ts composable for direct presenter method calls

Files:

  • src/renderer/src/components/message/MessageList.vue
src/renderer/src/**/*

📄 CodeRabbit inference engine (.cursor/rules/i18n.mdc)

src/renderer/src/**/*: All user-facing strings must use i18n keys (avoid hardcoded user-visible text in code)
Use the 'vue-i18n' framework for all internationalization in the renderer
Ensure all user-visible text in the renderer uses the translation system

Files:

  • src/renderer/src/components/message/MessageList.vue
src/renderer/**/*.{vue,ts,js,tsx,jsx}

📄 CodeRabbit inference engine (.cursor/rules/project-structure.mdc)

渲染进程代码放在 src/renderer

Files:

  • src/renderer/src/components/message/MessageList.vue
src/renderer/src/**/*.{vue,ts,tsx,js,jsx}

📄 CodeRabbit inference engine (.cursor/rules/vue-best-practices.mdc)

src/renderer/src/**/*.{vue,ts,tsx,js,jsx}: Use the Composition API for better code organization and reusability
Implement proper state management with Pinia
Utilize Vue Router for navigation and route management
Leverage Vue's built-in reactivity system for efficient data handling

Files:

  • src/renderer/src/components/message/MessageList.vue
src/renderer/**/*.{ts,tsx,vue}

📄 CodeRabbit inference engine (.cursor/rules/vue-shadcn.mdc)

src/renderer/**/*.{ts,tsx,vue}: Use descriptive variable names with auxiliary verbs (e.g., isLoading, hasError).
Use TypeScript for all code; prefer types over interfaces.
Avoid enums; use const objects instead.
Use arrow functions for methods and computed properties.
Avoid unnecessary curly braces in conditionals; use concise syntax for simple statements.

Files:

  • src/renderer/src/components/message/MessageList.vue
src/renderer/**/*.{vue,ts}

📄 CodeRabbit inference engine (.cursor/rules/vue-shadcn.mdc)

Implement lazy loading for routes and components.

Files:

  • src/renderer/src/components/message/MessageList.vue
src/renderer/**/*.{ts,vue}

📄 CodeRabbit inference engine (.cursor/rules/vue-shadcn.mdc)

src/renderer/**/*.{ts,vue}: Use useFetch and useAsyncData for data fetching.
Implement SEO best practices using Nuxt's useHead and useSeoMeta.

Files:

  • src/renderer/src/components/message/MessageList.vue
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: build-check (x64)
🔇 Additional comments (1)
src/renderer/src/components/message/MessageList.vue (1)

71-78: Add missing i18n key and improve the icon-only button for accessibility

It looks like the translation key common.scrollToBottom is not defined in any of your locale files under src/renderer/src/i18n/**/common.json. Please add entries in each locale before using t('common.scrollToBottom').

• In each /src/renderer/src/i18n/<locale>/common.json, add:

{
  // …existing keys…
  "scrollToBottom": "Scroll to Bottom"
}

(and the appropriate translations in non-en files)

• Update the <Button> in src/renderer/src/components/message/MessageList.vue as follows:

-          <Button
-            v-if="aboveThreshold || showCancelButton"
-            variant="outline"
-            size="icon"
-            :class="[
-              'w-8 h-8 shrink-0 rounded-lg relative',
-              showCancelButton ? 'scroll-to-bottom-loading' : ''
-            ]"
-            @click="scrollToBottom"
-          >
+          <Button
+            v-if="aboveThreshold || showCancelButton"
+            variant="outline"
+            size="icon"
+            :class="[
+              'w-8 h-8 shrink-0 rounded-lg relative',
+              { 'scroll-to-bottom-loading': showCancelButton }
+            ]"
+            :aria-label="t('common.scrollToBottom')"
+            :title="t('common.scrollToBottom')"
+            :aria-busy="showCancelButton"
+            type="button"
+            @click="scrollToBottom"
+          >
             <!-- icon-only content -->
           </Button>

• These changes:

  • Simplify the conditional class binding (object syntax)
  • Add aria-label/title via i18n
  • Expose loading state with aria-busy
  • Explicitly set type="button"

@zerob13 zerob13 merged commit 6a5868e into dev Aug 26, 2025
2 checks passed
@zerob13 zerob13 deleted the feat/scroll-to-bottom-loading-animation branch January 6, 2026 12:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants