File tree Expand file tree Collapse file tree
apps/editor/src/commands/apply-chat-response-command Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -267,6 +267,8 @@ export const apply_chat_response_command = (params: {
267267 lines_removed : diff_stats . lines_removed ,
268268 diff_application_method : state . diff_application_method ,
269269 content : current_content ,
270+ proposed_content :
271+ state . proposed_content ?? state . ai_content ?? current_content ,
270272 is_checked : true ,
271273 apply_failed : state . apply_failed ,
272274 ai_content : state . ai_content ,
@@ -290,6 +292,7 @@ export const apply_chat_response_command = (params: {
290292 lines_added : 0 ,
291293 lines_removed : deleted_diff_stats . lines_removed ,
292294 content : '' ,
295+ proposed_content : '' ,
293296 is_checked : true
294297 } )
295298 }
Original file line number Diff line number Diff line change @@ -78,6 +78,7 @@ export const process_chat_response = async (
7878 ai_content : file_in_preview ?. ai_content ,
7979 proposed_content :
8080 file_in_preview ?. proposed_content ?? file_in_preview ?. content ,
81+ current_content : file_in_preview ?. content ,
8182 is_checked : file_in_preview ?. is_checked ,
8283 apply_failed : file_in_preview ?. apply_failed ,
8384 applied_with_intelligent_update :
Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ export type OriginalFileState = {
1010 is_checked ?: boolean
1111 ai_content ?: string
1212 proposed_content ?: string
13+ current_content ?: string
1314 apply_failed ?: boolean
1415 applied_with_intelligent_update ?: boolean
1516}
Original file line number Diff line number Diff line change @@ -36,7 +36,11 @@ export const prepare_files_from_original_states = async (params: {
3636 if ( fs . existsSync ( sanitized_file_path ) ) {
3737 file_exists = true
3838 current_content =
39- state . proposed_content ?? fs . readFileSync ( sanitized_file_path , 'utf8' )
39+ state . current_content ??
40+ state . proposed_content ??
41+ fs . readFileSync ( sanitized_file_path , 'utf8' )
42+ } else if ( state . current_content !== undefined ) {
43+ current_content = state . current_content
4044 } else if ( state . proposed_content !== undefined ) {
4145 current_content = state . proposed_content
4246 }
@@ -45,7 +49,10 @@ export const prepare_files_from_original_states = async (params: {
4549 }
4650
4751 let new_content_for_diff = current_content
48- if ( state . is_checked === false && state . ai_content !== undefined ) {
52+ if ( state . is_checked === false && state . current_content !== undefined ) {
53+ current_content = state . current_content
54+ new_content_for_diff = state . content
55+ } else if ( state . is_checked === false && state . ai_content !== undefined ) {
4956 current_content = state . ai_content
5057 new_content_for_diff = state . content
5158 }
You can’t perform that action at this time.
0 commit comments