Skip to content

Open-source Grok Bot alternative with a virtual machine that bots can use

Sign-in: an expired reason reads as the expired line; drop narrating comments

milind-soni1c82a0f0c991
diff --git a/src/components/ClaudeSignIn.tsx b/src/components/ClaudeSignIn.tsx
index 93b268fceb..0a2db970f1 100644
--- a/src/components/ClaudeSignIn.tsx
+++ b/src/components/ClaudeSignIn.tsx
@@ -29,7 +29,7 @@ function ended(phase: "expired" | "failed", message?: string): DeviceSignInStatu
}
/** Anthropic's code is long (`code#state`); a short or digits-only one is the login code Claude emails, which belongs on
- * Claude's own page. The server refuses it too. */
+ * Claude's own page. */
export function looksLikeEmailedCode(value: string): boolean {
const code = value.trim();
return code.length > 0 && (code.length < 8 || /^\d{1,8}$/.test(code));
@@ -104,7 +104,6 @@ export function ClaudeSignIn({ instanceId, autoStart = false, onDone, onStart }:
await succeeded();
} catch (cause) {
const message = cause instanceof Error ? cause.message : t("engineSetup.device.failed");
- // The server no longer has this sign-in, as after the Cloud restarted: say so and offer a fresh one.
if (signInInterrupted(cause)) {
setAuth(ended("failed", t("engineSetup.device.interrupted")));
return;
diff --git a/src/components/DeviceSignIn.test.ts b/src/components/DeviceSignIn.test.ts
index 0962d55478..d4d69f6cce 100644
--- a/src/components/DeviceSignIn.test.ts
+++ b/src/components/DeviceSignIn.test.ts
@@ -50,6 +50,8 @@ describe("Codex device sign-in UI", () => {
const html = render({ phase: "failed", flowId: "fixture-flow", authorizationUrl: null, expiresAt: null, reason: "interrupted" });
expect(html).toContain("This sign-in was interrupted. Start again.");
expect(html).not.toContain("could not be completed");
+ expect(render({ phase: "failed", flowId: "fixture-flow", authorizationUrl: null, expiresAt: null, reason: "expired", message: "The ChatGPT sign-in code expired. Start sign-in again for a new code." }))
+ .toContain("This code expired. Request a new code to try again.");
});
it.each([
diff --git a/src/components/DeviceSignIn.tsx b/src/components/DeviceSignIn.tsx
index dd6c29fcc6..9caeb959b7 100644
--- a/src/components/DeviceSignIn.tsx
+++ b/src/components/DeviceSignIn.tsx
@@ -21,7 +21,6 @@ export interface DeviceSignInStatus {
reason?: SignInOutcome;
}
-/** The server's reason code on a status or a refused request, if it sent one. */
export function signInReason(source: unknown): SignInOutcome | null {
if (source instanceof ApiError) return signInOutcome(source.body?.reason);
return source && typeof source === "object" ? signInOutcome((source as { reason?: unknown }).reason) : null;
@@ -100,8 +99,6 @@ function endedFlow(phase: "expired" | "failed", browserPkce = false): DeviceSign
return { phase, flowId: null, authorizationUrl: null, expiresAt: null, ...(phase === "failed" ? { message: t(browserPkce ? "engineSetup.chatgpt.flowEnded" : "engineSetup.device.flowEnded") } : {}) };
}
-/** A flow the server answers for no more: 404/410 when it lost it (as after the Cloud restarted), 401/403 when this
- * browser lost its pairing. */
export function unavailableFlow(cause: unknown, browserPkce = false): DeviceSignInStatus {
return signInInterrupted(cause)
? { phase: "failed", flowId: null, authorizationUrl: null, expiresAt: null, reason: "interrupted", message: t("engineSetup.device.interrupted") }
@@ -133,8 +130,7 @@ export function DeviceSignInProgress({ auth, browserPkce = false, provider = "co
if (auth.phase !== "waiting") {
const label = auth.phase === "succeeded" ? t(copy.connected)
: auth.phase === "cancelled" ? t(browserPkce ? "engineSetup.chatgpt.cancelled" : "engineSetup.device.cancelled")
- : auth.phase === "expired" ? t(browserPkce ? "engineSetup.chatgpt.expired" : "engineSetup.device.expired")
- // The server words an interrupted sign-in with its code alone, so the line is in the person's language.
+ : auth.phase === "expired" || signInReason(auth) === "expired" ? t(browserPkce ? "engineSetup.chatgpt.expired" : "engineSetup.device.expired")
: signInInterrupted(auth) ? t("engineSetup.device.interrupted")
: auth.message || t(browserPkce ? "engineSetup.chatgpt.failed" : copy.failed);
return <p role="status" className={auth.phase === "succeeded" ? "text-[12px] text-success" : "text-[12px] text-ink-secondary"}>{label}</p>;