@@ -39,7 +39,7 @@ import { CONTEXT_CHAT_INPUT_CURSOR_AT_TOP, CONTEXT_CHAT_INPUT_HAS_TEXT, CONTEXT_
39
39
import { chatAgentLeader } from 'vs/workbench/contrib/chat/common/chatParserTypes' ;
40
40
import { IChatReplyFollowup } from 'vs/workbench/contrib/chat/common/chatService' ;
41
41
import { IChatResponseViewModel } from 'vs/workbench/contrib/chat/common/chatViewModel' ;
42
- import { IChatWidgetHistoryService } from 'vs/workbench/contrib/chat/common/chatWidgetHistoryService' ;
42
+ import { IChatHistoryEntry , IChatWidgetHistoryService } from 'vs/workbench/contrib/chat/common/chatWidgetHistoryService' ;
43
43
import { getSimpleCodeEditorWidgetOptions , getSimpleEditorOptions } from 'vs/workbench/contrib/codeEditor/browser/simpleEditorOptions' ;
44
44
import { ChatSubmitEditorAction , ChatSubmitSecondaryAgentEditorAction } from 'vs/workbench/contrib/chat/browser/actions/chatActions' ;
45
45
import { IPosition } from 'vs/editor/common/core/position' ;
@@ -82,8 +82,7 @@ export class ChatInputPart extends Disposable implements IHistoryNavigationWidge
82
82
return this . _inputEditor ;
83
83
}
84
84
85
- private history : HistoryNavigator < string > ;
86
- private historyStates : Map < string , any > = new Map ( ) ;
85
+ private history : HistoryNavigator < IChatHistoryEntry > ;
87
86
private historyNavigationBackwardsEnablement ! : IContextKey < boolean > ;
88
87
private historyNavigationForewardsEnablement ! : IContextKey < boolean > ;
89
88
private onHistoryEntry = false ;
@@ -134,11 +133,7 @@ export class ChatInputPart extends Disposable implements IHistoryNavigationWidge
134
133
setState ( providerId : string , inputValue : string | undefined ) : void {
135
134
this . providerId = providerId ;
136
135
const history = this . historyService . getHistory ( providerId ) ;
137
- this . historyStates = new Map ( history . map ( h => [ h . text , h . state ] ) ) ;
138
- const historyTexts : string [ ] = [ ] ;
139
- this . historyStates . forEach ( ( _ , str ) => historyTexts . push ( str ) ) ;
140
-
141
- this . history = new HistoryNavigator ( historyTexts , 50 ) ;
136
+ this . history = new HistoryNavigator ( history , 50 ) ;
142
137
143
138
if ( typeof inputValue === 'string' ) {
144
139
this . setValue ( inputValue ) ;
@@ -158,15 +153,15 @@ export class ChatInputPart extends Disposable implements IHistoryNavigationWidge
158
153
}
159
154
160
155
private navigateHistory ( previous : boolean ) : void {
161
- const historyInput = ( previous ?
156
+ const historyEntry = ( previous ?
162
157
( this . history . previous ( ) ?? this . history . first ( ) ) : this . history . next ( ) )
163
- ?? '' ;
158
+ ?? { text : '' } ;
164
159
165
160
this . onHistoryEntry = previous || this . history . current ( ) !== null ;
166
161
167
- aria . status ( historyInput ) ;
168
- this . setValue ( historyInput ) ;
169
- this . _onDidLoadInputState . fire ( this . historyStates . get ( historyInput ) ) ;
162
+ aria . status ( historyEntry . text ) ;
163
+ this . setValue ( historyEntry . text ) ;
164
+ this . _onDidLoadInputState . fire ( historyEntry . state ) ;
170
165
if ( previous ) {
171
166
this . _inputEditor . setPosition ( { lineNumber : 1 , column : 1 } ) ;
172
167
} else {
@@ -199,8 +194,7 @@ export class ChatInputPart extends Disposable implements IHistoryNavigationWidge
199
194
*/
200
195
async acceptInput ( userQuery ?: string , inputState ?: any ) : Promise < void > {
201
196
if ( userQuery ) {
202
- this . history . add ( userQuery ) ;
203
- this . historyStates . set ( userQuery , inputState ) ;
197
+ this . history . add ( { text : userQuery , state : inputState } ) ;
204
198
}
205
199
206
200
if ( this . accessibilityService . isScreenReaderOptimized ( ) && isMacintosh ) {
@@ -391,8 +385,7 @@ export class ChatInputPart extends Disposable implements IHistoryNavigationWidge
391
385
392
386
saveState ( ) : void {
393
387
const inputHistory = this . history . getHistory ( ) ;
394
- const historyEntries = inputHistory . map ( entry => ( { text : entry , state : this . historyStates . get ( entry ) } ) ) ;
395
- this . historyService . saveHistory ( this . providerId ! , historyEntries ) ;
388
+ this . historyService . saveHistory ( this . providerId ! , inputHistory ) ;
396
389
}
397
390
}
398
391
0 commit comments