@@ -14,8 +14,8 @@ type ResponseHistoryItem = {
1414 response : string
1515 raw_instructions ?: string
1616 created_at : number
17- lines_added : number
18- lines_removed : number
17+ lines_added ? : number
18+ lines_removed ? : number
1919 files ?: FileInPreview [ ]
2020}
2121
@@ -160,10 +160,10 @@ export const use_panel = (vscode: any) => {
160160 } )
161161 set_response_history ( ( current_history ) => {
162162 const history_item_index = current_history . findIndex (
163- ( item ) => item . created_at === selected_history_item_created_at
163+ ( item ) => item . created_at == selected_history_item_created_at
164164 )
165165
166- if ( history_item_index === - 1 ) {
166+ if ( history_item_index == - 1 ) {
167167 return current_history
168168 }
169169
@@ -176,11 +176,11 @@ export const use_panel = (vscode: any) => {
176176
177177 const file_in_history_index = files_in_history . findIndex (
178178 ( f ) =>
179- f . file_path === message . file . file_path &&
180- f . workspace_name === message . file . workspace_name
179+ f . file_path == message . file . file_path &&
180+ f . workspace_name == message . file . workspace_name
181181 )
182182
183- if ( file_in_history_index !== - 1 ) {
183+ if ( file_in_history_index != - 1 ) {
184184 files_in_history [ file_in_history_index ] = message . file
185185 } else {
186186 files_in_history . push ( message . file )
@@ -242,12 +242,12 @@ export const use_panel = (vscode: any) => {
242242 }
243243 ] )
244244 } else {
245- const is_duplicate = response_history . some (
245+ const duplicate_index = response_history . findIndex (
246246 ( item ) =>
247247 item . response == message . response &&
248248 item . raw_instructions == message . raw_instructions
249249 )
250- if ( ! is_duplicate ) {
250+ if ( duplicate_index == - 1 ) {
251251 const new_item = {
252252 response : message . response ,
253253 raw_instructions : message . raw_instructions ,
@@ -261,13 +261,15 @@ export const use_panel = (vscode: any) => {
261261 set_selected_history_item_created_at ( now )
262262 }
263263 } else {
264- set_selected_history_item_created_at (
265- response_history . find (
266- ( item ) =>
267- item . response == message . response &&
268- item . raw_instructions == message . raw_instructions
269- ) ?. created_at
270- )
264+ const new_history = [ ...response_history ]
265+ const existing_item = new_history [ duplicate_index ]
266+ new_history [ duplicate_index ] = {
267+ ...existing_item ,
268+ ...message ,
269+ created_at : existing_item . created_at
270+ }
271+ set_response_history ( new_history )
272+ set_selected_history_item_created_at ( existing_item . created_at )
271273 }
272274 }
273275 } else if ( message . command == 'CONTEXT_SIZE_WARNING_THRESHOLD' ) {
0 commit comments