Skip to content

Commit 1a7fa65

Browse files
committed
More fixes
1 parent 3eebfb4 commit 1a7fa65

File tree

19 files changed

+620
-919
lines changed

19 files changed

+620
-919
lines changed

src/core/Cline.ts

Lines changed: 25 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,7 @@ import { TokenUsage } from "../schemas"
1616
import { ApiHandler, buildApiHandler } from "../api"
1717
import { ApiStream } from "../api/transform/stream"
1818
import { DIFF_VIEW_URI_SCHEME, DiffViewProvider } from "../integrations/editor/DiffViewProvider"
19-
import {
20-
CheckpointServiceOptions,
21-
RepoPerTaskCheckpointService,
22-
RepoPerWorkspaceCheckpointService,
23-
} from "../services/checkpoints"
19+
import { CheckpointServiceOptions, RepoPerTaskCheckpointService } from "../services/checkpoints"
2420
import { findToolName, formatContentBlockToMarkdown } from "../integrations/misc/export-markdown"
2521
import { fetchInstructionsTool } from "./tools/fetchInstructionsTool"
2622
import { listFilesTool } from "./tools/listFilesTool"
@@ -30,7 +26,6 @@ import { Terminal } from "../integrations/terminal/Terminal"
3026
import { TerminalRegistry } from "../integrations/terminal/TerminalRegistry"
3127
import { UrlContentFetcher } from "../services/browser/UrlContentFetcher"
3228
import { listFiles } from "../services/glob/list-files"
33-
import { CheckpointStorage } from "../shared/checkpoints"
3429
import { ApiConfiguration } from "../shared/api"
3530
import { findLastIndex } from "../shared/array"
3631
import { combineApiRequests } from "../shared/combineApiRequests"
@@ -104,7 +99,6 @@ export type ClineOptions = {
10499
customInstructions?: string
105100
enableDiff?: boolean
106101
enableCheckpoints?: boolean
107-
checkpointStorage?: CheckpointStorage
108102
fuzzyMatchThreshold?: number
109103
consecutiveMistakeLimit?: number
110104
task?: string
@@ -162,8 +156,8 @@ export class Cline extends EventEmitter<ClineEvents> {
162156

163157
// checkpoints
164158
private enableCheckpoints: boolean
165-
private checkpointStorage: CheckpointStorage
166-
private checkpointService?: RepoPerTaskCheckpointService | RepoPerWorkspaceCheckpointService
159+
private checkpointService?: RepoPerTaskCheckpointService
160+
private checkpointServiceInitializing = false
167161

168162
// streaming
169163
isWaitingForFirstChunk = false
@@ -184,7 +178,6 @@ export class Cline extends EventEmitter<ClineEvents> {
184178
customInstructions,
185179
enableDiff = false,
186180
enableCheckpoints = true,
187-
checkpointStorage = "task",
188181
fuzzyMatchThreshold = 1.0,
189182
consecutiveMistakeLimit = 3,
190183
task,
@@ -223,7 +216,6 @@ export class Cline extends EventEmitter<ClineEvents> {
223216
this.providerRef = new WeakRef(provider)
224217
this.diffViewProvider = new DiffViewProvider(this.cwd)
225218
this.enableCheckpoints = enableCheckpoints
226-
this.checkpointStorage = checkpointStorage
227219

228220
this.rootTask = rootTask
229221
this.parentTask = parentTask
@@ -2399,6 +2391,11 @@ export class Cline extends EventEmitter<ClineEvents> {
23992391
return this.checkpointService
24002392
}
24012393

2394+
if (this.checkpointServiceInitializing) {
2395+
console.log("[Cline#getCheckpointService] checkpoint service is still initializing")
2396+
return undefined
2397+
}
2398+
24022399
const log = (message: string) => {
24032400
console.log(message)
24042401

@@ -2409,19 +2406,21 @@ export class Cline extends EventEmitter<ClineEvents> {
24092406
}
24102407
}
24112408

2409+
console.log("[Cline#getCheckpointService] initializing checkpoints service")
2410+
24122411
try {
24132412
const workspaceDir = getWorkspacePath()
24142413

24152414
if (!workspaceDir) {
2416-
log("[Cline#initializeCheckpoints] workspace folder not found, disabling checkpoints")
2415+
log("[Cline#getCheckpointService] workspace folder not found, disabling checkpoints")
24172416
this.enableCheckpoints = false
24182417
return undefined
24192418
}
24202419

24212420
const globalStorageDir = this.providerRef.deref()?.context.globalStorageUri.fsPath
24222421

24232422
if (!globalStorageDir) {
2424-
log("[Cline#initializeCheckpoints] globalStorageDir not found, disabling checkpoints")
2423+
log("[Cline#getCheckpointService] globalStorageDir not found, disabling checkpoints")
24252424
this.enableCheckpoints = false
24262425
return undefined
24272426
}
@@ -2433,28 +2432,26 @@ export class Cline extends EventEmitter<ClineEvents> {
24332432
log,
24342433
}
24352434

2436-
// Only `task` is supported at the moment until we figure out how
2437-
// to fully isolate the `workspace` variant.
2438-
// const service =
2439-
// this.checkpointStorage === "task"
2440-
// ? RepoPerTaskCheckpointService.create(options)
2441-
// : RepoPerWorkspaceCheckpointService.create(options)
2442-
24432435
const service = RepoPerTaskCheckpointService.create(options)
24442436

2437+
this.checkpointServiceInitializing = true
2438+
24452439
service.on("initialize", () => {
2440+
log("[Cline#getCheckpointService] service initialized")
2441+
24462442
try {
24472443
const isCheckpointNeeded =
24482444
typeof this.clineMessages.find(({ say }) => say === "checkpoint_saved") === "undefined"
24492445

24502446
this.checkpointService = service
2447+
this.checkpointServiceInitializing = false
24512448

24522449
if (isCheckpointNeeded) {
2453-
log("[Cline#initializeCheckpoints] no checkpoints found, saving initial checkpoint")
2450+
log("[Cline#getCheckpointService] no checkpoints found, saving initial checkpoint")
24542451
this.checkpointSave()
24552452
}
24562453
} catch (err) {
2457-
log("[Cline#initializeCheckpoints] caught error in on('initialize'), disabling checkpoints")
2454+
log("[Cline#getCheckpointService] caught error in on('initialize'), disabling checkpoints")
24582455
this.enableCheckpoints = false
24592456
}
24602457
})
@@ -2464,29 +2461,31 @@ export class Cline extends EventEmitter<ClineEvents> {
24642461
this.providerRef.deref()?.postMessageToWebview({ type: "currentCheckpointUpdated", text: to })
24652462

24662463
this.say("checkpoint_saved", to, undefined, undefined, { isFirst, from, to }).catch((err) => {
2467-
log("[Cline#initializeCheckpoints] caught unexpected error in say('checkpoint_saved')")
2464+
log("[Cline#getCheckpointService] caught unexpected error in say('checkpoint_saved')")
24682465
console.error(err)
24692466
})
24702467
} catch (err) {
24712468
log(
2472-
"[Cline#initializeCheckpoints] caught unexpected error in on('checkpoint'), disabling checkpoints",
2469+
"[Cline#getCheckpointService] caught unexpected error in on('checkpoint'), disabling checkpoints",
24732470
)
24742471
console.error(err)
24752472
this.enableCheckpoints = false
24762473
}
24772474
})
24782475

2476+
log("[Cline#getCheckpointService] initializing shadow git")
2477+
24792478
service.initShadowGit().catch((err) => {
24802479
log(
2481-
`[Cline#initializeCheckpoints] caught unexpected error in initShadowGit, disabling checkpoints (${err.message})`,
2480+
`[Cline#getCheckpointService] caught unexpected error in initShadowGit, disabling checkpoints (${err.message})`,
24822481
)
24832482
console.error(err)
24842483
this.enableCheckpoints = false
24852484
})
24862485

24872486
return service
24882487
} catch (err) {
2489-
log("[Cline#initializeCheckpoints] caught unexpected error, disabling checkpoints")
2488+
log("[Cline#getCheckpointService] caught unexpected error, disabling checkpoints")
24902489
this.enableCheckpoints = false
24912490
return undefined
24922491
}

src/core/webview/ClineProvider.ts

Lines changed: 1 addition & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -483,7 +483,6 @@ export class ClineProvider extends EventEmitter<ClineProviderEvents> implements
483483
| "customInstructions"
484484
| "enableDiff"
485485
| "enableCheckpoints"
486-
| "checkpointStorage"
487486
| "fuzzyMatchThreshold"
488487
| "consecutiveMistakeLimit"
489488
| "experiments"
@@ -495,7 +494,6 @@ export class ClineProvider extends EventEmitter<ClineProviderEvents> implements
495494
customModePrompts,
496495
diffEnabled: enableDiff,
497496
enableCheckpoints,
498-
checkpointStorage,
499497
fuzzyMatchThreshold,
500498
mode,
501499
customInstructions: globalInstructions,
@@ -511,7 +509,6 @@ export class ClineProvider extends EventEmitter<ClineProviderEvents> implements
511509
customInstructions: effectiveInstructions,
512510
enableDiff,
513511
enableCheckpoints,
514-
checkpointStorage,
515512
fuzzyMatchThreshold,
516513
task,
517514
images,
@@ -540,7 +537,6 @@ export class ClineProvider extends EventEmitter<ClineProviderEvents> implements
540537
customModePrompts,
541538
diffEnabled: enableDiff,
542539
enableCheckpoints,
543-
checkpointStorage,
544540
fuzzyMatchThreshold,
545541
mode,
546542
customInstructions: globalInstructions,
@@ -550,38 +546,12 @@ export class ClineProvider extends EventEmitter<ClineProviderEvents> implements
550546
const modePrompt = customModePrompts?.[mode] as PromptComponent
551547
const effectiveInstructions = [globalInstructions, modePrompt?.customInstructions].filter(Boolean).join("\n\n")
552548

553-
const taskId = historyItem.id
554-
const globalStorageDir = this.contextProxy.globalStorageUri.fsPath
555-
const workspaceDir = this.cwd
556-
557-
const checkpoints: Pick<ClineOptions, "enableCheckpoints" | "checkpointStorage"> = {
558-
enableCheckpoints,
559-
checkpointStorage,
560-
}
561-
562-
if (enableCheckpoints) {
563-
try {
564-
checkpoints.checkpointStorage = await ShadowCheckpointService.getTaskStorage({
565-
taskId,
566-
globalStorageDir,
567-
workspaceDir,
568-
})
569-
570-
this.log(
571-
`[ClineProvider#initClineWithHistoryItem] Using ${checkpoints.checkpointStorage} storage for ${taskId}`,
572-
)
573-
} catch (error) {
574-
checkpoints.enableCheckpoints = false
575-
this.log(`[ClineProvider#initClineWithHistoryItem] Error getting task storage: ${error.message}`)
576-
}
577-
}
578-
579549
const cline = new Cline({
580550
provider: this,
581551
apiConfiguration,
582552
customInstructions: effectiveInstructions,
583553
enableDiff,
584-
...checkpoints,
554+
enableCheckpoints,
585555
fuzzyMatchThreshold,
586556
historyItem,
587557
experiments,
@@ -1210,7 +1180,6 @@ export class ClineProvider extends EventEmitter<ClineProviderEvents> implements
12101180
ttsSpeed,
12111181
diffEnabled,
12121182
enableCheckpoints,
1213-
checkpointStorage,
12141183
taskHistory,
12151184
soundVolume,
12161185
browserViewportSize,
@@ -1282,7 +1251,6 @@ export class ClineProvider extends EventEmitter<ClineProviderEvents> implements
12821251
ttsSpeed: ttsSpeed ?? 1.0,
12831252
diffEnabled: diffEnabled ?? true,
12841253
enableCheckpoints: enableCheckpoints ?? true,
1285-
checkpointStorage: checkpointStorage ?? "task",
12861254
shouldShowAnnouncement:
12871255
telemetrySetting !== "unset" && lastShownAnnouncementId !== this.latestAnnouncementId,
12881256
allowedCommands,
@@ -1377,7 +1345,6 @@ export class ClineProvider extends EventEmitter<ClineProviderEvents> implements
13771345
ttsSpeed: stateValues.ttsSpeed ?? 1.0,
13781346
diffEnabled: stateValues.diffEnabled ?? true,
13791347
enableCheckpoints: stateValues.enableCheckpoints ?? true,
1380-
checkpointStorage: stateValues.checkpointStorage ?? "task",
13811348
soundVolume: stateValues.soundVolume,
13821349
browserViewportSize: stateValues.browserViewportSize ?? "900x600",
13831350
screenshotQuality: stateValues.screenshotQuality ?? 75,

src/core/webview/__tests__/ClineProvider.test.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,6 @@ describe("ClineProvider", () => {
407407
ttsEnabled: false,
408408
diffEnabled: false,
409409
enableCheckpoints: false,
410-
checkpointStorage: "task",
411410
writeDelayMs: 1000,
412411
browserViewportSize: "900x600",
413412
fuzzyMatchThreshold: 1.0,
@@ -829,7 +828,6 @@ describe("ClineProvider", () => {
829828
mode: "code",
830829
diffEnabled: true,
831830
enableCheckpoints: false,
832-
checkpointStorage: "task",
833831
fuzzyMatchThreshold: 1.0,
834832
experiments: experimentDefault,
835833
} as any)
@@ -848,7 +846,6 @@ describe("ClineProvider", () => {
848846
customInstructions: modeCustomInstructions,
849847
enableDiff: true,
850848
enableCheckpoints: false,
851-
checkpointStorage: "task",
852849
fuzzyMatchThreshold: 1.0,
853850
task: "Test task",
854851
experiments: experimentDefault,

src/core/webview/webviewMessageHandler.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import pWaitFor from "p-wait-for"
44
import * as vscode from "vscode"
55

66
import { ClineProvider } from "./ClineProvider"
7-
import { CheckpointStorage, Language, ApiConfigMeta } from "../../schemas"
7+
import { Language, ApiConfigMeta } from "../../schemas"
88
import { changeLanguage, t } from "../../i18n"
99
import { ApiConfiguration } from "../../shared/api"
1010
import { supportPrompt } from "../../shared/support-prompt"
@@ -655,12 +655,6 @@ export const webviewMessageHandler = async (provider: ClineProvider, message: We
655655
await updateGlobalState("enableCheckpoints", enableCheckpoints)
656656
await provider.postStateToWebview()
657657
break
658-
case "checkpointStorage":
659-
console.log(`[ClineProvider] checkpointStorage: ${message.text}`)
660-
const checkpointStorage = message.text ?? "task"
661-
await updateGlobalState("checkpointStorage", checkpointStorage as CheckpointStorage)
662-
await provider.postStateToWebview()
663-
break
664658
case "browserViewportSize":
665659
const browserViewportSize = message.text ?? "900x600"
666660
await updateGlobalState("browserViewportSize", browserViewportSize)

src/exports/roo-code.d.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,6 @@ type GlobalSettings = {
259259
remoteBrowserHost?: string | undefined
260260
cachedChromeHostUrl?: string | undefined
261261
enableCheckpoints?: boolean | undefined
262-
checkpointStorage?: ("task" | "workspace") | undefined
263262
showGreeting?: boolean | undefined
264263
ttsEnabled?: boolean | undefined
265264
ttsSpeed?: number | undefined

src/exports/types.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,6 @@ type GlobalSettings = {
262262
remoteBrowserHost?: string | undefined
263263
cachedChromeHostUrl?: string | undefined
264264
enableCheckpoints?: boolean | undefined
265-
checkpointStorage?: ("task" | "workspace") | undefined
266265
showGreeting?: boolean | undefined
267266
ttsEnabled?: boolean | undefined
268267
ttsSpeed?: number | undefined

src/schemas/index.ts

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -44,19 +44,6 @@ export const toolGroupsSchema = z.enum(toolGroups)
4444

4545
export type ToolGroup = z.infer<typeof toolGroupsSchema>
4646

47-
/**
48-
* CheckpointStorage
49-
*/
50-
51-
export const checkpointStorages = ["task", "workspace"] as const
52-
53-
export const checkpointStoragesSchema = z.enum(checkpointStorages)
54-
55-
export type CheckpointStorage = z.infer<typeof checkpointStoragesSchema>
56-
57-
export const isCheckpointStorage = (value: string): value is CheckpointStorage =>
58-
checkpointStorages.includes(value as CheckpointStorage)
59-
6047
/**
6148
* Language
6249
*/
@@ -536,7 +523,6 @@ export const globalSettingsSchema = z.object({
536523
cachedChromeHostUrl: z.string().optional(),
537524

538525
enableCheckpoints: z.boolean().optional(),
539-
checkpointStorage: checkpointStoragesSchema.optional(),
540526

541527
showGreeting: z.boolean().optional(),
542528

@@ -614,7 +600,6 @@ const globalSettingsRecord: GlobalSettingsRecord = {
614600
remoteBrowserHost: undefined,
615601

616602
enableCheckpoints: undefined,
617-
checkpointStorage: undefined,
618603

619604
showGreeting: undefined,
620605

0 commit comments

Comments
 (0)