Skip to content

Commit 51d5290

Browse files
committed
feat: update session management to store launch configuration and target cluster in workspace state
Signed-off-by: Gordon Smith <[email protected]>
1 parent 6ee3583 commit 51d5290

File tree

6 files changed

+34
-17
lines changed

6 files changed

+34
-17
lines changed

.github/copilot-instructions.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ How to apply:
128128
- Before adding a new contribution, confirm an existing pattern in `package.json` (e.g. replicate a command object, adjust `enablement`).
129129
- For a new Tree View / data provider, follow existing HPCC platform tree patterns under `src/hpccplatform/` and reference TreeDataProvider docs.
130130
- For new notebook renderer: add entry in `esbuild.mjs` (browser target) + `notebookRenderer` contribution + MIME type contract.
131-
- For status bar interactions replicate existing approach (search for usages setting `ecl.launchConfiguration` & `ecl.targetCluster`).
131+
- For status bar interactions replicate existing approach (launch configuration and target cluster state is stored in workspace state, not settings).
132132

133133
When unsure of an API surface (e.g. `WorkspaceEdit`, `TextDocumentContentProvider`, etc.) prefer stable APIs listed in the vscode-api reference; avoid proposed APIs unless already adopted in this repo.
134134

.vscode/launch.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,19 @@
144144
"<node_internals>/**"
145145
],
146146
"type": "node"
147+
},
148+
{
149+
"name": "localhost",
150+
"type": "ecl",
151+
"request": "launch",
152+
"protocol": "http",
153+
"serverAddress": "localhost",
154+
"port": 8010,
155+
"targetCluster": "thor",
156+
"rejectUnauthorized": true,
157+
"resultLimit": 100,
158+
"timeoutSecs": 60,
159+
"user": "gordon"
147160
}
148161
]
149162
}

package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1625,13 +1625,15 @@
16251625
"type": "string",
16261626
"scope": "resource",
16271627
"default": "",
1628-
"description": "%Default launch configuration%"
1628+
"description": "%Default launch configuration%",
1629+
"deprecationMessage": "%This setting is deprecated. Launch configuration state is now stored in workspace state.%"
16291630
},
16301631
"ecl.targetCluster": {
16311632
"type": "object",
16321633
"scope": "resource",
16331634
"default": {},
1634-
"description": "%Target cluster (per launch configuration)%"
1635+
"description": "%Target cluster (per launch configuration)%",
1636+
"deprecationMessage": "%This setting is deprecated. Target cluster state is now stored in workspace state.%"
16351637
},
16361638
"ecl.pinnedLaunchConfigurations": {
16371639
"type": "object",

package.nls.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@
5252
"Database Name": "Database Name",
5353
"Debug level logging (requires restart)": "Debug level logging (requires restart)",
5454
"Default launch configuration": "Default launch configuration",
55+
"This setting is deprecated. Launch configuration state is now stored in workspace state.": "This setting is deprecated. Launch configuration state is now stored in workspace state.",
56+
"This setting is deprecated. Target cluster state is now stored in workspace state.": "This setting is deprecated. Target cluster state is now stored in workspace state.",
5557
"Dismiss": "Dismiss",
5658
"Default timeout (secs)": "Default timeout (secs)",
5759
"Delete Workunit": "Delete Workunit",

src/ecl/main.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ const logger = scopedLogger("ecl/main.ts");
2121

2222
export function activate(ctx: vscode.ExtensionContext): void {
2323
logger.debug("Activating SessionManager");
24-
sessionManager.initialize();
24+
sessionManager.initialize(ctx);
2525
logger.debug("Activating ECLDiagnostic");
2626
ECLDiagnostic.attach(ctx);
2727
logger.debug("Activating ECLCommands");

src/hpccplatform/session.ts

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ export interface ICreateWorkunit {
151151

152152
class SessionManager {
153153

154+
private _context?: vscode.ExtensionContext;
154155
private _globalSession?: Session;
155156
private _pinnedSession?: Session;
156157

@@ -169,7 +170,8 @@ class SessionManager {
169170
this._statusBarLaunch.command = "hpccPlatform.switch";
170171
}
171172

172-
initialize() {
173+
initialize(context: vscode.ExtensionContext) {
174+
this._context = context;
173175
this._statusBarTargetCluster = vscode.window.createStatusBarItem(vscode.StatusBarAlignment.Left, Number.MIN_VALUE + 1);
174176
this._statusBarTargetCluster.command = "hpccPlatform.switchTargetCluster";
175177

@@ -260,17 +262,15 @@ class SessionManager {
260262
void this.switchTo(this.session.id, this.session.overriddenTargetCluster);
261263
}
262264
}
263-
if (e.affectsConfiguration("ecl.launchConfiguration") || e.affectsConfiguration("ecl.targetCluster")) {
264-
const currentEclConfig = vscode.workspace.getConfiguration("ecl", null);
265-
const launchConfig = currentEclConfig.get<string>("launchConfiguration");
266-
const targetCluster = currentEclConfig.get<object>("targetCluster")[launchConfig];
267-
void this.switchTo(launchConfig, targetCluster);
268-
}
269265
});
270266

271267
const eclConfig = vscode.workspace.getConfiguration("ecl", null);
272-
const launchConfig = eclConfig.get<string>("launchConfiguration");
273-
const targetCluster = eclConfig.get<object>("targetCluster")[launchConfig];
268+
const settingsLaunchConfig = eclConfig.get<string>("launchConfiguration");
269+
const settingsTargetCluster = eclConfig.get<object>("targetCluster")[settingsLaunchConfig];
270+
const launchConfig = context.workspaceState.get<string>("ecl.launchConfiguration") || settingsLaunchConfig;
271+
const targetClusters = context.workspaceState.get<Record<string, string>>("ecl.targetCluster") || eclConfig.get<object>("targetCluster");
272+
const targetCluster = targetClusters[launchConfig];
273+
274274
this.switchTo(launchConfig, targetCluster).then(() => {
275275
vscode.commands.executeCommand("setContext", "hpccPlatformActive", true);
276276
}).finally(() => {
@@ -438,16 +438,16 @@ class SessionManager {
438438
}
439439
}
440440
} else {
441-
const currentLaunchConfig = eclConfig.get<string>("launchConfiguration");
442-
const targetClusters = eclConfig.get<object>("targetCluster");
441+
const currentLaunchConfig = this._context.workspaceState.get<string>("ecl.launchConfiguration");
442+
const targetClusters = this._context.workspaceState.get<Record<string, string>>("ecl.targetCluster") || {};
443443
const currentTargetCluster = targetClusters[this.session.id];
444444

445445
if (currentLaunchConfig !== this.session.id) {
446-
eclConfig.update("launchConfiguration", this.session.id);
446+
void this._context.workspaceState.update("ecl.launchConfiguration", this.session.id);
447447
}
448448
if (currentTargetCluster !== this.session.overriddenTargetCluster) {
449449
targetClusters[this.session.id] = this.session.overriddenTargetCluster;
450-
eclConfig.update("targetCluster", targetClusters);
450+
void this._context.workspaceState.update("ecl.targetCluster", targetClusters);
451451
}
452452
}
453453
}

0 commit comments

Comments
 (0)