Skip to content

fix: store persistent state under XDG state directory - #920

Open
mikemikimike wants to merge 2 commits into
modem-dev:mainfrom
mikemikimike:fix/issue-821-xdg-state
Open

fix: store persistent state under XDG state directory#920
mikemikimike wants to merge 2 commits into
modem-dev:mainfrom
mikemikimike:fix/issue-821-xdg-state

Conversation

@mikemikimike

@mikemikimike mikemikimike commented Aug 30, 2026

Copy link
Copy Markdown

Problem

Hunk currently stores its persistent state file at $XDG_CONFIG_HOME/hunk/state.json, alongside the user-editable configuration at $XDG_CONFIG_HOME/hunk/config.toml.

This mixes two different kinds of data defined by the XDG Base Directory Specification: XDG_CONFIG_HOME is intended for user-editable configuration, while XDG_STATE_HOME is intended for data that persists across restarts but is not important or portable enough to belong in XDG_DATA_HOME. The state file and the user-scoped directory used for globally installed extensions belong in the latter category.

Changes

  • Resolve state.json from $XDG_STATE_HOME/hunk, falling back to ~/.local/state/hunk when XDG_STATE_HOME is unset.
  • Keep config.toml under $XDG_CONFIG_HOME/hunk, with the existing ~/.config/hunk fallback.
  • Move global extension discovery and managed extension installs to the same XDG state directory.
  • Add regression coverage for explicit XDG directories and state-directory fallbacks.

Validation

  • bun test src/core/run/paths.test.ts src/extensions/discovery.test.ts src/extensions/startup.test.ts src/extensions/manage/install.test.ts
  • bun run typecheck
  • bun run lint
  • bun run deps:check
  • Changed files pass the formatter check.
  • git diff --check

The repository-wide format check reports pre-existing failures elsewhere in the checkout; the changed files pass the formatter check.

Compatibility / Known limitations

This changes the default location of persistent state and globally managed extensions on XDG-compatible systems. User-editable configuration remains at its existing location. Existing state or extensions under the old configuration directory are not migrated automatically.

Fixes #821

@greptile-apps

greptile-apps Bot commented Aug 30, 2026

Copy link
Copy Markdown
Contributor

PR author is not in the allowed authors list.

@vercel

vercel Bot commented Aug 30, 2026

Copy link
Copy Markdown

@mikemikimike is attempting to deploy a commit to the Modem Team on Vercel.

A member of the Team first needs to authorize it.

@benvinegar

Copy link
Copy Markdown
Member

Can you fix the PR description? It's poorly formatted. What problem are you solving, etc? (I can guess, but ...)

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.

state.json (and extensions dir) hardcoded under $XDG_CONFIG_HOME instead of $XDG_STATE_HOME

2 participants