Skip to content

Commit

Permalink
Enable remote control on launch (#503)
Browse files Browse the repository at this point in the history
* Enable remote control on launch

* remoteControlMode - PR nursing

* remoteControlMode type change

* Update comment
  • Loading branch information
iBicha committed Sep 28, 2023
1 parent bdae42c commit 5f9e0c7
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 3 deletions.
22 changes: 22 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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."
}
]
}
}
}
Expand Down
15 changes: 14 additions & 1 deletion src/DebugConfigurationProvider.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
}
}
});
Expand All @@ -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, <any>{
remoteControlMode: input
});
expect(config.remoteControlMode).to.deep.equal(expected);
});
});
});

describe('processLogfilePath', () => {
Expand Down
23 changes: 22 additions & 1 deletion src/DebugConfigurationProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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') || {};
Expand Down Expand Up @@ -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`);
Expand Down Expand Up @@ -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 };
}
7 changes: 7 additions & 0 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
}
});

Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/managers/RemoteControlManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,4 +128,4 @@ export class RemoteControlManager {
}
}

export type RemoteControlModeInitiator = 'statusbar' | 'command';
export type RemoteControlModeInitiator = 'statusbar' | 'command' | 'launch';

0 comments on commit 5f9e0c7

Please sign in to comment.