Skip to content

Commit 126fbe8

Browse files
fix(desktop): discover Zen Flatpak profiles
1 parent 9ad1cc3 commit 126fbe8

2 files changed

Lines changed: 35 additions & 1 deletion

File tree

‎apps/desktop/src/preview/BrowserImport/Sources.test.ts‎

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,7 @@ describe("Zen", () => {
357357
);
358358
assert.deepEqual(zen.alternateLinuxRoots?.(linuxContext), [
359359
linuxContext.path.join("/home/zen-user", ".zen"),
360+
linuxContext.path.join("/home/zen-user", ".var", "app", "app.zen_browser.zen", "zen"),
360361
]);
361362
}),
362363
),
@@ -472,6 +473,36 @@ describe("Zen", () => {
472473
),
473474
);
474475

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+
475506
it.effect("does not mistake Firefox Snap installs for Zen profiles", () =>
476507
run(
477508
Effect.gen(function* () {

‎apps/desktop/src/preview/BrowserImport/Sources.ts‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,10 @@ export const BROWSER_IMPORT_SOURCES: ReadonlyArray<BrowserImportSourceDefinition
186186
}
187187
return context.path.join(context.home, ".config", "zen");
188188
},
189-
alternateLinuxRoots: (context) => [context.path.join(context.home, ".zen")],
189+
alternateLinuxRoots: (context) => [
190+
context.path.join(context.home, ".zen"),
191+
context.path.join(context.home, ".var", "app", "app.zen_browser.zen", "zen"),
192+
],
190193
},
191194
];
192195

0 commit comments

Comments
 (0)