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

Function openWorkspaceCommand

vscode/src/extension.ts:506–588  ·  view source on GitHub ↗

* Command: Open a mux workspace

(
  context: vscode.ExtensionContext,
  options?: {
    chatViewProvider?: MuxChatViewProvider;
  }
)

Source from the content-addressed store, hash-verified

504 * Command: Open a mux workspace
505 */
506async function openWorkspaceCommand(
507 context: vscode.ExtensionContext,
508 options?: {
509 chatViewProvider?: MuxChatViewProvider;
510 }
511): Promise<void> {
512 // Get all workspaces, this is intentionally not cached.
513 const workspaces = await getWorkspacesForCommand(context);
514 if (!workspaces) {
515 return;
516 }
517
518 if (workspaces.length === 0) {
519 const selection = await vscode.window.showInformationMessage(
520 "No mux workspaces found. Create a workspace in mux first.",
521 "Open mux"
522 );
523
524 // User can't easily open mux from VS Code, so just inform them
525 if (selection === "Open mux") {
526 vscode.window.showInformationMessage("Please open the mux application to create workspaces.");
527 }
528 return;
529 }
530
531 // Create QuickPick items (already sorted by recency in getAllWorkspaces)
532 const allItems = workspaces.map(createWorkspaceQuickPickItem);
533
534 // Use createQuickPick for more control over sorting behavior
535 const quickPick = vscode.window.createQuickPick<
536 vscode.QuickPickItem & { workspace: WorkspaceWithContext }
537 >();
538 quickPick.placeholder = "Select a mux workspace to open";
539 quickPick.matchOnDescription = true;
540 quickPick.matchOnDetail = false;
541 quickPick.items = allItems;
542
543 // When user types, filter items but preserve recency order
544 quickPick.onDidChangeValue((value) => {
545 if (!value) {
546 // No filter - show all items in recency order
547 quickPick.items = allItems;
548 return;
549 }
550
551 // Filter items manually to preserve recency order
552 const lowerValue = value.toLowerCase();
553 quickPick.items = allItems.filter((item) => {
554 const labelMatch = item.label.toLowerCase().includes(lowerValue);
555 const descMatch = item.description?.toLowerCase().includes(lowerValue);
556 return labelMatch || descMatch;
557 });
558 });
559
560 quickPick.show();
561
562 // Wait for user selection
563 const selected = await new Promise<

Callers 1

activateFunction · 0.85

Calls 7

openWorkspaceFunction · 0.90
getWorkspacesForCommandFunction · 0.85
revealChatViewFunction · 0.85
disposeMethod · 0.65
resolveFunction · 0.50

Tested by

no test coverage detected