@@ -73,61 +73,65 @@ export function getCheckpointService(cline: Task) {
7373 cline . checkpointServiceInitializing = true
7474
7575 // Check if Git is installed before initializing the service
76- ; ( async ( ) => {
77- try {
78- const gitInstalled = await checkGitInstalled ( )
76+ // Note: This is intentionally fire-and-forget to match the original IIFE pattern
77+ // The service is returned immediately while Git check happens asynchronously
78+ checkGitInstallation ( cline , service , log , provider )
7979
80- if ( ! gitInstalled ) {
81- log ( "[Task#getCheckpointService] Git is not installed, disabling checkpoints" )
82- cline . enableCheckpoints = false
83- cline . checkpointServiceInitializing = false
80+ return service
81+ } catch ( err ) {
82+ log ( `[Task#getCheckpointService] ${ err . message } ` )
83+ cline . enableCheckpoints = false
84+ return undefined
85+ }
86+ }
8487
85- // Show user-friendly notification
86- const selection = await vscode . window . showWarningMessage (
87- t ( "common:errors.git_not_installed" ) ,
88- t ( "common:buttons.learn_more" ) ,
89- )
88+ async function checkGitInstallation (
89+ cline : Task ,
90+ service : RepoPerTaskCheckpointService ,
91+ log : ( message : string ) => void ,
92+ provider : any ,
93+ ) {
94+ try {
95+ const gitInstalled = await checkGitInstalled ( )
9096
91- if ( selection === t ( "common:buttons.learn_more" ) ) {
92- vscode . env . openExternal ( vscode . Uri . parse ( "https://git-scm.com/downloads" ) )
93- }
97+ if ( ! gitInstalled ) {
98+ log ( "[Task#getCheckpointService] Git is not installed, disabling checkpoints" )
99+ cline . enableCheckpoints = false
100+ cline . checkpointServiceInitializing = false
94101
95- return
96- }
102+ // Show user-friendly notification
103+ const selection = await vscode . window . showWarningMessage (
104+ t ( "common:errors.git_not_installed" ) ,
105+ t ( "common:buttons.learn_more" ) ,
106+ )
97107
98- // Git is installed, proceed with initialization
99- service . on ( "initialize" , ( ) => {
100- log ( "[Task#getCheckpointService] service initialized" )
101-
102- try {
103- const isCheckpointNeeded =
104- typeof cline . clineMessages . find ( ( { say } ) => say === "checkpoint_saved" ) === "undefined"
105-
106- cline . checkpointService = service
107- cline . checkpointServiceInitializing = false
108-
109- if ( isCheckpointNeeded ) {
110- log ( "[Task#getCheckpointService] no checkpoints found, saving initial checkpoint" )
111- checkpointSave ( cline )
112- }
113- } catch ( err ) {
114- log ( "[Task#getCheckpointService] caught error in on('initialize'), disabling checkpoints" )
115- cline . enableCheckpoints = false
116- }
117- } )
118- } catch ( err ) {
119- // Differentiate between Git check errors and other errors
120- if ( err ?. message ?. includes ( "git" ) || err ?. message ?. includes ( "Git" ) ) {
121- log ( "[Task#getCheckpointService] Git check failed, disabling checkpoints" )
122- console . error ( "Git check error:" , err )
123- } else {
124- log ( "[Task#getCheckpointService] Unexpected error during initialization, disabling checkpoints" )
125- console . error ( "Initialization error:" , err )
108+ if ( selection === t ( "common:buttons.learn_more" ) ) {
109+ await vscode . env . openExternal ( vscode . Uri . parse ( "https://git-scm.com/downloads" ) )
110+ }
111+
112+ return
113+ }
114+
115+ // Git is installed, proceed with initialization
116+ service . on ( "initialize" , ( ) => {
117+ log ( "[Task#getCheckpointService] service initialized" )
118+
119+ try {
120+ const isCheckpointNeeded =
121+ typeof cline . clineMessages . find ( ( { say } ) => say === "checkpoint_saved" ) === "undefined"
122+
123+ cline . checkpointService = service
124+ cline . checkpointServiceInitializing = false
125+
126+ if ( isCheckpointNeeded ) {
127+ log ( "[Task#getCheckpointService] no checkpoints found, saving initial checkpoint" )
128+ checkpointSave ( cline )
126129 }
130+ } catch ( err ) {
131+ log ( "[Task#getCheckpointService] caught error in on('initialize'), disabling checkpoints" )
127132 cline . enableCheckpoints = false
128- cline . checkpointServiceInitializing = false
129133 }
130- } ) ( )
134+ } )
131135
132136 service . on ( "checkpoint" , ( { isFirst, fromHash : from , toHash : to } ) => {
133137 try {
@@ -154,12 +158,11 @@ export function getCheckpointService(cline: Task) {
154158 log ( `[Task#getCheckpointService] initShadowGit -> ${ err . message } ` )
155159 cline . enableCheckpoints = false
156160 } )
157-
158- return service
159161 } catch ( err ) {
160- log ( `[Task#getCheckpointService] ${ err . message } ` )
162+ log ( `[Task#getCheckpointService] Unexpected error during Git check: ${ err . message } ` )
163+ console . error ( "Git check error:" , err )
161164 cline . enableCheckpoints = false
162- return undefined
165+ cline . checkpointServiceInitializing = false
163166 }
164167}
165168
0 commit comments