Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: rework control entities #3185

Draft
wants to merge 71 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
71 commits
Select commit Hold shift + click to select a range
3f12941
wip
Julusian Dec 15, 2024
cf4b750
wip: expand feedback fragments to support multiple types of children
Julusian Dec 17, 2024
ab2a59a
wip: 'Conditionalise existing feedbacks' feedback
Julusian Dec 17, 2024
f81c6c0
wip: ux
Julusian Dec 17, 2024
2ffa9e6
fix: fixup feedbacks on import
Julusian Dec 18, 2024
dfdf985
wip
Julusian Dec 19, 2024
b6aa691
wip
Julusian Dec 19, 2024
781f913
wip
Julusian Dec 19, 2024
a66dcbc
wip: more
Julusian Dec 19, 2024
a30fde4
wip: tidy
Julusian Dec 19, 2024
f940583
wip: more
Julusian Dec 20, 2024
81cb0e8
wip
Julusian Dec 20, 2024
95fae4d
wip
Julusian Dec 20, 2024
c8e87fb
wip
Julusian Dec 20, 2024
fd83abc
wip: prune
Julusian Dec 20, 2024
aa319db
wip: tidy
Julusian Dec 20, 2024
5659b91
wip: tidy
Julusian Dec 20, 2024
9eca8ff
wip: consolidate
Julusian Dec 20, 2024
d9e34d0
wip
Julusian Dec 20, 2024
402c5e9
wip
Julusian Dec 20, 2024
5e150a8
wip
Julusian Dec 20, 2024
4b5a7c5
wip
Julusian Dec 20, 2024
dc1acd3
wip
Julusian Dec 20, 2024
c90ecc3
wip
Julusian Dec 20, 2024
3ce4ced
wip
Julusian Dec 20, 2024
6b6237a
wip
Julusian Dec 20, 2024
d077dc7
wip
Julusian Dec 20, 2024
f5f89ba
wip
Julusian Dec 20, 2024
f904dbd
wip
Julusian Dec 20, 2024
7d9c457
wip
Julusian Dec 20, 2024
1cafdba
wip
Julusian Dec 20, 2024
25a88f5
wip
Julusian Dec 20, 2024
cd5eb0e
wip
Julusian Dec 20, 2024
3ac8a5f
wip
Julusian Dec 20, 2024
f20654a
wip
Julusian Dec 20, 2024
001d3fe
wip: more
Julusian Dec 20, 2024
f2767ee
wip
Julusian Dec 20, 2024
1a7be8a
wip: start ui
Julusian Dec 20, 2024
52de00d
wip: ui
Julusian Dec 20, 2024
51c2313
wip
Julusian Dec 20, 2024
7ece893
wip
Julusian Dec 20, 2024
58d466c
wip
Julusian Dec 20, 2024
0b84fff
wip
Julusian Dec 20, 2024
dab38c8
wip
Julusian Dec 20, 2024
7a930b1
wip: reduce ui duplication in drop zone
Julusian Dec 21, 2024
16f0546
wip: reduce ui duplication
Julusian Dec 21, 2024
8925666
wip
Julusian Dec 22, 2024
18e1799
wip
Julusian Dec 22, 2024
4ee9ae9
wip: refactor panelcollapsehelper to be via a context sometimes
Julusian Dec 22, 2024
d932740
wip: refactor
Julusian Dec 22, 2024
6f514e5
wip: refactor
Julusian Dec 22, 2024
1de27cc
wip: deduplicate
Julusian Dec 22, 2024
71866eb
wip: deduplicate
Julusian Dec 22, 2024
c20daea
wip: duplicate
Julusian Dec 22, 2024
b2b6d98
wip: deduplicate
Julusian Dec 22, 2024
4ed8b0a
wip: consolidate entity definition types
Julusian Dec 22, 2024
5cf9f28
wip
Julusian Dec 22, 2024
8540dde
wip: deduplicate
Julusian Dec 22, 2024
e426312
wip: deduplicate
Julusian Dec 22, 2024
d3191cf
wip
Julusian Dec 22, 2024
1b60176
wip: deduplicate
Julusian Dec 22, 2024
d2f0eaf
wip
Julusian Dec 22, 2024
5ee3a0d
wip: fixup tests
Julusian Dec 22, 2024
e26c3a5
wip: extra file
Julusian Dec 22, 2024
ad36c8f
wip: deduplicate
Julusian Dec 22, 2024
cedd32b
chore: suppress logging during testing
Julusian Dec 22, 2024
3db45ab
chore: rename
Julusian Dec 23, 2024
71f5777
wip
Julusian Dec 23, 2024
404ef83
wip: tidy and tests
Julusian Dec 23, 2024
612104a
wip: some unit tests
Julusian Dec 23, 2024
f2a02ef
fix
Julusian Dec 23, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 12 additions & 8 deletions companion/lib/Controls/ActionRecorder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@ import LogController from '../Log/Controller.js'
import { EventEmitter } from 'events'
import type { Registry } from '../Registry.js'
import type {
RecordActionTmp,
RecordActionEntityModel,
RecordSessionInfo,
RecordSessionListInfo,
} from '@companion-app/shared/Model/ActionRecorderModel.js'
import type { ClientSocket } from '../UI/Handler.js'
import type { ActionSetId } from '@companion-app/shared/Model/ActionModel.js'
import { EntityModelType, SomeSocketEntityLocation } from '@companion-app/shared/Model/EntityModel.js'

