From c6d740f3ce7f67a5c415b264e1d49dbebc9faf9c Mon Sep 17 00:00:00 2001 From: karishmas6 Date: Sat, 1 Jun 2024 11:22:01 +0530 Subject: [PATCH] feat: interpret current workflow in active browser instance --- server/src/browser-management/controller.ts | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/server/src/browser-management/controller.ts b/server/src/browser-management/controller.ts index eb41106a..8646a5cb 100644 --- a/server/src/browser-management/controller.ts +++ b/server/src/browser-management/controller.ts @@ -120,5 +120,23 @@ export const getRemoteBrowserCurrentTabs = (id: string): string[] | undefined => }); }; - +/** + * Interprets the currently generated workflow in the active browser instance. + * If there is no active browser, the function logs an error. + * @returns {Promise} + * @category BrowserManagement-Controller + */ +export const interpretWholeWorkflow = async() => { + const id = getActiveBrowserId(); + if (id) { + const browser = browserPool.getRemoteBrowser(id); + if (browser) { + await browser.interpretCurrentRecording(); + } else { + logger.log('error', `No active browser with id ${id} found in the browser pool`); + } + } else { + logger.log('error', `Cannot interpret the workflow: bad id ${id}.`); + } +}; };