Registry Mirror
Skip to content

Conversation

@mikemikimike

@mikemikimike mikemikimike commented Aug 30, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Hunk stores persistent state in $XDG_CONFIG_HOME/hunk/state.json, alongside user-editable configuration. The XDG specification reserves XDG_STATE_HOME for persistent application state.

Solution

  • Store state.json under an absolute $XDG_STATE_HOME/hunk, falling back to ~/.local/state/hunk when the variable is unset or relative (with the existing platform-home fallback).
  • Preserve legacy state on first use: stage a complete owner-only copy and publish it without overwriting an existing destination, including one created concurrently. Keep the original file intact. If migration fails, continue using the legacy file rather than resetting state/trust decisions.
  • Reuse this preparation for repository extension trust and startup/update state; explicit state-path overrides remain unchanged.
  • Keep configuration and all global extension discovery/install paths unchanged. Moving global extension code to XDG_DATA_HOME, with migration and collision handling, is tracked separately in Move global extensions to XDG_DATA_HOME with upgrade migration #1172.
  • Update documentation and the Changeset, isolate PTY state, and add unit plus real-PTY upgrade coverage.

Validation

  • bun run test: both shards passed.
  • Focused state/migration/update-notice/trust/path tests: 68 passed.
  • bun run test:integration: 247 passed, 1 platform-specific skip, 0 failed.
  • bun run typecheck
  • bun run lint
  • bun run deps:check
  • bun run check:docs
  • Changed-file formatting and git diff --check
  • Source bun run packages/hunk/src/main.tsx -- diff --help

Validated locally on Linux; macOS/Windows verification remains with CI. No terminal rendering/layout behavior changes. The real PTY upgrade test verifies remembered trust survives, repository extensions run without another prompt, and global extensions still load from the config directory.

Compatibility

Existing state at the new destination always wins, even if empty or malformed. The legacy file is copied, not deleted; it becomes a backup after successful migration rather than a synchronized second state file. Failed migration retains legacy persistence and retries on later use. Global extensions, managed installs, repo-local extensions, and user-editable configuration do not move in this PR.

Fixes #821. Extension relocation follow-up: #1172.

This PR description was generated by Pi using GPT-6.1 (gpt-6.1-sol)

@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 ...)

@mikemikimike

Copy link
Copy Markdown
Contributor Author

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?

@mikemikimike

Copy link
Copy Markdown
Contributor Author

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.

@benvinegar
benvinegar force-pushed the fix/issue-821-xdg-state branch from 7983451 to 9ba207e Compare October 12, 2026 18:03
@benvinegar

Copy link
Copy Markdown
Member

Rebased onto fresh main (7572a228) and force-pushed with a lease. Resolved conflicts while preserving current npm-install documentation, bundled GitHub command coverage, and PTY terminal responder startup. Updated newer startup/npm tests to use the relocated state/extension paths.

Validation on 9ba207e4:

  • bun run test: both shards passed.
  • Focused path/discovery/startup/install/trust tests: 75 passed.
  • npm unit tests: 12 passed; npm CLI coverage passed in the full suite.
  • bun test test/pty/extensions-integration.test.ts: 24 passed.
  • Typecheck, lint, dependency boundaries, generated docs, changed-file formatting, and diff checks passed.
  • Source diff --help works.
  • Full bun run test:integration exceeded the 300-second timeout; no failure was reported before timeout. This is not a full integration pass.

Merge assessment: the state.json issue remains valid, but I recommend not merging the current behavior without addressing upgrades. Existing state/trust decisions and globally installed extensions under the old config directory are not migrated or read as a fallback, so an upgrade silently resets state and stops discovering existing extensions. Consider narrowing this to persistent state plus a safe migration/legacy fallback, and separately deciding the appropriate location and migration policy for extension code.

This comment was generated by Pi using GPT-6.1 (gpt-6.1-sol)

@benvinegar

Copy link
Copy Markdown
Member

Updated in 0c9680ea after maintainer direction: this PR now moves only persistent state, with safe legacy-state migration/fallback. Global extension paths remain unchanged; their move to XDG_DATA_HOME is tracked in #1172.

The full unit/CLI suite passes, as does the full PTY integration suite (247 passed, 1 platform skip). New coverage verifies migration, existing-destination precedence, failed migration, trust/update state preservation, and real TUI startup with both remembered repository trust and global extensions at their existing location. Typecheck, lint, dependency checks, generated docs and formatting checks pass. PR description updated to match the narrowed scope and current validation.

This comment was generated by Pi using GPT-6.1 (gpt-6.1-sol)

@benvinegar
benvinegar force-pushed the fix/issue-821-xdg-state branch from 0c9680e to c217a50 Compare October 13, 2026 02:15
@benvinegar

Copy link
Copy Markdown
Member

Rebased onto current main (9eb14212) and pushed c217a505 with two targeted CI test fixes:

  • Wait for the mouse click paint to commit rather than assuming output idleness acknowledges input.
  • Allow 20 seconds on Windows only for the jj source fixture that launches seven external processes; content assertions and Linux timeout remain unchanged.

Highlighting responsiveness coverage remains unchanged; it passed in three repeated focused runs. Full unit/CLI tests, typecheck, lint, dependency boundaries and generated docs pass. The full local PTY rerun passed these affected tests but exposed the newly merged suspension/stale-TTL test failing; that exact test also fails on clean current main (bun test test/pty/lifecycle.test.ts --test-name-pattern "longer than the stale TTL"), so it is not attributed to the state-location change. I am rerunning GitHub CI rather than weakening that test here.

This comment was generated by Pi using GPT-6.1 (gpt-6.1-sol)

@benvinegar

Copy link
Copy Markdown
Member

CI fixes are complete on 6e81bafb. Windows and PTY runs now pass, with the highlighting responsiveness assertions unchanged. Synced the package README with the canonical root README to fix the final npm packaging check; bun run check:pack also passes locally. The latest GitHub CI run is green, including Linux validation/packaging, Windows compatibility, PTY integration, and the aggregate Typecheck + Test + Smoke gate. Remaining Vercel authorization is deployment access, not a code/test failure.

This comment was generated by Pi using GPT-6.1 (gpt-6.1-sol)

@benvinegar
benvinegar merged commit f3e78cb into modem-dev:main Oct 13, 2026
14 of 15 checks passed
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