@devries-cameron20 / t3code-1 / commits / 9d2634e9bd
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

fix(desktop): read the Chrome cookie key off the main thread on macOS (#23157)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: maria-rcks <maria@kuuro.net>

Victor Vogel committed Oct 31, 2026 at 21:25 UTC 9d2634e9bdbe7d8708e6644b16ba333eb02ed3a2
2 files changed +21 -8
apps/desktop/src/preview/BrowserImport/ChromiumKeys.test.ts
+18 -5
@@ -19,10 +19,17 @@ import {
19 import { LinuxBrowserSecretPath } from "./LinuxBrowserSecret.ts";
20 import { BROWSER_IMPORT_SOURCES } from "./Sources.ts";
21
22 -const { getPassword } = vi.hoisted(() => ({ getPassword: vi.fn<() => string | null>() }));
22 +const { getPassword } = vi.hoisted(() => ({
23 + getPassword: vi.fn<() => Promise<string | undefined>>(),
24 +}));
25
26 vi.mock("@napi-rs/keyring", () => ({
27 Entry: class {
28 + getPassword() {
29 + throw new Error("synchronous keychain read");
30 + }
31 + },
32 + AsyncEntry: class {
33 getPassword = getPassword;
34 },
35 }));
@@ -91,18 +98,24 @@ describe("macOS Chromium secrets", () => {
98
99 it.effect("derives the cookie key from the keychain secret", () =>
100 Effect.gen(function* () {
94 - getPassword.mockReturnValue("macos-secret");
101 + getPassword.mockResolvedValue("macos-secret");
102 const keys = yield* resolveChromiumKeys(request);
103 expect(keys.cbcV10?.toString("hex")).toBe("3df7306fb1eac353289565a2f6b64f74");
104 }).pipe(Effect.provide(layerNoProcesses)),
105 );
106
107 + it.effect("reports a keychain entry the async read resolves as undefined", () =>
108 + Effect.gen(function* () {
109 + getPassword.mockResolvedValue(undefined);
110 + const error = yield* resolveChromiumKeys(request).pipe(Effect.flip);
111 + expect(error.reason).toBe("keychainItemMissing");
112 + }).pipe(Effect.provide(layerNoProcesses)),
113 + );
114 +
115 it.effect("preserves a denied keychain approval", () =>
116 Effect.gen(function* () {
117 const denied = new Error("User denied access");
103 - getPassword.mockImplementation(() => {
104 - throw denied;
105 - });
118 + getPassword.mockRejectedValue(denied);
119 const error = yield* resolveChromiumKeys(request).pipe(Effect.flip);
120 expect(error.reason).toBe("needsKeychainApproval");
121 expect(error.cause).toBe(denied);
apps/desktop/src/preview/BrowserImport/ChromiumKeys.ts
+3 -3
@@ -59,8 +59,8 @@ const readKeychainSecret = Effect.fn("ChromiumKeys.readKeychainSecret")(function
59 try: () => import("@napi-rs/keyring"),
60 catch: (cause) => new ChromiumKeyError({ reason: "keychainUnavailable", cause }),
61 });
62 - const secret = yield* Effect.try({
63 - try: () => new Keyring.Entry(service, account).getPassword(),
62 + const secret = yield* Effect.tryPromise({
63 + try: () => new Keyring.AsyncEntry(service, account).getPassword(),
64 catch: (cause) => {
65 const message = String((cause as { message?: unknown } | undefined)?.message ?? "");
66 const missing = /no (matching )?entry|not found/i.test(message);
@@ -70,7 +70,7 @@ const readKeychainSecret = Effect.fn("ChromiumKeys.readKeychainSecret")(function
70 });
71 },
72 });
73 - if (secret === null || secret === "") {
73 + if (!secret) {
74 return yield* new ChromiumKeyError({ reason: "keychainItemMissing" });
75 }
76 return secret;