@devries-cameron20 / t3code-1 / commits / 4088b7ac3c
Fork 0

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

fix(desktop): use filesystem-friendly userData directory name (#607)

Electron derives the userData path from productName in package.json, which produces directories with spaces and parentheses on all platforms (e.g. ~/.config/T3 Code (Alpha) on Linux). This is hostile to shell usage and violates Linux XDG naming conventions. Override the userData path via app.setPath() before the ready event to use a clean lowercase name (t3code). If the legacy directory already exists it is used as-is so existing users keep their Chromium profile data (localStorage, cookies, sessions, cache). This follows the same pattern VS Code uses — keeping productName for display purposes while explicitly setting the data directory path. Closes #578

0x1f99d committed Mar 9, 2026 at 16:02 UTC 4088b7ac3cddc1fc92ccf3f99e7a844c629ebad0
1 file changed +35
apps/desktop/src/main.ts
+35
@@ -50,6 +50,8 @@ const ROOT_DIR = Path.resolve(__dirname, "../../..");
50 const isDevelopment = Boolean(process.env.VITE_DEV_SERVER_URL);
51 const APP_DISPLAY_NAME = isDevelopment ? "T3 Code (Dev)" : "T3 Code (Alpha)";
52 const APP_USER_MODEL_ID = "com.t3tools.t3code";
53 +const USER_DATA_DIR_NAME = isDevelopment ? "t3code-dev" : "t3code";
54 +const LEGACY_USER_DATA_DIR_NAME = isDevelopment ? "T3 Code (Dev)" : "T3 Code (Alpha)";
55 const COMMIT_HASH_PATTERN = /^[0-9a-f]{7,40}$/i;
56 const COMMIT_HASH_DISPLAY_LENGTH = 12;
57 const LOG_DIR = Path.join(STATE_DIR, "logs");
@@ -593,6 +595,34 @@ function resolveIconPath(ext: "ico" | "icns" | "png"): string | null {
595 return resolveResourcePath(`icon.${ext}`);
596 }
597
598 +/**
599 + * Resolve the Electron userData directory path.
600 + *
601 + * Electron derives the default userData path from `productName` in
602 + * package.json, which currently produces directories with spaces and
603 + * parentheses (e.g. `~/.config/T3 Code (Alpha)` on Linux). This is
604 + * unfriendly for shell usage and violates Linux naming conventions.
605 + *
606 + * We override it to a clean lowercase name (`t3code`). If the legacy
607 + * directory already exists we keep using it so existing users don't
608 + * lose their Chromium profile data (localStorage, cookies, sessions).
609 + */
610 +function resolveUserDataPath(): string {
611 + const appDataBase =
612 + process.platform === "win32"
613 + ? process.env.APPDATA || Path.join(OS.homedir(), "AppData", "Roaming")
614 + : process.platform === "darwin"
615 + ? Path.join(OS.homedir(), "Library", "Application Support")
616 + : process.env.XDG_CONFIG_HOME || Path.join(OS.homedir(), ".config");
617 +
618 + const legacyPath = Path.join(appDataBase, LEGACY_USER_DATA_DIR_NAME);
619 + if (FS.existsSync(legacyPath)) {
620 + return legacyPath;
621 + }
622 +
623 + return Path.join(appDataBase, USER_DATA_DIR_NAME);
624 +}
625 +
626 function configureAppIdentity(): void {
627 app.setName(APP_DISPLAY_NAME);
628 const commitHash = resolveAboutCommitHash();
@@ -1187,6 +1217,11 @@ function createWindow(): BrowserWindow {
1217 return window;
1218 }
1219
1220 +// Override Electron's userData path before the `ready` event so that
1221 +// Chromium session data uses a filesystem-friendly directory name.
1222 +// Must be called synchronously at the top level — before `app.whenReady()`.
1223 +app.setPath("userData", resolveUserDataPath());
1224 +
1225 configureAppIdentity();
1226
1227 async function bootstrap(): Promise<void> {