Skip to content

Commit 8ae1ee3

Browse files
fix(server): Codex sign-in hint names the instance's CODEX_HOME
An existing-CLI Codex instance with its own CODEX_HOME got the bare `codex login` hint, which signs in the default ~/.codex instead. Fixes #34988 AI-assisted; verified with the tests and tools listed above.
1 parent 2b6d0d7 commit 8ae1ee3

1 file changed

Lines changed: 15 additions & 3 deletions

File tree

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

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -760,7 +760,12 @@ const makePendingCodexProvider = Effect.fn("CodexProvider.makePendingCodexProvid
760760
});
761761
});
762762

763-
function accountProbeStatus({ account, rateLimits }: CodexAppServerProviderSnapshot): {
763+
const quotePath = Schema.encodeSync(Schema.fromJsonString(Schema.String));
764+
765+
function accountProbeStatus(
766+
{ account, rateLimits }: CodexAppServerProviderSnapshot,
767+
codexHome: string | undefined,
768+
): {
764769
readonly status: Exclude<ServerProviderState, "disabled">;
765770
readonly auth: ServerProvider["auth"];
766771
readonly message?: string;
@@ -788,7 +793,9 @@ function accountProbeStatus({ account, rateLimits }: CodexAppServerProviderSnaps
788793
return {
789794
status: "error",
790795
auth: { status: "unauthenticated" },
791-
message: "Codex CLI is not authenticated. Run `codex login` and try again.",
796+
message: codexHome
797+
? `Codex CLI is not authenticated. Run \`codex login\` with CODEX_HOME set to ${quotePath(codexHome)} and try again.`
798+
: "Codex CLI is not authenticated. Run `codex login` and try again.",
792799
};
793800
}
794801

@@ -903,7 +910,12 @@ export const checkCodexProviderStatus = Effect.fn("checkCodexProviderStatus")(fu
903910
const snapshot = probeResult.success.value;
904911
const accountStatus = managedAuth
905912
? { status: "ready" as const, auth: managedAuth, message: undefined }
906-
: accountProbeStatus(snapshot);
913+
: accountProbeStatus(
914+
snapshot,
915+
codexSettings.homePath
916+
? expandHomePath(codexSettings.homePath, yield* HostProcess.HomeDirectory)
917+
: undefined,
918+
);
907919
// Sign-in guidance still applies when Codex itself says it needs an OpenAI login.
908920
const usageLimits =
909921
!snapshot.nativeUsage && !accountStatus.message

0 commit comments

Comments
 (0)