Skip to content

Enhance Bot component with scroll management and new features#348

Merged
HenryHengZJ merged 3 commits into
mainfrom
feature/Streaming-Flickering
Mar 6, 2026
Merged

Enhance Bot component with scroll management and new features#348
HenryHengZJ merged 3 commits into
mainfrom
feature/Streaming-Flickering

Conversation

@HenryHengZJ

Copy link
Copy Markdown
Contributor
  • Added scroll handling to show/hide a button based on scroll position.
  • Introduced programmatic scroll guard to manage scrolling behavior.
  • Updated message handling to improve user experience with audio playback and message updates.
  • Integrated new utility function getRecordingExtensionForMime for better file handling.
  • Added new StopButton component and ChevronDownIcon for UI enhancements.
  • Updated CSS for improved scrollbar visibility and behavior across browsers.

- Added scroll handling to show/hide a button based on scroll position.
- Introduced programmatic scroll guard to manage scrolling behavior.
- Updated message handling to improve user experience with audio playback and message updates.
- Integrated new utility function `getRecordingExtensionForMime` for better file handling.
- Added new `StopButton` component and `ChevronDownIcon` for UI enhancements.
- Updated CSS for improved scrollbar visibility and behavior across browsers.
@gemini-code-assist

Copy link
Copy Markdown

Summary of Changes

Hello, 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 enhances the Bot component with improved scroll management, new UI features, and updated message handling. The changes aim to provide a smoother user experience, especially regarding audio playback and message updates. Additionally, it introduces a utility function for better file handling and improves CSS for cross-browser compatibility.

Highlights

  • Scroll Management: Implemented scroll handling to show/hide a button based on the scroll position, enhancing user experience.
  • Programmatic Scroll Guard: Introduced a programmatic scroll guard to manage scrolling behavior, ensuring smooth transitions.
  • Message Handling: Improved message handling to enhance user experience with audio playback and message updates.
  • UI Enhancements: Added new UI components like StopButton and ChevronDownIcon to improve the interface.
  • File Handling: Integrated a new utility function getRecordingExtensionForMime for better file handling.
  • CSS Updates: Improved scrollbar visibility and behavior across different browsers with CSS updates.
Changelog
  • dist/components/Bot.d.ts.map
    • Updated type definitions for the Bot component to reflect changes in props and functionality.
  • dist/components/buttons/StopButton.d.ts
    • Added type definitions for the new StopButton component.
  • dist/components/buttons/StopButton.d.ts.map
    • Added source map for the new StopButton component.
  • dist/components/icons/ChevronDownIcon.d.ts
    • Added type definitions for the new ChevronDownIcon component.
  • dist/components/icons/ChevronDownIcon.d.ts.map
    • Added source map for the new ChevronDownIcon component.
  • dist/components/icons/index.d.ts
    • Exported the new ChevronDownIcon component.
  • dist/components/icons/index.d.ts.map
    • Updated source map to include the new ChevronDownIcon component.
  • dist/components/inputs/textInput/components/TextInput.d.ts
    • Updated type definitions for the TextInput component to include new props related to loading and aborting messages.
  • dist/components/inputs/textInput/components/TextInput.d.ts.map
    • Updated source map for the TextInput component to reflect new props.
  • dist/queries/sendMessageQuery.d.ts
    • Added type definitions and declaration for abortMessageQuery.
  • dist/queries/sendMessageQuery.d.ts.map
    • Updated source map to include abortMessageQuery.
  • dist/utils/index.d.ts
    • Added type definitions for the new getRecordingExtensionForMime utility function.
  • dist/utils/index.d.ts.map
    • Updated source map to include getRecordingExtensionForMime.
  • rollup.config.js
    • Modified rollup configuration to conditionally include uglify and terser plugins based on the isDev variable, and added headers to the serve plugin configuration.
  • src/assets/index.css
    • Updated CSS to improve scrollbar visibility and behavior across browsers, including auto-hiding on touch devices.
  • src/components/Bot.tsx
    • Implemented scroll handling, programmatic scroll guard, message updates, and integrated new components and utility functions.
  • src/components/buttons/StopButton.tsx
    • Added a new StopButton component.
  • src/components/icons/ChevronDownIcon.tsx
    • Added a new ChevronDownIcon component.
  • src/components/icons/index.ts
    • Exported the new ChevronDownIcon component.
  • src/components/inputs/textInput/components/TextInput.tsx
    • Updated TextInput component to include abort functionality and loading state.
  • src/queries/sendMessageQuery.ts
    • Added abortMessageQuery to allow aborting message sending.
  • src/utils/index.ts
    • Added getRecordingExtensionForMime utility function to determine file extension based on MIME type.
