@devries-cameron20 / t3code-1 / commits / bbdc13640c
Fork 0

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

feat(desktop): import cookies from Zen Browser (#22970)

Utkarsh Patil committed Oct 25, 2026 at 19:32 UTC bbdc13640cfb48db0d07f0bfb9e8c5655d64281d
4 files changed +256 -6
apps/desktop/src/preview/BrowserImport/Sources.test.ts
+231
@@ -318,6 +318,237 @@ describe("cookieDatabaseCandidatePaths", () => {
318
319 const firefox = BROWSER_IMPORT_SOURCES.find((source) => source.id === "firefox")!;
320
321 +const zen = BROWSER_IMPORT_SOURCES.find((source) => source.id === "zen")!;
322 +
323 +describe("Zen", () => {
324 + it.effect("resolves Zen's native user-data roots on every supported platform", () =>
325 + run(
326 + Effect.gen(function* () {
327 + const darwinContext = yield* sourcePathContext.pipe(
328 + Effect.provideService(HostProcess.Environment, { HOME: "/Users/zen-user" }),
329 + Effect.provideService(HostProcess.Platform, "darwin"),
330 + );
331 + const windowsContext = yield* sourcePathContext.pipe(
332 + Effect.provideService(HostProcess.Environment, {
333 + HOME: "C:\\Users\\zen-user",
334 + APPDATA: "C:\\Users\\zen-user\\AppData\\Roaming",
335 + }),
336 + Effect.provideService(HostProcess.Platform, "win32"),
337 + );
338 + const linuxContext = yield* sourcePathContext.pipe(
339 + Effect.provideService(HostProcess.Environment, { HOME: "/home/zen-user" }),
340 + Effect.provideService(HostProcess.Platform, "linux"),
341 + );
342 +
343 + assert.equal(zen.name, "Zen");
344 + assert.equal(zen.engine, "firefox");
345 + assert.deepEqual([...zen.platforms], ["darwin", "win32", "linux"]);
346 + assert.equal(
347 + zen.userDataDirectory(darwinContext),
348 + darwinContext.path.join("/Users/zen-user", "Library", "Application Support", "zen"),
349 + );
350 + assert.equal(
351 + zen.userDataDirectory(windowsContext),
352 + windowsContext.path.join("C:\\Users\\zen-user\\AppData\\Roaming", "zen"),
353 + );
354 + assert.equal(
355 + zen.userDataDirectory(linuxContext),
356 + linuxContext.path.join("/home/zen-user", ".config", "zen"),
357 + );
358 + assert.deepEqual(zen.alternateLinuxRoots?.(linuxContext), [
359 + linuxContext.path.join("/home/zen-user", ".zen"),
360 + linuxContext.path.join("/home/zen-user", ".var", "app", "app.zen_browser.zen", "zen"),
361 + ]);
362 + }),
363 + ),
364 + );
365 +
366 + it.effect("discovers Zen profiles through its Firefox-compatible metadata", () =>
367 + run(
368 + Effect.gen(function* () {
369 + const fileSystem = yield* FileSystem.FileSystem;
370 + const home = yield* fileSystem.makeTempDirectoryScoped({ prefix: "t3code-zen-" });
371 + const context = yield* sourcePathContext.pipe(
372 + Effect.provideService(HostProcess.Environment, { HOME: home }),
373 + Effect.provideService(HostProcess.Platform, "darwin"),
374 + );
375 + const root = zen.userDataDirectory(context)!;
376 + yield* fileSystem.makeDirectory(root, { recursive: true });
377 + const profile = context.path.join(root, "Profiles", "zen.default");
378 + yield* fileSystem.makeDirectory(profile, { recursive: true });
379 + yield* writeFirefoxCookieDatabase(context.path.join(profile, "cookies.sqlite"), 2, 1);
380 + yield* fileSystem.makeDirectory(context.path.join(root, "Profiles", "empty.default"), {
381 + recursive: true,
382 + });
383 + yield* fileSystem.writeFileString(
384 + context.path.join(root, "profiles.ini"),
385 + [
386 + "[Profile0]",
387 + "Name=Zen",
388 + "IsRelative=1",
389 + "Path=Profiles/zen.default",
390 + "ZenAvatarPath=chrome://browser/content/zen-avatars/avatar-55.svg",
391 + "Default=1",
392 + "",
393 + "[Profile1]",
394 + "Name=Empty",
395 + "IsRelative=1",
396 + "Path=Profiles/empty.default",
397 + "",
398 + ].join("\n"),
399 + );
400 +
401 + assert.deepEqual(yield* listSourceProfiles(zen, context), [
402 + {
403 + directory: context.path.join("Profiles", "zen.default"),
404 + name: "Zen",
405 + cookieCount: 2,
406 + },
407 + ]);
408 + assert.isTrue(yield* isSourceInstalled(zen, context));
409 + assert.isFalse(yield* isSourceRunning(zen, context));
410 + assert.equal(
411 + yield* resolveCookieDatabase(zen, context, context.path.join("Profiles", "zen.default")),
412 + context.path.join(profile, "cookies.sqlite"),
413 + );
414 + }),
415 + ),
416 + );
417 +
418 + it.effect("discovers Zen profiles in both current and legacy Linux roots", () =>
419 + run(
420 + Effect.gen(function* () {
421 + const fileSystem = yield* FileSystem.FileSystem;
422 + const home = yield* fileSystem.makeTempDirectoryScoped({ prefix: "t3code-zen-linux-" });
423 + const context = yield* sourcePathContext.pipe(
424 + Effect.provideService(HostProcess.Environment, { HOME: home }),
425 + Effect.provideService(HostProcess.Platform, "linux"),
426 + );
427 + const currentRoot = context.path.join(home, ".config", "zen");
428 + const legacyRoot = context.path.join(home, ".zen");
429 + const currentProfile = context.path.join(currentRoot, "current.default");
430 + const legacyProfile = context.path.join(legacyRoot, "legacy.default");
431 +
432 + for (const [root, profile, name] of [
433 + [currentRoot, currentProfile, "Current"],
434 + [legacyRoot, legacyProfile, "Legacy"],
435 + ] as const) {
436 + yield* fileSystem.makeDirectory(profile, { recursive: true });
437 + yield* writeFirefoxCookieDatabase(context.path.join(profile, "cookies.sqlite"), 1, 0);
438 + yield* fileSystem.writeFileString(
439 + context.path.join(root, "profiles.ini"),
440 + [
441 + "[Profile0]",
442 + `Name=${name}`,
443 + "IsRelative=1",
444 + `Path=${context.path.basename(profile)}`,
445 + ].join("\n"),
446 + );
447 + }
448 +
449 + assert.deepEqual(yield* listSourceProfiles(zen, context), [
450 + { directory: "current.default", name: "Current", cookieCount: 1 },
451 + { directory: legacyProfile, name: "Legacy", cookieCount: 1 },
452 + ]);
453 + assert.isTrue(yield* isSourceInstalled(zen, context));
454 + assert.equal(
455 + yield* resolveCookieDatabase(zen, context, legacyProfile),
456 + context.path.join(legacyProfile, "cookies.sqlite"),
457 + );
458 +
459 + yield* fileSystem.writeFileString(
460 + context.path.join(currentRoot, "profiles.ini"),
461 + `[Profile0]\nName=Shared\nIsRelative=0\nPath=${legacyProfile}\n`,
462 + );
463 + assert.deepEqual(yield* listSourceProfiles(zen, context), [
464 + { directory: legacyProfile, name: "Shared", cookieCount: 1 },
465 + ]);
466 +
467 + yield* fileSystem.remove(currentRoot, { recursive: true });
468 + assert.isTrue(yield* isSourceInstalled(zen, context));
469 + assert.deepEqual(yield* listSourceProfiles(zen, context), [
470 + { directory: legacyProfile, name: "Legacy", cookieCount: 1 },
471 + ]);
472 + }),
473 + ),
474 + );
475 +
476 + it.effect("discovers a Flatpak-only Zen installation and resolves its cookies", () =>
477 + run(
478 + Effect.gen(function* () {
479 + const fileSystem = yield* FileSystem.FileSystem;
480 + const home = yield* fileSystem.makeTempDirectoryScoped({ prefix: "t3code-zen-flatpak-" });
481 + const context = yield* sourcePathContext.pipe(
482 + Effect.provideService(HostProcess.Environment, { HOME: home }),
483 + Effect.provideService(HostProcess.Platform, "linux"),
484 + );
485 + const root = context.path.join(home, ".var", "app", "app.zen_browser.zen", "zen");
486 + const profile = context.path.join(root, "flatpak.default");
487 + yield* fileSystem.makeDirectory(profile, { recursive: true });
488 + yield* writeFirefoxCookieDatabase(context.path.join(profile, "cookies.sqlite"), 2, 1);
489 + yield* fileSystem.writeFileString(
490 + context.path.join(root, "profiles.ini"),
491 + "[Profile0]\nName=Flatpak\nIsRelative=1\nPath=flatpak.default\n",
492 + );
493 +
494 + assert.deepEqual(yield* listSourceProfiles(zen, context), [
495 + { directory: profile, name: "Flatpak", cookieCount: 2 },
496 + ]);
497 + assert.isTrue(yield* isSourceInstalled(zen, context));
498 + assert.equal(
499 + yield* resolveCookieDatabase(zen, context, profile),
500 + context.path.join(profile, "cookies.sqlite"),
501 + );
502 + }),
503 + ),
504 + );
505 +
506 + it.effect("does not mistake Firefox Snap installs for Zen profiles", () =>
507 + run(
508 + Effect.gen(function* () {
509 + const fileSystem = yield* FileSystem.FileSystem;
510 + const home = yield* fileSystem.makeTempDirectoryScoped({ prefix: "t3code-zen-snap-" });
511 + const context = yield* sourcePathContext.pipe(
512 + Effect.provideService(HostProcess.Environment, { HOME: home }),
513 + Effect.provideService(HostProcess.Platform, "linux"),
514 + );
515 + const zenRoot = context.path.join(home, ".config", "zen");
516 + const snapRoot = context.path.join(
517 + home,
518 + "snap",
519 + "firefox",
520 + "common",
521 + ".mozilla",
522 + "firefox",
523 + );
524 + const zenProfile = context.path.join(zenRoot, "zen.default");
525 + const snapProfile = context.path.join(snapRoot, "snap.default");
526 + for (const root of [zenRoot, snapRoot]) {
527 + const profile = root === zenRoot ? zenProfile : snapProfile;
528 + yield* fileSystem.makeDirectory(profile, { recursive: true });
529 + yield* writeFirefoxCookieDatabase(context.path.join(profile, "cookies.sqlite"), 1, 0);
530 + yield* fileSystem.writeFileString(
531 + context.path.join(root, "profiles.ini"),
532 + [
533 + "[Profile0]",
534 + "Name=Personal",
535 + "IsRelative=1",
536 + `Path=${profile === zenProfile ? "zen.default" : "snap.default"}`,
537 + ].join("\n"),
538 + );
539 + }
540 +
541 + const profiles = yield* listSourceProfiles(zen, context);
542 + assert.deepEqual(
543 + profiles.map((profile) => profile.directory),
544 + ["zen.default"],
545 + );
546 + assert.isTrue(yield* isSourceInstalled(zen, context));
547 + }),
548 + ),
549 + );
550 +});
551 +
552 describe("Firefox Snap profiles", () => {
553 it.effect.skipIf(!symlinksSupported)(
554 "finds Snap profiles with or without profiles.ini and checks their locks",
apps/desktop/src/preview/BrowserImport/Sources.ts
+23 -5
@@ -26,6 +26,7 @@ export interface BrowserImportSourceDefinition {
26 readonly engine: BrowserImportEngine;
27 readonly platforms: ReadonlyArray<NodeJS.Platform>;
28 readonly userDataDirectory: (context: BrowserImportPathContext) => string | undefined;
29 + readonly alternateLinuxRoots?: (context: BrowserImportPathContext) => ReadonlyArray<string>;
30 readonly keychainService?: string;
31 readonly keychainAccount?: string;
32 readonly linuxSecretApplication?: string;
@@ -169,6 +170,26 @@ export const BROWSER_IMPORT_SOURCES: ReadonlyArray<BrowserImportSourceDefinition
170 }
171 return context.path.join(context.home, ".mozilla", "firefox");
172 },
173 + alternateLinuxRoots: (context) => [
174 + context.path.join(context.home, "snap", "firefox", "common", ".mozilla", "firefox"),
175 + ],
176 + },
177 + {
178 + id: "zen",
179 + name: "Zen",
180 + engine: "firefox",
181 + platforms: ["darwin", "win32", "linux"],
182 + userDataDirectory: (context) => {
183 + if (context.platform === "darwin") return macApplicationSupport(context, "zen");
184 + if (context.platform === "win32") {
185 + return context.appData ? context.path.join(context.appData, "zen") : undefined;
186 + }
187 + return context.path.join(context.home, ".config", "zen");
188 + },
189 + alternateLinuxRoots: (context) => [
190 + context.path.join(context.home, ".zen"),
191 + context.path.join(context.home, ".var", "app", "app.zen_browser.zen", "zen"),
192 + ],
193 },
194 ];
195
@@ -470,7 +491,7 @@ const listSourceProfilesInDirectory = Effect.fnUntraced(function* (
491 );
492 });
493
473 -/** Keep Snap profile paths absolute so reads and locks distinguish native and Snap installations. */
494 +/** Keep alternate-root profile paths absolute so cookie reads and locks use the correct installation. */
495 export const listSourceProfiles = Effect.fn("BrowserImportSources.listSourceProfiles")(function* (
496 definition: BrowserImportSourceDefinition,
497 context: BrowserImportPathContext,
@@ -481,10 +502,7 @@ export const listSourceProfiles = Effect.fn("BrowserImportSources.listSourceProf
502
503 const root = definition.userDataDirectory(context);
504 if (root === undefined) return [];
484 - const roots = [
485 - root,
486 - context.path.join(context.home, "snap", "firefox", "common", ".mozilla", "firefox"),
487 - ];
505 + const roots = [root, ...(definition.alternateLinuxRoots?.(context) ?? [])];
506 const profiles = new Map<string, BrowserImportSourceProfile>();
507 for (const directory of roots) {
508 const found = yield* listSourceProfilesInDirectory(
docs/user/browser-import.md
+1 -1
@@ -15,6 +15,6 @@ System Settings permission list, and turn access on. **Continue** becomes availa
15 is detected. macOS may require you to quit and reopen T3 Code before the grant applies; reopen
16 the import wizard afterward. You can revoke Full Disk Access once the import is done.
17
18 -On Windows, import supports Firefox and Helium profiles that use standard profile encryption.
18 +On Windows, import supports Firefox, Zen, and Helium profiles that use standard profile encryption.
19 Other Chromium-based browsers use app-bound encryption and cannot be imported. Partitioned cookies
20 are skipped on all platforms.
packages/contracts/src/browserImport.ts
+1
@@ -11,6 +11,7 @@ const BROWSER_IMPORT_SOURCE_IDS = [
11 "arc",
12 "helium",
13 "firefox",
14 + "zen",
15 "safari",
16 ] as const;
17