@devries-cameron20 / t3code Mirror · read-only / commits / b1ca56209c
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 21, 07:15 UTC

fix(server): an Antigravity update refreshes every instance's model list (#36035)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

sittingmongoose committed Nov 18, 2026 at 07:39 UTC b1ca56209cc525af236cd3d4d1bb8ca2aa1479b7
2 files changed +110 -26
apps/server/src/provider/providerInstallation.test.ts
+80 -5
@@ -12,6 +12,7 @@ import * as SubscriptionRef from "effect/SubscriptionRef";
12 import * as FileSystem from "effect/FileSystem";
13 import * as Layer from "effect/Layer";
14 import * as Path from "effect/Path";
15 +import * as Queue from "effect/Queue";
16 import * as Stream from "effect/Stream";
17
18 import * as ServerSettings from "../serverSettings.ts";
@@ -59,28 +60,39 @@ function instance(kind = driver, id = instanceId): ProviderInstance {
60 const makeHarness = Effect.fn("providerInstallation.test.makeHarness")(function* (
61 input: {
62 instance?: ProviderInstance;
63 + others?: ReadonlyArray<ProviderInstance>;
64 settings?: Parameters<typeof ServerSettings.layerTest>[0];
65 } = {},
66 ) {
67 const calls: string[] = [];
68 const refreshed = yield* Deferred.make<void>();
69 + const lastRefreshes = yield* Queue.unbounded<void>();
70 const observed = yield* Deferred.make<void>();
71 const listening = yield* Deferred.make<void>();
72 const installationState = yield* SubscriptionRef.make(state);
73 let protectedPaths: ReadonlyArray<string> = [];
74 const configured = input.instance ?? instance();
75 + const all = [configured, ...(input.others ?? [])];
76 + const refreshedInstances: ProviderInstanceId[] = [];
77 + let watches = 0;
78 const dependencies = Layer.mergeAll(
79 ServerSettings.layerTest(input.settings),
80 Layer.mock(ProviderInstanceRegistry.ProviderInstanceRegistry)({
75 - getInstance: (id) => Effect.succeed(id === configured.instanceId ? configured : undefined),
76 - listInstances: Effect.succeed([configured]),
81 + getInstance: (id) => Effect.succeed(all.find((entry) => entry.instanceId === id)),
82 + listInstances: Effect.succeed(all),
83 }),
84 Layer.mock(ProviderRegistry.ProviderRegistry)({
79 - refreshInstance: () =>
85 + refreshInstance: (id) =>
86 Effect.sync(() => {
87 calls.push("refresh");
88 + refreshedInstances.push(id);
89 return [];
83 - }).pipe(Effect.tap(() => Deferred.succeed(refreshed, undefined))),
90 + }).pipe(
91 + Effect.tap(() => Deferred.succeed(refreshed, undefined)),
92 + Effect.tap(() =>
93 + id === all.at(-1)?.instanceId ? Queue.offer(lastRefreshes, undefined) : Effect.void,
94 + ),
95 + ),
96 }),
97 Layer.mock(CodexInstallation.CodexInstallation)({
98 managedDirectory: "/unused-managed-codex",
@@ -115,8 +127,13 @@ const makeHarness = Effect.fn("providerInstallation.test.makeHarness")(function*
127 return state;
128 }),
129 state: Effect.succeed(state),
118 - changes: input.instance?.refreshModels
130 + changes: all.some((entry) => entry.refreshModels)
131 ? SubscriptionRef.changes(installationState).pipe(
132 + Stream.onStart(
133 + Effect.sync(() => {
134 + watches++;
135 + }),
136 + ),
137 Stream.tap(() => Deferred.succeed(listening, undefined)),
138 Stream.ensuring(Deferred.succeed(observed, undefined)),
139 )
@@ -139,8 +156,11 @@ const makeHarness = Effect.fn("providerInstallation.test.makeHarness")(function*
156 listening,
157 calls,
158 refreshed,
159 + lastRefreshes,
160 + watches: () => watches,
161 observed,
162 installationState,
163 + refreshedInstances,
164 protectedPaths: () => protectedPaths,
165 };
166 });
@@ -204,6 +224,61 @@ describe("provider installation routing", () => {
224 }).pipe(Effect.scoped, Effect.provide(NodeServices.layer)),
225 );
226
227 + it.effect(
228 + "checks every enabled instance on the managed runtime once, whichever instance started the install",
229 + () =>
230 + Effect.gen(function* () {
231 + const checked: string[] = [];
232 + const managed = (id: string, enabled: boolean) =>
233 + Object.assign(instance(driver, ProviderInstanceId.make(id)), {
234 + enabled,
235 + refreshModels: () =>
236 + Effect.sync(() => {
237 + checked.push(id);
238 + }),
239 + });
240 + const work = managed("antigravity_work", true);
241 + const personal = managed("antigravity_personal", true);
242 + const harness = yield* makeHarness({
243 + // The disabled default instance is listed first, as server.getConfig lists it.
244 + instance: managed("antigravity", false),
245 + others: [managed("antigravity_custom", true), work, personal],
246 + settings: {
247 + providerInstances: {
248 + [ProviderInstanceId.make("antigravity_custom")]: {
249 + driver,
250 + config: { binaryPath: "/external/agy" },
251 + },
252 + },
253 + },
254 + });
255 + yield* Effect.gen(function* () {
256 + const first = yield* harness.connect;
257 + const second = yield* harness.connect;
258 + yield* Effect.all(
259 + [first.start({ instanceId }), second.start({ instanceId: personal.instanceId })],
260 + { concurrency: "unbounded" },
261 + );
262 + yield* Deferred.await(harness.listening);
263 + }).pipe(Effect.scoped);
264 + yield* SubscriptionRef.set(harness.installationState, {
265 + ...state,
266 + operationId: "install-1",
267 + phase: "succeeded",
268 + installedVersion: "1.5.8",
269 + });
270 + yield* Deferred.await(harness.observed);
271 + // Instances refresh in list order, so the last one's refresh ends a watch's pass.
272 + yield* Queue.take(harness.lastRefreshes);
273 + assert.deepEqual(checked, [work.instanceId, personal.instanceId]);
274 + // Let every other watch of this install finish its pass; none may refresh again.
275 + yield* Queue.takeN(harness.lastRefreshes, harness.watches() - 1);
276 + assert.deepEqual(checked, [work.instanceId, personal.instanceId]);
277 + assert.deepEqual(harness.refreshedInstances, [work.instanceId, personal.instanceId]);
278 + assert.strictEqual(harness.watches(), 1);
279 + }).pipe(Effect.scoped, Effect.provide(NodeServices.layer)),
280 + );
281 +
282 it.effect("keeps external installs manual without hiding shared install status", () =>
283 Effect.gen(function* () {
284 const harness = yield* makeHarness({
apps/server/src/provider/providerInstallation.ts
+30 -21
@@ -58,7 +58,8 @@ const make = Effect.fn("makeProviderInstallation")(function* () {
58 const fileSystem = yield* FileSystem.FileSystem;
59 const path = yield* Path.Path;
60 const scope = yield* Effect.scope;
61 - const accountCheckOperations = new Map<ProviderInstanceId, string>();
61 + // A start during a running install joins it, so one operation is checked once whichever instance asked.
62 + let accountCheckOperation: string | undefined;
63
64 const readEntries = Effect.fn("ProviderInstallation.readEntries")(function* (
65 instanceId: ProviderInstanceId,
@@ -133,15 +134,34 @@ const make = Effect.fn("makeProviderInstallation")(function* () {
134 ) =>
135 new ProviderSetupError({ instanceId, operation: error.operation, detail: error.detail });
136
137 + // Every instance without a custom executable runs the one managed runtime, so an install
138 + // replaces the runtime behind all of their model lists, not only the instance that asked.
139 + const checkManagedRuntimeInstances = Effect.fn(
140 + "ProviderInstallation.checkManagedRuntimeInstances",
141 + )(function* (instanceId: ProviderInstanceId) {
142 + const entries = yield* readEntries(instanceId, "install");
143 + for (const instance of yield* instances.listInstances) {
144 + if (instance.driverKind !== ANTIGRAVITY || !instance.enabled || !instance.refreshModels) {
145 + continue;
146 + }
147 + const config = yield* decodeAntigravitySettings(
148 + entries[instance.instanceId]?.config ?? {},
149 + ).pipe(Effect.option);
150 + if (Option.isNone(config) || config.value.binaryPath) continue;
151 + yield* instance.refreshModels().pipe(Effect.ignore({ log: true }));
152 + yield* providers.refreshInstance(instance.instanceId);
153 + }
154 + });
155 +
156 const start = Effect.fn("ProviderInstallation.start")(function* (input: ProviderSetupInput) {
157 const { installation, driver } = yield* requireInstance(input.instanceId, "install", true);
158 const started = yield* installation.start.pipe(Effect.mapError(failure(input.instanceId)));
159 if (
160 driver === ANTIGRAVITY &&
161 started.operationId !== null &&
142 - accountCheckOperations.get(input.instanceId) !== started.operationId
162 + accountCheckOperation !== started.operationId
163 ) {
144 - accountCheckOperations.set(input.instanceId, started.operationId);
164 + accountCheckOperation = started.operationId;
165 // Installation outlives the request and may finish while every client is disconnected.
166 yield* installation.changes.pipe(
167 Stream.filter(
@@ -152,25 +172,14 @@ const make = Effect.fn("makeProviderInstallation")(function* () {
172 state.phase === "cancelled",
173 ),
174 Stream.runHead,
155 - Effect.flatMap(
156 - Effect.fnUntraced(function* (result) {
157 - if (
158 - Option.isNone(result) ||
159 - result.value.operationId !== started.operationId ||
160 - result.value.phase !== "succeeded"
161 - )
162 - return;
163 - const instance = yield* instances.getInstance(input.instanceId);
164 - if (
165 - instance?.driverKind !== ANTIGRAVITY ||
166 - !instance.enabled ||
167 - !instance.refreshModels
168 - )
169 - return;
170 - yield* instance.refreshModels().pipe(Effect.ignore({ log: true }));
171 - yield* providers.refreshInstance(input.instanceId);
172 - }),
175 + Effect.flatMap((result) =>
176 + Option.isSome(result) &&
177 + result.value.operationId === started.operationId &&
178 + result.value.phase === "succeeded"
179 + ? checkManagedRuntimeInstances(input.instanceId)
180 + : Effect.void,
181 ),
182 + Effect.ignore({ log: true }),
183 Effect.forkIn(scope),
184 );
185 }