The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 22, 02:00 UTC
fix(desktop): discover browser profiles in XDG config home (#29243)
Lakshmi Tanmay committed
Nov 9, 2026 at 20:00 UTC
220a7439b683aaa409c0613809b6e5001215c327
2 files changed
+91
-7
apps/desktop/src/preview/BrowserImport/Sources.test.ts
+75
-4
@@ -199,6 +199,51 @@ describe("chromiumProcessIsAlive", () => {
199
});
200
201
describe("isSourceInstalled", () => {
202
+ it.effect.each([undefined, "", "relative-config", "relocated", "chrome-override"])(
203
+ "discovers Linux Chromium profiles with XDG_CONFIG_HOME=%s",
204
+ (configHome) =>
205
+ run(
206
+ Effect.gen(function* () {
207
+ const fileSystem = yield* FileSystem.FileSystem;
208
+ const path = yield* Path.Path;
209
+ const home = yield* fileSystem.makeTempDirectoryScoped({ prefix: "t3code-sources-xdg-" });
210
+ const xdgConfigHome =
211
+ configHome === "relocated" || configHome === "chrome-override"
212
+ ? path.join(home, "config")
213
+ : configHome;
214
+ const chromeConfigHome =
215
+ configHome === "chrome-override" ? path.join(home, ".config") : undefined;
216
+ const context = yield* sourcePathContext.pipe(
217
+ Effect.provideService(HostProcess.Environment, {
218
+ HOME: home,
219
+ XDG_CONFIG_HOME: xdgConfigHome,
220
+ CHROME_CONFIG_HOME: chromeConfigHome,
221
+ }),
222
+ Effect.provideService(HostProcess.Platform, "linux"),
223
+ );
224
+ const configRoot =
225
+ chromeConfigHome ??
226
+ (configHome === "relocated" ? path.join(home, "config") : path.join(home, ".config"));
227
+ const source = BROWSER_IMPORT_SOURCES.find((source) => source.id === "chrome")!;
228
+ const root = path.join(configRoot, "google-chrome");
229
+ const database = path.join(root, "Default", "Network", "Cookies");
230
+ assert.isFalse(yield* isSourceInstalled(source, context));
231
+ yield* fileSystem.makeDirectory(path.dirname(database), { recursive: true });
232
+ yield* writeCookieDatabase(database, 2);
233
+ yield* fileSystem.writeFileString(
234
+ path.join(root, "Local State"),
235
+ '{"profile":{"info_cache":{"Default":{"name":"Fixture"}}}}',
236
+ );
237
+
238
+ assert.isTrue(yield* isSourceInstalled(source, context));
239
+ assert.deepEqual(yield* listSourceProfiles(source, context), [
240
+ { directory: "Default", name: "Fixture", cookieCount: 2 },
241
+ ]);
242
+ assert.equal(yield* resolveCookieDatabase(source, context, "Default"), database);
243
+ }),
244
+ ),
245
+ );
246
+
247
it.effect("ignores a user-data directory that holds no cookie database", () =>
248
run(
249
Effect.gen(function* () {
@@ -325,13 +370,18 @@ describe("Zen", () => {
370
run(
371
Effect.gen(function* () {
372
const darwinContext = yield* sourcePathContext.pipe(
328
- Effect.provideService(HostProcess.Environment, { HOME: "/Users/zen-user" }),
373
+ Effect.provideService(HostProcess.Environment, {
374
+ HOME: "/Users/zen-user",
375
+ XDG_CONFIG_HOME: "/custom-config",
376
+ }),
377
Effect.provideService(HostProcess.Platform, "darwin"),
378
);
379
const windowsContext = yield* sourcePathContext.pipe(
380
Effect.provideService(HostProcess.Environment, {
381
HOME: "C:\\Users\\zen-user",
382
APPDATA: "C:\\Users\\zen-user\\AppData\\Roaming",
383
+ LOCALAPPDATA: "C:\\Users\\zen-user\\AppData\\Local",
384
+ XDG_CONFIG_HOME: "/custom-config",
385
}),
386
Effect.provideService(HostProcess.Platform, "win32"),
387
);
@@ -359,6 +409,24 @@ describe("Zen", () => {
409
linuxContext.path.join("/home/zen-user", ".zen"),
410
linuxContext.path.join("/home/zen-user", ".var", "app", "app.zen_browser.zen", "zen"),
411
]);
412
+ assert.equal(
413
+ helium.userDataDirectory(darwinContext),
414
+ darwinContext.path.join(
415
+ "/Users/zen-user",
416
+ "Library",
417
+ "Application Support",
418
+ "net.imput.helium",
419
+ ),
420
+ );
421
+ assert.equal(
422
+ helium.userDataDirectory(windowsContext),
423
+ windowsContext.path.join(
424
+ "C:\\Users\\zen-user\\AppData\\Local",
425
+ "imput",
426
+ "Helium",
427
+ "User Data",
428
+ ),
429
+ );
430
}),
431
),
432
);
@@ -415,16 +483,19 @@ describe("Zen", () => {
483
),
484
);
485
418
- it.effect("discovers Zen profiles in both current and legacy Linux roots", () =>
486
+ it.effect("discovers Zen profiles in relocated and legacy Linux roots", () =>
487
run(
488
Effect.gen(function* () {
489
const fileSystem = yield* FileSystem.FileSystem;
490
const home = yield* fileSystem.makeTempDirectoryScoped({ prefix: "t3code-zen-linux-" });
491
const context = yield* sourcePathContext.pipe(
424
- Effect.provideService(HostProcess.Environment, { HOME: home }),
492
+ Effect.provideService(HostProcess.Environment, {
493
+ HOME: home,
494
+ XDG_CONFIG_HOME: NodePath.join(home, "config"),
495
+ }),
496
Effect.provideService(HostProcess.Platform, "linux"),
497
);
427
- const currentRoot = context.path.join(home, ".config", "zen");
498
+ const currentRoot = context.path.join(home, "config", "zen");
499
const legacyRoot = context.path.join(home, ".zen");
500
const currentProfile = context.path.join(currentRoot, "current.default");
501
const legacyProfile = context.path.join(legacyRoot, "legacy.default");
apps/desktop/src/preview/BrowserImport/Sources.ts
+16
-3
@@ -16,6 +16,8 @@ export interface BrowserImportPathContext {
16
readonly path: Path.Path;
17
readonly platform: NodeJS.Platform;
18
readonly home: string;
19
+ readonly linuxConfigHome: string;
20
+ readonly linuxChromeConfigHome: string;
21
readonly appData: string | undefined;
22
readonly localAppData: string | undefined;
23
}
@@ -68,7 +70,10 @@ const chromiumSource = (input: {
70
: undefined;
71
}
72
return input.linuxSegments
71
- ? context.path.join(context.home, ".config", ...input.linuxSegments)
73
+ ? context.path.join(
74
+ input.id === "chrome" ? context.linuxChromeConfigHome : context.linuxConfigHome,
75
+ ...input.linuxSegments,
76
+ )
77
: undefined;
78
},
79
});
@@ -185,7 +190,7 @@ export const BROWSER_IMPORT_SOURCES: ReadonlyArray<BrowserImportSourceDefinition
190
if (context.platform === "win32") {
191
return context.appData ? context.path.join(context.appData, "zen") : undefined;
192
}
188
- return context.path.join(context.home, ".config", "zen");
193
+ return context.path.join(context.linuxConfigHome, "zen");
194
},
195
alternateLinuxRoots: (context) => [
196
context.path.join(context.home, ".zen"),
@@ -292,10 +297,18 @@ export const sourcePathContext = Effect.gen(function* () {
297
const path = yield* Path.Path;
298
const platform = yield* HostProcess.Platform;
299
const environment = yield* HostProcess.Environment;
300
+ const home = environment.HOME ?? environment.USERPROFILE ?? "";
301
+ const xdgConfigHome = environment.XDG_CONFIG_HOME;
302
+ const linuxConfigHome =
303
+ xdgConfigHome && path.isAbsolute(xdgConfigHome) ? xdgConfigHome : path.join(home, ".config");
304
+ const chromeConfigHome = environment.CHROME_CONFIG_HOME;
305
return {
306
path,
307
platform,
298
- home: environment.HOME ?? environment.USERPROFILE ?? "",
308
+ home,
309
+ linuxConfigHome,
310
+ linuxChromeConfigHome:
311
+ chromeConfigHome && path.isAbsolute(chromeConfigHome) ? chromeConfigHome : linuxConfigHome,
312
appData: environment.APPDATA,
313
localAppData: environment.LOCALAPPDATA,
314
} satisfies BrowserImportPathContext;