Skip to content

Commit 1c9a606

Browse files
authored
Merge pull request #2041 from posit-dev/upkeep/rename-frontend
Rename frontend comm to UI comm
2 parents 9c9da2b + 278ef10 commit 1c9a606

24 files changed

+129
-126
lines changed

extensions/jupyter-adapter/src/LanguageRuntimeAdapter.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ export class LanguageRuntimeAdapter
110110
async callMethod(method: string, ...args: any[]): Promise<any> {
111111
// Find the frontend comm
112112
const frontend = Array.from(this._comms.values())
113-
.find(c => c.getClientType() === positron.RuntimeClientType.FrontEnd);
113+
.find(c => c.getClientType() === positron.RuntimeClientType.Ui);
114114
if (!frontend) {
115115
throw new Error(`Cannot invoke '${method}'; no frontend comm is open.`);
116116
}
@@ -399,7 +399,7 @@ export class LanguageRuntimeAdapter
399399
if (type === positron.RuntimeClientType.Variables ||
400400
type === positron.RuntimeClientType.Lsp ||
401401
type === positron.RuntimeClientType.Dap ||
402-
type === positron.RuntimeClientType.FrontEnd ||
402+
type === positron.RuntimeClientType.Ui ||
403403
type === positron.RuntimeClientType.Help) {
404404
this._kernel.log(`Creating '${type}' client for ${this.metadata.languageName}`);
405405

extensions/positron-python

extensions/positron-r/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -503,7 +503,7 @@
503503
},
504504
"positron": {
505505
"binaryDependencies": {
506-
"ark": "0.1.44"
506+
"ark": "0.1.45"
507507
}
508508
}
509509
}

extensions/positron-zed/src/positronZedLanguageRuntime.ts

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { ZedData } from './positronZedData';
1212
import { ZedPreview } from './positronZedPreview';
1313
import { ZedVariables } from './positronZedVariables';
1414
import { makeCUB, makeCUF, makeCUP, makeED, makeEL, makeSGR, SGR } from './ansi';
15-
import { ZedFrontend } from './positronZedFrontend';
15+
import { ZedUi as ZedUi } from './positronZedUi';
1616
import { ZedConnection } from './positronZedConnection';
1717

1818
/**
@@ -147,7 +147,7 @@ export class PositronZedLanguageRuntime implements positron.LanguageRuntime {
147147
/**
148148
* The currently connected frontend, if any
149149
*/
150-
private _frontend: ZedFrontend | undefined;
150+
private _ui: ZedUi | undefined;
151151

