diff --git a/electron/services/opencodeService.ts b/electron/services/opencodeService.ts index d6ede19..c274af7 100644 --- a/electron/services/opencodeService.ts +++ b/electron/services/opencodeService.ts @@ -113,14 +113,21 @@ class OpenCodeService { this.process = null; }); - await new Promise((resolve) => { - setTimeout(resolve, 2000); - }); + const maxWaitTime = 30000; + const checkInterval = 500; + const startTime = Date.now(); - const isHealthy = await this.checkHealth(); - if (!isHealthy) { - log.warn('[OpenCodeService] Server started but health check failed, waiting longer...'); - await new Promise((resolve) => setTimeout(resolve, 3000)); + while (Date.now() - startTime < maxWaitTime) { + const isHealthy = await this.checkHealth(); + if (isHealthy) { + break; + } + await new Promise((resolve) => setTimeout(resolve, checkInterval)); + } + + const finalHealth = await this.checkHealth(); + if (!finalHealth) { + log.warn('[OpenCodeService] Health check failed after max wait time'); } this._isRunning = true; diff --git a/electron/services/sddService.ts b/electron/services/sddService.ts index 9112b1e..ab57863 100644 --- a/electron/services/sddService.ts +++ b/electron/services/sddService.ts @@ -125,7 +125,22 @@ class SDDService { this.processPid = null; }); - await new Promise((resolve) => setTimeout(resolve, 2000)); + const maxWaitTime = 30000; + const checkInterval = 500; + const startTime = Date.now(); + + while (Date.now() - startTime < maxWaitTime) { + const isHealthy = await this.checkHealth(); + if (isHealthy) { + break; + } + await new Promise((resolve) => setTimeout(resolve, checkInterval)); + } + + const finalHealth = await this.checkHealth(); + if (!finalHealth) { + log.warn('[SDDService] Health check failed after max wait time'); + } this._isRunning = true; this._isStarting = false; diff --git a/electron/services/terminalService.ts b/electron/services/terminalService.ts index 379c687..d0e6d7f 100644 --- a/electron/services/terminalService.ts +++ b/electron/services/terminalService.ts @@ -125,7 +125,22 @@ class TerminalService { this.processPid = null; }); - await new Promise((resolve) => setTimeout(resolve, 2000)); + const maxWaitTime = 30000; + const checkInterval = 500; + const startTime = Date.now(); + + while (Date.now() - startTime < maxWaitTime) { + const isHealthy = await this.checkHealth(); + if (isHealthy) { + break; + } + await new Promise((resolve) => setTimeout(resolve, checkInterval)); + } + + const finalHealth = await this.checkHealth(); + if (!finalHealth) { + log.warn('[TerminalService] Health check failed after max wait time'); + } this._isRunning = true; this._isStarting = false; diff --git a/electron/services/xcOpenCodeWebService.ts b/electron/services/xcOpenCodeWebService.ts index b6eb49e..0aab344 100644 --- a/electron/services/xcOpenCodeWebService.ts +++ b/electron/services/xcOpenCodeWebService.ts @@ -125,7 +125,22 @@ class XCOpenCodeWebService { this.processPid = null; }); - await new Promise((resolve) => setTimeout(resolve, 2000)); + const maxWaitTime = 30000; + const checkInterval = 500; + const startTime = Date.now(); + + while (Date.now() - startTime < maxWaitTime) { + const isHealthy = await this.checkHealth(); + if (isHealthy) { + break; + } + await new Promise((resolve) => setTimeout(resolve, checkInterval)); + } + + const finalHealth = await this.checkHealth(); + if (!finalHealth) { + log.warn('[XCOpenCodeWebService] Health check failed after max wait time'); + } this._isRunning = true; this._isStarting = false;