Skip to content

Commit 00c249c

Browse files
fix(server): a signed-out Claude instance's sign-in hint names its config dir
A Claude instance with its own config dir showed "Run `claude auth login`". Running that as written signs in the default dir instead: it replaces the login of the instance that uses the default dir, and this instance stays signed out. The status now reuses the turn-failure message for an instance with its own config dir, so it names CLAUDE_CONFIG_DIR. Instances on the default dir keep the old wording. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
1 parent d5606f2 commit 00c249c

2 files changed

Lines changed: 40 additions & 2 deletions

File tree

‎apps/server/src/provider/ClaudeProvider.ts‎

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,11 @@ import {
3939
type ServerProviderDraft,
4040
} from "@t3tools/provider-core/server/snapshotProbe";
4141
import { resolveClaudeSdkExecutablePath } from "./Drivers/ClaudeExecutable.ts";
42-
import { hasClaudeManagedMcpConfig, makeClaudeEnvironment } from "./Drivers/ClaudeHome.ts";
42+
import {
43+
claudeSignedOutMessage,
44+
hasClaudeManagedMcpConfig,
45+
makeClaudeEnvironment,
46+
} from "./Drivers/ClaudeHome.ts";
4347
import { discoverClaudeSkills, readClaudeSettingsEnv } from "./Drivers/ClaudeSkills.ts";
4448
import type { ProviderWorkspaceSnapshot } from "@t3tools/provider-core/server/driver";
4549
import { makeUnavailableUsageLimits } from "@t3tools/provider-core/server/usageLimits";
@@ -673,6 +677,9 @@ export const checkClaudeProviderStatus = Effect.fn("checkClaudeProviderStatus")(
673677
endpoint.hostname !== "" &&
674678
endpoint.hostname !== "api.anthropic.com";
675679
if (!customApiEndpoint && claudeAuthStatus(capabilities) === "unauthenticated") {
680+
const path = yield* Path.Path;
681+
const configDir = (yield* makeClaudeEnvironment(claudeSettings, resolvedEnvironment))
682+
.CLAUDE_CONFIG_DIR;
676683
return buildServerProvider({
677684
presentation: CLAUDE_PRESENTATION,
678685
enabled: claudeSettings.enabled,
@@ -686,7 +693,10 @@ export const checkClaudeProviderStatus = Effect.fn("checkClaudeProviderStatus")(
686693
version: parsedVersion,
687694
status: "error",
688695
auth: { status: "unauthenticated" },
689-
message: "Claude Code is not authenticated. Run `claude auth login` and try again.",
696+
// A bare `claude auth login` signs in the default config dir, not this instance's.
697+
message: configDir
698+
? claudeSignedOutMessage({ configDir, cwd: path.resolve(cwd ?? ".") })
699+
: "Claude Code is not authenticated. Run `claude auth login` and try again.",
690700
},
691701
});
692702
}

‎apps/server/src/provider/ProviderRegistry.test.ts‎

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3120,6 +3120,34 @@ it.layer(
31203120
);
31213121
assert.strictEqual(status.status, "error");
31223122
assert.strictEqual(status.auth.status, "unauthenticated");
3123+
assert.notInclude(status.message, "CLAUDE_CONFIG_DIR");
3124+
}).pipe(
3125+
Effect.provide(
3126+
layerMockSpawner((args) => {
3127+
const joined = args.join(" ");
3128+
if (joined === "--version") return { stdout: "1.0.0\n", stderr: "", code: 0 };
3129+
throw new Error(`Unexpected args: ${joined}`);
3130+
}),
3131+
),
3132+
),
3133+
);
3134+
3135+
it.effect("names a logged-out instance's own config dir in the sign-in hint", () =>
3136+
Effect.gen(function* () {
3137+
const path = yield* Path.Path;
3138+
const homePath = path.resolve("/synthetic/claude-personal");
3139+
// A bare `claude auth login` signs in the default config dir and replaces that account's login.
3140+
const status = yield* checkClaudeProviderStatus(
3141+
{ ...defaultClaudeSettings, homePath },
3142+
claudeCapabilities({
3143+
tokenSource: "none",
3144+
apiKeySource: "none",
3145+
apiProvider: "firstParty",
3146+
}),
3147+
{ ANTHROPIC_BASE_URL: "" },
3148+
);
3149+
assert.strictEqual(status.auth.status, "unauthenticated");
3150+
assert.include(status.message, `CLAUDE_CONFIG_DIR set to ${JSON.stringify(homePath)}`);
31233151
}).pipe(
31243152
Effect.provide(
31253153
layerMockSpawner((args) => {

0 commit comments

Comments
 (0)