-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Add Toggle-able Buttons on Chat and Enhance information panel persistence and state management and step Collapse #2088
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
lengyueyang
wants to merge
7
commits into
Chainlit:main
Choose a base branch
from
lengyueyang:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This commit implements a complete separation between toggleable buttons and standard commands, allowing developers to independently define and configure these two distinct types of interactive UI elements. Key features: - Created dedicated IToggleCommand interface distinct from ICommand - Added new backend method set_toggle_commands for setting toggleable buttons - Implemented toggleCommandsState for frontend state management - Updated frontend components to use the new toggle command state - Added persistent toggle functionality that preserves state between message submissions Technical implementation: - Added ToggleCommandDict type in backend and removed toggleable property from CommandDict - Created toggleCommandsState for frontend state management - Modified ToggleableButtons component to use the new toggleCommand state - Added socket event handling for set_toggle_commands events - Implemented automatic reset of non-persistent toggles after message submission - Created demo example showing how to use separated toggle commands Usage example: ```python commands = [ {"id": "Search", "icon": "globe", "description": "Web search", "button": True} ] toggle_commands = [ {"id": "Debug", "icon": "bug", "description": "Show debug info", "persistent": True}, {"id": "Thinking", "icon": "brain", "description": "Show thinking process"} ] @cl.on_chat_start async def start(): await cl.context.emitter.set_commands(commands) await cl.context.emitter.set_toggle_commands(toggle_commands) ``` This implementation enhances UI interaction flexibility and provides developers with more granular control options. ```
…gement - Implement localStorage for saving panel data and title - Add visibility change listeners to restore state when returning from other tabs - Optimize state update logic to reduce unnecessary re-renders - Maintain global state in backend to ensure panel visibility after message interactions - Add data validation logic to prevent rendering with empty data These improvements ensure users can continuously view the information panel throughout their chat session, including after sending messages, refreshing the page, and navigating back from other pages.
This was referenced Apr 3, 2025
This commit includes several UX enhancements to the Chainlit components: 1. Step Component: - Add 'collapse' property to automatically collapse completed steps - Steps with 'collapse=True' will fold up once they're finished - Maintain backward compatibility with existing 'default_open' behavior 2. InfoPanel Component: - Improve InfoPanel behavior to hide by default when no data is sent - Add session-based tracking to prevent showing stale data across sessions - Clear localStorage when new sessions begin without panel data 3. Action Component: - Add customization options including background color and text color - Support 'fullWidth' layout for actions that should appear one per line - Implement custom styling through 'variant', 'size', and 'className' props - Fix icon display issues in fullWidth buttons by adding proper spacing - Optimize responsive layout for better mobile experience Each feature includes accompanying example files demonstrating usage patterns.
This was referenced Apr 3, 2025
Fixed the following issues: 1. When starter.toggle_commands is an empty array, all toggleables (including persistent ones) are now set to inactive, making behavior consistent with commands handling 2. Fixed UI state and backend message synchronization issues, ensuring toggleables sent to backend match UI display 3. Improved state update logic, distinguishing between empty array and undefined toggle_commands 4. Added detailed logging for debugging and tracking state changes Changes: - Optimized toggle_commands handling logic in Starter.tsx - Enhanced state monitoring in ToggleableButtons component - Added debug logs to track toggleables state changes - Fixed synchronization issues between state updates and message sending ```
This commit improves the history refresh mechanism by: - Simplifying the `trigger_history_refresh` function to focus on the primary refresh method - Moving history refresh from chat start to chat end to ensure updates are visible after session completion - Removing redundant refresh attempts to improve performance - Adding clearer logging messages for better debugging and monitoring - Restructuring the code for better maintainability These changes ensure that thread history is properly refreshed when needed, providing a better user experience while improving application efficiency.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Separate toggleable buttons from commands
This commit implements a complete separation between toggleable buttons and standard commands, allowing developers to independently define and configure these two distinct types of interactive UI elements.
Key features:
Technical implementation:
Usage example:
This implementation enhances UI interaction flexibility and provides developers with more granular control options.
feat(InfoPanel): Enhance information panel persistence and state management
These improvements ensure users can continuously view the information panel throughout their chat session, including after sending messages, refreshing the page, and navigating back from other pages.