Skip to content

Checkpoints cannot be initialized in large repositories #7843

@NaccOll

Description

@NaccOll

App Version

3.27.0

API Provider

Not Applicable / Other

Model Used

N/A

Roo Code Task Links (Optional)

No response

🔁 Steps to Reproduce

When I enable checkpointing, I expect it to be initialized.

However, when the repository is large, initializing the checkpoint takes a long time. But now it only has a 15 second wait time. Please see below for the code

src\core\checkpoints\index.ts:19-99

export async function getCheckpointService(
	task: Task,
	{ interval = 250, timeout = 15_000 }: { interval?: number; timeout?: number } = {},
) {
	if (!task.enableCheckpoints) {
		return undefined
	}

	if (task.checkpointService) {
		return task.checkpointService
	}

	const provider = task.providerRef.deref()

	const log = (message: string) => {
		console.log(message)

		try {
			provider?.log(message)
		} catch (err) {
			// NO-OP
		}
	}

	console.log("[Task#getCheckpointService] initializing checkpoints service")

	try {
		const workspaceDir = task.cwd || getWorkspacePath()

		if (!workspaceDir) {
			log("[Task#getCheckpointService] workspace folder not found, disabling checkpoints")
			task.enableCheckpoints = false
			return undefined
		}

		const globalStorageDir = provider?.context.globalStorageUri.fsPath

		if (!globalStorageDir) {
			log("[Task#getCheckpointService] globalStorageDir not found, disabling checkpoints")
			task.enableCheckpoints = false
			return undefined
		}

		const options: CheckpointServiceOptions = {
			taskId: task.taskId,
			workspaceDir,
			shadowDir: globalStorageDir,
			log,
		}

		if (task.checkpointServiceInitializing) {
			await pWaitFor(
				() => {
					console.log("[Task#getCheckpointService] waiting for service to initialize")
					return !!task.checkpointService && !!task?.checkpointService?.isInitialized
				},
				{ interval, timeout },
			)
			if (!task?.checkpointService) {
				task.enableCheckpoints = false
				return undefined
			}
			return task.checkpointService
		}

		if (!task.enableCheckpoints) {
			return undefined
		}

		const service = RepoPerTaskCheckpointService.create(options)
		task.checkpointServiceInitializing = true
		await checkGitInstallation(task, service, log, provider)
		task.checkpointService = service
		return service
	} catch (err) {
		log(`[Task#getCheckpointService] ${err.message}`)
		task.enableCheckpoints = false
		task.checkpointServiceInitializing = false
		return undefined
	}
}

When the task starts, getCheckpointService is called by async.

src\core\task\Task.ts:1664-1664

		getCheckpointService(this)

After my investigation, it turns out that Cline's checkpoints can work on large code repositories simply because they don't have a timeout. After more than 15 seconds, Cline only displays a reminder but continues to wait for the checkpoint to initialize.

To address this issue, I believe two approaches should be considered.

  1. Optimize the existing checkpoint timeout warning. Since checkpoint initialization became asynchronous, the checkpoint timeout warning has been ineffective because the message length is non-zero.
  2. Allow custom checkpoint timeouts.

💥 Outcome Summary

Expected initialize checkpoint, But checkpoint disabled even though the editing tool is called much later in the task, it takes more than 15 seconds to initialize the checkpoint due to the large repository.

📄 Relevant Logs or Errors (Optional)

Metadata

Metadata

Assignees

Labels

Issue - In ProgressSomeone is actively working on this. Should link to a PR soon.bugSomething isn't working

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions