diff --git a/package.json b/package.json index d10286d2..f91c7695 100644 --- a/package.json +++ b/package.json @@ -824,6 +824,28 @@ "type": "boolean", "default": false, "description": "Delete any currently installed dev channel before starting the debug session" + }, + "remoteControlMode": { + "oneOf": [ + { + "type": "object", + "description": "Options for activating and deactivating remote control mode", + "properties": { + "activateOnSessionStart": { + "type": "boolean", + "description": "Activate remote control mode on debug session start" + }, + "deactivateOnSessionEnd": { + "type": "boolean", + "description": "Deactivate remote control mode on session end" + } + } + }, + { + "type": "boolean", + "description": "Activate on session start, deactivate on session end." + } + ] } } } diff --git a/src/DebugConfigurationProvider.spec.ts b/src/DebugConfigurationProvider.spec.ts index 8148b288..3a3f55a9 100644 --- a/src/DebugConfigurationProvider.spec.ts +++ b/src/DebugConfigurationProvider.spec.ts @@ -149,7 +149,7 @@ describe('BrightScriptConfigurationProvider', () => { s`${folder.uri.fsPath}/out/` ); } else { - expect(config[key], `Expected "${key}" to match the default`).to.equal(configDefaults[key]); + expect(config[key], `Expected "${key}" to match the default`).to.deep.equal(configDefaults[key]); } } }); @@ -164,6 +164,19 @@ describe('BrightScriptConfigurationProvider', () => { expect(config.packagePort).to.equal(1234); expect(config.remotePort).to.equal(5678); }); + + [ + { input: true, expected: { activateOnSessionStart: true, deactivateOnSessionEnd: true } }, + { input: false, expected: { activateOnSessionStart: false, deactivateOnSessionEnd: false } }, + { input: undefined, expected: { activateOnSessionStart: false, deactivateOnSessionEnd: false } } + ].forEach(({ input, expected }) => { + it('allows using a bool value for remoteConfigMode', async () => { + let config = await configProvider.resolveDebugConfiguration(folder, { + remoteControlMode: input + }); + expect(config.remoteControlMode).to.deep.equal(expected); + }); + }); }); describe('processLogfilePath', () => { diff --git a/src/DebugConfigurationProvider.ts b/src/DebugConfigurationProvider.ts index 972106be..5f46cd9a 100644 --- a/src/DebugConfigurationProvider.ts +++ b/src/DebugConfigurationProvider.ts @@ -52,7 +52,11 @@ export class BrightScriptDebugConfigurationProvider implements DebugConfiguratio enableDebugProtocol: false, remotePort: 8060, rendezvousTracking: true, - deleteDevChannelBeforeInstall: false + deleteDevChannelBeforeInstall: false, + remoteControlMode: { + activateOnSessionStart: false, + deactivateOnSessionEnd: false + } }; let config: any = vscode.workspace.getConfiguration('brightscript') || {}; @@ -243,6 +247,17 @@ export class BrightScriptDebugConfigurationProvider implements DebugConfiguratio config.cwd = folderUri.fsPath; config.rendezvousTracking = config.rendezvousTracking === false ? false : true; config.deleteDevChannelBeforeInstall = config.deleteDevChannelBeforeInstall === true; + if (typeof config.remoteControlMode === 'boolean') { + config.remoteControlMode = { + activateOnSessionStart: config.remoteControlMode, + deactivateOnSessionEnd: config.remoteControlMode + }; + } else { + config.remoteControlMode = { + activateOnSessionStart: config.remoteControlMode?.activateOnSessionStart ?? this.configDefaults.remoteControlMode.activateOnSessionStart, + deactivateOnSessionEnd: config.remoteControlMode?.deactivateOnSessionEnd ?? this.configDefaults.remoteControlMode.deactivateOnSessionEnd + }; + } if (config.request !== 'launch') { await vscode.window.showErrorMessage(`roku-debug only supports the 'launch' request type`); @@ -561,4 +576,10 @@ export interface BrightScriptLaunchConfiguration extends LaunchConfiguration { * If injectRdbOnDeviceComponent is true and this is true the screen saver will be be disabled while the deployed application is running. */ disableScreenSaver?: boolean; + + /** + * If set, the remote control will be enabled/disabled at the start/end of the debug session, respectively. + * @default { activateOnSessionStart: false, deactivateOnSessionEnd: false } + */ + remoteControlMode?: { activateOnSessionStart?: boolean; deactivateOnSessionEnd?: boolean }; } diff --git a/src/extension.ts b/src/extension.ts index 7a9eb016..c733d938 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -177,6 +177,10 @@ export class Extension { //if this is a brightscript debug session if (e.type === 'brightscript') { this.chanperfStatusBar.hide(); + const config = e.configuration as BrightScriptLaunchConfiguration; + if (config.remoteControlMode?.deactivateOnSessionEnd) { + void this.remoteControlManager.setRemoteControlMode(false, 'launch'); + } } }); @@ -212,6 +216,9 @@ export class Extension { const config = e.body as BrightScriptLaunchConfiguration; await docLinkProvider.setLaunchConfig(config); logOutputManager.setLaunchConfig(config); + if (config.remoteControlMode?.activateOnSessionStart) { + void this.remoteControlManager.setRemoteControlMode(true, 'launch'); + } } else if (isChannelPublishedEvent(e)) { this.webviewViewProviderManager.onChannelPublishedEvent(e); //write debug server log statements to the DebugServer output channel diff --git a/src/managers/RemoteControlManager.ts b/src/managers/RemoteControlManager.ts index 2e2289d3..9a3bb68e 100644 --- a/src/managers/RemoteControlManager.ts +++ b/src/managers/RemoteControlManager.ts @@ -128,4 +128,4 @@ export class RemoteControlManager { } } -export type RemoteControlModeInitiator = 'statusbar' | 'command'; +export type RemoteControlModeInitiator = 'statusbar' | 'command' | 'launch';