From fc57daef618598d506e7096376159b8a9483754e Mon Sep 17 00:00:00 2001 From: karishmas6 Date: Sat, 1 Jun 2024 11:22:23 +0530 Subject: [PATCH] feat:stop interpretatopn of current workflow in active browser instance --- server/src/browser-management/controller.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/server/src/browser-management/controller.ts b/server/src/browser-management/controller.ts index 8646a5cb..98962c1e 100644 --- a/server/src/browser-management/controller.ts +++ b/server/src/browser-management/controller.ts @@ -139,4 +139,19 @@ export const interpretWholeWorkflow = async() => { logger.log('error', `Cannot interpret the workflow: bad id ${id}.`); } }; + +/** + * Stops the interpretation of the current workflow in the active browser instance. + * If there is no active browser, the function logs an error. + * @returns {Promise} + * @category BrowserManagement-Controller + */ +export const stopRunningInterpretation = async() => { + const id = getActiveBrowserId(); + if (id) { + const browser = browserPool.getRemoteBrowser(id); + await browser?.stopCurrentInterpretation(); + } else { + logger.log('error', 'Cannot stop interpretation: No active browser or generator.'); + } };