(context: vscode.ExtensionContext)
| 588 | } |
| 589 | |
| 590 | async function configureConnectionCommand(context: vscode.ExtensionContext): Promise<void> { |
| 591 | const config = vscode.workspace.getConfiguration("mux"); |
| 592 | |
| 593 | // Small loop so users can set/clear both URL + token in one command. |
| 594 | // Keep UX minimal: no nested quick picks or extra commands. |
| 595 | for (;;) { |
| 596 | const currentUrl = config.get<string>("serverUrl")?.trim() ?? ""; |
| 597 | const hasToken = (await context.secrets.get("mux.serverAuthToken")) !== undefined; |
| 598 | |
| 599 | const pick = await vscode.window.showQuickPick( |
| 600 | [ |
| 601 | { |
| 602 | label: "Set server URL", |
| 603 | description: currentUrl ? `Current: ${currentUrl}` : "Current: auto-discover", |
| 604 | }, |
| 605 | ...(currentUrl |
| 606 | ? ([ |
| 607 | { label: "Clear server URL override", description: "Use env/lockfile/default" }, |
| 608 | ] as const) |
| 609 | : ([] as const)), |
| 610 | { |
| 611 | label: "Set auth token", |
| 612 | description: hasToken ? "Current: set" : "Current: none", |
| 613 | }, |
| 614 | ...(hasToken ? ([{ label: "Clear auth token" }] as const) : ([] as const)), |
| 615 | { label: "Done" }, |
| 616 | ], |
| 617 | { placeHolder: "Configure mux server connection" } |
| 618 | ); |
| 619 | |
| 620 | if (!pick || pick.label === "Done") { |
| 621 | return; |
| 622 | } |
| 623 | |
| 624 | if (pick.label === "Set server URL") { |
| 625 | const value = await vscode.window.showInputBox({ |
| 626 | title: "mux server URL", |
| 627 | value: currentUrl, |
| 628 | prompt: "Example: http://127.0.0.1:3000 (leave blank for auto-discovery)", |
| 629 | validateInput(input) { |
| 630 | const trimmed = input.trim(); |
| 631 | if (!trimmed) { |
| 632 | return null; |
| 633 | } |
| 634 | try { |
| 635 | const url = new URL(trimmed); |
| 636 | if (url.protocol !== "http:" && url.protocol !== "https:") { |
| 637 | return "URL must start with http:// or https://"; |
| 638 | } |
| 639 | return null; |
| 640 | } catch { |
| 641 | return "Invalid URL"; |
| 642 | } |
| 643 | }, |
| 644 | }); |
| 645 | |
| 646 | if (value === undefined) { |
| 647 | continue; |
no test coverage detected