diff --git a/apps/server/src/routes/enhance-prompt/routes/enhance.ts b/apps/server/src/routes/enhance-prompt/routes/enhance.ts index 0b06891d..ad6e9602 100644 --- a/apps/server/src/routes/enhance-prompt/routes/enhance.ts +++ b/apps/server/src/routes/enhance-prompt/routes/enhance.ts @@ -136,14 +136,13 @@ export function createEnhanceHandler( const prompts = await getPromptCustomization(settingsService, '[EnhancePrompt]'); // Get the system prompt for this mode from merged prompts - const systemPrompt = - validMode === 'improve' - ? prompts.enhancement.improveSystemPrompt - : validMode === 'technical' - ? prompts.enhancement.technicalSystemPrompt - : validMode === 'simplify' - ? prompts.enhancement.simplifySystemPrompt - : prompts.enhancement.acceptanceSystemPrompt; + const systemPromptMap: Record = { + improve: prompts.enhancement.improveSystemPrompt, + technical: prompts.enhancement.technicalSystemPrompt, + simplify: prompts.enhancement.simplifySystemPrompt, + acceptance: prompts.enhancement.acceptanceSystemPrompt, + }; + const systemPrompt = systemPromptMap[validMode]; logger.debug(`Using ${validMode} system prompt (length: ${systemPrompt.length} chars)`); diff --git a/apps/ui/src/components/views/settings-view/prompts/prompt-customization-section.tsx b/apps/ui/src/components/views/settings-view/prompts/prompt-customization-section.tsx index c1b1888a..06ffb924 100644 --- a/apps/ui/src/components/views/settings-view/prompts/prompt-customization-section.tsx +++ b/apps/ui/src/components/views/settings-view/prompts/prompt-customization-section.tsx @@ -72,15 +72,10 @@ function PromptField({ const minHeight = calculateMinHeight(displayValue); const handleToggle = (enabled: boolean) => { - if (enabled) { - // Enable custom mode - preserve existing custom value or initialize with default - const value = customValue?.value ?? defaultValue; - onCustomValueChange({ value, enabled: true }); - } else { - // Disable custom mode - preserve custom value but mark as disabled - const value = customValue?.value ?? defaultValue; - onCustomValueChange({ value, enabled: false }); - } + // When toggling, preserve the existing custom value if it exists, + // otherwise initialize with the default value. + const value = customValue?.value ?? defaultValue; + onCustomValueChange({ value, enabled }); }; const handleTextChange = (newValue: string) => { @@ -148,9 +143,9 @@ export function PromptCustomizationSection({ }: PromptCustomizationSectionProps) { const [activeTab, setActiveTab] = useState('auto-mode'); - const updatePrompt = ( - category: keyof PromptCustomization, - field: string, + const updatePrompt = ( + category: T, + field: keyof NonNullable, value: CustomPrompt | undefined ) => { const updated = {