Skip to content

feat(storage): add opt-in XDG storage configuration - #108

Open
specter119 wants to merge 8 commits into
tommy0103:mainfrom
specter119:feature/xdg_support
Open

feat(storage): add opt-in XDG storage configuration#108
specter119 wants to merge 8 commits into
tommy0103:mainfrom
specter119:feature/xdg_support

Conversation

@specter119

@specter119 specter119 commented Aug 25, 2026

Copy link
Copy Markdown

What and why

Adds opt-in XDG Base Directory support for Obelisk's storage locations, as discussed in #101.

Introduces a shared path resolver (packages/core/src/paths.ts) used by Core, CLI, and Electron, with the following precedence (per the maintainer's confirmed design):

  1. OBELISK_HOME → single directory for everything (highest precedence)
  2. Existing ~/.obelisk → keep using it
  3. OBELISK_USE_XDG=1 → config at $XDG_CONFIG_HOME/obelisk, data at $XDG_DATA_HOME/obelisk (with per-user fallbacks)
  4. Otherwise → ~/.obelisk (unchanged)

No automatic migration into custom/XDG layouts. Obelisk emits a one-time warning linking to the new README section when ~/.claude/obelisk.sqlite is found in a non-legacy layout.

Closes #101

Verification

  • npm test — 476/477 pass; 1 failure is an npm 12 packaging-test compatibility issue. Manual npm pack --json succeeds.
  • npm run typecheck — 0 errors (root + app)
  • npm run lint — 0 errors, 4 pre-existing warnings
  • npm run test:electron:all — 2/5 suites pass; 3 failures are WSL2/dzn GPU-related, unrelated to storage-path changes. --disable-gpu fixes electron-session-images (GPU crash was the cause); electron-session-virtualization and electron-session-reader-state still fail due to WSLg software-rendering timing, not GPU. CI (ubuntu-latest) should not exhibit these.
  • New tests actually run in CI — Not yet. cli.yml does not include the new test files.
  • No existing assertion was loosened
  • Every capability exercised end to end (CLI --build, Electron main settings:get/settings:set, Electron indexer)

Focused test results

Suite Result
tests/paths.test.mjs (11 tests) 11/11 pass
tests/app-storage-paths.test.mjs (2 tests) 2/2 pass
tests/app-main-storage.test.mjs (1 test) 1/1 pass
npm run build:core / build:cli pass

Deliberately out of scope

  • CI workflow updatecli.yml does not run the new storage-path tests. Can add a step if preferred.
  • Electron main XDG split e2e test — mocked main test covers OBELISK_HOME; worker test covers both. Full XDG split through IPC handlers is a follow-up.
  • Consolidating migration/schema logic — Electron and Core differ intentionally (better-sqlite3, writer leases, WSL path probing).
  • Warning for ~/.obelisk/obelisk.sqlite when switching to OBELISK_HOME — author confirmed no extra warnings beyond ~/.claude/obelisk.sqlite.

Files changed

File Change
packages/core/src/paths.ts New shared path resolver
packages/core/src/db.ts Uses resolver; warns on non-legacy layouts
packages/core/src/core.ts Re-exports resolveObeliskPaths
packages/core/src/provider-settings.ts Uses resolver for settings path
packages/core/package.json Adds "./paths" export
app/src/main/index.ts Uses resolver for all storage paths
app/src/main/indexer.ts Uses resolver for default DB path
app/src/renderer/src/views/Settings.vue Drops hardcoded recap fallback
README.md Adds "Advanced configuration" section
tests/paths.test.mjs 11 resolver and warning tests
tests/app-storage-paths.test.mjs 2 Electron indexer subprocess tests
tests/app-main-storage.test.mjs 1 Electron main mocked integration test

Resolve conflict in app/src/main/index.ts: keep resolver-based
OBELISK_DIR/RECAP_DIR at module top, adopt upstream's createAdaptiveWatcher
type and notify-debounce infrastructure. Update app-main-storage test to
mock createAdaptiveWatcher instead of chokidar.
This reverts commit 4013f7d, reversing
changes made to ca59a09.
@specter119

Copy link
Copy Markdown
Author

Validation follow-up

The XDG storage coverage is passing locally:

  • Storage contract tests: 12/12
  • npm test: 672/672
  • npm run typecheck: pass
  • npm run lint: 0 errors (11 warnings)

I do not have a reliable native Electron/GUI environment locally. The full npm --prefix app run test:electron:all run currently passes 3/5 suites; the remaining electron-session-virtualization.mjs and electron-session-reader-state.mjs failures are Linux/Wayland rendering/timing related and are not a trustworthy local signal for this storage change.

Could a maintainer please approve the fork workflow and help run the Electron validation in CI? The current workflow runs the focused storage contracts on Linux, but does not include the full Electron UI suite.

Please let us know if you would like any additional checks, coverage, or changes to the validation scope before merging.

@specter119

Copy link
Copy Markdown
Author

hi @tommy0103 please review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support XDG Base Directory paths for Obelisk's own config/data (settings.json + index), with legacy migration

1 participant