MCPcopy
hub / github.com/coder/mux / getWorkspacesForCommand

Function getWorkspacesForCommand

vscode/src/extension.ts:335–407  ·  view source on GitHub ↗
(
  context: vscode.ExtensionContext
)

Source from the content-addressed store, hash-verified

333}
334
335async function getWorkspacesForCommand(
336 context: vscode.ExtensionContext
337): Promise<WorkspaceWithContext[] | null> {
338 const modeSetting: ConnectionMode = getConnectionModeSetting();
339
340 if (modeSetting === "file-only" || sessionPreferredMode === "file") {
341 sessionPreferredMode = "file";
342 return getAllWorkspacesFromFiles();
343 }
344
345 const apiResult = await tryGetWorkspacesFromApi(context);
346 if ("workspaces" in apiResult) {
347 sessionPreferredMode = "api";
348 return apiResult.workspaces;
349 }
350
351 const failure = apiResult.failure;
352
353 if (modeSetting === "server-only") {
354 const selection = await vscode.window.showErrorMessage(
355 `mux: ${describeFailure(failure)}. (${failure.error})`,
356 ACTION_FIX_CONNECTION_CONFIG
357 );
358
359 if (selection === ACTION_FIX_CONNECTION_CONFIG) {
360 await configureConnectionCommand(context);
361 }
362
363 return null;
364 }
365
366 // modeSetting is auto.
367 if (didShowFallbackPrompt) {
368 sessionPreferredMode = "file";
369 void vscode.window.showWarningMessage(
370 `mux: ${describeFailure(failure)}. Falling back to local file access. Run "mux: Configure Connection" to fix.`
371 );
372 return getAllWorkspacesFromFiles();
373 }
374
375 const selection = await vscode.window.showWarningMessage(
376 `mux: ${describeFailure(failure)}. ${getWarningSuffix(failure)}`,
377 ACTION_FIX_CONNECTION_CONFIG,
378 ACTION_USE_LOCAL_FILES,
379 ACTION_CANCEL
380 );
381
382 if (!selection || selection === ACTION_CANCEL) {
383 return null;
384 }
385
386 didShowFallbackPrompt = true;
387
388 if (selection === ACTION_USE_LOCAL_FILES) {
389 sessionPreferredMode = "file";
390 return getAllWorkspacesFromFiles();
391 }
392

Callers 1

openWorkspaceCommandFunction · 0.85

Calls 6

getConnectionModeSettingFunction · 0.90
tryGetWorkspacesFromApiFunction · 0.85
describeFailureFunction · 0.85
getWarningSuffixFunction · 0.85

Tested by

no test coverage detected