@@ -41,6 +41,7 @@ import { InteractiveSessionEditorOptions } from 'vs/workbench/contrib/interactiv
4141import { CONTEXT_INTERACTIVE_REQUEST_IN_PROGRESS , CONTEXT_IN_INTERACTIVE_INPUT , CONTEXT_IN_INTERACTIVE_SESSION } from 'vs/workbench/contrib/interactiveSession/common/interactiveSessionContextKeys' ;
4242import { IInteractiveSessionReplyFollowup , IInteractiveSessionService , IInteractiveSlashCommand } from 'vs/workbench/contrib/interactiveSession/common/interactiveSessionService' ;
4343import { IInteractiveSessionViewModel , InteractiveSessionViewModel , isRequestVM , isResponseVM , isWelcomeVM } from 'vs/workbench/contrib/interactiveSession/common/interactiveSessionViewModel' ;
44+ import { IInteractiveSessionWidgetHistoryService } from 'vs/workbench/contrib/interactiveSession/common/interactiveSessionWidgetHistoryService' ;
4445import { IExtensionService } from 'vs/workbench/services/extensions/common/extensions' ;
4546
4647export const IInteractiveSessionWidgetService = createDecorator < IInteractiveSessionWidgetService > ( 'interactiveSessionWidgetService' ) ;
@@ -64,11 +65,9 @@ function revealLastElement(list: WorkbenchObjectTree<any>) {
6465}
6566
6667interface IViewState {
67- history : string [ ] ;
6868 inputValue : string ;
6969}
7070
71- const HISTORY_STORAGE_KEY = 'interactiveSession.history' ;
7271const INPUT_EDITOR_MAX_HEIGHT = 250 ;
7372
7473export class InteractiveSessionWidget extends Disposable implements IInteractiveSessionWidget , IHistoryNavigationWidget {
@@ -155,14 +154,15 @@ export class InteractiveSessionWidget extends Disposable implements IInteractive
155154 private readonly listBackgroundColorDelegate : ( ) => string ,
156155 private readonly inputEditorBackgroundColorDelegate : ( ) => string ,
157156 private readonly resultEditorBackgroundColorDelegate : ( ) => string ,
158- @IStorageService private readonly storageService : IStorageService ,
157+ @IStorageService storageService : IStorageService ,
159158 @IContextKeyService private readonly contextKeyService : IContextKeyService ,
160159 @IInstantiationService private readonly instantiationService : IInstantiationService ,
161160 @IModelService private readonly modelService : IModelService ,
162161 @IExtensionService private readonly extensionService : IExtensionService ,
163162 @IInteractiveSessionService private readonly interactiveSessionService : IInteractiveSessionService ,
164163 @IInteractiveSessionWidgetService interactiveSessionWidgetService : IInteractiveSessionWidgetService ,
165164 @IContextMenuService private readonly contextMenuService : IContextMenuService ,
165+ @IInteractiveSessionWidgetHistoryService private readonly historyService : IInteractiveSessionWidgetHistoryService ,
166166 ) {
167167 super ( ) ;
168168 CONTEXT_IN_INTERACTIVE_SESSION . bindTo ( contextKeyService ) . set ( true ) ;
@@ -171,12 +171,12 @@ export class InteractiveSessionWidget extends Disposable implements IInteractive
171171 this . _register ( ( interactiveSessionWidgetService as InteractiveSessionWidgetService ) . register ( this ) ) ;
172172 this . initializeSessionModel ( true ) ;
173173
174- const oldPersistedHistory = JSON . parse ( this . storageService . get ( this . getHistoryStorageKey ( ) , StorageScope . WORKSPACE , '[]' ) ) ;
174+ const history = this . historyService . getHistory ( this . providerId ) ;
175+ this . history = new HistoryNavigator ( history , 50 ) ;
176+ this . _register ( this . historyService . onDidClearHistory ( ( ) => this . history . clear ( ) ) ) ;
177+
175178 this . memento = new Memento ( 'interactive-session-' + this . providerId , storageService ) ;
176179 this . viewState = this . memento . getMemento ( StorageScope . WORKSPACE , StorageTarget . USER ) as IViewState ;
177-
178- const history = this . viewState . history ?? oldPersistedHistory ;
179- this . history = new HistoryNavigator ( history , 50 ) ;
180180 }
181181
182182 get element ( ) : HTMLElement {
@@ -637,13 +637,10 @@ export class InteractiveSessionWidget extends Disposable implements IInteractive
637637 this . _inputEditor . layout ( { width : width - inputPartPadding - editorBorder - editorPadding - executeToolbarWidth , height : inputEditorHeight } ) ;
638638 }
639639
640- private getHistoryStorageKey ( ) : string {
641- return HISTORY_STORAGE_KEY + this . providerId ;
642- }
643-
644640 saveState ( ) : void {
645641 const inputHistory = this . history . getHistory ( ) ;
646- this . viewState . history = inputHistory ;
642+ this . historyService . saveHistory ( this . providerId , inputHistory ) ;
643+
647644 this . viewState . inputValue = this . _inputEditor . getValue ( ) ;
648645 this . memento . saveMemento ( ) ;
649646 }
0 commit comments