Browse Source

Merge pull request #914 from RooVetGit/cte/disable-checkpoints-on-windows

Disable checkpoints on Windows
Matt Rubens 11 months ago
parent
commit
cbf47aa05c

+ 2 - 1
src/core/Cline.ts

@@ -143,7 +143,7 @@ export class Cline {
 		this.fuzzyMatchThreshold = fuzzyMatchThreshold ?? 1.0
 		this.providerRef = new WeakRef(provider)
 		this.diffViewProvider = new DiffViewProvider(cwd)
-		this.checkpointsEnabled = enableCheckpoints ?? false
+		this.checkpointsEnabled = process.platform !== "win32" && !!enableCheckpoints
 
 		if (historyItem) {
 			this.taskId = historyItem.id
@@ -3240,6 +3240,7 @@ export class Cline {
 			this.checkpointService = await CheckpointService.create({
 				taskId: this.taskId,
 				baseDir: vscode.workspace.workspaceFolders?.map((folder) => folder.uri.fsPath).at(0) ?? "",
+				log: (message) => this.providerRef.deref()?.log(message),
 			})
 		}
 

+ 5 - 10
src/services/checkpoints/CheckpointService.ts

@@ -2,7 +2,6 @@ import fs from "fs/promises"
 import { existsSync } from "fs"
 import path from "path"
 
-import debug from "debug"
 import simpleGit, { SimpleGit, CleanOptions } from "simple-git"
 
 export type CheckpointServiceOptions = {
@@ -246,15 +245,11 @@ export class CheckpointService {
 	}
 
 	public static async create({ taskId, git, baseDir, log = console.log }: CheckpointServiceOptions) {
-		git =
-			git ||
-			simpleGit({
-				baseDir,
-				binary: "git",
-				maxConcurrentProcesses: 1,
-				config: [],
-				trimmed: true,
-			})
+		if (process.platform === "win32") {
+			throw new Error("Checkpoints are not supported on Windows.")
+		}
+
+		git = git || simpleGit({ baseDir })
 
 		const version = await git.version()
 

+ 14 - 0
src/services/checkpoints/__tests__/CheckpointService.test.ts

@@ -14,6 +14,7 @@ describe("CheckpointService", () => {
 	let git: SimpleGit
 	let testFile: string
 	let service: CheckpointService
+	let originalPlatform: string
 
 	const initRepo = async ({
 		baseDir,
@@ -48,6 +49,19 @@ describe("CheckpointService", () => {
 		return { git, testFile }
 	}
 
+	beforeAll(() => {
+		originalPlatform = process.platform
+		Object.defineProperty(process, "platform", {
+			value: "darwin",
+		})
+	})
+
+	afterAll(() => {
+		Object.defineProperty(process, "platform", {
+			value: originalPlatform,
+		})
+	})
+
 	beforeEach(async () => {
 		const baseDir = path.join(os.tmpdir(), `checkpoint-service-test-${Date.now()}`)
 		const repo = await initRepo({ baseDir })

+ 21 - 19
webview-ui/src/components/settings/SettingsView.tsx

@@ -701,27 +701,29 @@ const SettingsView = ({ onDone }: SettingsViewProps) => {
 							</div>
 						)}
 
-						<div style={{ marginBottom: 15 }}>
-							<div style={{ display: "flex", alignItems: "center", gap: "5px" }}>
-								<span style={{ color: "var(--vscode-errorForeground)" }}>⚠️</span>
-								<VSCodeCheckbox
-									checked={checkpointsEnabled}
-									onChange={(e: any) => {
-										setCheckpointsEnabled(e.target.checked)
+						{process.platform !== "win32" && (
+							<div style={{ marginBottom: 15 }}>
+								<div style={{ display: "flex", alignItems: "center", gap: "5px" }}>
+									<span style={{ color: "var(--vscode-errorForeground)" }}>⚠️</span>
+									<VSCodeCheckbox
+										checked={checkpointsEnabled}
+										onChange={(e: any) => {
+											setCheckpointsEnabled(e.target.checked)
+										}}>
+										<span style={{ fontWeight: "500" }}>Enable experimental checkpoints</span>
+									</VSCodeCheckbox>
+								</div>
+								<p
+									style={{
+										fontSize: "12px",
+										marginTop: "5px",
+										color: "var(--vscode-descriptionForeground)",
 									}}>
-									<span style={{ fontWeight: "500" }}>Enable experimental checkpoints</span>
-								</VSCodeCheckbox>
+									When enabled, Roo will save a checkpoint whenever a file in the workspace is
+									modified, added or deleted, letting you easily revert to a previous state.
+								</p>
 							</div>
-							<p
-								style={{
-									fontSize: "12px",
-									marginTop: "5px",
-									color: "var(--vscode-descriptionForeground)",
-								}}>
-								When enabled, Roo will save a checkpoint whenever a file in the workspace is modified,
-								added or deleted, letting you easily revert to a previous state.
-							</p>
-						</div>
+						)}
 
 						{Object.entries(experimentConfigsMap)
 							.filter((config) => config[0] !== "DIFF_STRATEGY")