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

⚡ Restore chat state when user is remembered #1333

Merged
merged 2 commits into from
Mar 7, 2024

Conversation

baptisteArno
Copy link
Owner

@baptisteArno baptisteArno commented Mar 7, 2024

Closes #993

Summary by CodeRabbit

  • New Features

    • Added a detailed explanation page for the "Remember user" setting in the app documentation.
    • Introduced persistence of chat state across sessions, with options for local or session storage.
    • Enhanced bot functionality to store and retrieve initial chat replies and manage bot open state with improved storage handling.
    • Added a new callback for chat state persistence to bot component props.
  • Improvements

    • Updated the general settings form to clarify the description of the "Remember user" feature.
    • Enhanced custom CSS handling and progress value persistence in bot components.
    • Added conditional transition disabling in various components for smoother user experiences.
    • Simplified the handling of onTransitionEnd across multiple bubble components.
  • Refactor

    • Renamed inputIndex to chunkIndex or index in various components for consistency.
    • Removed unused ESLint disable comments related to reactivity rules.
    • Adjusted import statements and cleaned up code across several files.
  • Bug Fixes

    • Fixed potential issues with undefined callbacks by introducing optional chaining in component props.

Copy link

coderabbitai bot commented Mar 7, 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

This update introduces a significant enhancement to the "Remember user" feature, focusing on saving and restoring the chat state across user sessions. It involves changes across multiple files, from adding new utility functions for managing chat state in web storage to updating components for handling transitions and persistence. The primary goal is to ensure a seamless user experience by maintaining chat continuity, with added attention to security and data integrity in the storage mechanism.

Changes

Files Change Summary
GeneralSettingsForm.tsx, .../settings/overview.mdx, .../settings/remember-user.mdx Updated and added documentation for the "Remember user" feature, detailing its functionality and storage options.
.../.eslintrc.cjs, .../utils/injectStartProps.ts, .../window.ts Disabled Solid.js reactivity linting and adjusted related imports.
.../components/Bot.tsx, .../components/ConversationContainer/..., .../components/InputChatBlock.tsx, .../components/bubbles/..., .../features/blocks/inputs/..., .../features/bubble/components/Bubble.tsx, .../features/popup/components/Popup.tsx Enhanced chat state persistence, added handling for custom CSS, improved progress value persistence, and updated component properties for transition handling.
.../types.ts, .../utils/persist.ts, .../utils/storage.ts Added types and utility functions for managing chat state and bot opened state in storage, and for data persistence.

Assessment against linked issues

