Browse Source

feat(RooCodeAPI): implement resumeTask and isTaskInHistory (#1672)

Franciszek Piszcz 10 months ago
parent
commit
cf74568f66
2 changed files with 29 additions and 0 deletions
  1. 15 0
      src/exports/api.ts
  2. 14 0
      src/exports/roo-code.d.ts

+ 15 - 0
src/exports/api.ts

@@ -132,6 +132,21 @@ export class API extends EventEmitter<RooCodeEvents> implements RooCodeAPI {
 		return taskId
 	}
 
+	public async resumeTask(taskId: string): Promise<void> {
+		const { historyItem } = await this.provider.getTaskWithId(taskId)
+		await this.provider.initClineWithHistoryItem(historyItem)
+		await this.provider.postMessageToWebview({ type: "action", action: "chatButtonClicked" })
+	}
+
+	public async isTaskInHistory(taskId: string): Promise<boolean> {
+		try {
+			await this.provider.getTaskWithId(taskId)
+			return true
+		} catch {
+			return false
+		}
+	}
+
 	public getCurrentTaskStack() {
 		return this.sidebarProvider.getCurrentTaskStack()
 	}

+ 14 - 0
src/exports/roo-code.d.ts

@@ -551,6 +551,20 @@ interface RooCodeAPI extends EventEmitter<RooCodeEvents> {
 		images?: string[]
 		newTab?: boolean
 	}): Promise<string>
+	/**
+	 * Resumes a task with the given ID.
+	 * @param taskId The ID of the task to resume.
+	 * @throws Error if the task is not found in the task history.
+	 */
+	resumeTask(taskId: string): Promise<void>
+
+	/**
+	 * Checks if a task with the given ID is in the task history.
+	 * @param taskId The ID of the task to check.
+	 * @returns True if the task is in the task history, false otherwise.
+	 */
+	isTaskInHistory(taskId: string): Promise<boolean>
+
 	/**
 	 * Returns the current task stack.
 	 * @returns An array of task IDs.