@@ -82,7 +82,8 @@ export class ChatInputPart extends Disposable implements IHistoryNavigationWidge
8282 return this . _inputEditor ;
8383 }
8484
85- private history : HistoryNavigator < { text : string ; state ?: any } > ;
85+ private history : HistoryNavigator < string > ;
86+ private historyStates : Map < string , any > = new Map ( ) ;
8687 private historyNavigationBackwardsEnablement ! : IContextKey < boolean > ;
8788 private historyNavigationForewardsEnablement ! : IContextKey < boolean > ;
8889 private inputModel : ITextModel | undefined ;
@@ -129,7 +130,11 @@ export class ChatInputPart extends Disposable implements IHistoryNavigationWidge
129130 setState ( providerId : string , inputValue : string | undefined ) : void {
130131 this . providerId = providerId ;
131132 const history = this . historyService . getHistory ( providerId ) ;
132- this . history = new HistoryNavigator ( history , 50 ) ;
133+ this . historyStates = new Map ( history . map ( h => [ h . text , h . state ] ) ) ;
134+ const historyTexts : string [ ] = [ ] ;
135+ this . historyStates . forEach ( ( _ , str ) => historyTexts . push ( str ) ) ;
136+
137+ this . history = new HistoryNavigator ( historyTexts , 50 ) ;
133138
134139 if ( typeof inputValue === 'string' ) {
135140 this . setValue ( inputValue ) ;
@@ -151,11 +156,11 @@ export class ChatInputPart extends Disposable implements IHistoryNavigationWidge
151156 private navigateHistory ( previous : boolean ) : void {
152157 const historyInput = ( previous ?
153158 ( this . history . previous ( ) ?? this . history . first ( ) ) : this . history . next ( ) )
154- ?? { text : '' } ;
159+ ?? '' ;
155160
156- aria . status ( historyInput . text ) ;
157- this . setValue ( historyInput . text ) ;
158- this . _onDidLoadInputState . fire ( historyInput . state ) ;
161+ aria . status ( historyInput ) ;
162+ this . setValue ( historyInput ) ;
163+ this . _onDidLoadInputState . fire ( this . historyStates . get ( historyInput ) ) ;
159164 if ( previous ) {
160165 this . _inputEditor . setPosition ( { lineNumber : 1 , column : 1 } ) ;
161166 } else {
@@ -188,7 +193,8 @@ export class ChatInputPart extends Disposable implements IHistoryNavigationWidge
188193 */
189194 async acceptInput ( userQuery ?: string , inputState ?: any ) : Promise < void > {
190195 if ( userQuery ) {
191- this . history . add ( { text : userQuery , state : inputState } ) ;
196+ this . history . add ( userQuery ) ;
197+ this . historyStates . set ( userQuery , inputState ) ;
192198 }
193199
194200 if ( this . accessibilityService . isScreenReaderOptimized ( ) && isMacintosh ) {
@@ -364,7 +370,8 @@ export class ChatInputPart extends Disposable implements IHistoryNavigationWidge
364370
365371 saveState ( ) : void {
366372 const inputHistory = this . history . getHistory ( ) ;
367- this . historyService . saveHistory ( this . providerId ! , inputHistory ) ;
373+ const historyEntries = inputHistory . map ( entry => ( { text : entry , state : this . historyStates . get ( entry ) } ) ) ;
374+ this . historyService . saveHistory ( this . providerId ! , historyEntries ) ;
368375 }
369376}
370377
0 commit comments