Skip to content
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

✨ (theme) Add progress bar option #1276

Merged
merged 4 commits into from
Feb 23, 2024
Merged

✨ (theme) Add progress bar option #1276

merged 4 commits into from
Feb 23, 2024

Conversation

baptisteArno
Copy link
Owner

@baptisteArno baptisteArno commented Feb 21, 2024

Summary by CodeRabbit

  • New Features
    • Introduced progress bar functionality across various components for a more interactive user experience.
    • Added progress tracking and display in chat sessions.
  • Enhancements
    • Adjusted layout height calculations in the settings and theme pages for consistency.
    • Improved theme customization options with progress bar styling and placement settings.
  • Bug Fixes
    • Fixed dynamic height calculation issues in settings and theme side menus by standardizing heights.
  • Style
    • Added custom styling properties for the progress bar in chat interfaces.

Copy link

vercel bot commented Feb 21, 2024

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

Name Status Preview Comments Updated (UTC)
builder-v2 ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 22, 2024 3:38pm
landing-page-v2 ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 22, 2024 3:38pm
viewer-v2 🔄 Building (Inspect) Visit Preview Feb 22, 2024 3:38pm

Copy link

coderabbitai bot commented Feb 21, 2024

Important

Auto Review Skipped

Auto reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository.

To trigger a single review, invoke the @coderabbitai review command.

Walkthrough

The updates mainly focus on integrating a progress bar into the application, affecting both the UI components and the bot engine's logic. The progress bar's appearance and behavior are governed by new constants and schemas, with specific changes to calculate and display progress in chat sessions. Additionally, adjustments were made to the settings and theme components for consistent height management, leveraging a shared headerHeight constant for layout consistency.

Changes

File(s) Change Summary
.../SettingsPage.tsx, .../ThemePage.tsx Imported headerHeight for height calculation adjustments.
.../SettingsSideMenu.tsx, .../ThemeSideMenu.tsx Modified height properties for layout consistency.
.../general/GeneralSettings.tsx Added progress bar functionality with imports and update handling.
.../chat/api/continueChat.ts, .../chat/api/startChat.ts, .../chat/api/startChatPreview.ts Integrated progress calculation and conditional assignment.
.../bot-engine/computeCurrentProgress.ts, .../bot-engine/continueBotFlow.ts, .../bot-engine/getNextGroup.ts, .../bot-engine/startSession.ts Added logic for progress tracking and metadata management.
.../embeds/js/src/assets/index.css, .../embeds/js/src/components/ProgressBar.tsx, .../embeds/js/src/utils/setCssVariablesValue.ts Introduced progress bar styling, component, and utility updates for theme management.
.../embeds/js/src/components/Bot.tsx, .../embeds/js/src/components/ConversationContainer/ConversationContainer.tsx Added progress bar initialization and update callback handling.
.../schemas/features/chat/schema.ts, .../schemas/features/chat/sessionState.ts, .../schemas/features/typebot/theme/constants.ts, .../schemas/features/typebot/theme/schema.ts Updated schemas and constants to support progress bar functionality.

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

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>.
    • Generate unit-tests for this file.
  • 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. Examples:
    • @coderabbitai generate unit tests for this file.
    • @coderabbitai modularize this function.
  • 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 generate interesting stats about this repository from git and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit tests.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • 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/coderabbit-overrides.v2.json

CodeRabbit Discord Community

Join our Discord Community to get help, request features, and share feedback.

Copy link

@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.

Review Status

Actionable comments generated: 4

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between eec5041 and d0f5f75.
Files selected for processing (22)
  • apps/builder/src/features/settings/components/SettingsPage.tsx (2 hunks)
  • apps/builder/src/features/settings/components/SettingsSideMenu.tsx (2 hunks)
  • apps/builder/src/features/theme/components/ThemePage.tsx (2 hunks)
  • apps/builder/src/features/theme/components/ThemeSideMenu.tsx (2 hunks)
  • apps/builder/src/features/theme/components/general/GeneralSettings.tsx (4 hunks)
  • apps/builder/src/features/theme/components/general/ProgressBarForm.tsx (1 hunks)
  • apps/viewer/src/features/chat/api/continueChat.ts (2 hunks)
  • apps/viewer/src/features/chat/api/startChat.ts (1 hunks)
  • apps/viewer/src/features/chat/api/startChatPreview.ts (1 hunks)
  • packages/bot-engine/computeCurrentProgress.ts (1 hunks)
  • packages/bot-engine/continueBotFlow.ts (1 hunks)
  • packages/bot-engine/getNextGroup.ts (1 hunks)
  • packages/bot-engine/startSession.ts (1 hunks)
  • packages/embeds/js/src/assets/index.css (2 hunks)
  • packages/embeds/js/src/components/Bot.tsx (7 hunks)
  • packages/embeds/js/src/components/ConversationContainer/ConversationContainer.tsx (3 hunks)
  • packages/embeds/js/src/components/ProgressBar.tsx (1 hunks)
  • packages/embeds/js/src/utils/setCssVariablesValue.ts (3 hunks)
  • packages/schemas/features/chat/schema.ts (1 hunks)
  • packages/schemas/features/chat/sessionState.ts (1 hunks)
  • packages/schemas/features/typebot/theme/constants.ts (2 hunks)
  • packages/schemas/features/typebot/theme/schema.ts (2 hunks)
