Repository navigation
feat(theme): add a default terminal theme that follows terminal colors - #1128
Conversation
Probe the terminal's foreground, background, and 16-color ANSI palette at startup and derive a `terminal` theme from them for diffs, chrome, and syntax highlighting. Make it the default theme. Keep following the terminal while Hunk runs: re-probe on mode 2031 color-scheme notifications (Ghostty, kitty, herdr) and on SIGWINCH (what tmux-aware theme tools send after rewriting pane colors), and repaint when the palette changed. Sessions launched with an explicit theme probe once after startup so switching to `terminal` shows the real palette. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
PR author is not in the allowed authors list. |
|
@dhh is attempting to deploy a commit to the Modem Team on Vercel. A member of the Team first needs to authorize it. |
benvinegar
left a comment
There was a problem hiding this comment.
Reviewed the startup OSC probe, terminal palette derivation and fallback, OpenTUI watcher lifecycle, controller/selector repaint path, syntax-theme replacement, docs, and compatibility updates. I did not find a blocking correctness issue.
Validation: bun run test, bun run typecheck, bun run lint, bun run deps:check, bun run check:docs, and the changed-file format check pass. bun run test:integration had one unrelated watch-start process-cleanup failure; that test passed immediately when rerun alone.
Non-blocking: the scripted palette-switch PTY scenario described in the PR body would be valuable as a checked-in regression test; the current watcher coverage mocks the renderer boundary.
This comment was generated by Pi using gpt-5.6-sol
Posted in error; no review was requested to be submitted.
|
Thanks! I tried this on my desktop Omarchy (by switching through some themes) and it looked pretty nice As a follow-up I'd love to have hunk detect the theme switch somehow (vs having to restart today) |
|
It'll do the update in Omarchy when it gets SIGWINCH. We'll get that setup on our side. |
|
Follow-up on the Omarchy side: omacom/omarchy#13518 adds 🤖 Generated with Claude Code |
Problem
Every built-in theme paints Hunk with a fixed editor color scheme, so Hunk never matches the terminal it runs in. On setups where the terminal theme changes (Omarchy theme switching, light/dark toggles, herdr/tmux theme sync) Hunk also can't follow along without a restart.
What this does
New
terminaltheme, now the default. At startup Hunk queries the terminal's foreground, background, and 16-color ANSI palette (OSC 10/11/4) and derives the whole theme from them:syntaxScopesReplaceBase) so no bundled editor palette leaks throughThe probe ends with a DA1 query as a sentinel, so responsive terminals finish immediately instead of waiting out the timeout.
autokeeps meaning GitHub light/dark, explicit themes are unchanged, andterminalis reserved from custom-theme ids.Live refresh.
HunkSessionHostruns a watcher that re-probes through OpenTUI's renderer-ownedgetPalette()and republishes throughThemeControllerwhen the colors changed:CSI ? 997 ; n n), which OpenTUI already opts into and Ghostty/kitty/herdr send; the handler leaves the sequence for OpenTUI's own light/dark trackingSIGWINCH, which tmux-aware theme tools send after rewriting pane colors (OpenTUI skips its resize path when the size is unchanged)terminallater shows the real paletteOpenTUI only clears its palette cache on a light↔dark flip, so the watcher clears it before each probe to catch dark→dark switches. Probes are debounced, and only changed reports repaint.
Tradeoffs
documentWorkerEligibilityrule), which now applies to the default theme on very large diffs.SIGWINCHalso fires on ordinary resizes; those cost one palette query and repaint nothing.Verification
bun run typecheck,lint,format:check,deps:check,check:docsbun run test: passes exceptJujutsu source reading > logs unexpected source failures…, which fails identically onmainlocallybun run test:integration: passes. PTY tests that assert exact GitHub hex colors now pin--theme github-dark-default; tests that assert the default id or selector order now expectterminal.997notification arrives, repaints entirely in palette B.Not yet verified by hand in a real terminal session across an actual theme switch.
🤖 Generated with Claude Code