From 3a969842f7e06d8eabb5418a94db259d86d61c14 Mon Sep 17 00:00:00 2001 From: Julian Waller Date: Sun, 15 Dec 2024 17:01:46 +0000 Subject: [PATCH] feat: add 'inherit' execution mode to action-groups --- companion/lib/Controls/ActionRunner.ts | 3 ++- companion/lib/Instance/Wrapper.ts | 1 + companion/lib/Internal/BuildingBlocks.ts | 25 +++++++++++++++++++++--- 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/companion/lib/Controls/ActionRunner.ts b/companion/lib/Controls/ActionRunner.ts index 69ddf04f9e..ca73a7ecdf 100644 --- a/companion/lib/Controls/ActionRunner.ts +++ b/companion/lib/Controls/ActionRunner.ts @@ -143,7 +143,7 @@ export class ControlActionRunner { async runActions( actions: ActionInstance[], - extras: Omit + extras: Omit ): Promise { const controller = new AbortController() @@ -160,6 +160,7 @@ export class ControlActionRunner { ...extras, controlId: this.#controlId, abortDelayed: controller.signal, + executionMode: 'concurrent', }) .finally(() => { // If this removes the last chain, trigger a redraw diff --git a/companion/lib/Instance/Wrapper.ts b/companion/lib/Instance/Wrapper.ts index 6c8b375f5b..c2f818c208 100644 --- a/companion/lib/Instance/Wrapper.ts +++ b/companion/lib/Instance/Wrapper.ts @@ -927,6 +927,7 @@ export interface RunActionExtras { surfaceId: string | undefined location: ControlLocation | undefined abortDelayed: AbortSignal + executionMode: 'sequential' | 'concurrent' } export interface VariableDefinitionTmp { diff --git a/companion/lib/Internal/BuildingBlocks.ts b/companion/lib/Internal/BuildingBlocks.ts index 866f0aa39b..b28ef3ebcd 100644 --- a/companion/lib/Internal/BuildingBlocks.ts +++ b/companion/lib/Internal/BuildingBlocks.ts @@ -98,8 +98,9 @@ export class InternalBuildingBlocks implements InternalModuleFragment { type: 'dropdown', label: 'Execution mode', id: 'execution_mode', - default: 'concurrent', + default: 'inherit', choices: [ + { id: 'inherit', label: 'Inherit' }, { id: 'concurrent', label: 'Concurrent' }, { id: 'sequential', label: 'Sequential' }, ], @@ -172,10 +173,28 @@ export class InternalBuildingBlocks implements InternalModuleFragment { } else if (action.action === 'action_group') { if (extras.abortDelayed.aborted) return true - const executeSequential = action.options.execution_mode === 'sequential' + let executeSequential = false + switch (action.options.execution_mode) { + case 'sequential': + executeSequential = true + break + case 'concurrent': + executeSequential = false + break + case 'inherit': + executeSequential = extras.executionMode === 'sequential' + break + default: + this.#logger.error(`Unknown execution mode: ${action.options.execution_mode}`) + } + + const newExtras: RunActionExtras = { + ...extras, + executionMode: executeSequential ? 'sequential' : 'concurrent', + } return this.#actionRunner - .runMultipleActions(action.children?.['default'] ?? [], extras, executeSequential) + .runMultipleActions(action.children?.['default'] ?? [], newExtras, executeSequential) .catch((e) => { this.#logger.error(`Failed to run actions: ${e.message}`) })