The best way to control Claude Code, Codex and more from any computer or phone
fix(server): allow more time for Pi model discovery (#15529)
Co-authored-by: Julius Marminge <julius0216@outlook.com>
Marcus committed
Oct 20, 2026 at 02:28 UTC
cbcd0fd80cd814838d893c00405b666eeadb5e15
3 files changed
+51
-8
packages/provider-pi/src/server/driver.test.ts
+1
-1
@@ -256,7 +256,7 @@ it.layer(layerTest)("PiDriver workspace discovery", (it) => {
256
);
257
const probe = yield* instance.snapshotForCwd!("/pending").pipe(Effect.flip, Effect.forkChild);
258
yield* Deferred.await(pendingCommand);
259
- yield* TestClock.adjust("15 seconds");
259
+ yield* TestClock.adjust("30 seconds");
260
const error = yield* Fiber.join(probe);
261
assert.equal(error._tag, "ProviderDriverError");
262
assert.include(error.detail, "workspace commands");
packages/provider-pi/src/server/status.test.ts
+49
-6
@@ -1,13 +1,17 @@
1
import * as NodeServices from "@effect/platform-node/NodeServices";
2
import { assert, describe, it } from "@effect/vitest";
3
import * as Cause from "effect/Cause";
4
+import * as Deferred from "effect/Deferred";
5
+import * as Duration from "effect/Duration";
6
import * as Effect from "effect/Effect";
7
+import * as Fiber from "effect/Fiber";
8
import * as Queue from "effect/Queue";
9
import * as Schema from "effect/Schema";
10
import * as Sink from "effect/Sink";
11
import * as Stream from "effect/Stream";
12
import * as ChildProcess from "effect/process/ChildProcess";
13
import * as ChildProcessSpawner from "effect/process/ChildProcessSpawner";
14
+import * as TestClock from "effect/testing/TestClock";
15
16
import { checkPiProviderStatus, MINIMUM_PI_VERSION } from "./status.ts";
17
@@ -52,7 +56,13 @@ function piProbeSpawner(version: string) {
56
});
57
}
58
55
-const piDiscoverySpawner = (inventory: unknown) =>
59
+const piDiscoverySpawner = (
60
+ inventory: unknown,
61
+ slowStartup?: {
62
+ readonly delay: Duration.Input;
63
+ readonly getStateReceived: Deferred.Deferred<void>;
64
+ },
65
+) =>
66
Effect.gen(function* () {
67
const stdout = yield* Queue.unbounded<Uint8Array, Cause.Done>();
68
let stdinBuffer = "";
@@ -66,6 +76,10 @@ const piDiscoverySpawner = (inventory: unknown) =>
76
stdinBuffer = stdinBuffer.slice(newline + 1);
77
if (line.length === 0) continue;
78
const request = decodeRpcRequest(line);
79
+ if (request.type === "get_state" && slowStartup !== undefined) {
80
+ yield* Deferred.succeed(slowStartup.getStateReceived, undefined);
81
+ yield* Effect.sleep(slowStartup.delay);
82
+ }
83
const data =
84
request.type === "get_available_models"
85
? inventory
@@ -131,14 +145,20 @@ describe("PiProvider", () => {
145
}).pipe(Effect.provide(NodeServices.layer)),
146
);
147
134
- it.effect("reports only the models returned by successful Pi discovery", () =>
148
+ it.effect("reports discovered models when Pi startup takes 20 seconds", () =>
149
Effect.gen(function* () {
136
- const spawner = yield* piDiscoverySpawner({
137
- models: [{ provider: "anthropic", id: "claude-sonnet-4" }],
138
- });
139
- const snapshot = yield* checkPiProviderStatus(settings).pipe(
150
+ const getStateReceived = yield* Deferred.make<void>();
151
+ const spawner = yield* piDiscoverySpawner(
152
+ { models: [{ provider: "anthropic", id: "claude-sonnet-4" }] },
153
+ { delay: "20 seconds", getStateReceived },
154
+ );
155
+ const probe = yield* checkPiProviderStatus(settings).pipe(
156
Effect.provideService(ChildProcessSpawner.ChildProcessSpawner, spawner),
157
+ Effect.forkChild,
158
);
159
+ yield* Deferred.await(getStateReceived);
160
+ yield* TestClock.adjust("20 seconds");
161
+ const snapshot = yield* Fiber.join(probe);
162
assert.equal(snapshot.status, "ready");
163
assert.equal(snapshot.auth.status, "authenticated");
164
assert.deepEqual(
@@ -149,6 +169,29 @@ describe("PiProvider", () => {
169
}).pipe(Effect.provide(NodeServices.layer)),
170
);
171
172
+ it.effect("keeps compatible Pi selectable when startup outlasts the discovery deadline", () =>
173
+ Effect.gen(function* () {
174
+ const getStateReceived = yield* Deferred.make<void>();
175
+ const spawner = yield* piDiscoverySpawner(
176
+ { models: [{ provider: "anthropic", id: "claude-sonnet-4" }] },
177
+ { delay: "1 hour", getStateReceived },
178
+ );
179
+ const probe = yield* checkPiProviderStatus(settings).pipe(
180
+ Effect.provideService(ChildProcessSpawner.ChildProcessSpawner, spawner),
181
+ Effect.forkChild,
182
+ );
183
+ yield* Deferred.await(getStateReceived);
184
+ yield* TestClock.adjust("30 seconds");
185
+ const snapshot = yield* Fiber.join(probe);
186
+ assert.equal(snapshot.status, "ready");
187
+ assert.equal(snapshot.auth.status, "unknown");
188
+ assert.deepEqual(
189
+ snapshot.models.map((model) => model.slug),
190
+ ["default"],
191
+ );
192
+ }).pipe(Effect.provide(NodeServices.layer)),
193
+ );
194
+
195
it.effect("reports a known unauthenticated inventory when Pi returns no usable models", () =>
196
Effect.gen(function* () {
197
const spawner = yield* piDiscoverySpawner({ models: [] });
packages/provider-pi/src/server/status.ts
+1
-1
@@ -57,7 +57,7 @@ const PI_PRESENTATION = {
57
} as const;
58
59
const VERSION_PROBE_TIMEOUT_MS = 4_000;
60
-const PI_RPC_DISCOVERY_TIMEOUT_MS = 15_000;
60
+const PI_RPC_DISCOVERY_TIMEOUT_MS = 30_000;
61
/**
62
* get_entries arrived in 0.80.3 and agent_settled landed in source at 0.80.4.
63
* Version 0.80.5 was the first published package containing both hooks.