Skip to content

feat: persist Hunk view preferences#7

Merged
benvinegar merged 2 commits intomasterfrom
feat/persist-view-config
Mar 19, 2026
Merged

feat: persist Hunk view preferences#7
benvinegar merged 2 commits intomasterfrom
feat/persist-view-config

Conversation

@benvinegar
Copy link
Copy Markdown
Member

Summary

  • add layered Hunk config loading with global and repo-local TOML files
  • persist theme/layout/view toggles between invocations, including pager mode
  • add CLI overrides for persistent view prefs and document the new config model

Details

  • support $XDG_CONFIG_HOME/hunk/config.toml and ~/.config/hunk/config.toml
  • support repo-local .hunk/config.toml
  • apply precedence: built-ins < global config < repo config < command/pager profiles < CLI flags
  • persist view prefs back to .hunk/config.toml in repos, or global config outside repos
  • add command/pager profile sections like [pager], [git], [diff], [patch], [difftool]
  • add CLI flags for line numbers, wrapping, hunk headers, and agent notes

Validation

  • bun run typecheck
  • bun test
  • bun run test:tty-smoke

Comment thread src/core/config.ts
@benvinegar benvinegar merged commit c3861bf into master Mar 19, 2026
7 checks passed
Comment thread src/core/config.ts
Comment on lines +274 to +278
existing.line_numbers = preferences.showLineNumbers;
existing.wrap_lines = preferences.wrapLines;
existing.hunk_headers = preferences.showHunkHeaders;
existing.agent_notes = preferences.showAgentNotes;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: The system-detected theme is incorrectly persisted on first launch, which prevents the application from automatically following system theme changes on subsequent runs.
Severity: HIGH

Suggested Fix

Modify the persistence logic to only save the theme to the configuration file if the user has explicitly selected one. This can be achieved by tracking whether the theme was user-selected or inferred from the system default, and only persisting it in the former case. This will allow the application to re-detect the system theme on each launch if no explicit theme is set.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.

Location: src/core/config.ts#L274-L278

Potential issue: On the first run, the application detects the user's system theme
(e.g., 'dark' mode resolves to the 'midnight' theme) and immediately persists this theme
to the configuration file. The persistence logic in `src/core/config.ts` always saves
the `preferences.theme` value because the `resolveTheme` function ensures it is never
undefined. As a result, on all subsequent launches, the application uses this saved
theme instead of re-evaluating the current system theme. This prevents the application
from automatically adapting to system theme changes after its initial execution, locking
it into the theme from the first run.

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.

1 participant