const SessionListRoom = 'action-recorder:session-list'
function SessionRoom(id: string): string {
Expand Down Expand Up @@ -356,10 +357,11 @@ export class ActionRecorder extends EventEmitter<ActionRecorderEvents> {
const session = this.#currentSession

if (session.connectionIds.includes(connectionId)) {
const newAction: RecordActionTmp = {
const newAction: RecordActionEntityModel = {
type: EntityModelType.Action,
id: nanoid(),
instance: connectionId,
action: actionId,
connectionId: connectionId,
definitionId: actionId,
options: options,
delay: (session.actionDelay ?? 0) + delay,

Expand Down Expand Up @@ -395,14 +397,16 @@ export class ActionRecorder extends EventEmitter<ActionRecorderEvents> {
if (!control) throw new Error(`Unknown control: ${controlId}`)

if (mode === 'append') {
if (control.supportsActions) {
if (!control.actionAppend(stepId, setId, this.#currentSession.actions, null)) throw new Error('Unknown set')
if (control.supportsEntities) {
if (!control.entities.entityAdd({ stepId, setId }, null, ...this.#currentSession.actions))
throw new Error('Unknown set')
} else {
throw new Error('Not supported by control')
}
} else {
if (control.supportsActions) {
if (!control.actionReplaceAll(stepId, setId, this.#currentSession.actions)) throw new Error('Unknown set')
if (control.supportsEntities) {
const listId: SomeSocketEntityLocation = { stepId, setId }
if (!control.entities.entityReplaceAll(listId, this.#currentSession.actions)) throw new Error('Unknown set')
} else {
throw new Error('Not supported by control')
}
Expand Down
34 changes: 18 additions & 16 deletions companion/lib/Controls/ActionRunner.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { CoreBase } from '../Core/Base.js'
import type { Registry } from '../Registry.js'
import type { RunActionExtras } from '../Instance/Wrapper.js'
import { ActionInstance } from '@companion-app/shared/Model/ActionModel.js'
import { nanoid } from 'nanoid'
import { ActionEntityModel, EntityModelType, SomeEntityModel } from '@companion-app/shared/Model/EntityModel.js'

/**
* Class to handle execution of actions.
Expand Down Expand Up @@ -32,13 +32,13 @@ export class ActionRunner extends CoreBase {
/**
* Run a single action
*/
async #runAction(action: ActionInstance, extras: RunActionExtras): Promise<void> {
async #runAction(action: ActionEntityModel, extras: RunActionExtras): Promise<void> {
this.logger.silly('Running action', action)

if (action.instance === 'internal') {
if (action.connectionId === 'internal') {
await this.internalModule.executeAction(action, extras)
} else {
const instance = this.instance.moduleHost.getChild(action.instance)
const instance = this.instance.moduleHost.getChild(action.connectionId)
if (instance) {
await instance.actionRun(action, extras)
} else {
Expand All @@ -51,11 +51,13 @@ export class ActionRunner extends CoreBase {
* Run multiple actions
*/
async runMultipleActions(
actions0: ActionInstance[],
actions0: SomeEntityModel[],
extras: RunActionExtras,
executeSequential = false
): Promise<void> {
const actions = actions0.filter((act) => !act.disabled)
const actions = actions0.filter(
(act): act is ActionEntityModel => act.type === EntityModelType.Action && !act.disabled
)
if (actions.length === 0) return

if (extras.abortDelayed.aborted) return
Expand All @@ -66,7 +68,7 @@ export class ActionRunner extends CoreBase {
for (const action of actions) {
if (extras.abortDelayed.aborted) break
await this.#runAction(action, extras).catch((e) => {
this.logger.silly(`Error executing action for ${action.instance}: ${e.message ?? e}`)
this.logger.silly(`Error executing action for ${action.connectionId}: ${e.message ?? e}`)
})
}
} else {
Expand All @@ -78,7 +80,7 @@ export class ActionRunner extends CoreBase {
if (waitAction) {
// Perform the wait action
await this.#runAction(waitAction, extras).catch((e) => {
this.logger.silly(`Error executing action for ${waitAction.instance}: ${e.message ?? e}`)
this.logger.silly(`Error executing action for ${waitAction.connectionId}: ${e.message ?? e}`)
})
}

Expand All @@ -87,7 +89,7 @@ export class ActionRunner extends CoreBase {
await Promise.all(
actions.map(async (action) =>
this.#runAction(action, extras).catch((e) => {
this.logger.silly(`Error executing action for ${action.instance}: ${e.message ?? e}`)
this.logger.silly(`Error executing action for ${action.connectionId}: ${e.message ?? e}`)
})
)
)
Expand All @@ -96,16 +98,16 @@ export class ActionRunner extends CoreBase {
}
}

#splitActionsAroundWaits(actions: ActionInstance[]): GroupedActionInstances[] {
const groupedActions: GroupedActionInstances[] = [
#splitActionsAroundWaits(actions: ActionEntityModel[]): GroupedActionEntityModels[] {
const groupedActions: GroupedActionEntityModels[] = [
{
waitAction: undefined,
actions: [],
},
]

for (const action of actions) {
if (action.action === 'wait') {
if (action.definitionId === 'wait') {
groupedActions.push({
waitAction: action,
actions: [],
Expand All @@ -119,9 +121,9 @@ export class ActionRunner extends CoreBase {
}
}

interface GroupedActionInstances {
waitAction: ActionInstance | undefined
actions: ActionInstance[]
interface GroupedActionEntityModels {
waitAction: ActionEntityModel | undefined
actions: ActionEntityModel[]
}

export class ControlActionRunner {
Expand All @@ -142,7 +144,7 @@ export class ControlActionRunner {
}

async runActions(
actions: ActionInstance[],
actions: SomeEntityModel[],
extras: Omit<RunActionExtras, 'controlId' | 'abortDelayed' | 'executionMode'>
): Promise<void> {
const controller = new AbortController()
Expand Down
5 changes: 0 additions & 5 deletions companion/lib/Controls/ControlBase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,11 +196,6 @@ export abstract class ControlBase<TJson> {
*/
abstract renameVariables(labelFrom: string, labelTo: string): void

/**
* Prune any items on controls which belong to an unknown connectionId
*/
abstract verifyConnectionIds(knownConnectionIds: Set<string>): void

/**
* Execute a press of a control
* @param pressed Whether the control is pressed
Expand Down
Loading
Loading