Skip to content

Commit e55f0e9

Browse files
committed
🤖 refactor: rename VS Code oRPC helpers to API
Change-Id: If3f21c66817720222e5f5adfae79ab90abc7f01f Signed-off-by: Thomas Kosiewski <tk@coder.com>
1 parent 3a45a3b commit e55f0e9

File tree

5 files changed

+27
-27
lines changed

5 files changed

+27
-27
lines changed
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ import assert from "node:assert";
55
import { createClient } from "mux/common/orpc/client";
66
import type { AppRouter } from "mux/node/orpc/router";
77

8-
export type ORPCClient = RouterClient<AppRouter>;
8+
export type ApiClient = RouterClient<AppRouter>;
99

10-
export interface VscodeOrpcClientConfig {
10+
export interface ApiClientConfig {
1111
baseUrl: string;
1212
authToken?: string | undefined;
1313
}
@@ -25,7 +25,7 @@ function normalizeBaseUrl(baseUrl: string): string {
2525
return parsed.toString().replace(/\/$/, "");
2626
}
2727

28-
export function createVscodeORPCClient(config: VscodeOrpcClientConfig): ORPCClient {
28+
export function createApiClient(config: ApiClientConfig): ApiClient {
2929
assert(typeof config.baseUrl === "string", "baseUrl must be a string");
3030

3131
const normalizedBaseUrl = normalizeBaseUrl(config.baseUrl);
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import assert from "node:assert";
22

3-
import type { ORPCClient } from "./client";
3+
import type { ApiClient } from "./client";
44

55
export type ServerReachabilityResult =
66
| { status: "ok" }
@@ -99,14 +99,14 @@ export async function checkServerReachable(
9999
}
100100

101101
export async function checkAuth(
102-
client: ORPCClient,
102+
client: ApiClient,
103103
options?: { timeoutMs?: number }
104104
): Promise<AuthCheckResult> {
105105
const timeoutMs = options?.timeoutMs ?? 1_000;
106106

107107
try {
108108
// Used both as an auth check and a basic liveness check.
109-
await promiseWithTimeout(client.general.ping("vscode"), timeoutMs, "oRPC ping");
109+
await promiseWithTimeout(client.general.ping("vscode"), timeoutMs, "API ping");
110110
return { status: "ok" };
111111
} catch (error) {
112112
if (isUnauthorizedError(error)) {

vscode/src/extension.ts

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,26 @@ import * as vscode from "vscode";
22

33
import { formatRelativeTime } from "mux/browser/utils/ui/dateTime";
44

5-
import { getAllWorkspacesFromFiles, getAllWorkspacesFromOrpc, WorkspaceWithContext } from "./muxConfig";
6-
import { checkAuth, checkServerReachable } from "./orpc/connectionCheck";
7-
import { createVscodeORPCClient } from "./orpc/client";
5+
import { getAllWorkspacesFromFiles, getAllWorkspacesFromApi, WorkspaceWithContext } from "./muxConfig";
6+
import { checkAuth, checkServerReachable } from "./api/connectionCheck";
7+
import { createApiClient } from "./api/client";
88
import {
99
clearAuthTokenOverride,
1010
discoverServerConfig,
1111
getConnectionModeSetting,
1212
storeAuthTokenOverride,
1313
type ConnectionMode,
14-
} from "./orpc/discovery";
14+
} from "./api/discovery";
1515
import { openWorkspace } from "./workspaceOpener";
1616

17-
let sessionPreferredMode: "orpc" | "file" | null = null;
17+
let sessionPreferredMode: "api" | "file" | null = null;
1818
let didShowFallbackPrompt = false;
1919

2020
const ACTION_FIX_CONNECTION_CONFIG = "Fix connection config";
2121
const ACTION_USE_LOCAL_FILES = "Use local file access";
2222
const ACTION_CANCEL = "Cancel";
2323

24-
type OrpcConnectionFailure =
24+
type ApiConnectionFailure =
2525
| { kind: "unreachable"; baseUrl: string; error: string }
2626
| { kind: "unauthorized"; baseUrl: string; error: string }
2727
| { kind: "error"; baseUrl: string; error: string };
@@ -30,7 +30,7 @@ function formatError(error: unknown): string {
3030
return error instanceof Error ? error.message : String(error);
3131
}
3232

33-
function describeFailure(failure: OrpcConnectionFailure): string {
33+
function describeFailure(failure: ApiConnectionFailure): string {
3434
switch (failure.kind) {
3535
case "unreachable":
3636
return `mux server is not reachable at ${failure.baseUrl}`;
@@ -41,19 +41,19 @@ function describeFailure(failure: OrpcConnectionFailure): string {
4141
}
4242
}
4343

44-
function getWarningSuffix(failure: OrpcConnectionFailure): string {
44+
function getWarningSuffix(failure: ApiConnectionFailure): string {
4545
if (failure.kind === "unauthorized") {
4646
return "Using local file access while mux is running can cause inconsistencies.";
4747
}
4848
return "Using local file access can cause inconsistencies.";
4949
}
5050

51-
async function tryGetWorkspacesFromOrpc(
51+
async function tryGetWorkspacesFromApi(
5252
context: vscode.ExtensionContext
53-
): Promise<{ workspaces: WorkspaceWithContext[] } | { failure: OrpcConnectionFailure }> {
53+
): Promise<{ workspaces: WorkspaceWithContext[] } | { failure: ApiConnectionFailure }> {
5454
try {
5555
const discovery = await discoverServerConfig(context);
56-
const client = createVscodeORPCClient({ baseUrl: discovery.baseUrl, authToken: discovery.authToken });
56+
const client = createApiClient({ baseUrl: discovery.baseUrl, authToken: discovery.authToken });
5757

5858
const reachable = await checkServerReachable(discovery.baseUrl);
5959
if (reachable.status !== "ok") {
@@ -86,7 +86,7 @@ async function tryGetWorkspacesFromOrpc(
8686
};
8787
}
8888

89-
const workspaces = await getAllWorkspacesFromOrpc(client);
89+
const workspaces = await getAllWorkspacesFromApi(client);
9090
return { workspaces };
9191
} catch (error) {
9292
return {
@@ -109,13 +109,13 @@ async function getWorkspacesForCommand(
109109
return getAllWorkspacesFromFiles();
110110
}
111111

112-
const orpcResult = await tryGetWorkspacesFromOrpc(context);
113-
if ("workspaces" in orpcResult) {
114-
sessionPreferredMode = "orpc";
115-
return orpcResult.workspaces;
112+
const apiResult = await tryGetWorkspacesFromApi(context);
113+
if ("workspaces" in apiResult) {
114+
sessionPreferredMode = "api";
115+
return apiResult.workspaces;
116116
}
117117

118-
const failure = orpcResult.failure;
118+
const failure = apiResult.failure;
119119

120120
if (modeSetting === "server-only") {
121121
const selection = await vscode.window.showErrorMessage(
@@ -159,9 +159,9 @@ async function getWorkspacesForCommand(
159159

160160
await configureConnectionCommand(context);
161161

162-
const retry = await tryGetWorkspacesFromOrpc(context);
162+
const retry = await tryGetWorkspacesFromApi(context);
163163
if ("workspaces" in retry) {
164-
sessionPreferredMode = "orpc";
164+
sessionPreferredMode = "api";
165165
return retry.workspaces;
166166
}
167167

vscode/src/muxConfig.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import type { FrontendWorkspaceMetadata, WorkspaceActivitySnapshot } from "mux/c
33
import { type ExtensionMetadata, readExtensionMetadata } from "mux/node/utils/extensionMetadata";
44
import { createRuntime } from "mux/node/runtime/runtimeFactory";
55

6-
import type { ORPCClient } from "./orpc/client";
6+
import type { ApiClient } from "./api/client";
77

88
/**
99
* Workspace with extension metadata for display in VS Code extension.
@@ -44,7 +44,7 @@ export async function getAllWorkspacesFromFiles(): Promise<WorkspaceWithContext[
4444
return enrichAndSort(workspaces, extensionMeta);
4545
}
4646

47-
export async function getAllWorkspacesFromOrpc(client: ORPCClient): Promise<WorkspaceWithContext[]> {
47+
export async function getAllWorkspacesFromApi(client: ApiClient): Promise<WorkspaceWithContext[]> {
4848
const workspaces = await client.workspace.list();
4949
const activityById: Record<string, WorkspaceActivitySnapshot> = await client.workspace.activity.list();
5050

0 commit comments

Comments
 (0)