Skip to content
Source
Sign inSign up
pingdotgg/t3code

Honor XDG base directories for data and settings #4419

Closedcolonelpanic8(GitHub profile, opens in a new tab)wants to merge 3 commits intomain fromrefs/pull/4419/headopened View on GitHub

What Changed

  • Use $XDG_DATA_HOME/t3code as the default application data directory and $XDG_CONFIG_HOME/t3code for settings on Linux and macOS when the corresponding XDG variable is an absolute path.
  • Preserve existing legacy ~/.t3 data or config until matching, environment-specific XDG state/config artifacts exist. Empty XDG directories—and development artifacts when launching production—do not count as migration.
  • Keep T3CODE_HOME, CLI overrides, and explicit desktop bootstrap homes at higher precedence; explicit homes keep data and settings together.
  • Pass the desktop-resolved config directory and explicit-home intent to the child server so Electron and the server agree in production and development.
  • Treat blank bootstrap homes as unset.
  • Make the dev runner report the effective XDG/legacy fallback path and protect both legacy and XDG shared databases from direct mutation by t3-sqlite-state.

Why

Adopting XDG paths must not make an existing installation appear empty. Users upgrading with data or settings in ~/.t3 should continue from that installation, while new users and already-initialized XDG installations receive the XDG-compliant layout.

Data and config are selected independently, and production/development initialization is detected from their actual state/config files rather than parent-directory existence. This prevents a development launch or a partial startup from hiding legacy production data.

The explicit bootstrap metadata also fixes the development-path mismatch where an implicit desktop home could be treated as an explicit server home, causing the desktop and server to select different state or config directories.

UI Changes

None.

A one-click data migration is intentionally not included here: safely moving the live SQLite database and Git worktrees requires a restart-time migration that also repairs worktree metadata containing absolute paths.

Checklist

  • pnpm vp test run scripts/dev-runner.test.ts apps/server/scripts/t3-sqlite-state.test.ts packages/shared/src/path.test.ts apps/desktop/src/app/DesktopEnvironment.test.ts apps/desktop/src/backend/DesktopBackendConfiguration.test.ts apps/server/src/cli/config.test.ts (82 tests)
  • Targeted vp fmt and vp lint --report-unused-disable-directives for all changed TypeScript files
  • pnpm vp run --filter @t3tools/shared --filter @t3tools/contracts --filter t3 --filter @t3tools/desktop --filter @t3tools/scripts typecheck
  • git diff --check

Full repository checks were left to CI in accordance with the repository's local verification guidance.

Note

Honor XDG base directories for data and settings storage

  • Adds XDG Base Directory support across the desktop and server CLI: when T3CODE_HOME is unset, the app selects between legacy ~/.t3 and XDG paths (XDG_DATA_HOME/t3code, XDG_CONFIG_HOME/t3code) based on which directory is already initialized (detected by presence of state.sqlite or settings files).
  • Introduces shared path utilities resolveT3XdgBaseDir, resolveDefaultT3BaseDir, and selectT3XdgDirectory in packages/shared/src/path.ts to centralize XDG vs legacy directory selection logic.
  • Separates configDir (settings/keybindings) from stateDir (SQLite database), allowing them to reside in different XDG directories; deriveServerPaths accepts an optional configDir to decouple settings paths from state.
  • Propagates t3HomeIsExplicit and configDir from the desktop through the bootstrap envelope to the server CLI so the server honors desktop directory decisions.
  • The t3-sqlite-state script now also refuses destructive mutations when baseDir resolves to the XDG data home, in addition to the legacy ~/.t3.
  • Behavioral Change: new installations default to XDG directories; existing installations using legacy ~/.t3 continue to use it until XDG directories are initialized. Setting T3CODE_HOME explicitly keeps data and config co-located under that path.
Macroscope summarized 4d7c106.
    1. coderabbitai[bot](GitHub profile, opens in a new tab)commented

      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 Plus

      Run ID: aa299b02-4b49-44fa-9315-75ab3631545a

      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

      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.
    2. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched

    3. macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      Approvability

      Verdict: Needs human review

      This PR adds XDG Base Directory support, fundamentally changing where application data and settings are stored on Linux/macOS. The cross-cutting changes affect storage path resolution in desktop, server, and scripts with non-trivial migration logic to preserve legacy data.

      You can customize Macroscope's approvability policy. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    4. Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

      Fix All in Cursor ❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the [Cursor dashboard](https://www.cursor.com/dashboard/bugbot). Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 28f42e3d8b2f7b4f5c4e385081ac1be70fa18523. Configure [here](https://www.cursor.com/dashboard/bugbot).
    5. Superseded by #4437, which starts from current main, implements the full five-root storage contract, preserves initialized legacy installations without automatic migration, and adds storage diagnostics.

Sign in to join this conversation.