152152
/**
153153
* A map of plot IDs to plot instances.
@@ -946,13 +946,13 @@ export class PositronZedLanguageRuntime implements positron.LanguageRuntime {
946946
this.createVariablesClient(id);
947947
break;
948948

949-
case positron.RuntimeClientType.FrontEnd:
949+
case positron.RuntimeClientType.Ui:
950950
// Create the front-end client when requested
951-
this.createFrontendClient(id);
951+
this.createUiClient(id);
952952

953953
// Immediately notify Positron of a "working directory"
954-
if (this._frontend) {
955-
this._frontend.changeDirectory('');
954+
if (this._ui) {
955+
this._ui.changeDirectory('');
956956
}
957957
break;
958958

@@ -994,17 +994,17 @@ export class PositronZedLanguageRuntime implements positron.LanguageRuntime {
994994
}
995995

996996
/**
997-
* Creates a new Zed frontend client.
997+
* Creates a new Zed UI client.
998998
*
999999
* @param id The ID of the client.
10001000
*/
1001-
createFrontendClient(id: string) {
1001+
createUiClient(id: string) {
10021002
// Allocate a new ID and ZedVariables object for this variables backend
1003-
const frontend = new ZedFrontend(id);
1003+
const ui = new ZedUi(id);
10041004

10051005
// Connect it and save the instance to coordinate future communication
1006-
this.connectClientEmitter(frontend);
1007-
this._frontend = frontend;
1006+
this.connectClientEmitter(ui);
1007+
this._ui = ui;
10081008
}
10091009

10101010
/**
@@ -1035,9 +1035,9 @@ export class PositronZedLanguageRuntime implements positron.LanguageRuntime {
10351035
clients[data.id] = positron.RuntimeClientType.Plot;
10361036
}
10371037
}
1038-
if (!type || type === positron.RuntimeClientType.FrontEnd) {
1039-
if (this._frontend) {
1040-
clients[this._frontend.id] = positron.RuntimeClientType.FrontEnd;
1038+
if (!type || type === positron.RuntimeClientType.Ui) {
1039+
if (this._ui) {
1040+
clients[this._ui.id] = positron.RuntimeClientType.Ui;
10411041
}
10421042
}
10431043
return clients;
@@ -1180,8 +1180,8 @@ export class PositronZedLanguageRuntime implements positron.LanguageRuntime {
11801180
this.simulateIdleState(this._busyOperationId!);
11811181

11821182
// Notify Positron that the interrupt is complete.
1183-
if (this._frontend) {
1184-
this._frontend.markBusy(false);
1183+
if (this._ui) {
1184+
this._ui.markBusy(false);
11851185
}
11861186
this._busyOperationId = undefined;
11871187
}, this._busyInterruptSeconds * 1000);
@@ -1417,7 +1417,7 @@ export class PositronZedLanguageRuntime implements positron.LanguageRuntime {
14171417
}
14181418

14191419
/**
1420-
* Simulates a directory change by sending the relevant event to the frontend comm.
1420+
* Simulates a directory change by sending the relevant event to the UI comm.
14211421
*
14221422
* @param parentId The ID of the message that requested the directory change.
14231423
* @param code The code that was executed.
@@ -1428,9 +1428,9 @@ export class PositronZedLanguageRuntime implements positron.LanguageRuntime {
14281428
this.simulateBusyState(parentId);
14291429
this.simulateInputMessage(parentId, code);
14301430

1431-
if (this._frontend) {
1432-
this._frontend.changeDirectory(directory);
1433-
this.simulateOutputMessage(parentId, `Changed directory to '${this._frontend.directory}'.`);
1431+
if (this._ui) {
1432+
this._ui.changeDirectory(directory);
1433+
this.simulateOutputMessage(parentId, `Changed directory to '${this._ui.directory}'.`);
14341434
} else {
14351435
this.simulateErrorMessage(parentId, 'No Frontend', 'No frontend is connected.', []);
14361436
}
@@ -1834,8 +1834,8 @@ export class PositronZedLanguageRuntime implements positron.LanguageRuntime {
18341834
this.simulateStreamMessage(parentId, positron.LanguageRuntimeStreamName.Stderr, 'Initializing task...');
18351835

18361836
// Mark the runtime as busy while we show the progress bar.
1837-
if (this._frontend) {
1838-
this._frontend.markBusy(true);
1837+
if (this._ui) {
1838+
this._ui.markBusy(true);
18391839
}
18401840

18411841
// After a tingle of delay, output the progress bar.
@@ -1861,8 +1861,8 @@ export class PositronZedLanguageRuntime implements positron.LanguageRuntime {
18611861
// End the progress bar.
18621862
this.simulateStreamMessage(parentId, positron.LanguageRuntimeStreamName.Stdout, 'Long running task is completed.');
18631863
this.simulateIdleState(parentId);
1864-
if (this._frontend) {
1865-
this._frontend.markBusy(false);
1864+
if (this._ui) {
1865+
this._ui.markBusy(false);
18661866
}
18671867
}
18681868
}, 25);
@@ -2011,7 +2011,7 @@ export class PositronZedLanguageRuntime implements positron.LanguageRuntime {
20112011
*
20122012
* @param client The environment or plot to connect
20132013
*/
2014-
private connectClientEmitter(client: ZedVariables | ZedPlot | ZedData | ZedFrontend | ZedConnection) {
2014+
private connectClientEmitter(client: ZedVariables | ZedPlot | ZedData | ZedUi | ZedConnection) {
20152015

20162016
// Listen for data emitted from the environment instance
20172017
client.onDidEmitData(data => {
@@ -2046,8 +2046,8 @@ export class PositronZedLanguageRuntime implements positron.LanguageRuntime {
20462046
this.simulateOutputMessage(parentId, `Entering busy state for ${durationSeconds} seconds.`);
20472047

20482048
// Notify the frontend that a computation is in progress
2049-
if (this._frontend) {
2050-
this._frontend.markBusy(true);
2049+
if (this._ui) {
2050+
this._ui.markBusy(true);
20512051
}
20522052

20532053
// Exit the busy state after the specified duration. We save the timer to a
@@ -2060,8 +2060,8 @@ export class PositronZedLanguageRuntime implements positron.LanguageRuntime {
20602060
this._busyTimer = undefined;
20612061

20622062
// Notify frontend that the computation is complete
2063-
if (this._frontend) {
2064-
this._frontend.markBusy(false);
2063+
if (this._ui) {
2064+
this._ui.markBusy(false);
20652065
}
20662066
}, durationSeconds * 1000);
20672067
}

extensions/positron-zed/src/positronZedFrontend.ts renamed to extensions/positron-zed/src/positronZedUi.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
/*---------------------------------------------------------------------------------------------
2-
* Copyright (C) 2023 Posit Software, PBC. All rights reserved.
2+
* Copyright (C) 2023-2024 Posit Software, PBC. All rights reserved.
33
*--------------------------------------------------------------------------------------------*/
44

55
import * as vscode from 'vscode';
66

77
/**
8-
* A ZedFrontend instance; wraps the back end of the Zed frontend comm.
8+
* A ZedUi instance; wraps the back end of the Zed frontend comm.
99
*/
10-
export class ZedFrontend {
10+
export class ZedUi {
1111
private _directory = '';
1212

1313
constructor(readonly id: string) {

positron/comms/generate-comms.ts

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,7 @@ use serde::Serialize;
490490
yield ' */\n';
491491
yield `#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]\n`;
492492
yield `#[serde(tag = "method", content = "params")]\n`;
493-
yield `pub enum ${snakeCaseToSentenceCase(name)}${contract.name}RpcRequest {\n`;
493+
yield `pub enum ${snakeCaseToSentenceCase(name)}${contract.name}Request {\n`;
494494
for (const method of source.methods) {
495495
if (!method.result) {
496496
continue;
@@ -517,7 +517,7 @@ use serde::Serialize;
517517
yield ' */\n';
518518
yield `#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]\n`;
519519
yield `#[serde(tag = "method", content = "result")]\n`;
520-
yield `pub enum ${snakeCaseToSentenceCase(name)}${contract.name}RpcReply {\n`;
520+
yield `pub enum ${snakeCaseToSentenceCase(name)}${contract.name}Reply {\n`;
521521
for (const method of source.methods) {
522522
if (method.result) {
523523
if (!method.result.schema) {
@@ -570,7 +570,7 @@ use serde::Serialize;
570570
yield ' */\n';
571571
yield `#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]\n`;
572572
yield `#[serde(tag = "method", content = "params")]\n`;
573-
yield `pub enum ${snakeCaseToSentenceCase(name)}Event {\n`;
573+
yield `pub enum ${snakeCaseToSentenceCase(name)}FrontendEvent {\n`;
574574
for (const method of frontend.methods) {
575575
if (method.result !== undefined) {
576576
continue;
@@ -590,15 +590,15 @@ use serde::Serialize;
590590
}
591591

592592
if (frontend && frontend.methods.some((method: any) => method.result && method.result.schema)) {
593-
const enumRequestType = `${snakeCaseToSentenceCase(name)}FrontendRpcRequest`
594-
const enumReplyType = `${snakeCaseToSentenceCase(name)}FrontendRpcReply`
593+
const enumRequestType = `${snakeCaseToSentenceCase(name)}FrontendRequest`
594+
const enumReplyType = `${snakeCaseToSentenceCase(name)}FrontendReply`
595595
yield `/**
596596
* Conversion of JSON values to frontend RPC Reply types
597597
*/
598598
pub fn ${name}_frontend_reply_from_value(
599599
reply: serde_json::Value,
600600
request: &${enumRequestType},
601-
) -> anyhow::Result<${snakeCaseToSentenceCase(name)}FrontendRpcReply> {
601+
) -> anyhow::Result<${snakeCaseToSentenceCase(name)}FrontendReply> {
602602
match request {
603603
`;
604604
for (const method of frontend.methods) {
@@ -749,9 +749,9 @@ JsonData = Union[Dict[str, "JsonData"], List["JsonData"], str, int, float, bool,
749749

750750
if (backend) {
751751
yield '@enum.unique\n';
752-
yield `class ${snakeCaseToSentenceCase(name)}Request(str, enum.Enum):\n`;
752+
yield `class ${snakeCaseToSentenceCase(name)}BackendRequest(str, enum.Enum):\n`;
753753
yield ` """\n`;
754-
yield ` An enumeration of all the possible requests that can be sent to the ${name} comm.\n`;
754+
yield ` An enumeration of all the possible requests that can be sent to the backend ${name} comm.\n`;
755755
yield ` """\n`;
756756
yield `\n`;
757757
for (const method of backend.methods) {
@@ -810,12 +810,12 @@ JsonData = Union[Dict[str, "JsonData"], List["JsonData"], str, int, float, bool,
810810
yield ` )\n`;
811811
yield `\n`;
812812
}
813-
yield ` method: ${snakeCaseToSentenceCase(name)}Request = field(\n`;
813+
yield ` method: ${snakeCaseToSentenceCase(name)}BackendRequest = field(\n`;
814814
yield ` metadata={\n`;
815815
yield ` "description": "The JSON-RPC method name (${method.name})"\n`;
816816
yield ` },\n`;
817817
yield ` default=`;
818-
yield `${snakeCaseToSentenceCase(name)}Request.${snakeCaseToSentenceCase(method.name)}\n`;
818+
yield `${snakeCaseToSentenceCase(name)}BackendRequest.${snakeCaseToSentenceCase(method.name)}\n`;
819819
yield ` )\n`;
820820
yield '\n';
821821
yield ` jsonrpc: str = field(\n`;
@@ -831,9 +831,9 @@ JsonData = Union[Dict[str, "JsonData"], List["JsonData"], str, int, float, bool,
831831

832832
if (frontend) {
833833
yield `@enum.unique\n`;
834-
yield `class ${snakeCaseToSentenceCase(name)}Event(str, enum.Enum):\n`;
834+
yield `class ${snakeCaseToSentenceCase(name)}FrontendEvent(str, enum.Enum):\n`;
835835
yield ` """\n`;
836-
yield ` An enumeration of all the possible events that can be sent from the ${name} comm.\n`;
836+
yield ` An enumeration of all the possible events that can be sent to the frontend ${name} comm.\n`;
837837
yield ` """\n`;
838838
yield `\n`;
839839
for (const method of frontend.methods) {
@@ -965,6 +965,9 @@ import { IRuntimeClientInstance } from 'vs/workbench/services/languageRuntime/co
965965
966966
`;
967967
const contracts = [backend, frontend];
968+
const namedContracts = [{ name: 'Backend', source: backend },
969+
{ name: 'Frontend', source: frontend }];
970+
968971
for (const source of contracts) {
969972
if (!source) {
970973
continue;
@@ -1086,13 +1089,13 @@ import { IRuntimeClientInstance } from 'vs/workbench/services/languageRuntime/co
10861089
}
10871090

10881091
if (events.length) {
1089-
yield `export enum ${snakeCaseToSentenceCase(name)}Event {\n`;
1092+
yield `export enum ${snakeCaseToSentenceCase(name)}FrontendEvent {\n`;
10901093
yield events.join(',\n');
10911094
yield '\n}\n\n';
10921095
}
10931096

10941097
if (requests.length) {
1095-
yield `export enum ${snakeCaseToSentenceCase(name)}Request {\n`;
1098+
yield `export enum ${snakeCaseToSentenceCase(name)}FrontendRequest {\n`;
10961099
yield requests.join(',\n');
10971100
yield '\n}\n\n';
10981101
}

positron/comms/frontend-backend-openrpc.json renamed to positron/comms/ui-backend-openrpc.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"openrpc": "1.3.0",
33
"info": {
4-
"title": "Frontend Backend",
4+
"title": "UI Backend",
55
"version": "1.0.0"
66
},
77
"methods": [

positron/comms/frontend-frontend-openrpc.json renamed to positron/comms/ui-frontend-openrpc.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"openrpc": "1.3.0",
33
"info": {
4-
"title": "Frontend Frontend",
4+
"title": "UI Frontend",
55
"version": "1.0.0"
66
},
77
"methods": [

positron/comms/frontend.json renamed to positron/comms/ui.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "frontend",
2+
"name": "ui",
33
"initiator": "frontend",
44
"initial_data": {
55
"schema": {

src/positron-dts/positron.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,7 @@ declare module 'positron' {
438438
Dap = 'positron.dap',
439439
Plot = 'positron.plot',
440440
DataViewer = 'positron.dataViewer',
441-
FrontEnd = 'positron.frontEnd',
441+
Ui = 'positron.ui',
442442
Help = 'positron.help',
443443
Connection = 'positron.connection',
444444
IPyWidget = 'jupyter.widget',

0 commit comments

Comments
 (0)