From 36b80da631f16238765385973eabaed2bc2c081d Mon Sep 17 00:00:00 2001 From: amhsirak Date: Fri, 2 Jan 2026 11:18:23 +0530 Subject: [PATCH] feat(core): real time progress update for runs --- maxun-core/src/interpret.ts | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/maxun-core/src/interpret.ts b/maxun-core/src/interpret.ts index b909376a..e6bd62f9 100644 --- a/maxun-core/src/interpret.ts +++ b/maxun-core/src/interpret.ts @@ -48,6 +48,7 @@ interface InterpreterOptions { debugMessage: (msg: string) => void, setActionType: (type: string) => void, incrementScrapeListIndex: () => void, + progressUpdate: (current: number, total: number, percentage: number) => void, }> } @@ -84,6 +85,10 @@ export default class Interpreter extends EventEmitter { private scrapeListCounter: number = 0; + private totalActions: number = 0; + + private executedActions: number = 0; + constructor(workflow: WorkflowFile, options?: Partial) { super(); this.workflow = workflow.workflow; @@ -1596,6 +1601,17 @@ export default class Interpreter extends EventEmitter { workflowCopy.splice(actionId, 1); console.log(`Action with ID ${action.id} removed from the workflow copy.`); + + this.executedActions++; + const percentage = Math.round((this.executedActions / this.totalActions) * 100); + + if (this.options.debugChannel?.progressUpdate) { + this.options.debugChannel.progressUpdate( + this.executedActions, + this.totalActions, + percentage + ); + } // const newSelectors = this.getPreviousSelectors(workflow, actionId); // const newSelectors = this.getSelectors(workflowCopy); @@ -1686,6 +1702,13 @@ export default class Interpreter extends EventEmitter { */ this.initializedWorkflow = Preprocessor.initWorkflow(this.workflow, params); + this.totalActions = this.initializedWorkflow.length; + this.executedActions = 0; + + if (this.options.debugChannel?.progressUpdate) { + this.options.debugChannel.progressUpdate(0, this.totalActions, 0); + } + await this.ensureScriptsLoaded(page); this.stopper = () => {