Additional comments: 30
apps/builder/src/features/theme/components/ThemePage.tsx (1)
  • 5-11: > 📝 NOTE

This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [8-18]

The changes in ThemePage to use headerHeight for dynamic height calculation are correctly implemented and follow best practices for maintaining layout consistency.

apps/builder/src/features/settings/components/SettingsPage.tsx (1)
  • 6-12: > 📝 NOTE

This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [9-19]

The use of headerHeight in SettingsPage for dynamic height calculation is correctly implemented, enhancing layout consistency with the progress bar feature.

packages/schemas/features/typebot/theme/constants.ts (1)
  • 35-47: > 📝 NOTE

This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [11-45]

The addition of progressBarPlacements, progressBarPositions, and their incorporation into the defaultTheme object are well-implemented, promoting consistency and maintainability for progress bar settings.

apps/viewer/src/features/chat/api/startChatPreview.ts (1)
  • 86-86: The conditional assignment of the progress property in startChatPreview is correctly implemented. Ensure that the consumer code correctly handles the presence or absence of this property.

Ensure that the consumer code correctly handles the progress property, especially its absence, to avoid potential issues.

apps/viewer/src/features/chat/api/startChat.ts (1)
  • 99-99: The addition of a conditional progress property in startChat is correctly implemented. As with startChatPreview, ensure the consumer code properly handles the presence or absence of this property.

Verify that the consumer code correctly handles the progress property to ensure a smooth user experience.

packages/schemas/features/typebot/theme/schema.ts (1)
  • 59-72: The introduction of progressBarSchema and its inclusion in generalThemeSchema are well-implemented, allowing for customizable progress bar settings within the theme schema.
apps/viewer/src/features/chat/api/continueChat.ts (1)
  • 97-118: The enhancements in continueChat to compute and return the progress property based on the chat session's state are correctly implemented. Ensure that the handling of the progress property is consistent and correctly managed across the application.

Verify that the handling of the progress property is consistent across the application to ensure a seamless user experience.

apps/builder/src/features/theme/components/general/ProgressBarForm.tsx (1)
  • 18-100: The ProgressBarForm component is well-structured and correctly implements form inputs for configuring the progress bar's appearance and behavior. The use of defaultTheme for default values and controlled components aligns with best practices.
apps/builder/src/features/settings/components/SettingsSideMenu.tsx (1)
  • 54-54: The change to use a fixed height of "full" in SettingsSideMenu simplifies the layout and ensures the component occupies the entire available vertical space, which is a positive change for UI consistency.
apps/builder/src/features/theme/components/general/GeneralSettings.tsx (4)
  • 9-9: The import of ProgressBar from @typebot.io/schemas is correctly added to support the new progress bar feature in the theme settings.
  • 27-27: The import of ProgressBarForm component is correctly added, which is essential for rendering the progress bar settings form in the UI.
  • 67-68: The updateProgressBar function is correctly implemented to update the progress bar settings in the theme. It ensures that any changes made through the ProgressBarForm are reflected in the theme's general settings.
  • 134-139: The usage of ProgressBarForm within the GeneralSettings component is correctly implemented. It passes the current progress bar settings from the theme and provides a callback to update these settings, ensuring a seamless user experience for configuring the progress bar.
packages/bot-engine/getNextGroup.ts (1)
  • 73-79: The logic added to update progressMetadata by incrementing totalAnswers based on the answers length of the first item in typebotsQueue is correctly implemented. This change is crucial for accurately tracking the user's progress through the session.
packages/schemas/features/chat/sessionState.ts (1)
  • 84-88: The addition of the progressMetadata field to the sessionStateSchemaV2 object is correctly implemented. This new field, which includes a totalAnswers property of type number, is essential for tracking the user's progress in a session.
apps/builder/src/features/theme/components/ThemeSideMenu.tsx (1)
  • 63-63: The change to use a fixed height value (h="full") for the ThemeSideMenu component is correctly implemented. This adjustment ensures that the component's layout is consistent and accommodates the new progress bar feature effectively.
