The best way to control Claude Code, Codex and more from any computer or phone
fix(cursor): ignore a stale Keychain login when Cursor is not installed (#27143)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: maria-rcks <maria@kuuro.net>
Riccardo Palleschi committed
Nov 1, 2026 at 03:35 UTC
22ee8a43e57bdae2b72d2b61826f4d7f17d4baa5
2 files changed
+34
-4
apps/server/src/usage/UsageService.test.ts
+31
@@ -1462,6 +1462,37 @@ describe("UsageService", () => {
1462
}).pipe(Effect.scoped),
1463
);
1464
1465
+ it.effect("ignores a stale macOS Keychain login when Cursor is not installed", () =>
1466
+ Effect.gen(function* () {
1467
+ const { settings, home } = yield* setup;
1468
+ const cursor = makeFakeCursor();
1469
+ cursor.state.error = "Sign in to Cursor again to read account usage.";
1470
+ const readCursorSource = Effect.gen(function* () {
1471
+ const service = yield* makeWithCursor(cursor.read);
1472
+ const summary = yield* service.readSummary({ ...WINDOW, awaitRefresh: true });
1473
+ return cursorSource(summary);
1474
+ }).pipe(
1475
+ Effect.provide(
1476
+ layerService({
1477
+ prefix: "usage-service-cursor-keychain-uninstalled",
1478
+ home,
1479
+ settings: { ...settings, cursorKeychainUsageEnabled: true },
1480
+ platform: "darwin",
1481
+ environment: {},
1482
+ }),
1483
+ ),
1484
+ );
1485
+
1486
+ assert.isUndefined(yield* readCursorSource);
1487
+ assert.lengthOf(cursor.state.calls, 0);
1488
+
1489
+ yield* Effect.promise(() => NodeFSP.mkdir(NodePath.join(home, ".cursor")));
1490
+ const installed = yield* readCursorSource;
1491
+ assert.strictEqual(installed?.message, "Sign in to Cursor again to read account usage.");
1492
+ assert.lengthOf(cursor.state.calls, 1);
1493
+ }).pipe(Effect.scoped),
1494
+ );
1495
+
1496
it.live("ignores stale Cursor file logins when the active credential store differs", () =>
1497
Effect.gen(function* () {
1498
const { settings, home } = yield* setup;
packages/provider-cursor/src/server/CursorUsageAccounts.ts
+3
-4
@@ -186,10 +186,9 @@ const make = Effect.gen(function* () {
186
retentionStartMs: number,
187
awaitRefresh: boolean,
188
) {
189
- if (
190
- typeof credential === "string" &&
191
- !(yield* fileSystem.exists(credential).pipe(Effect.orElseSucceed(() => true)))
192
- ) {
189
+ // A Keychain login outlives an uninstalled Cursor, so it also needs Cursor's local directory.
190
+ const localLogin = typeof credential === "string" ? credential : path.dirname(authPath);
191
+ if (!(yield* fileSystem.exists(localLogin).pipe(Effect.orElseSucceed(() => true)))) {
192
return null;
193
}
194
yield* ensureLoaded;