@@ -22,6 +22,7 @@ import { ongoing_preview_cleanup_promise } from '@/commands/apply-response-comma
2222import { CommitMessageDetails } from '@/utils/commit-message-details'
2323import { t } from '@/i18n'
2424import { get_error_message } from '@/utils/get-error-message'
25+ import { ResponseHistoryItem } from '@shared/types/response-history-item'
2526
2627export const restore_checkpoint = async ( params : {
2728 checkpoint : Checkpoint
@@ -58,32 +59,11 @@ export const restore_checkpoint = async (params: {
5859 } )
5960 }
6061
61- let open_files : {
62- uri : vscode . Uri
63- viewColumn : vscode . ViewColumn
64- isActive : boolean
65- } [ ] = [ ]
66-
67- if ( params . checkpoint . active_tabs ) {
68- open_files = params . checkpoint . active_tabs . map ( ( tab ) => ( {
69- uri : vscode . Uri . parse ( tab . uri ) ,
70- viewColumn : tab . view_column as vscode . ViewColumn ,
71- isActive : tab . is_active && tab . is_group_active
72- } ) )
73- } else {
74- const tab_groups = vscode . window . tabGroups . all
75- for ( const group of tab_groups ) {
76- for ( const tab of group . tabs ) {
77- if ( tab . input instanceof vscode . TabInputText ) {
78- open_files . push ( {
79- uri : ( tab . input as vscode . TabInputText ) . uri ,
80- viewColumn : group . viewColumn ,
81- isActive : tab . isActive && group . isActive
82- } )
83- }
84- }
85- }
86- }
62+ const open_files = ( params . checkpoint . active_tabs ?? [ ] ) . map ( ( tab ) => ( {
63+ uri : vscode . Uri . parse ( tab . uri ) ,
64+ viewColumn : tab . view_column as vscode . ViewColumn ,
65+ isActive : tab . is_active && tab . is_group_active
66+ } ) )
8767
8868 let temp_checkpoint : Checkpoint | undefined
8969 try {
@@ -176,12 +156,24 @@ export const restore_checkpoint = async (params: {
176156 progress
177157 )
178158
179- if ( params . checkpoint . response_history ) {
180- params . prompt_view_provider . response_history =
181- params . checkpoint . response_history
159+ let loaded_history : ResponseHistoryItem [ ] = [ ]
160+ try {
161+ const history_file_path = vscode . Uri . joinPath (
162+ vscode . Uri . file ( checkpoint_dir_path ) ,
163+ 'response-history.json'
164+ )
165+ const history_data =
166+ await vscode . workspace . fs . readFile ( history_file_path )
167+ loaded_history = JSON . parse ( new TextDecoder ( ) . decode ( history_data ) )
168+ } catch {
169+ // Ignore if file doesn't exist
170+ }
171+
172+ if ( loaded_history . length > 0 ) {
173+ params . prompt_view_provider . response_history = loaded_history
182174 params . prompt_view_provider . send_message ( {
183175 command : 'RESPONSE_HISTORY' ,
184- history : params . checkpoint . response_history
176+ history : loaded_history
185177 } )
186178 } else {
187179 params . prompt_view_provider . response_history = [ ]
@@ -191,18 +183,31 @@ export const restore_checkpoint = async (params: {
191183 } )
192184 }
193185
194- if ( params . checkpoint . completed_tasks ) {
195- params . prompt_view_provider . completed_tasks =
196- params . checkpoint . completed_tasks
186+ let loaded_completed_tasks : string [ ] | undefined
187+ try {
188+ const completed_tasks_file_path = vscode . Uri . joinPath (
189+ vscode . Uri . file ( checkpoint_dir_path ) ,
190+ 'completed-tasks.json'
191+ )
192+ const completed_tasks_data = await vscode . workspace . fs . readFile (
193+ completed_tasks_file_path
194+ )
195+ loaded_completed_tasks = JSON . parse (
196+ new TextDecoder ( ) . decode ( completed_tasks_data )
197+ )
198+ } catch { }
199+
200+ if ( loaded_completed_tasks !== undefined ) {
201+ params . prompt_view_provider . completed_tasks = loaded_completed_tasks
197202 await params . extension_context . workspaceState . update (
198203 COMPLETED_TASKS_STATE_KEY ,
199- params . checkpoint . completed_tasks
204+ loaded_completed_tasks
200205 )
201206 params . prompt_view_provider . send_message ( {
202207 command : 'COMPLETED_TASKS' ,
203- completed_tasks : params . checkpoint . completed_tasks
208+ completed_tasks : loaded_completed_tasks
204209 } )
205- } else {
210+ } else if ( params . checkpoint . trigger !== 'temporary' ) {
206211 params . prompt_view_provider . completed_tasks = [ ]
207212 await params . extension_context . workspaceState . update (
208213 COMPLETED_TASKS_STATE_KEY ,
@@ -243,13 +248,11 @@ export const restore_checkpoint = async (params: {
243248 } catch { }
244249 }
245250
246- if ( params . checkpoint . selected_files ) {
247- await params . extension_context . workspaceState . update (
248- CONTEXT_SELECTED_PATHS_STATE_KEY ,
249- params . checkpoint . selected_files
250- )
251- params . workspace_provider . load_selected_files_state ( )
252- }
251+ await params . extension_context . workspaceState . update (
252+ CONTEXT_SELECTED_PATHS_STATE_KEY ,
253+ params . checkpoint . selected_files
254+ )
255+ params . workspace_provider . load_selected_files_state ( )
253256
254257 params . prompt_view_provider . send_token_count ( )
255258
@@ -261,9 +264,9 @@ export const restore_checkpoint = async (params: {
261264 if (
262265 params . checkpoint . trigger === 'response-accepted' &&
263266 params . checkpoint . response_preview_item_created_at &&
264- params . checkpoint . response_history
267+ loaded_history . length > 0
265268 ) {
266- const item_to_preview = params . checkpoint . response_history . find (
269+ const item_to_preview = loaded_history . find (
267270 ( item ) =>
268271 item . created_at ==
269272 params . checkpoint . response_preview_item_created_at
0 commit comments