Repository navigation
fix: store persistent state under XDG state directory - #920
mikemikimike wants to merge 6 commits into
Conversation
|
PR author is not in the allowed authors list. |
|
@mikemikimike is attempting to deploy a commit to the Modem Team on Vercel. A member of the Team first needs to authorize it. |
|
Can you fix the PR description? It's poorly formatted. What problem are you solving, etc? (I can guess, but ...) |
|
I rechecked this PR for issue #821. The PR description covers the reported persistent-state behavior, and I do not see a human changes-requested review or a failing check for the current head. Could a maintainer please review whether this fully resolves the issue and approve it, or advise on any remaining work? |
|
The PR description now documents the problem, the XDG state/config split, the compatibility limitation, and the focused validation. Issue #821 is still open. Please review the current head when available; Vercel authorization is intentionally ignored. |
# Conflicts: # test/cli/compiled-headless-native-lib.test.ts # test/cli/entrypoint.test.ts # test/pty/harness.ts
Problem
Hunk stores persistent state at
$XDG_CONFIG_HOME/hunk/state.json, next to the user-editable configuration file$XDG_CONFIG_HOME/hunk/config.toml. The XDG Base Directory Specification reservesXDG_CONFIG_HOMEfor configuration andXDG_STATE_HOMEfor persistent, non-portable application state. The same misplaced location is also used for the user-scoped global extensions directory.This addresses issue #821, where
state.jsonwas expected under the state directory.Root cause
Path resolution treated the configuration directory as the base for both editable configuration and persistent extension state. It also accepted a relative
XDG_STATE_HOME, which could resolve state relative to the process working directory instead of an absolute user state location.Solution
state.jsonand the global extensions directory under an absolute$XDG_STATE_HOME/hunk.~/.local/state/hunkwhenXDG_STATE_HOMEis unset or relative.config.tomlunder$XDG_CONFIG_HOME/hunk, with the existing~/.config/hunkfallback.XDG_STATE_HOME.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(66 passed)bun run test:integration(193 passed, 1 skipped)bun run typecheckbun run lintbun run deps:checkbun run check:docsgit diff --checkThe repository-wide
bun run testfailures are reproducible on clean upstreammain; the affected tests are unchanged by this PR.Compatibility
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