@devries-cameron20 / t3code-1 / commits / 8198b2ed5e
Fork 0

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

fix(kiro): slow kiro-cli starts no longer show Kiro as unavailable (#29841)

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

Alex Southwell committed Nov 3, 2026 at 23:36 UTC 8198b2ed5e1286afa46b26e65290d31977555dce
2 files changed +44 -5
apps/server/src/provider/KiroProvider.test.ts
+42 -3
@@ -3,13 +3,16 @@ import * as NodeServices from "@effect/platform-node/NodeServices";
3 import { assert, describe, it } from "@effect/vitest";
4 import { KiroSettings } from "@t3tools/provider-kiro/settings";
5 import * as Deferred from "effect/Deferred";
6 +import type * as Duration from "effect/Duration";
7 import * as Effect from "effect/Effect";
8 +import * as Fiber from "effect/Fiber";
9 import * as Layer from "effect/Layer";
10 import * as Queue from "effect/Queue";
11 import * as Schema from "effect/Schema";
12 import * as Sink from "effect/Sink";
13 import * as Stream from "effect/Stream";
14 import { ChildProcess, ChildProcessSpawner } from "effect/process";
15 +import * as TestClock from "effect/testing/TestClock";
16
17 import {
18 checkKiroProviderStatus,
@@ -23,18 +26,25 @@ const settings = Schema.decodeSync(KiroSettings)({ enabled: true });
26 interface CliOutput {
27 readonly stdout: string;
28 readonly code: number;
29 + /** Holds stdout and the exit back this long, like a CLI slow to answer. */
30 + readonly delay?: Duration.Input;
31 }
32
33 function processHandle(output: CliOutput) {
34 + const answered = Effect.sleep(output.delay ?? 0);
35 return ChildProcessSpawner.makeHandle({
36 pid: ChildProcessSpawner.ProcessId(900_000_002),
31 - exitCode: Effect.succeed(ChildProcessSpawner.ExitCode(output.code)),
37 + exitCode: Effect.as(answered, ChildProcessSpawner.ExitCode(output.code)),
38 isRunning: Effect.succeed(false),
39 kill: () => Effect.void,
40 unref: Effect.succeed(Effect.void),
41 stdin: Sink.drain,
36 - stdout:
37 - output.stdout.length === 0 ? Stream.empty : Stream.succeed(encoder.encode(output.stdout)),
42 + stdout: Stream.unwrap(
43 + Effect.as(
44 + answered,
45 + output.stdout.length === 0 ? Stream.empty : Stream.succeed(encoder.encode(output.stdout)),
46 + ),
47 + ),
48 stderr: Stream.empty,
49 all: Stream.empty,
50 getInputFd: () => Sink.drain,
@@ -123,6 +133,35 @@ const check = (
133 }).pipe(Effect.provide(Layer.mergeAll(NodeServices.layer, NodeCrypto.layer)));
134
135 describe("KiroProvider", () => {
136 + it.effect.each([
137 + {
138 + label: "answers after 6 s",
139 + delay: "6 seconds",
140 + status: "ready",
141 + version: "2.27.0",
142 + message: undefined,
143 + },
144 + {
145 + label: "never answers",
146 + delay: "Infinity",
147 + status: "error",
148 + version: null,
149 + message: "Failed to run `kiro-cli --version`.",
150 + },
151 + ] as const)("gives `kiro-cli --version` 10 s when it $label", (row) =>
152 + Effect.gen(function* () {
153 + const fiber = yield* check({
154 + "--version": { stdout: "kiro-cli 2.27.0\n", code: 0, delay: row.delay },
155 + "whoami --format json": { stdout: '{"accountType":"ApiKey","email":null}\n', code: 0 },
156 + }).pipe(Effect.forkChild);
157 + yield* TestClock.adjust("10 seconds");
158 + const { snapshot } = yield* Fiber.join(fiber);
159 + assert.equal(snapshot.status, row.status);
160 + assert.equal(snapshot.version, row.version);
161 + assert.equal(snapshot.message, row.message);
162 + }),
163 + );
164 +
165 it.effect("reports a CLI whose version probe exits nonzero as failing to run", () =>
166 Effect.gen(function* () {
167 const { snapshot, invoked } = yield* check({
packages/provider-kiro/src/server/status.ts
+2 -2
@@ -26,7 +26,6 @@ import {
26 AUTH_PROBE_TIMEOUT_MS,
27 buildServerProvider,
28 COMPACT_SLASH_COMMAND,
29 - DEFAULT_TIMEOUT_MS,
29 isCommandMissingCause,
30 parseGenericCliVersion,
31 buildSelectOptionDescriptor,
@@ -54,6 +53,7 @@ const KIRO_BUILT_IN_MODELS: ReadonlyArray<ServerProviderModel> = [
53 },
54 ];
55 const KIRO_API_KEY_ENV = "KIRO_API_KEY";
56 +const VERSION_PROBE_TIMEOUT_MS = 10_000;
57
58 /**
59 * The agent picker is not a model trait, but the composer reads options per
@@ -374,7 +374,7 @@ export const checkKiroProviderStatus = Effect.fn("checkKiroProviderStatus")(func
374 }
375
376 const versionResult = yield* runKiroCli(settings, ["--version"], environment).pipe(
377 - Effect.timeoutOption(DEFAULT_TIMEOUT_MS),
377 + Effect.timeoutOption(VERSION_PROBE_TIMEOUT_MS),
378 Effect.result,
379 );
380 if (Result.isFailure(versionResult) || Option.isNone(versionResult.success)) {