diff --git a/src/core/config/CustomModesManager.ts b/src/core/config/CustomModesManager.ts index 095ed86cb7..a9a2e6a6b5 100644 --- a/src/core/config/CustomModesManager.ts +++ b/src/core/config/CustomModesManager.ts @@ -405,9 +405,13 @@ export class CustomModesManager { // Validate the mode configuration before saving const validationResult = modeConfigSchema.safeParse(config) if (!validationResult.success) { - const errors = validationResult.error.errors.map((e) => e.message).join(", ") - logger.error(`Invalid mode configuration for ${slug}`, { errors: validationResult.error.errors }) - throw new Error(`Invalid mode configuration: ${errors}`) + const errorMessages = validationResult.error.errors + .map((err) => `${err.path.join(".")}: ${err.message}`) + .join(", ") + const errorMessage = `Invalid mode configuration: ${errorMessages}` + logger.error("Mode validation failed", { slug, errors: validationResult.error.errors }) + vscode.window.showErrorMessage(t("common:customModes.errors.updateFailed", { error: errorMessage })) + return } const isProjectMode = config.source === "project" @@ -786,7 +790,7 @@ export class CustomModesManager { // This excludes the rules-{slug} folder from the path const relativePath = path.relative(modeRulesDir, filePath) // Normalize path to use forward slashes for cross-platform compatibility - const normalizedRelativePath = relativePath.replace(/\\/g, '/') + const normalizedRelativePath = relativePath.replace(/\\/g, "/") rulesFiles.push({ relativePath: normalizedRelativePath, content: content.trim() }) } } diff --git a/webview-ui/src/components/modes/ModesView.tsx b/webview-ui/src/components/modes/ModesView.tsx index c2b67bc450..5d3700ac07 100644 --- a/webview-ui/src/components/modes/ModesView.tsx +++ b/webview-ui/src/components/modes/ModesView.tsx @@ -755,17 +755,25 @@ const ModesView = ({ onDone }: ModesViewProps) => { } }} onChange={(e) => { - setLocalModeName(e.target.value) + const newName = e.target.value + // Allow users to type freely, including emptying the field + setLocalModeName(newName) }} onBlur={() => { const customMode = findModeBySlug(visualMode, customModes) - if (customMode && localModeName.trim()) { + if (customMode) { + const trimmedName = localModeName.trim() // Only update if the name is not empty - updateCustomMode(visualMode, { - ...customMode, - name: localModeName, - source: customMode.source || "global", - }) + if (trimmedName) { + updateCustomMode(visualMode, { + ...customMode, + name: trimmedName, + source: customMode.source || "global", + }) + } else { + // Revert to the original name if empty + setLocalModeName(customMode.name) + } } // Clear the editing state setCurrentEditingModeSlug(null) diff --git a/webview-ui/src/vite-plugins/sourcemapPlugin.ts b/webview-ui/src/vite-plugins/sourcemapPlugin.ts index 9eb1e7b642..1449c888f2 100644 --- a/webview-ui/src/vite-plugins/sourcemapPlugin.ts +++ b/webview-ui/src/vite-plugins/sourcemapPlugin.ts @@ -88,8 +88,8 @@ export function sourcemapPlugin(): Plugin { }) } - // Write back the updated source map - fs.writeFileSync(mapPath, JSON.stringify(mapContent)) + // Write back the updated source map with proper formatting + fs.writeFileSync(mapPath, JSON.stringify(mapContent, null, 2)) console.log(`Updated source map for ${jsFile}`) } catch (error) { console.error(`Error processing source map for ${jsFile}:`, error)