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

Method setClient

src/browser/stores/WorkspaceStore.ts:1251–1289  ·  view source on GitHub ↗
(client: RouterClient<AppRouter> | null)

Source from the content-addressed store, hash-verified

1249 }
1250
1251 setClient(client: RouterClient<AppRouter> | null): void {
1252 if (this.client === client) {
1253 return;
1254 }
1255
1256 // Drop stats subscriptions before swapping clients so reconnects resubscribe cleanly.
1257 for (const unsubscribe of this.statsUnsubscribers.values()) {
1258 unsubscribe();
1259 }
1260 this.statsUnsubscribers.clear();
1261
1262 this.client = client;
1263 this.clientChangeController.abort();
1264 this.clientChangeController = new AbortController();
1265
1266 this.bumpAllUsageStoreEntries();
1267
1268 for (const workspaceId of this.workspaceMetadata.keys()) {
1269 this.pendingReplayReset.add(workspaceId);
1270 }
1271
1272 if (client) {
1273 this.ensureActivitySubscription();
1274 this.ensureTerminalActivitySubscription();
1275 }
1276
1277 if (!client) {
1278 return;
1279 }
1280
1281 // Re-subscribe any workspaces that already have UI consumers.
1282 for (const workspaceId of this.statsListenerCounts.keys()) {
1283 this.subscribeToStats(workspaceId);
1284 }
1285
1286 this.ensureActiveOnChatSubscription();
1287 void this.refreshProvidersConfig(client);
1288 this.subscribeToProvidersConfig(client);
1289 }
1290
1291 setActiveWorkspaceId(workspaceId: string | null): void {
1292 assert(

Callers

nothing calls this directly

Calls 10

subscribeToStatsMethod · 0.95
addMethod · 0.80
abortMethod · 0.65
clearMethod · 0.45

Tested by

no test coverage detected