Skip to content

feat(watch): live-reload theme and chrome on config change#486

Open
eduwass wants to merge 1 commit into
modem-dev:mainfrom
eduwass:feat/live-config-reload
Open

feat(watch): live-reload theme and chrome on config change#486
eduwass wants to merge 1 commit into
modem-dev:mainfrom
eduwass:feat/live-config-reload

Conversation

@eduwass

@eduwass eduwass commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

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 --watch only 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:

  • The global config (~/.config/hunk/config.toml) and the repo-local config (.hunk/config.toml) are folded into the existing diff-input watch poll via a new computeConfigSignature() in core/watch.ts.
  • Keeping it in the same poll loop means there's a single in-flight guard, so a config reload can never race the diff reload.
  • On any change (input or config) it reuses 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/--mode flag gets silently clobbered by config).

Only active in --watch mode, so default one-shot reviews are unchanged.

Testing

  • bun run format:check
  • bun run lint
  • bun run typecheck
  • bun run test:theme-contrast
  • bun test src/core/watch.test.ts — added unit coverage for computeConfigSignature (missing global config, change detection, repo-local .hunk/config.toml pickup)
  • Real render smoke test: ran hunk diff --watch against 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.

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

greptile-apps Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

PR author is not in the allowed authors list.

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