feat: add selected option to commands for pre-selection#2817
Open
Br1an67 wants to merge 1 commit intoChainlit:mainfrom
Open
feat: add selected option to commands for pre-selection#2817Br1an67 wants to merge 1 commit intoChainlit:mainfrom
Br1an67 wants to merge 1 commit intoChainlit:mainfrom
Conversation
Add 'selected' boolean to CommandDict/ICommand. When set, the command is automatically pre-selected in the composer on load, enabling persistence across page refreshes via backend state.
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
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.
What
Add a
selectedboolean option to commands that enables pre-selecting a command when the page loads.Closes #2141
Why
Command selection resets on page refresh. Developers need a way to persist the selected command state by setting it from the backend (e.g. from a cached value).
Changes
backend/chainlit/types.py: Addselected: Optional[bool]toCommandDictlibs/react-client/src/types/command.ts: Addselected?: booleantoICommandfrontend/src/components/chat/MessageComposer/index.tsx: AdduseEffectthat auto-selects the command markedselected: Truewhen commands are received (only if no command is already selected)Usage
Testing
Backward compatible — commands without
selectedwork exactly as before. Theselectedflag is only honored when no command is already user-selected.Summary by cubic
Adds a selected option to commands to pre-select a command on load. This lets the backend persist command state across refreshes, addressing #2141.
Written for commit 0bccfa2. Summary will update on new commits.