Skip to content
Source
Sign inSign up
pingdotgg/t3code

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

Mergedbinbandit(GitHub profile, opens in a new tab)merged 1 commit intomain fromrefs/pull/607/headmerged by t3dotgg(GitHub profile, opens in a new tab) View on GitHub

Showing 1 changed file with 35 additions and 0 deletions.

x
0 of 1 viewed, 1 left
35 additions and 0 deletionsapps/desktop/src/main.tsModified
View file
@@ -50,6 +50,8 @@
const isDevelopment = Boolean(process.env.VITE_DEV_SERVER_URL);
const APP_DISPLAY_NAME = isDevelopment ? "T3 Code (Dev)" : "T3 Code (Alpha)";
const APP_USER_MODEL_ID = "com.t3tools.t3code";
+const USER_DATA_DIR_NAME = isDevelopment ? "t3code-dev" : "t3code";
+const LEGACY_USER_DATA_DIR_NAME = isDevelopment ? "T3 Code (Dev)" : "T3 Code (Alpha)";
const COMMIT_HASH_PATTERN = /^[0-9a-f]{7,40}$/i;
const COMMIT_HASH_DISPLAY_LENGTH = 12;
const LOG_DIR = Path.join(STATE_DIR, "logs");
@@ -574,6 +576,34 @@
return resolveResourcePath(`icon.${ext}`);
​
+/**
+ * Resolve the Electron userData directory path.
+ *
+ * Electron derives the default userData path from `productName` in
+ * package.json, which currently produces directories with spaces and
+ * parentheses (e.g. `~/.config/T3 Code (Alpha)` on Linux). This is
+ * unfriendly for shell usage and violates Linux naming conventions.
+ *
+ * We override it to a clean lowercase name (`t3code`). If the legacy
+ * directory already exists we keep using it so existing users don't
+ * lose their Chromium profile data (localStorage, cookies, sessions).
+ */
+function resolveUserDataPath(): string {
+ const appDataBase =
+ process.platform === "win32"
+ ? process.env.APPDATA || Path.join(OS.homedir(), "AppData", "Roaming")