From da9d62627a731c4f8234f7db4550909f0c65237d Mon Sep 17 00:00:00 2001 From: Mohammed Al Salhi Date: Tue, 27 Oct 2026 07:02:11 -0500 Subject: [PATCH] fix(provider-cursor): show why Cursor sign-in failed Closes #25926 --- .../provider-cursor/src/server/auth.test.ts | 17 ++++++++++++++++- packages/provider-cursor/src/server/auth.ts | 9 +++++++-- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/packages/provider-cursor/src/server/auth.test.ts b/packages/provider-cursor/src/server/auth.test.ts index 76ff39678a831..28ece5f9606db 100644 --- a/packages/provider-cursor/src/server/auth.test.ts +++ b/packages/provider-cursor/src/server/auth.test.ts @@ -11,7 +11,7 @@ import * as Option from "effect/Option"; import * as Stream from "effect/Stream"; import { makeCursorAuth, type CursorAuthOptions } from "./auth.ts"; -import { InMemoryCredentialStore } from "./sdk.ts"; +import { AuthenticationError, InMemoryCredentialStore } from "./sdk.ts"; const instanceId = ProviderInstanceId.make("cursor-personal"); const owner = "owner-client"; @@ -215,6 +215,21 @@ it.layer(NodeServices.layer)("CursorAuth", (it) => { }).pipe(Effect.scoped), ); + it.effect("shows why the Cursor SDK rejected the sign-in", () => + Effect.gen(function* () { + const sdkMessage = "Login failed or timed out. Please try again."; + const { auth } = yield* makeHarness({ + login: () => + Promise.reject( + new AuthenticationError(sdkMessage, { code: "unauthenticated", isRetryable: true }), + ), + }); + yield* auth.controller.start(owner); + const failed = yield* phase(auth, "failed"); + expect(failed.message).toBe(`Cursor sign-in failed: ${sdkMessage}`); + }).pipe(Effect.scoped), + ); + it.effect("clears only this instance's credential after its sessions stop", () => Effect.gen(function* () { const harness = yield* makeHarness(); diff --git a/packages/provider-cursor/src/server/auth.ts b/packages/provider-cursor/src/server/auth.ts index 0bcd3c0de9034..a7a5652b8cc51 100644 --- a/packages/provider-cursor/src/server/auth.ts +++ b/packages/provider-cursor/src/server/auth.ts @@ -18,7 +18,7 @@ import * as Semaphore from "effect/Semaphore"; import * as Stream from "effect/Stream"; import * as SubscriptionRef from "effect/SubscriptionRef"; -import { Cursor, InMemoryCredentialStore } from "./sdk.ts"; +import { Cursor, CursorSdkError, InMemoryCredentialStore } from "./sdk.ts"; import type { ProviderAuthController } from "@t3tools/provider-core/server/auth"; const AUTH_TIMEOUT_MS = 300_000; @@ -194,7 +194,10 @@ export const makeCursorAuth = Effect.fn("makeCursorAuth")(function* (options: Cu new ProviderSetupError({ instanceId: options.instanceId, operation: "start", - detail: "Cursor sign-in failed. Start sign-in again.", + detail: + cause instanceof CursorSdkError + ? `Cursor sign-in failed: ${cause.message}` + : "Cursor sign-in failed. Start sign-in again.", cause, }), }); @@ -264,6 +267,8 @@ export const makeCursorAuth = Effect.fn("makeCursorAuth")(function* (options: Cu Effect.flatMap((result) => lock.withPermits(1)( Effect.gen(function* () { + if (Exit.isFailure(result)) + yield* Effect.logWarning("Cursor sign-in failed", result.cause); if (active !== flow) return; active = undefined; operation = "idle";