Skip to content
This repository was archived by the owner on May 15, 2026. It is now read-only.

Commit 320bf26

Browse files
committed
fix: use sentinel value for 'Any mode' SelectItem to fix Radix UI error
Radix UI's Select component doesn't allow empty string values. Use '__any__' as a sentinel value and convert to undefined when submitting.
1 parent 761f7c4 commit 320bf26

2 files changed

Lines changed: 10 additions & 6 deletions

File tree

webview-ui/src/components/settings/CreateSkillDialog.tsx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@ const validateDescription = (description: string): string | null => {
5353
return null
5454
}
5555

56+
// Sentinel value for "Any mode" since Radix Select doesn't allow empty string values
57+
const MODE_ANY = "__any__"
58+
5659
export const CreateSkillDialog: React.FC<CreateSkillDialogProps> = ({
5760
open,
5861
onOpenChange,
@@ -65,7 +68,7 @@ export const CreateSkillDialog: React.FC<CreateSkillDialogProps> = ({
6568
const [name, setName] = useState("")
6669
const [description, setDescription] = useState("")
6770
const [source, setSource] = useState<"global" | "project">(hasWorkspace ? "project" : "global")
68-
const [mode, setMode] = useState<string>("")
71+
const [mode, setMode] = useState<string>(MODE_ANY)
6972
const [nameError, setNameError] = useState<string | null>(null)
7073
const [descriptionError, setDescriptionError] = useState<string | null>(null)
7174

@@ -87,7 +90,7 @@ export const CreateSkillDialog: React.FC<CreateSkillDialogProps> = ({
8790
setName("")
8891
setDescription("")
8992
setSource(hasWorkspace ? "project" : "global")
90-
setMode("")
93+
setMode(MODE_ANY)
9194
setNameError(null)
9295
setDescriptionError(null)
9396
}, [hasWorkspace])
@@ -124,12 +127,13 @@ export const CreateSkillDialog: React.FC<CreateSkillDialogProps> = ({
124127
}
125128

126129
// Send message to create skill
130+
// Convert MODE_ANY sentinel value to undefined for the backend
127131
vscode.postMessage({
128132
type: "createSkill",
129133
skillName: name,
130134
source,
131135
skillDescription: description,
132-
skillMode: mode || undefined,
136+
skillMode: mode === MODE_ANY ? undefined : mode,
133137
})
134138

135139
// Close dialog and notify parent
@@ -219,7 +223,7 @@ export const CreateSkillDialog: React.FC<CreateSkillDialogProps> = ({
219223
<SelectValue placeholder={t("settings:skills.createDialog.modePlaceholder")} />
220224
</SelectTrigger>
221225
<SelectContent>
222-
<SelectItem value="">{t("settings:skills.createDialog.modeAny")}</SelectItem>
226+
<SelectItem value={MODE_ANY}>{t("settings:skills.createDialog.modeAny")}</SelectItem>
223227
{availableModes.map((m) => (
224228
<SelectItem key={m.slug} value={m.slug}>
225229
{m.name}

webview-ui/src/components/settings/__tests__/CreateSkillDialog.spec.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -362,8 +362,8 @@ describe("CreateSkillDialog", () => {
362362
/>,
363363
)
364364

365-
// Should have "Any mode" option
366-
expect(screen.getByTestId("select-item-")).toBeInTheDocument()
365+
// Should have "Any mode" option (uses __any__ sentinel value)
366+
expect(screen.getByTestId("select-item-__any__")).toBeInTheDocument()
367367
// Should have built-in modes
368368
expect(screen.getByTestId("select-item-code")).toBeInTheDocument()
369369
expect(screen.getByTestId("select-item-architect")).toBeInTheDocument()

0 commit comments

Comments
 (0)