@devries-cameron20 / t3code Mirror · read-only / commits / c59ab7d92a
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 23, 04:15 UTC

fix(server): slow OpenCode wrappers no longer show as unavailable (#16544)

Joseph Vidal committed Oct 18, 2026 at 15:26 UTC c59ab7d92a7df65f3c4aedbbf983e860ba05585f
2 files changed +27 -4
packages/provider-opencode/src/server/status.test.ts
+25 -3
@@ -3,6 +3,7 @@ import * as NodeAssert from "node:assert/strict";
3 import * as NodeServices from "@effect/platform-node/NodeServices";
4 import { it } from "@effect/vitest";
5 import * as Deferred from "effect/Deferred";
6 +import * as Duration from "effect/Duration";
7 import * as Effect from "effect/Effect";
8 import * as Fiber from "effect/Fiber";
9 import * as FileSystem from "effect/FileSystem";
@@ -160,6 +161,7 @@ const runtimeMock = {
161 state: {
162 runVersionError: null as Error | null,
163 runVersionPending: false,
164 + runVersionDelay: null as Duration.Input | null,
165 versionStdout: DEFAULT_VERSION_STDOUT,
166 inventoryError: null as Error | null,
167 connectionError: null as Error | null,
@@ -179,6 +181,7 @@ const runtimeMock = {
181 reset() {
182 this.state.runVersionError = null;
183 this.state.runVersionPending = false;
184 + this.state.runVersionDelay = null;
185 this.state.versionStdout = DEFAULT_VERSION_STDOUT;
186 this.state.inventoryError = null;
187 this.state.connectionError = null;
@@ -251,7 +254,11 @@ const OpenCodeRuntimeTestDouble: OpenCodeRuntime.OpenCodeRuntime["Service"] = {
254 cause: runtimeMock.state.runVersionError,
255 }),
256 )
254 - : Effect.succeed({ stdout: runtimeMock.state.versionStdout, stderr: "", code: 0 }),
257 + : runtimeMock.state.runVersionDelay
258 + ? Effect.succeed({ stdout: runtimeMock.state.versionStdout, stderr: "", code: 0 }).pipe(
259 + Effect.delay(runtimeMock.state.runVersionDelay),
260 + )
261 + : Effect.succeed({ stdout: runtimeMock.state.versionStdout, stderr: "", code: 0 }),
262 createOpenCodeSdkClient: (input) => {
263 runtimeMock.state.sdkClientInputs.push(input);
264 return {} as unknown as ReturnType<
@@ -379,18 +386,33 @@ it.layer(layerTest)("checkOpenCodeProviderStatus", (it) => {
386 const probeFiber = yield* checkProvider(makeOpenCodeSettings()).pipe(Effect.forkChild);
387
388 yield* Effect.yieldNow;
382 - yield* TestClock.adjust("4 seconds");
389 + yield* TestClock.adjust("10 seconds");
390 const snapshot = yield* Fiber.join(probeFiber);
391
392 NodeAssert.equal(snapshot.status, "error");
393 NodeAssert.equal(snapshot.installed, true);
394 NodeAssert.equal(
395 snapshot.message,
389 - "Failed to execute OpenCode CLI health check: OpenCode CLI version probe timed out after 4 seconds.",
396 + "Failed to execute OpenCode CLI health check: OpenCode CLI version probe timed out after 10 seconds.",
397 );
398 }).pipe(Effect.provide(TestClock.layer())),
399 );
400
401 + it.effect("waits for a slow but healthy local CLI version probe", () =>
402 + Effect.gen(function* () {
403 + runtimeMock.state.runVersionDelay = "6 seconds";
404 + const probeFiber = yield* checkProvider(makeOpenCodeSettings()).pipe(Effect.forkChild);
405 +
406 + yield* Effect.yieldNow;
407 + yield* TestClock.adjust("6 seconds");
408 + const snapshot = yield* Fiber.join(probeFiber);
409 +
410 + NodeAssert.notEqual(snapshot.status, "error");
411 + NodeAssert.equal(snapshot.installed, true);
412 + NodeAssert.equal(snapshot.version, "1.14.19");
413 + }).pipe(Effect.provide(TestClock.layer())),
414 + );
415 +
416 it.effect("emits OpenCode variant defaults so trait picker can resolve a visible selection", () =>
417 Effect.gen(function* () {
418 runtimeMock.state.inventory = {
packages/provider-opencode/src/server/versionProbe.ts
+2 -1
@@ -16,7 +16,8 @@ export interface ProbedOpenCode {
16 readonly version: string;
17 }
18
19 -const OPENCODE_VERSION_PROBE_TIMEOUT = "4 seconds";
19 +// Meant to stop a hung `--version`; wrapped installs can take several seconds to start cold.
20 +const OPENCODE_VERSION_PROBE_TIMEOUT = "10 seconds";
21 const OPENCODE_SERVER_PROBE_TIMEOUT = "5 seconds";
22 // 2.x's own CLI decodes `{version, pid}` from `/api/info`; requiring both keeps unrelated JSON out.
23 const decodeApiInfo = Schema.decodeUnknownOption(