From 4d63bf95c7b4a0938ad2522e8c2bb83fe906b21c Mon Sep 17 00:00:00 2001 From: Brahim Hadriche Date: Tue, 26 Sep 2023 15:40:54 -0400 Subject: [PATCH 1/4] Enable remote control on launch --- package.json | 5 +++++ src/DebugConfigurationProvider.ts | 10 +++++++++- src/extension.ts | 7 +++++++ src/managers/RemoteControlManager.ts | 2 +- 4 files changed, 22 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index d10286d2..04f8afc0 100644 --- a/package.json +++ b/package.json @@ -824,6 +824,11 @@ "type": "boolean", "default": false, "description": "Delete any currently installed dev channel before starting the debug session" + }, + "enableRemoteControl": { + "type": "boolean", + "default": true, + "description": "Enable remote control mode when starting the debug session" } } } diff --git a/src/DebugConfigurationProvider.ts b/src/DebugConfigurationProvider.ts index 972106be..202d83bb 100644 --- a/src/DebugConfigurationProvider.ts +++ b/src/DebugConfigurationProvider.ts @@ -52,7 +52,8 @@ export class BrightScriptDebugConfigurationProvider implements DebugConfiguratio enableDebugProtocol: false, remotePort: 8060, rendezvousTracking: true, - deleteDevChannelBeforeInstall: false + deleteDevChannelBeforeInstall: false, + enableRemoteControl: false }; let config: any = vscode.workspace.getConfiguration('brightscript') || {}; @@ -243,6 +244,7 @@ export class BrightScriptDebugConfigurationProvider implements DebugConfiguratio config.cwd = folderUri.fsPath; config.rendezvousTracking = config.rendezvousTracking === false ? false : true; config.deleteDevChannelBeforeInstall = config.deleteDevChannelBeforeInstall === true; + config.enableRemoteControl = config.enableRemoteControl === true ? true : this.configDefaults.enableRemoteControl; if (config.request !== 'launch') { await vscode.window.showErrorMessage(`roku-debug only supports the 'launch' request type`); @@ -561,4 +563,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 true, the remote control will be enabled at the start of the debug session + * @default false + */ + enableRemoteControl?: boolean; } diff --git a/src/extension.ts b/src/extension.ts index 7a9eb016..66810440 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.enableRemoteControl) { + 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.enableRemoteControl) { + 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'; From fa8c8dd72609a3c117a4b279564c936d64077b3a Mon Sep 17 00:00:00 2001 From: Brahim Hadriche Date: Wed, 27 Sep 2023 13:45:44 -0400 Subject: [PATCH 2/4] remoteControlMode - PR nursing --- package.json | 25 +++++++++++++++++++++---- src/DebugConfigurationProvider.spec.ts | 13 +++++++++++++ src/DebugConfigurationProvider.ts | 12 ++++++++---- src/extension.ts | 4 ++-- 4 files changed, 44 insertions(+), 10 deletions(-) diff --git a/package.json b/package.json index 04f8afc0..f91c7695 100644 --- a/package.json +++ b/package.json @@ -825,10 +825,27 @@ "default": false, "description": "Delete any currently installed dev channel before starting the debug session" }, - "enableRemoteControl": { - "type": "boolean", - "default": true, - "description": "Enable remote control mode when 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..20eb5cdf 100644 --- a/src/DebugConfigurationProvider.spec.ts +++ b/src/DebugConfigurationProvider.spec.ts @@ -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 202d83bb..2b794aa8 100644 --- a/src/DebugConfigurationProvider.ts +++ b/src/DebugConfigurationProvider.ts @@ -53,7 +53,10 @@ export class BrightScriptDebugConfigurationProvider implements DebugConfiguratio remotePort: 8060, rendezvousTracking: true, deleteDevChannelBeforeInstall: false, - enableRemoteControl: false + remoteControlMode: { + activateOnSessionStart: false, + deactivateOnSessionEnd: false + } }; let config: any = vscode.workspace.getConfiguration('brightscript') || {}; @@ -244,7 +247,8 @@ export class BrightScriptDebugConfigurationProvider implements DebugConfiguratio config.cwd = folderUri.fsPath; config.rendezvousTracking = config.rendezvousTracking === false ? false : true; config.deleteDevChannelBeforeInstall = config.deleteDevChannelBeforeInstall === true; - config.enableRemoteControl = config.enableRemoteControl === true ? true : this.configDefaults.enableRemoteControl; + config.remoteControlMode = config.remoteControlMode ? config.remoteControlMode : this.configDefaults.remoteControlMode; + config.remoteControlMode = config.remoteControlMode === true ? { activateOnSessionStart: true, deactivateOnSessionEnd: true } : config.remoteControlMode; if (config.request !== 'launch') { await vscode.window.showErrorMessage(`roku-debug only supports the 'launch' request type`); @@ -565,8 +569,8 @@ export interface BrightScriptLaunchConfiguration extends LaunchConfiguration { disableScreenSaver?: boolean; /** - * If true, the remote control will be enabled at the start of the debug session + * If true, the remote control will be enabled at the start of the debug session, and disabled at the end of the debug session. * @default false */ - enableRemoteControl?: boolean; + remoteControlMode?: boolean | { activateOnSessionStart?: boolean; deactivateOnSessionEnd?: boolean }; } diff --git a/src/extension.ts b/src/extension.ts index 66810440..42f6f93c 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -178,7 +178,7 @@ export class Extension { if (e.type === 'brightscript') { this.chanperfStatusBar.hide(); const config = e.configuration as BrightScriptLaunchConfiguration; - if (config.enableRemoteControl) { + if (config.remoteControlMode && (config.remoteControlMode === true || config.remoteControlMode?.deactivateOnSessionEnd === true)) { void this.remoteControlManager.setRemoteControlMode(false, 'launch'); } } @@ -216,7 +216,7 @@ export class Extension { const config = e.body as BrightScriptLaunchConfiguration; await docLinkProvider.setLaunchConfig(config); logOutputManager.setLaunchConfig(config); - if (config.enableRemoteControl) { + if (config.remoteControlMode && (config.remoteControlMode === true || config.remoteControlMode?.activateOnSessionStart === true)) { void this.remoteControlManager.setRemoteControlMode(true, 'launch'); } } else if (isChannelPublishedEvent(e)) { From e32e45cbe381afeb53784418246fd25e945a7d14 Mon Sep 17 00:00:00 2001 From: Brahim Hadriche Date: Thu, 28 Sep 2023 14:39:36 -0400 Subject: [PATCH 3/4] remoteControlMode type change --- src/DebugConfigurationProvider.spec.ts | 2 +- src/DebugConfigurationProvider.ts | 15 ++++++++++++--- src/extension.ts | 4 ++-- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/DebugConfigurationProvider.spec.ts b/src/DebugConfigurationProvider.spec.ts index 20eb5cdf..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]); } } }); diff --git a/src/DebugConfigurationProvider.ts b/src/DebugConfigurationProvider.ts index 2b794aa8..39430949 100644 --- a/src/DebugConfigurationProvider.ts +++ b/src/DebugConfigurationProvider.ts @@ -247,8 +247,17 @@ export class BrightScriptDebugConfigurationProvider implements DebugConfiguratio config.cwd = folderUri.fsPath; config.rendezvousTracking = config.rendezvousTracking === false ? false : true; config.deleteDevChannelBeforeInstall = config.deleteDevChannelBeforeInstall === true; - config.remoteControlMode = config.remoteControlMode ? config.remoteControlMode : this.configDefaults.remoteControlMode; - config.remoteControlMode = config.remoteControlMode === true ? { activateOnSessionStart: true, deactivateOnSessionEnd: true } : config.remoteControlMode; + 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`); @@ -572,5 +581,5 @@ export interface BrightScriptLaunchConfiguration extends LaunchConfiguration { * If true, the remote control will be enabled at the start of the debug session, and disabled at the end of the debug session. * @default false */ - remoteControlMode?: boolean | { activateOnSessionStart?: boolean; deactivateOnSessionEnd?: boolean }; + remoteControlMode?: { activateOnSessionStart?: boolean; deactivateOnSessionEnd?: boolean }; } diff --git a/src/extension.ts b/src/extension.ts index 42f6f93c..c733d938 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -178,7 +178,7 @@ export class Extension { if (e.type === 'brightscript') { this.chanperfStatusBar.hide(); const config = e.configuration as BrightScriptLaunchConfiguration; - if (config.remoteControlMode && (config.remoteControlMode === true || config.remoteControlMode?.deactivateOnSessionEnd === true)) { + if (config.remoteControlMode?.deactivateOnSessionEnd) { void this.remoteControlManager.setRemoteControlMode(false, 'launch'); } } @@ -216,7 +216,7 @@ export class Extension { const config = e.body as BrightScriptLaunchConfiguration; await docLinkProvider.setLaunchConfig(config); logOutputManager.setLaunchConfig(config); - if (config.remoteControlMode && (config.remoteControlMode === true || config.remoteControlMode?.activateOnSessionStart === true)) { + if (config.remoteControlMode?.activateOnSessionStart) { void this.remoteControlManager.setRemoteControlMode(true, 'launch'); } } else if (isChannelPublishedEvent(e)) { From cb5e68cc3f719438417cfc6af56bc7c05dcaee3c Mon Sep 17 00:00:00 2001 From: Brahim Hadriche Date: Thu, 28 Sep 2023 14:43:44 -0400 Subject: [PATCH 4/4] Update comment --- src/DebugConfigurationProvider.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/DebugConfigurationProvider.ts b/src/DebugConfigurationProvider.ts index 39430949..5f46cd9a 100644 --- a/src/DebugConfigurationProvider.ts +++ b/src/DebugConfigurationProvider.ts @@ -578,8 +578,8 @@ export interface BrightScriptLaunchConfiguration extends LaunchConfiguration { disableScreenSaver?: boolean; /** - * If true, the remote control will be enabled at the start of the debug session, and disabled at the end of the debug session. - * @default false + * 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 }; }