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

Summary

  • Override Electron's userData directory path to use a clean, lowercase name (t3code) instead of the productName-derived T3 Code (Alpha).
  • Existing users with the legacy directory are automatically detected and continue using it — no data loss.

Closes #578

Problem

Electron derives the userData path from productName in package.json. With "T3 Code (Alpha)" this produces:

PlatformPath
Linux~/.config/T3 Code (Alpha)/
macOS~/Library/Application Support/T3 Code (Alpha)/
Windows%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's ready event) to override the path with a clean name. This is the same pattern VS Code uses — productName stays 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.existsSync on the legacy path. If the old directory exists, it is used as-is so Chromium profile data (localStorage, cookies, sessions, cache) is preserved.

The userData directory is purely for Electron/Chromium internals — T3 Code's own state directory (~/.t3/userdata) is unaffected.

Changes

  • apps/desktop/src/main.ts: Add resolveUserDataPath() 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 resolveUserDataPath to compute platform-specific app data paths and call app.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 resolveUserDataPath function and its invocation before app.whenReady() in main.ts.

Macroscope summarized 81a5efe.
    1. Important

      Review skipped

      Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

      ⚙️ Run configuration

      Configuration used: Repository UI

      Review profile: CHILL

      Plan: Pro

      Run ID: 328eb8e8-bdf3-4a43-8cc8-e93c8b9465b8

      You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

      Use the checkbox below for a quick retry:

      • 🔍 Trigger review
      ✨ Finishing Touches
      🧪 Generate unit tests (beta)
      • Create PR with unit tests
      • Post copyable unit tests in a comment

      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.

      ❤️ Share
      Comment `@coderabbitai help` to get the list of available commands and usage tips.
    2. i was about to make a pr for this, thanks

    3. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted

    4. maria-rcks approved these changes

    5. t3dotgg(GitHub profile, opens in a new tab) approved these changes

Sign in to join this conversation.