@@ -73,6 +73,7 @@ interface LocalCodeIndexSettings {
7373// Validation schema for codebase index settings
7474const createValidationSchema = ( provider : EmbedderProvider , t : any ) => {
7575 const baseSchema = z . object ( {
76+ codebaseIndexEnabled : z . boolean ( ) ,
7677 codebaseIndexQdrantUrl : z
7778 . string ( )
7879 . min ( 1 , t ( "settings:codeIndex.validation.qdrantUrlRequired" ) )
@@ -236,20 +237,20 @@ export const CodeIndexPopover: React.FC<CodeIndexPopoverProps> = ({
236237 // This ensures hasUnsavedChanges becomes false
237238 const savedSettings = { ...currentSettingsRef . current }
238239 setInitialSettings ( savedSettings )
239- // Don't request secret status immediately after save to avoid race conditions
240- // The secret status will be requested on next popover open
241- // Reset status after 3 seconds
242- setTimeout ( ( ) => {
243- setSaveStatus ( "idle" )
244- } , 3000 )
240+ // Also update current settings to maintain consistency
241+ setCurrentSettings ( savedSettings )
242+ // Request secret status to ensure we have the latest state
243+ // This is important to maintain placeholder display after save
244+
245+ vscode . postMessage ( { type : "requestCodeIndexSecretStatus" } )
246+
247+ setSaveStatus ( "idle" )
245248 } else {
246249 setSaveStatus ( "error" )
247250 setSaveError ( event . data . error || t ( "settings:codeIndex.saveError" ) )
248251 // Clear error message after 5 seconds
249- setTimeout ( ( ) => {
250- setSaveStatus ( "idle" )
251- setSaveError ( null )
252- } , 5000 )
252+ setSaveStatus ( "idle" )
253+ setSaveError ( null )
253254 }
254255 }
255256 }
@@ -292,9 +293,9 @@ export const CodeIndexPopover: React.FC<CodeIndexPopoverProps> = ({
292293 return updated
293294 }
294295
295- // Only update settings if we're not in the middle of saving or just saved
296- // This prevents overwriting user changes after a save
297- if ( saveStatus === "idle" ) {
296+ // Only update settings if we're not in the middle of saving
297+ // After save is complete (saved status), we still want to update to maintain consistency
298+ if ( saveStatus === "idle" || saveStatus === "saved" ) {
298299 setCurrentSettings ( updateWithSecrets )
299300 setInitialSettings ( updateWithSecrets )
300301 }
@@ -429,20 +430,26 @@ export const CodeIndexPopover: React.FC<CodeIndexPopoverProps> = ({
429430 setSaveStatus ( "saving" )
430431 setSaveError ( null )
431432
432- // Prepare settings to save - include all fields except secrets with placeholder values
433+ // Prepare settings to save
433434 const settingsToSave : any = { }
434435
435436 // Iterate through all current settings
436437 for ( const [ key , value ] of Object . entries ( currentSettings ) ) {
437- // Skip secret fields that still have placeholder value
438+ // For secret fields with placeholder, don't send the placeholder
439+ // but also don't send an empty string - just skip the field
440+ // This tells the backend to keep the existing secret
438441 if ( value === SECRET_PLACEHOLDER ) {
442+ // Skip sending placeholder values - backend will preserve existing secrets
439443 continue
440444 }
441445
442- // Include all other fields
446+ // Include all other fields, including empty strings (which clear secrets)
443447 settingsToSave [ key ] = value
444448 }
445449
450+ // Always include codebaseIndexEnabled to ensure it's persisted
451+ settingsToSave . codebaseIndexEnabled = currentSettings . codebaseIndexEnabled
452+
446453 // Save settings to backend
447454 vscode . postMessage ( {
448455 type : "saveCodeIndexSettingsAtomic" ,
0 commit comments