@@ -78,8 +78,6 @@ export const CodeIndexPopover: React.FC<CodeIndexPopoverProps> = ({
7878
7979 const [ saveStatus , setSaveStatus ] = useState < "idle" | "saving" | "saved" | "error" > ( "idle" )
8080 const [ saveError , setSaveError ] = useState < string | null > ( null )
81- const [ isSaving , setIsSaving ] = useState ( false )
82- const [ justSaved , setJustSaved ] = useState ( false )
8381
8482 // Default settings template
8583 const getDefaultSettings = ( ) : LocalCodeIndexSettings => ( {
@@ -160,23 +158,15 @@ export const CodeIndexPopover: React.FC<CodeIndexPopoverProps> = ({
160158 } else if ( event . data . type === "codeIndexSettingsSaved" ) {
161159 if ( event . data . success ) {
162160 setSaveStatus ( "saved" )
163- setIsSaving ( false )
164- setJustSaved ( true )
165-
166- // Delay secret status request to allow backend to stabilize
167- setTimeout ( ( ) => {
168- vscode . postMessage ( { type : "requestCodeIndexSecretStatus" } )
169- setJustSaved ( false )
170- } , 1000 )
171-
161+ // Don't update initial settings here - wait for the secret status response
162+ // Request updated secret status after save
163+ vscode . postMessage ( { type : "requestCodeIndexSecretStatus" } )
172164 // Reset status after 3 seconds
173165 setTimeout ( ( ) => {
174166 setSaveStatus ( "idle" )
175167 } , 3000 )
176168 } else {
177169 setSaveStatus ( "error" )
178- setIsSaving ( false )
179- setJustSaved ( false )
180170 setSaveError ( event . data . error || t ( "settings:codeIndex.saveError" ) )
181171 // Clear error message after 5 seconds
182172 setTimeout ( ( ) => {
@@ -202,27 +192,24 @@ export const CodeIndexPopover: React.FC<CodeIndexPopoverProps> = ({
202192 const updateWithSecrets = ( prev : LocalCodeIndexSettings ) : LocalCodeIndexSettings => {
203193 const updated = { ...prev }
204194
205- // Preserve user input during save operations
206- if ( ! isSaving && ! justSaved ) {
207- // Only update to placeholder if the field is currently empty or already a placeholder
208- // This preserves user input when they're actively editing
209- if ( ! prev . codeIndexOpenAiKey || prev . codeIndexOpenAiKey === SECRET_PLACEHOLDER ) {
210- updated . codeIndexOpenAiKey = secretStatus . hasOpenAiKey ? SECRET_PLACEHOLDER : ""
211- }
212- if ( ! prev . codeIndexQdrantApiKey || prev . codeIndexQdrantApiKey === SECRET_PLACEHOLDER ) {
213- updated . codeIndexQdrantApiKey = secretStatus . hasQdrantApiKey ? SECRET_PLACEHOLDER : ""
214- }
215- if (
216- ! prev . codebaseIndexOpenAiCompatibleApiKey ||
217- prev . codebaseIndexOpenAiCompatibleApiKey === SECRET_PLACEHOLDER
218- ) {
219- updated . codebaseIndexOpenAiCompatibleApiKey = secretStatus . hasOpenAiCompatibleApiKey
220- ? SECRET_PLACEHOLDER
221- : ""
222- }
223- if ( ! prev . codebaseIndexGeminiApiKey || prev . codebaseIndexGeminiApiKey === SECRET_PLACEHOLDER ) {
224- updated . codebaseIndexGeminiApiKey = secretStatus . hasGeminiApiKey ? SECRET_PLACEHOLDER : ""
225- }
195+ // Only update to placeholder if the field is currently empty or already a placeholder
196+ // This preserves user input when they're actively editing
197+ if ( ! prev . codeIndexOpenAiKey || prev . codeIndexOpenAiKey === SECRET_PLACEHOLDER ) {
198+ updated . codeIndexOpenAiKey = secretStatus . hasOpenAiKey ? SECRET_PLACEHOLDER : ""
199+ }
200+ if ( ! prev . codeIndexQdrantApiKey || prev . codeIndexQdrantApiKey === SECRET_PLACEHOLDER ) {
201+ updated . codeIndexQdrantApiKey = secretStatus . hasQdrantApiKey ? SECRET_PLACEHOLDER : ""
202+ }
203+ if (
204+ ! prev . codebaseIndexOpenAiCompatibleApiKey ||
205+ prev . codebaseIndexOpenAiCompatibleApiKey === SECRET_PLACEHOLDER
206+ ) {
207+ updated . codebaseIndexOpenAiCompatibleApiKey = secretStatus . hasOpenAiCompatibleApiKey
208+ ? SECRET_PLACEHOLDER
209+ : ""
210+ }
211+ if ( ! prev . codebaseIndexGeminiApiKey || prev . codebaseIndexGeminiApiKey === SECRET_PLACEHOLDER ) {
212+ updated . codebaseIndexGeminiApiKey = secretStatus . hasGeminiApiKey ? SECRET_PLACEHOLDER : ""
226213 }
227214
228215 return updated
@@ -235,7 +222,7 @@ export const CodeIndexPopover: React.FC<CodeIndexPopoverProps> = ({
235222
236223 window . addEventListener ( "message" , handleMessage )
237224 return ( ) => window . removeEventListener ( "message" , handleMessage )
238- } , [ isSaving , justSaved ] )
225+ } , [ ] )
239226
240227 // Generic comparison function that detects changes between initial and current settings
241228 const hasUnsavedChanges = useMemo ( ( ) => {
@@ -271,8 +258,6 @@ export const CodeIndexPopover: React.FC<CodeIndexPopoverProps> = ({
271258 }
272259
273260 const handleSaveSettings = ( ) => {
274- setIsSaving ( true )
275- setJustSaved ( false )
276261 setSaveStatus ( "saving" )
277262 setSaveError ( null )
278263
0 commit comments