-
Notifications
You must be signed in to change notification settings - Fork 2
feat(Combobox): add create to combobox #319
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
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR is being reviewed by Cursor Bugbot
Details
Your team is on the Bugbot Free tier. On this plan, Bugbot will review limited PRs each billing cycle for each member of your team.
To receive Bugbot reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.
Bug: Conflicting UI elements in empty search state.
When no filtered items match the search but createOptions is provided, both the "No option found" message and the create option are displayed simultaneously. The empty state message should be suppressed when the create option is available and there's search text, as the create option provides a valid action.
src/components/Combobox/index.tsx#L163-L165
moonshine/src/components/Combobox/index.tsx
Lines 163 to 165 in 44bab5c
| <CommandItem disabled>{errorText}</CommandItem> | |
| ) : filteredItems.length === 0 ? ( | |
| <CommandItem disabled>{emptyText}</CommandItem> |
| const { renderCreatePrompt, handleCreate } = createOptions | ||
| return ( | ||
| <CommandGroup> | ||
| <CommandItem onSelect={() => handleCreate(search)}> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: Ensure consistent popover behavior on creation.
When the create option is selected, the popover remains open and the search text isn't cleared. This differs from selecting a regular option, which closes the popover and clears the search via handleSelect. The handleCreate callback should trigger the same cleanup behavior for consistent UX.
Allows attaching environments to sources for all callers. This introduces the distinction between a System Environment and User Configuration to the system. These names might be stupid but they attempt to get around the idea that Headers are more of an implementation detail and the rules associated with how you merge these things should be derived from their provenance rather than how they were supplied. We make some decisions. First off, we complect the call sites of tool proxies by placing the onus of loading on them. This was more or less in the name of purity of the tools proxy. But might be a mistake because it forces the onus of reading system environments to a bunch of places in our code base. It's possible it's a little bug-prone to do this nonsense in a bunch of places. The other decision, which I feel a little better about is to provide both environments to each tool type and leave the responsibility of merging them at the call site. Even though we aim for consistent behavior (ie. preferring user config over system environment), leaving the flexibility on how to merge each tool type seems healthy. ## UX A dialog attached to source cards. Not good. Affordance to access functionality is currently buried behind: <img width="720" height="391" alt="image" src="https://github.com/user-attachments/assets/fce5cd45-7b45-4485-a26a-346c44e817a5" /> The interface for attaching an environment is implemented in this modal: <img width="779" height="356" alt="image" src="https://github.com/user-attachments/assets/89de283e-d412-44a8-b15b-276002762419" /> * We use a combobox * We try to preview what variables will be set to make more mistakes more obvious * Currently pretty ugly, but banking on the UX moving to a new location shortly before I figure out a good hierarchy for presenting. Happy to knock any quick fixes to make this present better if people feel strongly ## Things to pay Attention To * Moved sources components to new directory, but also changed the modal paradigm (separate content components, used `zustand` for state management) * I ported all of the `Dialog`s and Dropdown Menu's to the moonshine versions of those components. I couldn't visually tell the difference and there were some really nasty interplay issues. Hoping this is a nice stability move ## Considerations * Might consider adding a confirmation button considering this action is a pretty serious one * UX is quite ugly at the moment. Preferring to follow up with a dedicated sources page instead of burying behind a dialog * Blocked on this moonshine PR: speakeasy-api/moonshine#319
Adds an option to supply a create callback to the combo box which allows you to create an item that you supply
Note
Adds a
createOptionsAPI toComboboxto create a new option from the current search, with an example Storybook story.src/components/Combobox/index.tsxcreateOptionsprop withhandleCreate(search)and optionalrenderCreatePrompt(search).CommandItemwhen search is non-empty, invokinghandleCreate.src/components/Combobox/index.stories.tsxWithCreateOptionstory demonstrating dynamic option creation usinguseState.Written by Cursor Bugbot for commit 44bab5c. This will update automatically on new commits. Configure here.