Browse Source

Merge pull request #1268 from feifei325/optimize-task-id-init

Optimize Task ID Initialization Order
Chris Estreich 10 months ago
parent
commit
55466c9d6a
1 changed files with 2 additions and 5 deletions
  1. 2 5
      src/core/Cline.ts

+ 2 - 5
src/core/Cline.ts

@@ -148,7 +148,8 @@ export class Cline {
 			throw new Error("Either historyItem or task/images must be provided")
 			throw new Error("Either historyItem or task/images must be provided")
 		}
 		}
 
 
-		this.taskId = crypto.randomUUID()
+		this.taskId = historyItem ? historyItem.id : crypto.randomUUID()
+
 		this.apiConfiguration = apiConfiguration
 		this.apiConfiguration = apiConfiguration
 		this.api = buildApiHandler(apiConfiguration)
 		this.api = buildApiHandler(apiConfiguration)
 		this.terminalManager = new TerminalManager()
 		this.terminalManager = new TerminalManager()
@@ -161,10 +162,6 @@ export class Cline {
 		this.diffViewProvider = new DiffViewProvider(cwd)
 		this.diffViewProvider = new DiffViewProvider(cwd)
 		this.enableCheckpoints = enableCheckpoints ?? false
 		this.enableCheckpoints = enableCheckpoints ?? false
 
 
-		if (historyItem) {
-			this.taskId = historyItem.id
-		}
-
 		// Initialize diffStrategy based on current state
 		// Initialize diffStrategy based on current state
 		this.updateDiffStrategy(Experiments.isEnabled(experiments ?? {}, EXPERIMENT_IDS.DIFF_STRATEGY))
 		this.updateDiffStrategy(Experiments.isEnabled(experiments ?? {}, EXPERIMENT_IDS.DIFF_STRATEGY))