Compare commits

...

1 Commits

Author SHA1 Message Date
abeatrix 0f548eda7f fix: cache CLI detection and hard-kill on timeout
- Add cached result and timestamp to `isClineCliInstalled` to avoid
  repeated checks within a 5-minute window
- Force-kill CLI version check on timeout with SIGKILL to prevent
  zombie processes
- Re-check CLI installation after install command completes to refresh
  cached state and timer
- Remove unused Logger error log in install flow
2026-01-22 22:12:59 -08:00
2 changed files with 21 additions and 6 deletions
+4 -2
View File
@@ -2,7 +2,7 @@ import { Empty, EmptyRequest } from "@shared/proto/cline/common"
import { ShowMessageType } from "@shared/proto/host/window"
import { ExecuteCommandInTerminalRequest } from "@shared/proto/host/workspace"
import { HostProvider } from "@/hosts/host-provider"
import { Logger } from "@/shared/services/Logger"
import { isClineCliInstalled } from "@/utils/cli-detector"
import { Controller } from ".."
/**
@@ -26,8 +26,10 @@ export async function installClineCli(_controller: Controller, _request: EmptyRe
if (!response.success) {
throw new Error("Failed to execute command in terminal")
}
// Force a re-check and reset timeer
await isClineCliInstalled(true)
} catch (error) {
Logger.error("Error executing CLI installation:", error)
await HostProvider.window.showMessage({
type: ShowMessageType.ERROR,
message: `Failed to start CLI installation: ${error instanceof Error ? error.message : "Unknown error"}`,
+17 -4
View File
@@ -13,25 +13,38 @@ interface CliSubagentDetectionParams {
outputFormat?: string
}
let lastCheckTime = 0
let lastCheckResult = false
const CHECK_CACHE_DURATION_MS = 5 * 60 * 1000 // 5 minutes
/**
* Check if the Cline CLI tool is installed on the system
* @returns true if CLI is installed, false otherwise
*/
export async function isClineCliInstalled(): Promise<boolean> {
export async function isClineCliInstalled(force = false): Promise<boolean> {
try {
const current = Date.now()
if (!force && current - lastCheckTime < CHECK_CACHE_DURATION_MS) {
return lastCheckResult
}
// Try to get the version of the cline CLI tool
// This will fail if the tool is not installed
const { stdout } = await execAsync("cline version", {
timeout: 5000, // 5 second timeout
killSignal: "SIGKILL", // Force kill if timeout occurs
})
// If we get here, the CLI is installed
// We could also validate the version if needed
return stdout.includes("Cline CLI Version") || stdout.includes("Cline Core Version")
} catch (error) {
const result = stdout.includes("Cline CLI Version") || stdout.includes("Cline Core Version")
lastCheckResult = result
lastCheckTime = current
return result
} catch {
// Command failed, which likely means CLI is not installed
// or not in PATH
return false
return lastCheckResult
}
}