@@ -41,6 +41,7 @@ import { InteractiveSessionEditorOptions } from 'vs/workbench/contrib/interactiv
41
41
import { CONTEXT_INTERACTIVE_REQUEST_IN_PROGRESS , CONTEXT_IN_INTERACTIVE_INPUT , CONTEXT_IN_INTERACTIVE_SESSION } from 'vs/workbench/contrib/interactiveSession/common/interactiveSessionContextKeys' ;
42
42
import { IInteractiveSessionReplyFollowup , IInteractiveSessionService , IInteractiveSlashCommand } from 'vs/workbench/contrib/interactiveSession/common/interactiveSessionService' ;
43
43
import { IInteractiveSessionViewModel , InteractiveSessionViewModel , isRequestVM , isResponseVM , isWelcomeVM } from 'vs/workbench/contrib/interactiveSession/common/interactiveSessionViewModel' ;
44
+ import { IInteractiveSessionWidgetHistoryService } from 'vs/workbench/contrib/interactiveSession/common/interactiveSessionWidgetHistoryService' ;
44
45
import { IExtensionService } from 'vs/workbench/services/extensions/common/extensions' ;
45
46
46
47
export const IInteractiveSessionWidgetService = createDecorator < IInteractiveSessionWidgetService > ( 'interactiveSessionWidgetService' ) ;
@@ -64,11 +65,9 @@ function revealLastElement(list: WorkbenchObjectTree<any>) {
64
65
}
65
66
66
67
interface IViewState {
67
- history : string [ ] ;
68
68
inputValue : string ;
69
69
}
70
70
71
- const HISTORY_STORAGE_KEY = 'interactiveSession.history' ;
72
71
const INPUT_EDITOR_MAX_HEIGHT = 250 ;
73
72
74
73
export class InteractiveSessionWidget extends Disposable implements IInteractiveSessionWidget , IHistoryNavigationWidget {
@@ -155,14 +154,15 @@ export class InteractiveSessionWidget extends Disposable implements IInteractive
155
154
private readonly listBackgroundColorDelegate : ( ) => string ,
156
155
private readonly inputEditorBackgroundColorDelegate : ( ) => string ,
157
156
private readonly resultEditorBackgroundColorDelegate : ( ) => string ,
158
- @IStorageService private readonly storageService : IStorageService ,
157
+ @IStorageService storageService : IStorageService ,
159
158
@IContextKeyService private readonly contextKeyService : IContextKeyService ,
160
159
@IInstantiationService private readonly instantiationService : IInstantiationService ,
161
160
@IModelService private readonly modelService : IModelService ,
162
161
@IExtensionService private readonly extensionService : IExtensionService ,
163
162
@IInteractiveSessionService private readonly interactiveSessionService : IInteractiveSessionService ,
164
163
@IInteractiveSessionWidgetService interactiveSessionWidgetService : IInteractiveSessionWidgetService ,
165
164
@IContextMenuService private readonly contextMenuService : IContextMenuService ,
165
+ @IInteractiveSessionWidgetHistoryService private readonly historyService : IInteractiveSessionWidgetHistoryService ,
166
166
) {
167
167
super ( ) ;
168
168
CONTEXT_IN_INTERACTIVE_SESSION . bindTo ( contextKeyService ) . set ( true ) ;
@@ -171,12 +171,12 @@ export class InteractiveSessionWidget extends Disposable implements IInteractive
171
171
this . _register ( ( interactiveSessionWidgetService as InteractiveSessionWidgetService ) . register ( this ) ) ;
172
172
this . initializeSessionModel ( true ) ;
173
173
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
+
175
178
this . memento = new Memento ( 'interactive-session-' + this . providerId , storageService ) ;
176
179
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 ) ;
180
180
}
181
181
182
182
get element ( ) : HTMLElement {
@@ -637,13 +637,10 @@ export class InteractiveSessionWidget extends Disposable implements IInteractive
637
637
this . _inputEditor . layout ( { width : width - inputPartPadding - editorBorder - editorPadding - executeToolbarWidth , height : inputEditorHeight } ) ;
638
638
}
639
639
640
- private getHistoryStorageKey ( ) : string {
641
- return HISTORY_STORAGE_KEY + this . providerId ;
642
- }
643
-
644
640
saveState ( ) : void {
645
641
const inputHistory = this . history . getHistory ( ) ;
646
- this . viewState . history = inputHistory ;
642
+ this . historyService . saveHistory ( this . providerId , inputHistory ) ;
643
+
647
644
this . viewState . inputValue = this . _inputEditor . getValue ( ) ;
648
645
this . memento . saveMemento ( ) ;
649
646
}
0 commit comments