@@ -207,60 +207,6 @@ export const ExtensionStateContextProvider: React.FC<{
207207 }
208208 break
209209 }
210- case "state" : {
211- // Handler for direct state messages
212- if ( message . state ) {
213- const stateData = message . state as ExtensionState
214- console . log ( "[Webview Context Test Revert] Received direct 'state' message, updating state." )
215- setState ( ( prevState ) => {
216- // Versioning logic for autoApprovalSettings (copied from original onResponse)
217- const incomingVersion = stateData . autoApprovalSettings ?. version ?? 1
218- const currentVersion = prevState . autoApprovalSettings ?. version ?? 1
219- const shouldUpdateAutoApproval = incomingVersion > currentVersion
220-
221- const newState = {
222- ...stateData ,
223- autoApprovalSettings : shouldUpdateAutoApproval
224- ? stateData . autoApprovalSettings
225- : prevState . autoApprovalSettings ,
226- }
227-
228- // Update welcome screen state based on API configuration (copied from original onResponse)
229- const config = stateData . apiConfiguration
230- const hasKey = config
231- ? [
232- config . apiKey ,
233- config . openRouterApiKey ,
234- config . awsRegion ,
235- config . vertexProjectId ,
236- config . openAiApiKey ,
237- config . ollamaModelId ,
238- config . lmStudioModelId ,
239- config . liteLlmApiKey ,
240- config . geminiApiKey ,
241- config . openAiNativeApiKey ,
242- config . deepSeekApiKey ,
243- config . requestyApiKey ,
244- config . togetherApiKey ,
245- config . qwenApiKey ,
246- config . doubaoApiKey ,
247- config . mistralApiKey ,
248- config . vsCodeLmModelSelector ,
249- config . clineApiKey ,
250- config . asksageApiKey ,
251- config . xaiApiKey ,
252- config . sambanovaApiKey ,
253- config . nebiusApiKey ,
254- ] . some ( ( key ) => key !== undefined )
255- : false
256-
257- setShowWelcome ( ! hasKey )
258- setDidHydrateState ( true )
259- return newState
260- } )
261- }
262- break
263- }
264210 case "theme" : {
265211 if ( message . text ) {
266212 setTheme ( convertTextMateToHljs ( JSON . parse ( message . text ) ) )
@@ -326,33 +272,31 @@ export const ExtensionStateContextProvider: React.FC<{
326272 const stateSubscriptionRef = useRef < ( ( ) => void ) | null > ( null )
327273
328274 // Subscribe to state updates using the new gRPC streaming API
329- /* // TEST REVERT: Commenting out gRPC state subscription
330275 useEffect ( ( ) => {
331276 // Set up state subscription
332277 stateSubscriptionRef . current = StateServiceClient . subscribeToState (
333278 { } ,
334279 {
335280 onResponse : ( response ) => {
336- console.log("[DEBUG] got state update via subscription", response);
337281 if ( response . stateJson ) {
338282 try {
339- const stateData = JSON.parse(response.stateJson) as ExtensionState;
340- console.log("[DEBUG] parsed state JSON, updating state");
283+ const stateData = JSON . parse ( response . stateJson ) as ExtensionState
284+ console . log ( "[DEBUG] parsed state JSON, updating state" )
341285 setState ( ( prevState ) => {
342286 // Versioning logic for autoApprovalSettings
343- const incomingVersion = stateData.autoApprovalSettings?.version ?? 1;
344- const currentVersion = prevState.autoApprovalSettings?.version ?? 1;
345- const shouldUpdateAutoApproval = incomingVersion > currentVersion;
287+ const incomingVersion = stateData . autoApprovalSettings ?. version ?? 1
288+ const currentVersion = prevState . autoApprovalSettings ?. version ?? 1
289+ const shouldUpdateAutoApproval = incomingVersion > currentVersion
346290
347291 const newState = {
348292 ...stateData ,
349293 autoApprovalSettings : shouldUpdateAutoApproval
350294 ? stateData . autoApprovalSettings
351295 : prevState . autoApprovalSettings ,
352- };
296+ }
353297
354298 // Update welcome screen state based on API configuration
355- const config = stateData.apiConfiguration;
299+ const config = stateData . apiConfiguration
356300 const hasKey = config
357301 ? [
358302 config . apiKey ,
@@ -377,52 +321,41 @@ export const ExtensionStateContextProvider: React.FC<{
377321 config . xaiApiKey ,
378322 config . sambanovaApiKey ,
379323 ] . some ( ( key ) => key !== undefined )
380- : false;
324+ : false
381325
382- setShowWelcome(!hasKey);
383- setDidHydrateState(true);
326+ setShowWelcome ( ! hasKey )
327+ setDidHydrateState ( true )
384328
385- console.log("[DEBUG] returning new state in ESC");
329+ console . log ( "[DEBUG] returning new state in ESC" )
386330
387- return newState;
388- });
331+ return newState
332+ } )
389333 } catch ( error ) {
390- console.error("Error parsing state JSON:", error);
391- console.log("[DEBUG] ERR getting state", error);
334+ console . error ( "Error parsing state JSON:" , error )
335+ console . log ( "[DEBUG] ERR getting state" , error )
392336 }
393337 }
394- console.log('[DEBUG] ended "got subscribed state"');
338+ console . log ( '[DEBUG] ended "got subscribed state"' )
395339 } ,
396340 onError : ( error ) => {
397- console.error("Error in state subscription:", error);
341+ console . error ( "Error in state subscription:" , error )
398342 } ,
399343 onComplete : ( ) => {
400- console.log("State subscription completed");
344+ console . log ( "State subscription completed" )
401345 } ,
402346 } ,
403- );
347+ )
404348
405349 // Still send the webviewDidLaunch message for other initialization
406- vscode.postMessage({ type: "webviewDidLaunch" });
350+ vscode . postMessage ( { type : "webviewDidLaunch" } )
407351
408352 // Clean up subscription when component unmounts
409353 return ( ) => {
410354 if ( stateSubscriptionRef . current ) {
411- stateSubscriptionRef.current();
412- stateSubscriptionRef.current = null;
355+ stateSubscriptionRef . current ( )
356+ stateSubscriptionRef . current = null
413357 }
414- };
415- }, []);
416- */ // END TEST REVERT
417-
418- // For the test revert, ensure webviewDidLaunch is still sent if not done by the above useEffect
419- useEffect ( ( ) => {
420- // This effect now only sends webviewDidLaunch if the gRPC subscription is commented out.
421- // If the gRPC subscription is active, it sends webviewDidLaunch.
422- // To avoid sending it twice if you uncomment the above, you might add a flag.
423- // For this specific test (gRPC sub commented out), this is fine.
424- console . log ( "[Webview Context Test Revert] Sending webviewDidLaunch from separate useEffect." )
425- vscode . postMessage ( { type : "webviewDidLaunch" } )
358+ }
426359 } , [ ] )
427360
428361 const contextValue : ExtensionStateContextType = {
0 commit comments