@@ -64,15 +64,15 @@ import {
6464 INSTRUCTIONS_CODE_COMPLETIONS_STATE_KEY ,
6565 INSTRUCTIONS_EDIT_CONTEXT_STATE_KEY ,
6666 INSTRUCTIONS_NO_CONTEXT_STATE_KEY ,
67+ get_configurations_collapsed_state_key ,
6768 get_last_group_or_preset_choice_state_key ,
6869 get_last_selected_group_state_key ,
6970 get_last_selected_preset_key ,
7071 LAST_APPLIED_CHANGES_STATE_KEY ,
7172 LAST_APPLIED_CLIPBOARD_CONTENT_STATE_KEY ,
7273 LAST_SELECTED_CODE_COMPLETION_CONFIG_ID_STATE_KEY ,
7374 LAST_SELECTED_EDIT_CONTEXT_CONFIG_ID_STATE_KEY ,
74- PRESETS_COLLAPSED_STATE_KEY ,
75- CONFIGURATIONS_COLLAPSED_STATE_KEY ,
75+ get_presets_collapsed_state_key ,
7676 RECENT_DONATIONS_VISIBLE_STATE_KEY ,
7777 WEB_MODE_STATE_KEY
7878} from '@/constants/state-keys'
@@ -110,8 +110,6 @@ export class PanelProvider implements vscode.WebviewViewProvider {
110110 public intelligent_update_cancel_token_sources : CancelTokenSource [ ] = [ ]
111111 public api_call_cancel_token_source : CancelTokenSource | null = null
112112 public commit_was_staged_by_script : boolean = false
113- public presets_collapsed : boolean = false
114- public configurations_collapsed : boolean = false
115113
116114 constructor (
117115 public readonly extension_uri : vscode . Uri ,
@@ -130,15 +128,6 @@ export class PanelProvider implements vscode.WebviewViewProvider {
130128 }
131129 } )
132130
133- this . presets_collapsed = this . context . globalState . get < boolean > (
134- PRESETS_COLLAPSED_STATE_KEY ,
135- false
136- )
137- this . configurations_collapsed = this . context . globalState . get < boolean > (
138- CONFIGURATIONS_COLLAPSED_STATE_KEY ,
139- false
140- )
141-
142131 this . edit_instructions = this . context . workspaceState . get < string > (
143132 INSTRUCTIONS_EDIT_CONTEXT_STATE_KEY ,
144133 ''
@@ -180,22 +169,37 @@ export class PanelProvider implements vscode.WebviewViewProvider {
180169 RECENT_DONATIONS_VISIBLE_STATE_KEY ,
181170 false
182171 )
172+ const WEB_MODES : WebMode [ ] = [
173+ 'ask' ,
174+ 'edit-context' ,
175+ 'code-completions' ,
176+ 'no-context'
177+ ]
178+ const API_MODES : ApiMode [ ] = [ 'edit-context' , 'code-completions' ]
183179 this . send_message ( {
184180 command : 'DONATIONS_VISIBILITY' ,
185181 is_visible : are_donations_visible
186182 } )
187- this . presets_collapsed = this . context . globalState . get < boolean > (
188- PRESETS_COLLAPSED_STATE_KEY ,
189- false
190- )
191- this . configurations_collapsed = this . context . globalState . get < boolean > (
192- CONFIGURATIONS_COLLAPSED_STATE_KEY ,
193- false
194- )
195183 this . send_message ( {
196184 command : 'COLLAPSED_STATES' ,
197- presets_collapsed : this . presets_collapsed ,
198- configurations_collapsed : this . configurations_collapsed
185+ presets_collapsed_by_web_mode : Object . fromEntries (
186+ WEB_MODES . map ( ( mode ) => [
187+ mode ,
188+ this . context . globalState . get < boolean > (
189+ get_presets_collapsed_state_key ( mode ) ,
190+ false
191+ )
192+ ] )
193+ ) ,
194+ configurations_collapsed_by_api_mode : Object . fromEntries (
195+ API_MODES . map ( ( mode ) => [
196+ mode ,
197+ this . context . globalState . get < boolean > (
198+ get_configurations_collapsed_state_key ( mode ) ,
199+ false
200+ )
201+ ] )
202+ )
199203 } )
200204 }
201205 } )
@@ -565,22 +569,43 @@ export class PanelProvider implements vscode.WebviewViewProvider {
565569 section
566570 )
567571 } else if ( message . command == 'GET_COLLAPSED_STATES' ) {
572+ const WEB_MODES : WebMode [ ] = [
573+ 'ask' ,
574+ 'edit-context' ,
575+ 'code-completions' ,
576+ 'no-context'
577+ ]
578+ const API_MODES : ApiMode [ ] = [ 'edit-context' , 'code-completions' ]
568579 this . send_message ( {
569580 command : 'COLLAPSED_STATES' ,
570- presets_collapsed : this . presets_collapsed ,
571- configurations_collapsed : this . configurations_collapsed
581+ presets_collapsed_by_web_mode : Object . fromEntries (
582+ WEB_MODES . map ( ( mode ) => [
583+ mode ,
584+ this . context . globalState . get < boolean > (
585+ get_presets_collapsed_state_key ( mode ) ,
586+ false
587+ )
588+ ] )
589+ ) ,
590+ configurations_collapsed_by_api_mode : Object . fromEntries (
591+ API_MODES . map ( ( mode ) => [
592+ mode ,
593+ this . context . globalState . get < boolean > (
594+ get_configurations_collapsed_state_key ( mode ) ,
595+ false
596+ )
597+ ] )
598+ )
572599 } )
573600 } else if ( message . command == 'SAVE_COMPONENT_COLLAPSED_STATE' ) {
574601 if ( message . component == 'presets' ) {
575- this . presets_collapsed = message . is_collapsed
576602 await this . context . globalState . update (
577- PRESETS_COLLAPSED_STATE_KEY ,
603+ get_presets_collapsed_state_key ( message . mode as WebMode ) ,
578604 message . is_collapsed
579605 )
580606 } else if ( message . component == 'configurations' ) {
581- this . configurations_collapsed = message . is_collapsed
582607 await this . context . globalState . update (
583- CONFIGURATIONS_COLLAPSED_STATE_KEY ,
608+ get_configurations_collapsed_state_key ( message . mode as ApiMode ) ,
584609 message . is_collapsed
585610 )
586611 }
0 commit comments