Skip to content

fix(config): read Windows user-profile config#533

Merged
benvinegar merged 1 commit into
mainfrom
fix/windows-config-userprofile
Jul 13, 2026
Merged

fix(config): read Windows user-profile config#533
benvinegar merged 1 commit into
mainfrom
fix/windows-config-userprofile

Conversation

@benvinegar

@benvinegar benvinegar commented Jul 13, 2026

Copy link
Copy Markdown
Member

Summary

  • fall back to USERPROFILE when HOME is unavailable, preserving Hunk’s documented .config/hunk/config.toml location on Windows
  • cover both path resolution and config loading behavior
  • add a patch changeset

Closes #522

Testing

  • bun test src/core/paths.test.ts src/core/config.test.ts
  • bun run typecheck
  • bun test (timed out after 120 seconds; all reported tests passed before timeout)

This PR description was generated by Pi using GPT-5

@greptile-apps

greptile-apps Bot commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR fixes global config discovery on Windows by falling back to USERPROFILE when HOME is unset, keeping the existing .config/hunk/config.toml path convention intact. The core change is a single-line || fallback in resolveUserConfigDir, covered by new unit tests in both paths.test.ts and config.test.ts.

  • src/core/paths.ts: env.HOME || env.USERPROFILE replaces the HOME-only check, so both resolveGlobalConfigPath and resolveHunkStatePath pick up the right base directory on Windows.
  • src/core/paths.test.ts / src/core/config.test.ts: New tests verify the USERPROFILE fallback for raw path resolution and for full config loading end-to-end.
  • .changeset/seven-pans-hunt.md: Patch changeset entry added.

Confidence Score: 5/5

Safe to merge — the change is a one-line fallback that only activates when HOME is absent, with no effect on existing Linux/macOS behaviour.

The fix is minimal and well-scoped: a single || operand in resolveUserConfigDir that is already exercised by two new tests covering both the raw path-resolution layer and the full config-loading pipeline. Existing tests are unaffected.

No files require special attention.

Important Files Changed

Filename Overview
src/core/paths.ts One-line fix: env.HOME
src/core/paths.test.ts New test verifies both resolveGlobalConfigPath and resolveHunkStatePath produce correct paths when only USERPROFILE is present; uses the same cast pattern as existing env tests.
src/core/config.test.ts New integration-style test confirms that resolveConfiguredCliInput picks up and applies a global config placed under USERPROFILE/.config/hunk/config.toml when HOME is absent.
.changeset/seven-pans-hunt.md Patch changeset entry for the Windows config fix; correctly scoped to the hunkdiff package.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[resolveUserConfigDir] --> B{XDG_CONFIG_HOME set?}
    B -- Yes --> C[return XDG_CONFIG_HOME]
    B -- No --> D{HOME set?}
    D -- Yes --> E[return HOME + /.config]
    D -- No --> F{USERPROFILE set?}
    F -- Yes --> G[return USERPROFILE + /.config]
    F -- No --> H[return undefined]

    C --> I[resolveGlobalConfigPath + /hunk/config.toml]
    E --> I
    G --> I
    C --> J[resolveHunkStatePath + /hunk/state.json]
    E --> J
    G --> J
Loading
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
flowchart TD
    A[resolveUserConfigDir] --> B{XDG_CONFIG_HOME set?}
    B -- Yes --> C[return XDG_CONFIG_HOME]
    B -- No --> D{HOME set?}
    D -- Yes --> E[return HOME + /.config]
    D -- No --> F{USERPROFILE set?}
    F -- Yes --> G[return USERPROFILE + /.config]
    F -- No --> H[return undefined]

    C --> I[resolveGlobalConfigPath + /hunk/config.toml]
    E --> I
    G --> I
    C --> J[resolveHunkStatePath + /hunk/state.json]
    E --> J
    G --> J
Loading

Reviews (1): Last reviewed commit: "fix(config): resolve Windows user profil..." | Re-trigger Greptile

@benvinegar benvinegar merged commit 4fdf4bc into main Jul 13, 2026
9 checks passed
@benvinegar benvinegar deleted the fix/windows-config-userprofile branch July 13, 2026 09:19
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.

Config file not read on Windows

1 participant