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.

@greptile-apps

greptile-apps Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

PR author is not in the allowed authors list.

@benvinegar

Copy link
Copy Markdown
Member

I wonder if it should just do this always? Vs --watch

Precedent seems to be VS Code, Cursor, etc. Those all basically apply their settings immediately, right?

@eduwass

eduwass commented Jun 29, 2026

Copy link
Copy Markdown
Contributor Author

Hey @benvinegar yeah good point. VSCode/Cursor would update automatically, probably what we'd want here too.

Always poll Hunk's config files (global ~/.config/hunk/config.toml and
repo-local .hunk/config.toml) and reload on change — no --watch required,
the way VS Code / Cursor apply settings on save. In --watch mode the same
loop additionally tracks the diff input, folded together so a single
in-flight guard serializes reloads and a config reload can never race the
diff reload. Reloads reuse refreshCurrentInput so config is re-read —
repainting theme/chrome palette edits live — while preserving the active
view options (and any CLI overrides).
@eduwass eduwass force-pushed the feat/live-config-reload branch from b435f0a to d148a01 Compare June 29, 2026 22:28
@eduwass

eduwass commented Jun 29, 2026

Copy link
Copy Markdown
Contributor Author

@benvinegar made it always-on now, no --watch required. The viewer always polls the config files (global + repo-local) and live-reloads theme/chrome on change, the way VS Code / Cursor apply settings on save.

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.

2 participants