packages/embeds/js/src/utils/setCssVariablesValue.ts (4)
  • 22-29: The addition of the progressBar object with properties under cssVariableNames.general is correctly implemented. This setup is essential for defining CSS variables related to the progress bar's styling, ensuring a customizable appearance.
  • 60-70: The modification of setCssVariablesValue to accept an additional isPreview parameter is correctly implemented. This change allows for conditional styling adjustments based on whether the theme is being previewed, which is particularly relevant for the progress bar's position.
  • 89-93: The update to setGeneralTheme to include the isPreview parameter and call setProgressBar with this parameter is correctly implemented. This ensures that the progress bar's styling can be dynamically adjusted based on the preview state.
  • 96-133: The addition of the setProgressBar function is correctly implemented. This function handles setting CSS variables related to the progress bar's styling, including its position, color, background color, height, and placement. The conditional logic for the position property based on the isPreview state is particularly noteworthy, as it ensures the progress bar is displayed correctly in both preview and live modes.
packages/embeds/js/src/components/Bot.tsx (5)
  • 3-3: The import of isDefined is correctly added to support conditional rendering based on the progress bar's state.
  • 21-21: The import of ProgressBar is correctly added to support the display of the progress bar within the bot's UI.
  • 133-140: The logic to re-initialize the bot when the progress bar is enabled but not previously enabled in the initial chat reply is a thoughtful addition. However, ensure that this re-initialization does not lead to any unintended side effects or duplicate API calls.
  • 202-204: Creating a signal for progressValue based on the initialChatReply.progress is a clean way to manage the progress bar's state. This ensures that the progress bar accurately reflects the user's progress through the session.
  • 242-249: The conditional rendering of the ProgressBar component based on the progressValue and the progress bar's enabled state in the theme settings is correctly implemented. This ensures that the progress bar is only displayed when appropriate.
packages/schemas/features/chat/schema.ts (1)
  • 313-318: The addition of the progress field to the chatResponseBaseSchema with a description indicating its purpose and constraints is well-documented and correctly implemented. This field is essential for supporting the progress bar feature by providing a way to communicate the user's current progress through the chat session.
packages/embeds/js/src/assets/index.css (2)
  • 34-39: The custom properties for the Typebot progress bar's styling, including its position, background color, color, height, top, and bottom properties, are correctly defined. These properties provide a flexible way to customize the progress bar's appearance.
  • 411-427: The CSS rules for the .typebot-progress-bar-container and its child .typebot-progress-bar are correctly defined, ensuring the progress bar is styled according to the custom properties. The use of var() to apply the custom properties and the transition effect for the width change are best practices for a smooth user experience.
packages/embeds/js/src/components/ConversationContainer/ConversationContainer.tsx (1)
  • 67-67: The addition of the onProgressUpdate callback to the Props type is a good practice for extending functionality in a type-safe manner. This allows for a clean way to handle progress updates externally.
packages/bot-engine/startSession.ts (1)
  • 140-144: The conditional addition of progressMetadata to the session state object is well-implemented, taking into account the presence of initialSessionState.whatsApp and whether the progress bar is enabled in typebot.theme.general. This approach ensures that progressMetadata is only added when relevant, which is a good practice for maintaining clean and relevant state objects.

However, it's important to ensure that the rest of the system correctly handles the presence or absence of progressMetadata in the session state, especially in functions that consume this state.

Verification successful

The verification process has confirmed that the application correctly handles progressMetadata across various components, including session state management, progress computation, and user interface updates. The codebase demonstrates a consistent approach to managing this data, ensuring that progressMetadata is effectively integrated and utilized where necessary. This aligns with the initial review comment's emphasis on the importance of handling progressMetadata correctly throughout the system.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Verify that functions consuming session state handle progressMetadata correctly.
# This is a placeholder for the actual verification logic, which would depend on the specific usage of session state throughout the application.
echo "Verification logic to be implemented based on application specifics."

Length of output: 146



Script:

#!/bin/bash
# Search for references to 'progressMetadata' in the codebase to see how it's handled.
rg "progressMetadata" --context 5

Length of output: 9462

Copy link

@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.

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between d0f5f75 and 41ff1ff.
Files ignored due to path filters (3)
  • packages/embeds/js/package.json is excluded by: !**/*.json
  • packages/embeds/nextjs/package.json is excluded by: !**/*.json
  • packages/embeds/react/package.json is excluded by: !**/*.json
Files selected for processing (1)
  • packages/embeds/js/src/components/Bot.tsx (7 hunks)
Files skipped from review as they are similar to previous changes (1)
  • packages/embeds/js/src/components/Bot.tsx

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.

1 participant