@@ -70,7 +70,8 @@ import {
7070 handle_manage_configurations ,
7171 handle_save_component_collapsed_state ,
7272 handle_undo ,
73- handle_delete_checkpoint
73+ handle_delete_checkpoint ,
74+ handle_request_can_undo
7475} from './message-handlers'
7576import {
7677 API_EDIT_FORMAT_STATE_KEY ,
@@ -81,7 +82,6 @@ import {
8182 INSTRUCTIONS_EDIT_CONTEXT_STATE_KEY ,
8283 INSTRUCTIONS_NO_CONTEXT_STATE_KEY ,
8384 get_configurations_collapsed_state_key ,
84- LAST_APPLIED_CHANGES_STATE_KEY ,
8585 LAST_SELECTED_CODE_COMPLETION_CONFIG_ID_STATE_KEY ,
8686 LAST_SELECTED_EDIT_CONTEXT_CONFIG_ID_STATE_KEY ,
8787 get_presets_collapsed_state_key ,
@@ -92,7 +92,6 @@ import {
9292 config_preset_to_ui_format ,
9393 ConfigPresetFormat
9494} from '@/views/panel/backend/utils/preset-format-converters'
95- import { OriginalFileState } from '@/commands/apply-chat-response-command/types/original-file-state'
9695import { CHATBOTS } from '@shared/constants/chatbots'
9796import { MODE , Mode } from '../types/main-view-mode'
9897import { ApiPromptType , WebPromptType } from '@shared/types/prompt-types'
@@ -648,6 +647,8 @@ export class PanelProvider implements vscode.WebviewViewProvider {
648647 if ( this . preview_switch_choice_resolver ) {
649648 this . preview_switch_choice_resolver ( message . choice )
650649 }
650+ } else if ( message . command == 'REQUEST_CAN_UNDO' ) {
651+ handle_request_can_undo ( this )
651652 }
652653 } catch ( error : any ) {
653654 Logger . error ( {
@@ -661,15 +662,6 @@ export class PanelProvider implements vscode.WebviewViewProvider {
661662 }
662663 }
663664 )
664-
665- this . send_presets_to_webview ( webview_view . webview )
666- // We need to wait until the webview fully initialized
667- setTimeout ( ( ) => {
668- this . send_message ( {
669- command : 'CAN_UNDO_CHANGED' ,
670- can_undo : this . _can_undo ( )
671- } )
672- } , 1000 )
673665 }
674666
675667 public calculate_token_count ( ) {
@@ -907,13 +899,6 @@ export class PanelProvider implements vscode.WebviewViewProvider {
907899 } )
908900 }
909901
910- private _can_undo ( ) : boolean {
911- const original_states = this . context . workspaceState . get <
912- OriginalFileState [ ]
913- > ( LAST_APPLIED_CHANGES_STATE_KEY )
914- return ! ! original_states && original_states . length > 0
915- }
916-
917902 private _get_html_for_webview ( webview : vscode . Webview ) {
918903 const resources_uri = webview . asWebviewUri (
919904 vscode . Uri . joinPath ( this . extension_uri , 'resources' )
0 commit comments