@devries-cameron20 / t3code Mirror · read-only / commits / 52b65aabce
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 22, 07:00 UTC

fix(web): installing two providers at once starts both (#24655)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: maria-rcks <maria@kuuro.net>

Victor Vogel committed Nov 1, 2026 at 16:00 UTC 52b65aabceb870e80e16f2cf9c6d8645aa4eee72
2 files changed +87 -2
packages/client-runtime/src/state/server.test.ts
+86 -1
@@ -1,7 +1,10 @@
1 import {
2 EnvironmentId,
3 + ProviderDriverKind,
4 ServerSelfUpdateError,
5 ProviderInstanceId,
6 + type ProviderInstallState,
7 + type ProviderSetupInput,
8 ServerObservability,
9 EnvironmentThemeId,
10 UsageLimitSourceId,
@@ -34,8 +37,8 @@ import {
37 PrimaryConnectionTarget,
38 type PreparedConnection,
39 } from "../connection/model.ts";
37 -import * as EnvironmentSupervisor from "../connection/supervisor.ts";
40 import * as EnvironmentRegistry from "../connection/registry.ts";
41 +import * as EnvironmentSupervisor from "../connection/supervisor.ts";
42 import { RpcPermissionGuard } from "../rpc/client.ts";
43 import * as Persistence from "../platform/persistence.ts";
44 import type { WsRpcProtocolClient } from "../rpc/protocol.ts";
@@ -1309,3 +1312,85 @@ describe("server state projection", () => {
1312 }),
1313 );
1314 });
1315 +
1316 +describe("provider setup commands", () => {
1317 + it.effect("starts installs for two instances in one environment separately", () =>
1318 + Effect.gen(function* () {
1319 + const requested = yield* Queue.unbounded<ProviderInstanceId>();
1320 + const release = yield* Deferred.make<void>();
1321 + const installState = (driver: string): ProviderInstallState => ({
1322 + driver: ProviderDriverKind.make(driver),
1323 + operationId: null,
1324 + phase: "downloading",
1325 + downloadedBytes: 0,
1326 + totalBytes: null,
1327 + version: null,
1328 + installedVersion: null,
1329 + canRemove: false,
1330 + message: null,
1331 + });
1332 + const client = {
1333 + [WS_METHODS.providerInstallStart]: ({ instanceId }: ProviderSetupInput) =>
1334 + Queue.offer(requested, instanceId).pipe(
1335 + Effect.andThen(Deferred.await(release)),
1336 + Effect.as(installState(instanceId)),
1337 + ),
1338 + } as unknown as WsRpcProtocolClient;
1339 + const supervisor = EnvironmentSupervisor.EnvironmentSupervisor.of({
1340 + target: TARGET,
1341 + state: yield* SubscriptionRef.make(AVAILABLE_CONNECTION_STATE),
1342 + session: yield* SubscriptionRef.make(Option.some(session(client))),
1343 + prepared: yield* SubscriptionRef.make(Option.none<PreparedConnection>()),
1344 + connect: Effect.void,
1345 + disconnect: Effect.void,
1346 + retryNow: Effect.void,
1347 + } satisfies EnvironmentSupervisor.EnvironmentSupervisor["Service"]);
1348 + const runtime = Atom.runtime(
1349 + Layer.merge(
1350 + Layer.succeed(EnvironmentRegistry.EnvironmentRegistry, {
1351 + run: (_environmentId, effect) =>
1352 + Effect.provideService(
1353 + effect,
1354 + EnvironmentSupervisor.EnvironmentSupervisor,
1355 + supervisor,
1356 + ),
1357 + } as EnvironmentRegistry.EnvironmentRegistry["Service"]),
1358 + Layer.succeed(
1359 + Persistence.EnvironmentCacheStore,
1360 + {} as Persistence.EnvironmentCacheStore["Service"],
1361 + ),
1362 + ),
1363 + );
1364 + const atoms = createServerEnvironmentAtoms(runtime, {
1365 + initialConfigValueAtom: () => Atom.make(CONFIG),
1366 + });
1367 + const registry = yield* Effect.acquireRelease(Effect.sync(AtomRegistry.make), (registry) =>
1368 + Effect.sync(() => registry.dispose()),
1369 + );
1370 + const install = (instanceId: string) =>
1371 + atoms.startProviderInstall.run(registry, {
1372 + environmentId: TARGET.environmentId,
1373 + input: { instanceId: ProviderInstanceId.make(instanceId) },
1374 + });
1375 +
1376 + const codex = install("codex");
1377 + expect(yield* Queue.take(requested)).toBe("codex");
1378 + const duplicateCodex = install("codex");
1379 + const antigravity = install("antigravity");
1380 + yield* Deferred.succeed(release, undefined);
1381 +
1382 + expect(yield* Effect.promise(() => codex)).toMatchObject({
1383 + _tag: "Success",
1384 + value: { driver: "codex" },
1385 + });
1386 + expect(yield* Effect.promise(() => duplicateCodex)).toEqual(
1387 + yield* Effect.promise(() => codex),
1388 + );
1389 + expect(yield* Effect.promise(() => antigravity)).toMatchObject({
1390 + _tag: "Success",
1391 + value: { driver: "antigravity" },
1392 + });
1393 + expect(yield* Queue.takeAll(requested)).toEqual(["antigravity"]);
1394 + }).pipe(Effect.scoped),
1395 + );
1396 +});
packages/client-runtime/src/state/server.ts
+1 -1
@@ -1250,7 +1250,7 @@ export function createServerEnvironmentAtoms<R, E>(
1250 tag: WS_METHODS.providerInstallStart,
1251 concurrency: {
1252 mode: "singleFlight",
1253 - key: ({ environmentId }) => environmentId,
1253 + key: ({ environmentId, input }) => JSON.stringify([environmentId, input]),
1254 },
1255 }),
1256 cancelProviderInstall: createEnvironmentRpcCommand(runtime, {