Open
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
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
New, additive UI component and Storybook stories with no changes to existing core logic; main risk is minor UX/state edge cases in selection syncing.
Overview
Adds a new
CodeGroupSelectcomponent that renders two dropdowns (group + example) with a themed code block, copy-to-clipboard support, optionalaskAiButton, and an alternate audio player rendering when a snippet includesaudioUrl.Exports the new component/types from
components/code-group/index.tsand adds comprehensive Storybook stories covering themes, single-group/option behavior, custom className, and audio examples.Written by Cursor Bugbot for commit 8faaf4d. This will update automatically on new commits. Configure here.