feat(watch): live-reload theme and chrome on config change#486
Open
eduwass wants to merge 1 commit into
Open
Conversation
While running in --watch mode, also poll Hunk's config files (global ~/.config/hunk/config.toml and repo-local .hunk/config.toml) alongside the diff input, folded into the existing watch loop so a single in-flight guard serializes reloads. On change, reuse refreshCurrentInput so the reload re-reads config — repainting theme/chrome palette edits live — while preserving the active view options (and any CLI overrides).
Contributor
|
PR author is not in the allowed authors list. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
When running
hunk diff --watch, the viewer now live-reloads its theme and chrome the moment Hunk's config changes — no restart required. Previously--watchonly tracked the diff input, so editing~/.config/hunk/config.toml(e.g. switching a[custom_theme]palette from a theming tool) had no effect until you quit and relaunched.What this adds
The watch loop now also watches Hunk's config files and reloads on change:
~/.config/hunk/config.toml) and the repo-local config (.hunk/config.toml) are folded into the existing diff-input watch poll via a newcomputeConfigSignature()incore/watch.ts.refreshCurrentInput(), which re-runs the normal config resolution pipeline — so freshly-read[custom_theme]/[custom_theme.syntax]palettes repaint live — while preserving the active view options and any CLI overrides (no--theme/--modeflag gets silently clobbered by config).Only active in
--watchmode, so default one-shot reviews are unchanged.Testing
bun run format:checkbun run lintbun run typecheckbun run test:theme-contrastbun test src/core/watch.test.ts— added unit coverage forcomputeConfigSignature(missing global config, change detection, repo-local.hunk/config.tomlpickup)hunk diff --watchagainst a repo, switched the active theme so a tool rewrote[custom_theme], and confirmed the running viewer repainted from a dark to a light palette (background#2D2B55→#f9f9f9, panels and diff bands updated) without a restart, and back again.