fix(desktop): use filesystem-friendly userData directory name#607
Merged
t3dotgg merged 1 commit intopingdotgg:mainfrom Mar 9, 2026
Merged
fix(desktop): use filesystem-friendly userData directory name#607t3dotgg merged 1 commit intopingdotgg:mainfrom
t3dotgg merged 1 commit intopingdotgg:mainfrom
Conversation
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 pingdotgg#578
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Contributor
|
i was about to make a pr for this, thanks |
maria-rcks
approved these changes
Mar 9, 2026
t3dotgg
approved these changes
Mar 9, 2026
This was referenced Mar 9, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
userDatadirectory path to use a clean, lowercase name (t3code) instead of theproductName-derivedT3 Code (Alpha).Closes #578
Problem
Electron derives the
userDatapath fromproductNameinpackage.json. With"T3 Code (Alpha)"this produces:~/.config/T3 Code (Alpha)/~/Library/Application Support/T3 Code (Alpha)/%APPDATA%/T3 Code (Alpha)/Spaces and parentheses in directory names are hostile to shell usage and violate Linux XDG naming conventions.
Solution
Call
app.setPath("userData", ...)synchronously at the top level (before Electron'sreadyevent) to override the path with a clean name. This is the same pattern VS Code uses —productNamestays as-is for display purposes (window titles, About panel) while the data directory gets an explicit filesystem-friendly path.New users get
~/.config/t3code/(or platform equivalent).Existing users are detected via
fs.existsSyncon the legacy path. If the old directory exists, it is used as-is so Chromium profile data (localStorage, cookies, sessions, cache) is preserved.The
userDatadirectory is purely for Electron/Chromium internals — T3 Code's own state directory (~/.t3/userdata) is unaffected.Changes
apps/desktop/src/main.ts: AddresolveUserDataPath()function +app.setPath("userData", ...)call (+35 lines)Note
Set Electron desktop app userData path to a filesystem-friendly directory at startup to preserve legacy data when present
Add
resolveUserDataPathto compute platform-specific app data paths and callapp.setPath("userData", resolveUserDataPath())in main.ts to prefer a legacy Electron productName directory if it exists, otherwise use a sanitized lowercase directory.📍Where to Start
Start with the
resolveUserDataPathfunction and its invocation beforeapp.whenReady()in main.ts.Macroscope summarized 81a5efe.