GeezerVison is showing github.com — fix(server): Claude status starts the capabilities probe alongside claude --version by juliusmarminge · Pull Request #40192 · pingdotgg/t3code
fix(server): Claude status starts the capabilities probe alongside claude --version
#40192
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and
privacy statement . We’ll occasionally send you account related emails.
Already on GitHub?
Sign in
to your account
Show file tree
Hide file tree
Changes from all commits
Commits
File filter
Filter by extension
.ts
(3)
All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Hide whitespace
Diff view
Hide whitespace
There are no files selected for viewing
Original file line number
Diff line number
Diff line change
Expand Up
@@ -14,11 +14,13 @@ import * as Cause from "effect/Cause";
import * as DateTime from "effect/DateTime";
import * as Effect from "effect/Effect";
import * as FileSystem from "effect/FileSystem";
import * as Fiber from "effect/Fiber";
import * as Option from "effect/Option";
import * as Path from "effect/Path";
import * as Ref from "effect/Ref";
import * as Result from "effect/Result";
import * as Schema from "effect/Schema";
import * as Scope from "effect/Scope";
import { ChildProcess, ChildProcessSpawner } from "effect/process";
import { createModelCapabilities } from "@t3tools/shared/model";
import { envTrampoline, supportsEnvChdir } from "@t3tools/shared/envTrampoline";
Expand Down
Expand Up
@@ -678,7 +680,7 @@ export const checkClaudeProviderStatus = Effect.fn("checkClaudeProviderStatus")(
): Effect.fn.Return<
ServerProviderDraft,
never,
ChildProcessSpawner.ChildProcessSpawner | FileSystem.FileSystem | Path.Path
ChildProcessSpawner.ChildProcessSpawner | FileSystem.FileSystem | Path.Path | Scope.Scope
> {
const resolvedEnvironment = environment ?? process.env;
const checkedAt = DateTime.formatIso(yield* DateTime.now);
Expand All
@@ -703,6 +705,11 @@ export const checkClaudeProviderStatus = Effect.fn("checkClaudeProviderStatus")(
});
}
// Started alongside `--version`; the scope interrupts it on the early returns below.
const probeFiber = resolveCapabilities
? yield* resolveCapabilities(claudeSettings).pipe(Effect.result, Effect.forkScoped)
: undefined;
const versionProbe = yield* runClaudeCommand(
claudeSettings,
["--version"],
Expand Down
Expand Up
@@ -780,9 +787,7 @@ export const checkClaudeProviderStatus = Effect.fn("checkClaudeProviderStatus")(
const updateRequiredModels = resolveClaudeUpdateRequiredModels(modelCatalog, parsedVersion);
const versionUpgradeMessage = formatClaudeVersionUpgradeMessage(modelCatalog, parsedVersion);
const probeResult = resolveCapabilities
? yield* resolveCapabilities(claudeSettings).pipe(Effect.result)
: undefined;
const probeResult = probeFiber ? yield* Fiber.join(probeFiber) : undefined;
const capabilities =
probeResult && Result.isSuccess(probeResult) ? probeResult.success : undefined;
const probeFailure =
Expand Down
Expand Up
@@ -908,7 +913,7 @@ export const checkClaudeProviderStatus = Effect.fn("checkClaudeProviderStatus")(
usageLimits: resetCredits ? { ...usageLimits, resetCredits } : usageLimits,
},
});
});
}, Effect.scoped );
const nowIso = Effect.map(DateTime.now, DateTime.formatIso);
Expand Down
Original file line number
Diff line number
Diff line change
Expand Up
@@ -297,7 +297,7 @@ export const ClaudeDriver: ProviderDriver<ClaudeSettings, ClaudeDriverEnv, Path.
Effect.map(stampIdentity),
),
),
// Disabled, failed version checks and interruption never reach the probe .
// Disabled checks never reach the probe; failed version checks and interruption stop it early .
Effect.ensuring(modelRoutes.settle),
Effect.provideService(ChildProcessSpawner.ChildProcessSpawner, spawner),
Effect.provideService(FileSystem.FileSystem, fileSystem),
Expand Down
Original file line number
Diff line number
Diff line change
Expand Up
@@ -4545,6 +4545,52 @@ it.layer(
),
);
it.effect("starts the capabilities probe without waiting for `claude --version` (#40141)", () =>
Effect.gen(function* () {
const probeStarted = yield* Deferred.make<void>();
// `--version` exits only once the capabilities probe has started.
const spawner = Layer.succeed(
ChildProcessSpawner.ChildProcessSpawner,
ChildProcessSpawner.make((command) => {
const joined = (command as unknown as { args: ReadonlyArray<string> }).args.join(" ");
if (joined !== "--version") return Effect.die(`Unexpected args: ${joined}`);
return Effect.succeed(
ChildProcessSpawner.makeHandle({
pid: ChildProcessSpawner.ProcessId(1),
exitCode: Deferred.await(probeStarted).pipe(
Effect.as(ChildProcessSpawner.ExitCode(0)),
),
isRunning: Effect.succeed(true),
kill: () => Effect.void,
unref: Effect.succeed(Effect.void),
stdin: Sink.drain,
stdout: Stream.fromEffect(
Deferred.await(probeStarted).pipe(Effect.as(encoder.encode("2.1.0\n"))),
),
stderr: Stream.empty,
all: Stream.empty,
getInputFd: () => Sink.drain,
getOutputFd: () => Stream.empty,
}),
);
}),
);
const check = yield* checkClaudeProviderStatus(
defaultClaudeSettings,
() =>
Deferred.succeed(probeStarted, undefined).pipe(
Effect.andThen(claudeCapabilities({ subscriptionType: "max" })()),
),
{ ANTHROPIC_BASE_URL: "" },
).pipe(Effect.provide(spawner), Effect.forkChild);
yield* TestClock.adjust("1 minute");
const status = yield* Fiber.join(check);
assert.strictEqual(status.version, "2.1.0");
assert.strictEqual(status.status, "ready");
}),
);
it.effect.each([
{
name: "its own home path",
Expand Down
Loading
Oops, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.