Objective Addressed Explanation
Add a new option for "Remember user" functionality to save the chat state. (#993)
Enable the chat application to display the saved state on the user's second visit. (#993)
Implement a mechanism to persist and retrieve the chat state data securely. (#993)
Ensure the saved chat state is accurately restored without loss of information. (#993)
Provide a seamless user experience by maintaining continuity across visits through the saved chat state. (#993)
Consider security implications and implement appropriate measures to protect the stored data. (#993) The summary mentions storage options and persistence but does not detail security measures.
Document the new feature and its implementation details for future reference and maintenance. (#993)
Test the functionality thoroughly to guarantee the reliability and effectiveness of the "Remember user" option. (#993) The summary does not mention specific tests, focusing solely on code changes.

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

vercel bot commented Mar 7, 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 Mar 7, 2024 2:27pm
landing-page-v2 ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 7, 2024 2:27pm
viewer-v2 🔄 Building (Inspect) Visit Preview Mar 7, 2024 2:27pm

@baptisteArno
Copy link
Owner Author

@coderabbitai review

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: 1

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 583294f and 4de47ab.
Files ignored due to path filters (4)
  • apps/docs/mint.json is excluded by: !**/*.json
  • 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 (26)
  • apps/builder/src/features/settings/components/GeneralSettingsForm.tsx (2 hunks)
  • apps/docs/settings/overview.mdx (1 hunks)
  • apps/docs/settings/remember-user.mdx (1 hunks)
  • packages/embeds/js/.eslintrc.cjs (1 hunks)
  • packages/embeds/js/src/components/Bot.tsx (6 hunks)
  • packages/embeds/js/src/components/ConversationContainer/AvatarSideContainer.tsx (2 hunks)
  • packages/embeds/js/src/components/ConversationContainer/ChatChunk.tsx (6 hunks)
  • packages/embeds/js/src/components/ConversationContainer/ConversationContainer.tsx (4 hunks)
  • packages/embeds/js/src/components/InputChatBlock.tsx (6 hunks)
  • packages/embeds/js/src/components/bubbles/HostBubble.tsx (1 hunks)
  • packages/embeds/js/src/features/blocks/bubbles/audio/components/AudioBubble.tsx (4 hunks)
  • packages/embeds/js/src/features/blocks/bubbles/embed/components/CustomEmbedBubble.tsx (4 hunks)
  • packages/embeds/js/src/features/blocks/bubbles/embed/components/EmbedBubble.tsx (3 hunks)
  • packages/embeds/js/src/features/blocks/bubbles/image/components/ImageBubble.tsx (4 hunks)
  • packages/embeds/js/src/features/blocks/bubbles/textBubble/components/TextBubble.tsx (3 hunks)
  • packages/embeds/js/src/features/blocks/bubbles/video/components/VideoBubble.tsx (4 hunks)
  • packages/embeds/js/src/features/blocks/inputs/buttons/components/Buttons.tsx (2 hunks)
  • packages/embeds/js/src/features/blocks/inputs/buttons/components/MultipleChoicesForm.tsx (1 hunks)
  • packages/embeds/js/src/features/blocks/inputs/number/components/NumberInput.tsx (1 hunks)
  • packages/embeds/js/src/features/bubble/components/Bubble.tsx (7 hunks)
  • packages/embeds/js/src/features/popup/components/Popup.tsx (4 hunks)
  • packages/embeds/js/src/types.ts (1 hunks)
  • packages/embeds/js/src/utils/injectStartProps.ts (1 hunks)
  • packages/embeds/js/src/utils/persist.ts (1 hunks)
  • packages/embeds/js/src/utils/storage.ts (2 hunks)
  • packages/embeds/js/src/window.ts (1 hunks)
Files skipped from review due to trivial changes (1)
  • packages/embeds/js/src/features/blocks/inputs/buttons/components/MultipleChoicesForm.tsx
Additional comments: 55
packages/embeds/js/.eslintrc.cjs (1)
  • 9-9: Adding the rule 'solid/reactivity': 'off' disables the Solid.js reactivity linting rule. It's crucial to ensure that this decision doesn't negatively impact code quality, especially in a project that leverages Solid.js for its reactive capabilities. Could you provide more context on the rationale behind disabling this rule? It might be beneficial to consider enabling it to catch potential reactivity issues early in the development process.
packages/embeds/js/src/types.ts (1)
  • 14-14: The addition of the storage field to the BotContext type is a positive step towards achieving the PR's objectives of enhancing user experience through chat state persistence. It's recommended to add documentation or comments explaining the use of this field, especially the scenarios where undefined might be used, to provide clarity for future maintainers and developers.
apps/docs/settings/remember-user.mdx (1)
  • 6-13: The documentation for the "Remember user" feature is clear and informative, effectively explaining the functionality and the distinction between local and session storage options. To enhance clarity, consider adding examples or use cases that illustrate when one might prefer local storage over session storage and vice versa. This could help users make more informed decisions based on their specific needs.
packages/embeds/js/src/utils/injectStartProps.ts (1)
  • 1-1: The adjustments in import statements and the removal of the eslint-disable solid/reactivity comment are noted. While these changes likely aim to improve code quality and maintainability, it's important to ensure that the removal of the eslint-disable comment doesn't lead to overlooked reactivity issues in Solid.js components. Please ensure that this change has been thoroughly tested.
packages/embeds/js/src/components/ConversationContainer/AvatarSideContainer.tsx (1)
  • 5-8: The addition of the isTransitionDisabled property to the Props type in AvatarSideContainer is a thoughtful enhancement that offers more control over animations. To improve maintainability and clarity for future developers, consider adding documentation or comments explaining the scenarios in which disabling transitions might be desirable.
packages/embeds/js/src/features/blocks/bubbles/embed/components/EmbedBubble.tsx (1)
  • 10-10: The update making the onTransitionEnd property optional in the EmbedBubble component enhances flexibility and customization. To aid future developers and maintainers, it would be beneficial to document the scenarios in which the onTransitionEnd callback is expected to be used and its impact on the component's behavior.
packages/embeds/js/src/features/blocks/bubbles/audio/components/AudioBubble.tsx (1)
  • 10-10: The modifications to make the onTransitionEnd property optional in the AudioBubble component are well-considered, offering greater flexibility in how the component is used. Similar to previous suggestions, documenting the onTransitionEnd property's purpose and usage scenarios would be beneficial for clarity and maintainability.
packages/embeds/js/src/features/blocks/bubbles/embed/components/CustomEmbedBubble.tsx (1)
  • 10-10: The update making the onTransitionEnd property optional in the CustomEmbedBubble component is a positive change that enhances flexibility. Documenting the onTransitionEnd property's intended use and scenarios would further improve the component's clarity and maintainability.
packages/embeds/js/src/utils/storage.ts (5)
  • 1-2: Imports for InitialChatReply and defaultSettings have been added. Ensure that these imports are used appropriately within the file and that there are no unused imports to maintain code cleanliness.
  • 4-4: The renaming of sessionStorageKey to storageResultIdKey is a good practice for clarity and better reflects the purpose of the key. Ensure that all references to this key throughout the codebase have been updated accordingly to avoid any broken functionality.
Verification successful

The script execution did not find any occurrences of sessionStorageKey within JavaScript files in the codebase, suggesting that the renaming to storageResultIdKey has been successfully reflected throughout. This aligns with the goal of ensuring all references to this key have been updated accordingly.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Search for old key usage to ensure it's fully replaced.
rg --type js "sessionStorageKey"

Length of output: 32

* 32-65: The addition of `getInitialChatReplyFromStorage` and `setInitialChatReplyInStorage` functions is crucial for managing the initial chat reply state. It's important to ensure that error handling is consistent and that any potential exceptions are caught and handled appropriately to avoid breaking the chat application's flow. * 67-89: The functions `setBotOpenedStateInStorage`, `removeBotOpenedStateInStorage`, and `getBotOpenedStateFromStorage` are added to manage the bot's opened state. This is a good approach to track the bot's visibility state across sessions. However, consider adding logging for the catch blocks to help with debugging in case of errors.
+ console.error("Error managing bot opened state in storage:", error);
  • 91-96: The parseRememberUserStorage function simplifies the selection between local and session storage based on settings. This is a clean and efficient way to handle storage preferences. Ensure that the default setting aligns with the application's privacy and persistence requirements.
packages/embeds/js/src/components/bubbles/HostBubble.tsx (2)
  • 24-24: Making the onTransitionEnd function optional in the Props type is a good practice for flexibility, allowing components to be used in contexts where transition end handling is not necessary. This change enhances the component's reusability.
  • 28-70: The direct passing of onTransitionEnd and onCompleted from props to the respective components without intermediate functions simplifies the code and reduces unnecessary complexity. This is a good example of the KISS (Keep It Simple, Stupid) principle in action. Ensure that all components receiving these props are properly handling them, especially with onTransitionEnd now being optional.
apps/docs/settings/overview.mdx (1)
  • 17-17: Linking the "Remember user" setting to a separate page for more details is a user-friendly approach, providing users with a dedicated resource to understand the feature better. Ensure that the linked page is comprehensive and covers all necessary details about the "Remember user" functionality, including how the chat state is saved and restored.
packages/embeds/js/src/features/blocks/inputs/buttons/components/Buttons.tsx (2)
  • 10-10: Renaming the inputIndex prop to chunkIndex in the Props type declaration improves clarity, as it better describes the purpose of the prop within the context of handling chunks of input. Ensure that all instances where this prop is used have been updated accordingly to maintain consistency.
Verification successful

The renaming of the inputIndex prop to chunkIndex appears to have been thoroughly completed, as no instances of the old prop name were found in the JavaScript files. This suggests that the refactoring was successful and consistent throughout the codebase.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Search for old prop usage to ensure it's fully replaced.
rg --type js "inputIndex"

Length of output: 25

* 69-69: The conditional check using `chunkIndex` to determine if a ping animation should be shown is a good use of the renamed prop. This logic ensures that the animation is only applied under specific conditions, enhancing the user interface's dynamic aspects. Ensure that the logic aligns with the intended user experience and that the animation behaves as expected across different scenarios.
packages/embeds/js/src/features/blocks/bubbles/textBubble/components/TextBubble.tsx (2)
  • 14-14: Making the onTransitionEnd function optional in the Props type increases the component's flexibility, allowing it to be used in various contexts without requiring a transition end handler. This change is a good practice for component design.
  • 23-31: The conditional initialization of the isTyping state based on the presence of props.onTransitionEnd is a smart way to optimize the component's behavior based on its usage context. This ensures that typing animations are only processed when necessary, potentially improving performance. Ensure that this logic does not inadvertently affect the expected behavior in scenarios where onTransitionEnd is not provided.
packages/embeds/js/src/features/blocks/bubbles/image/components/ImageBubble.tsx (2)
  • 10-10: Making the onTransitionEnd function optional in the Props type is a thoughtful change that enhances the component's versatility. This allows for more flexible usage of the ImageBubble component in different contexts where transition end handling may not be necessary.
  • 19-33: > 📝 NOTE

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

The conditional initialization of the isTyping state and the dynamic setting of class names based on the presence of props.onTransitionEnd are well-implemented. These changes ensure that the component behaves appropriately based on whether transition end handling is required, improving the user experience by optimizing the display and animation of images. Verify that the conditional logic does not introduce any unintended side effects in scenarios where onTransitionEnd is not provided.

apps/builder/src/features/settings/components/GeneralSettingsForm.tsx (1)
  • 85-91: > 📝 NOTE

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

Updating the description related to remembering the user to emphasize restoring the chat state when the user returns after exiting is a valuable clarification. This change helps set clear expectations for the feature's behavior. Ensure that the description is consistent with the implemented functionality and that it is clearly communicated to users in the UI.

packages/embeds/js/src/features/blocks/bubbles/video/components/VideoBubble.tsx (3)
  • 18-18: Making the onTransitionEnd function optional in the Props type for the VideoBubble component is a good practice that increases the component's flexibility. This allows for its use in various contexts without the need for transition end handling, which can be particularly useful for video content that may not always require such functionality.
  • 15-31: > 📝 NOTE

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

The conditional initialization of the isTyping state based on the presence of props.onTransitionEnd is a thoughtful approach to optimize the component's behavior. This ensures that typing animations and related transitions are only processed when necessary. It's important to verify that this conditional logic does not affect the expected behavior in scenarios where onTransitionEnd is not provided, ensuring a smooth user experience.

  • 49-61: > 📝 NOTE

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

Conditionally setting the autoplay attribute of the video element based on the presence of props.onTransitionEnd is a clever way to control video playback behavior. This ensures that videos do not autoplay in contexts where a transition end event is expected to trigger playback, providing a more controlled and potentially less intrusive user experience. Ensure that this behavior aligns with user expectations and that it is tested across different browsers for consistency.

packages/embeds/js/src/features/popup/components/Popup.tsx (5)
  • 15-19: The import statements for getBotOpenedStateFromStorage, removeBotOpenedStateInStorage, and setBotOpenedStateInStorage are correctly added to manage the bot's opened state using storage utilities. This aligns with the PR's objective to enhance the chat application's user experience by remembering users and their chat states across sessions. Ensure that these utility functions are thoroughly tested, especially for edge cases where storage might be inaccessible (e.g., in private browsing modes).
  • 43-50: The logic within onMount to determine if the bot should be opened initially is well-structured and considers multiple conditions: defaultOpen, an ongoing payment process, and the bot's opened state from storage. This comprehensive approach ensures a seamless user experience by restoring the chat state accurately. However, consider adding comments to explain the rationale behind each condition for future maintainability.
  • 107-107: The call to removeBotOpenedStateInStorage within the closeBot function ensures that the bot's opened state is correctly reset when the bot is closed. This is crucial for maintaining the integrity of the user's session state. It's important to verify that this action does not inadvertently affect the user's experience, especially in scenarios where the user might close and reopen the bot in quick succession.
  • 114-117: The handleOnChatStatePersisted function is a thoughtful addition, allowing for the execution of a callback when the chat state is persisted, and conditionally calling setBotOpenedStateInStorage if the state is indeed persisted. This encapsulates the logic for handling chat state persistence neatly. However, ensure that the isPersisted flag accurately reflects the success of the chat state persistence operation, including error handling and potential failure scenarios.
  • 150-154: The updated Bot component invocation now includes the onChatStatePersisted prop, which is correctly passed the handleOnChatStatePersisted function. This change effectively integrates the chat state persistence functionality into the bot's behavior. It's essential to ensure that the Bot component and its props are well-documented, especially regarding how the onChatStatePersisted callback is expected to be used by the component.
packages/embeds/js/src/components/ConversationContainer/ChatChunk.tsx (5)
  • 15-20: The renaming of inputIndex to index and the addition of isTransitionDisabled prop are clear and straightforward. These changes align with the PR's objective to enhance chat functionality by potentially disabling transitions for certain chat chunks. This could improve performance or user experience under specific conditions.
  • 30-32: The initialization of displayedMessageIndex based on isTransitionDisabled prop is a logical change. By setting the displayedMessageIndex to the length of messages when transitions are disabled, it ensures that all messages are displayed immediately without waiting for transitions. This is a smart way to handle scenarios where animations or transitions are not desired, improving the chat's responsiveness.
  • 87-87: Passing the isTransitionDisabled prop to the AvatarSideContainer component is a good practice, ensuring that the behavior of child components aligns with the parent's state. This consistency is crucial for maintaining a predictable and coherent user experience across the chat interface.
  • 114-119: The conditional handling of onTransitionEnd based on isTransitionDisabled prop is well-implemented. By setting onTransitionEnd to undefined when transitions are disabled, it effectively skips the transition end handling, which is unnecessary in this context. This change optimizes performance by avoiding the execution of transition-related logic when it's not needed.
  • 131-131: Renaming inputIndex to chunkIndex in the InputChatBlock component call is consistent with the renaming done in the rest of the file. This consistency is important for readability and maintainability of the code. Ensuring that terminology is uniform across related components helps developers understand the codebase more easily.
packages/embeds/js/src/features/bubble/components/Bubble.tsx (5)
  • 17-21: The addition of storage utility functions (getBotOpenedStateFromStorage, removeBotOpenedStateInStorage, setBotOpenedStateInStorage) is a significant improvement for managing the bot's open state persistently. This change enhances the user experience by remembering the bot's state across sessions, aligning with the PR's objectives to improve chat functionality and user engagement.
  • 68-69: Using getBotOpenedStateFromStorage to determine whether to automatically open the bot on mount is a practical application of the newly added storage functions. This behavior supports the seamless user experience by restoring the bot's previous state, making the chat interaction more intuitive and less disruptive for returning users.
  • 119-119: The call to removeBotOpenedStateInStorage upon closing the bot ensures that the bot's open state is accurately reflected in the storage. This cleanup is essential for maintaining the integrity of the bot's state management, preventing potential discrepancies between the actual state and the stored state.
  • 153-156: The implementation of handleOnChatStatePersisted is a thoughtful addition, allowing for custom handling of chat state persistence events. This function not only triggers a callback with the persistence result but also calls setBotOpenedStateInStorage when the state is persisted, further enhancing the bot's state management capabilities.
  • 207-207: Passing handleOnChatStatePersisted as a prop to the Bot component is a good practice, ensuring that the bot component can react to chat state persistence events. This integration facilitates a more dynamic and responsive chat experience, allowing for additional actions or feedback based on the persistence outcome.
packages/embeds/js/src/components/InputChatBlock.tsx (5)
  • 39-39: The introduction of the persist import from @/utils/persist is a key change that suggests enhancements in how the component handles state persistence. This import is crucial for implementing the persistence logic that follows, indicating a shift towards more robust and maintainable state management practices.
  • 53-62: > 📝 NOTE

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

Renaming inputIndex to chunkIndex and modifying the state initialization for answer to include persistence settings based on context and chunk index are significant improvements. These changes not only enhance the clarity and consistency of the code but also introduce a more sophisticated approach to managing user input, ensuring that the chat state is preserved across sessions in a secure and efficient manner.

  • 74-74: Updating references to inputIndex to use chunkIndex within the createEffect hook is a necessary adjustment following the renaming. This consistency is important for ensuring that the logic operates correctly with the updated variable names, maintaining the integrity of the component's functionality.
  • 108-108: The propagation of the chunkIndex renaming to the Input component call within the InputChatBlock component is correctly implemented. This change ensures that all parts of the component are aligned with the new naming convention, contributing to the overall readability and maintainability of the code.
  • 124-124: The consistent use of chunkIndex in the Input component's props further demonstrates the thorough application of the renaming throughout the component. This attention to detail is commendable, as it helps prevent potential bugs and confusion that could arise from inconsistent naming.
packages/embeds/js/src/components/ConversationContainer/ConversationContainer.tsx (3)
  • 35-35: The addition of the persist import from @/utils/persist is a foundational change that sets the stage for the persistence-related modifications in this file. This import is essential for enabling the persistence functionality that follows, indicating a strategic enhancement to the component's state management capabilities.
  • 73-84: Modifying the initialization of chatChunks to use persist with additional configuration is a significant improvement. This change ensures that the chat chunks are persisted across sessions, enhancing the user experience by maintaining chat continuity. The use of a specific key and storage option based on the context is a thoughtful approach to ensuring that the persistence is both effective and contextually appropriate.
  • 283-289: > 📝 NOTE

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

Adjusting the ChatChunk component usage by changing the inputIndex prop to index and adding the isTransitionDisabled prop based on index comparison is a logical and necessary update. These changes align with the modifications in the ChatChunk component and introduce a mechanism to control transitions dynamically, contributing to a more refined and customizable chat experience.

packages/embeds/js/src/components/Bot.tsx (6)
  • 11-12: The addition of getInitialChatReplyFromStorage and setInitialChatReplyInStorage functions is crucial for the feature's functionality. Ensure that these functions properly handle edge cases and errors, such as invalid or corrupted data in storage.
  • 25-26: The import of defaultSettings and persist utilities is a good practice for maintaining consistency and leveraging existing functionality for data persistence. Verify that these utilities are used correctly throughout the file.
  • 42-42: The addition of onChatStatePersisted to BotProps is a thoughtful way to provide callbacks for the state persistence outcome. Ensure that this callback is invoked appropriately in all relevant scenarios.
  • 119-148: The logic for storing and retrieving the initial chat replies based on the rememberUser settings and the resultId is well-structured. However, consider adding error handling for potential issues with storage access or data serialization.
  • 207-216: The conditional logic for determining the storage mechanism based on the rememberUser settings is clear and concise. Ensure that the default settings are correctly applied when specific settings are not provided.
  • 242-247: The use of the persist utility to manage the progress value with local or session storage is a good approach for enhancing the user experience. Verify that the key used for storage (typebot-${props.context.typebot.id}-progressValue) is unique and does not conflict with other stored data.

packages/embeds/js/src/utils/persist.ts Show resolved Hide resolved
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.

New option for "Remember user": save the chat state to display it again on second visit.
1 participant