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 21, 21:00 UTC
fix(client-runtime): provider toggles no longer wait for another provider's update (#34858)
Julius Marminge committed
Nov 11, 2026 at 23:45 UTC
dcad1942a956cc9b2390a00bdda11a2030c0ef04
2 files changed
+72
-2
packages/client-runtime/src/state/server.test.ts
+72
@@ -1665,6 +1665,78 @@ describe("provider setup commands", () => {
1665
expect(yield* Queue.takeAll(requested)).toEqual(["antigravity"]);
1666
}).pipe(Effect.scoped),
1667
);
1668
+
1669
+ it.effect("toggles a provider while another provider's update is still running", () =>
1670
+ Effect.gen(function* () {
1671
+ const updateStarted = yield* Deferred.make<void>();
1672
+ const settingsSaved = yield* Deferred.make<void>();
1673
+ const client = {
1674
+ [WS_METHODS.serverUpdateProvider]: () =>
1675
+ Deferred.succeed(updateStarted, undefined).pipe(Effect.andThen(Effect.never)),
1676
+ [WS_METHODS.serverUpdateSettings]: () =>
1677
+ Deferred.succeed(settingsSaved, undefined).pipe(Effect.as(CONFIG.settings)),
1678
+ } as unknown as WsRpcProtocolClient;
1679
+ const supervisor = EnvironmentSupervisor.EnvironmentSupervisor.of({
1680
+ target: TARGET,
1681
+ state: yield* SubscriptionRef.make(AVAILABLE_CONNECTION_STATE),
1682
+ session: yield* SubscriptionRef.make(Option.some(session(client))),
1683
+ prepared: yield* SubscriptionRef.make(Option.none<PreparedConnection>()),
1684
+ connect: Effect.void,
1685
+ disconnect: Effect.void,
1686
+ retryNow: Effect.void,
1687
+ } satisfies EnvironmentSupervisor.EnvironmentSupervisor["Service"]);
1688
+ const runtime = Atom.runtime(
1689
+ Layer.merge(
1690
+ Layer.succeed(EnvironmentRegistry.EnvironmentRegistry, {
1691
+ run: (_environmentId, effect) =>
1692
+ Effect.provideService(
1693
+ effect,
1694
+ EnvironmentSupervisor.EnvironmentSupervisor,
1695
+ supervisor,
1696
+ ),
1697
+ } as EnvironmentRegistry.EnvironmentRegistry["Service"]),
1698
+ Layer.succeed(
1699
+ Persistence.EnvironmentCacheStore,
1700
+ {} as Persistence.EnvironmentCacheStore["Service"],
1701
+ ),
1702
+ ),
1703
+ );
1704
+ const atoms = createServerEnvironmentAtoms(runtime, {
1705
+ initialConfigValueAtom: () => Atom.make(CONFIG),
1706
+ });
1707
+ const registry = yield* Effect.acquireRelease(Effect.sync(AtomRegistry.make), (registry) =>
1708
+ Effect.sync(() => registry.dispose()),
1709
+ );
1710
+
1711
+ void atoms.updateProvider.run(registry, {
1712
+ environmentId: TARGET.environmentId,
1713
+ input: { provider: ProviderDriverKind.make("opencode") },
1714
+ });
1715
+ yield* Deferred.await(updateStarted);
1716
+ void atoms.mutateProviderInstance.run(registry, {
1717
+ environmentId: TARGET.environmentId,
1718
+ input: {
1719
+ patch: {},
1720
+ providerInstanceMutation: {
1721
+ operation: "upsert",
1722
+ instanceId: ProviderInstanceId.make("codex"),
1723
+ instance: { driver: ProviderDriverKind.make("codex"), enabled: false },
1724
+ },
1725
+ },
1726
+ });
1727
+
1728
+ const saved = yield* Deferred.await(settingsSaved).pipe(
1729
+ Effect.as(true),
1730
+ Effect.timeoutOrElse({
1731
+ duration: Duration.seconds(1),
1732
+ orElse: () => Effect.succeed(false),
1733
+ }),
1734
+ Effect.forkChild,
1735
+ );
1736
+ yield* TestClock.adjust(Duration.seconds(1));
1737
+ expect(yield* Fiber.join(saved)).toBe(true);
1738
+ }).pipe(Effect.scoped),
1739
+ );
1740
});
1741
1742
describe("resource telemetry history", () => {
packages/client-runtime/src/state/server.ts
-2
@@ -1511,8 +1511,6 @@ export function createServerEnvironmentAtoms<R, E>(
1511
updateProvider: createEnvironmentRpcCommand(runtime, {
1512
label: "environment-data:server:update-provider",
1513
tag: WS_METHODS.serverUpdateProvider,
1514
- scheduler: configScheduler,
1515
- concurrency: configConcurrency,
1514
}),
1515
updateServer,
1516
upsertKeybinding: createEnvironmentRpcCommand(runtime, {