Activity
  • Added scroll handling to show/hide a button based on scroll position.
  • Introduced programmatic scroll guard to manage scrolling behavior.
  • Updated message handling to improve user experience with audio playback and message updates.
  • Integrated new utility function getRecordingExtensionForMime for better file handling.
  • Added new StopButton component and ChevronDownIcon for UI enhancements.
  • Updated CSS for improved scrollbar visibility and behavior across browsers.
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

- Added a new function `hasAgentFlowExecutedData` to determine if the last message contains agent flow execution data.
- Updated the `showAbortButton` prop to conditionally display based on the loading state and agent flow execution status.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request introduces several significant enhancements to the Bot component, including scroll management with a 'scroll to bottom' button, refactoring to use immutable patterns instead of lodash.cloneDeep, and a message abort feature with a new StopButton and corresponding API call. It also includes better audio handling, improved scrollbar styling, and dynamic file extension for audio recordings. However, a critical security vulnerability was identified in the newly added abortMessageQuery function, where unsanitized variables are used to construct an API URL, potentially leading to path traversal attacks. This must be addressed by URL-encoding the path parameters. Additionally, a couple of suggestions have been made to further improve code clarity and robustness in the new handleAbort and handleTTSStart functions.

I am having trouble creating individual review comments. Click here to see my feedback.

src/queries/sendMessageQuery.ts (192-197)

security-medium medium

The abortMessageQuery function constructs an API URL by concatenating chatflowid and chatId directly into the URL path without proper sanitization or URL encoding. If an attacker can influence these values (for example, through a user-controlled customerId in the chatflowConfig), they could use path traversal sequences like ../ to manipulate the request path. This could allow them to target unauthorized API endpoints on the server.

To remediate this, use encodeURIComponent() for all variables inserted into the URL path to ensure they are properly escaped.

  sendRequest<any>({
    method: 'PUT',
    url: `${apiHost}/api/v1/chatmessage/abort/${encodeURIComponent(chatflowid)}/${encodeURIComponent(chatId)}`,
    onRequest: onRequest,
  });

src/components/Bot.tsx (988-1002)

medium

To avoid code duplication and ensure setIsMessageStopping(false) is always called after the async operation, whether it succeeds or fails, you can use a finally block. This makes the code cleaner and more robust.

  const handleAbort = async () => {
    setIsMessageStopping(true);
    try {
      await abortMessageQuery({
        chatflowid: props.chatflowid,
        apiHost: props.apiHost,
        chatId: chatId(),
        onRequest: props.onRequest,
      });
    } catch (error) {
      console.error('Error aborting message:', error);
    } finally {
      setIsMessageStopping(false);
    }
  };

src/components/Bot.tsx (1863-1875)

medium

The logic to update the message ID can be simplified for better readability and maintainability. Using the nullish coalescing operator (??) can make the intent clearer and the code more concise.

    setMessages((prevMessages) => {
      const lastMsg = prevMessages[prevMessages.length - 1];
      if (lastMsg.type === 'userMessage') return prevMessages;

      const newId = lastMsg.id ?? lastMsg.messageId ?? data.chatMessageId;
      if (newId && newId !== lastMsg.id) {
        const allMessages = [...prevMessages.slice(0, -1), { ...lastMsg, id: newId }];
        addChatMessage(allMessages);
        return allMessages;
      }

      return prevMessages;
    });

@HenryHengZJ HenryHengZJ merged commit e84e04d into main Mar 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant