Merged
Conversation
packages/components/src/components/code-group/code-group-select.stories.tsx
Show resolved
Hide resolved
packages/components/src/components/code-group/code-group-select.tsx
Outdated
Show resolved
Hide resolved
packages/components/src/components/code-group/code-group-select.tsx
Outdated
Show resolved
Hide resolved
packages/components/src/components/code-group/code-group-select.tsx
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix prepared a fix for the issue found in the latest run.
- ✅ Fixed: No safe fallback for stale
selectedGroupstate- Added a safe selected-group fallback and used it for snippet lookup and group dropdown rendering so stale group state no longer breaks the UI when snippets change.
Or push these changes by commenting:
@cursor push 93156cb57e
Preview (93156cb57e)
diff --git a/packages/components/src/components/code-group/code-group-select.tsx b/packages/components/src/components/code-group/code-group-select.tsx
--- a/packages/components/src/components/code-group/code-group-select.tsx
+++ b/packages/components/src/components/code-group/code-group-select.tsx
@@ -44,9 +44,11 @@
}: CodeGroupSelectProps) => {
const groups = Object.keys(snippets);
const [selectedGroup, setSelectedGroup] = useState(groups[0]);
+ const safeSelectedGroup =
+ selectedGroup && groups.includes(selectedGroup) ? selectedGroup : groups[0];
const groupSnippets =
- selectedGroup !== undefined ? snippets[selectedGroup] : undefined;
+ safeSelectedGroup !== undefined ? snippets[safeSelectedGroup] : undefined;
const options = useMemo(
() => (groupSnippets ? Object.keys(groupSnippets) : undefined),
[groupSnippets]
@@ -113,7 +115,7 @@
<CodeSelectDropdown
codeBlockTheme={codeBlockTheme}
options={groups}
- selectedOption={selectedGroup}
+ selectedOption={safeSelectedGroup}
setSelectedOption={handleGroupSelect}
/>
<div className="flex overflow-hidden">This Bugbot Autofix run was free. To enable autofix for future PRs, go to the Cursor dashboard.
packages/components/src/components/code-group/code-group-select.tsx
Outdated
Show resolved
Hide resolved
pqoqubbw
approved these changes
Mar 11, 2026
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.

Summary
CodeGroupSelect is used for code snippets and examples, it's just different enough from the regular CodeGroup (two dropdowns! optional audio examples!) that it deserves its own component and stories (and migrating the old one was gonna be a pain)
Test Plan
Note
Low Risk
Primarily additive UI work with isolated refactoring of
CodeSelectDropdownthat is only used by the new component, so blast radius is small.Overview
Introduces a new
CodeGroupSelectcomponent that renders two-level snippet selection (group + example) via dropdowns, shows either a highlightedBaseCodeBlockor an HTML5<audio>player per snippet, and supports optional copy, Ask AI, and external selection syncing viasyncedLabel/callbacks.Adds a comprehensive Storybook file demonstrating themes, single-group/option states, audio snippets, and custom styling, and exports the new component/types from
code-group/index.ts. Also simplifiesCodeSelectDropdownby removing thecodeBlockThemeprop and using fixed light/dark Tailwind classes (now only consumed byCodeGroupSelect).Written by Cursor Bugbot for commit ba79956. This will update automatically on new commits. Configure here.