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

Function debugConnectionCommand

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

Source from the content-addressed store, hash-verified

687}
688
689async function debugConnectionCommand(context: vscode.ExtensionContext): Promise<void> {
690 assert(context, "debugConnectionCommand requires context");
691
692 const output = getMuxLogChannel();
693 output.show(true);
694
695 muxLogInfo("mux: debugConnection start");
696
697 let discovery: Awaited<ReturnType<typeof discoverServerConfig>>;
698 try {
699 discovery = await discoverServerConfig(context);
700 } catch (error) {
701 muxLogError("mux: debugConnection discovery failed", { error: formatError(error) });
702 void vscode.window.showErrorMessage(
703 `mux: Failed to discover server config. (${formatError(error)})`
704 );
705 return;
706 }
707
708 muxLogInfo("mux: debugConnection discovered server config", {
709 baseUrl: discovery.baseUrl,
710 baseUrlSource: discovery.baseUrlSource,
711 authTokenSource: discovery.authTokenSource,
712 hasAuthToken: Boolean(discovery.authToken),
713 });
714
715 const reachable = await checkServerReachable(discovery.baseUrl, { timeoutMs: 2_000 });
716 muxLogInfo("mux: debugConnection server reachable", reachable);
717
718 if (reachable.status !== "ok") {
719 void vscode.window.showErrorMessage(
720 `mux: Server not reachable at ${discovery.baseUrl}. (${reachable.error})`
721 );
722 return;
723 }
724
725 const client = createApiClient({ baseUrl: discovery.baseUrl, authToken: discovery.authToken });
726
727 const auth = await checkAuth(client, { timeoutMs: 2_000 });
728 muxLogInfo("mux: debugConnection auth", auth);
729
730 if (auth.status !== "ok") {
731 const hint =
732 auth.status === "unauthorized"
733 ? ' Run "mux: Configure Connection" to update the auth token.'
734 : "";
735
736 void vscode.window.showErrorMessage(
737 `mux: Failed to authenticate at ${discovery.baseUrl}. (${auth.error})${hint}`
738 );
739 return;
740 }
741
742 let workspaceCount: number | null = null;
743 try {
744 const workspaces = await getAllWorkspacesFromApi(client);
745 workspaceCount = workspaces.length;
746 muxLogInfo("mux: debugConnection listed workspaces", { count: workspaceCount });

Callers 1

activateFunction · 0.85

Calls 11

discoverServerConfigFunction · 0.90
checkServerReachableFunction · 0.90
createApiClientFunction · 0.90
checkAuthFunction · 0.90
getAllWorkspacesFromApiFunction · 0.90
getMuxLogChannelFunction · 0.85
muxLogInfoFunction · 0.85
muxLogErrorFunction · 0.85
muxLogWarnFunction · 0.85
formatErrorFunction · 0.70
assertFunction · 0.50

Tested by

no test coverage detected