From cf74568f66d715b970b8ce6ab3198b561953ebba Mon Sep 17 00:00:00 2001 From: Franciszek Piszcz Date: Mon, 7 Apr 2025 17:19:47 +0200 Subject: [PATCH] feat(RooCodeAPI): implement resumeTask and isTaskInHistory (#1672) --- src/exports/api.ts | 15 +++++++++++++++ src/exports/roo-code.d.ts | 14 ++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/src/exports/api.ts b/src/exports/api.ts index b489df1f1c..19f1784676 100644 --- a/src/exports/api.ts +++ b/src/exports/api.ts @@ -132,6 +132,21 @@ export class API extends EventEmitter implements RooCodeAPI { return taskId } + public async resumeTask(taskId: string): Promise { + 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 { + try { + await this.provider.getTaskWithId(taskId) + return true + } catch { + return false + } + } + public getCurrentTaskStack() { return this.sidebarProvider.getCurrentTaskStack() } diff --git a/src/exports/roo-code.d.ts b/src/exports/roo-code.d.ts index 7b6f19a31d..06304dbda4 100644 --- a/src/exports/roo-code.d.ts +++ b/src/exports/roo-code.d.ts @@ -551,6 +551,20 @@ interface RooCodeAPI extends EventEmitter { images?: string[] newTab?: boolean }): Promise + /** + * 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 + + /** + * 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 + /** * Returns the current task stack. * @returns An array of task IDs.