Theme change interrupts/kills running opencode sessions (omarchy-restart-opencode broadcasts SIGUSR2)
Title
Theme change interrupts/kills running opencode sessions (omarchy-restart-opencode broadcasts SIGUSR2)
Body
Summary
Every omarchy theme set <name> runs omarchy-restart-opencode, which does a blanket
killall -SIGUSR2 opencode across all opencode processes. Any opencode process without a
SIGUSR2 handler terminates (default signal disposition), and even interactive TUI sessions
take a forced config reload that aborts in-flight generation. Changing theme while opencode
is working interrupts it — unlike Claude Code on the same system, which omarchy retints
passively via a watched file.
System details
- Omarchy: 4.0.0.r1816.g43bfe9b-1
- Kernel: 7.1.9-arch1-2
- CPU: 12th Gen Intel(R) Core(TM) i5-12450HX
- GPU: Intel Alder Lake-S UHD Graphics
- opencode: 1.18.21 (via mise)
Version
Omarchy 4.0.0.r1816.g43bfe9b-1 (Arch Linux, Hyprland)
Root cause
bin/omarchy-theme-setincludesomarchy-restart-opencodeinpost_theme_commandsand runs it on every theme apply.bin/omarchy-restart-opencode=pgrep -x opencode && killall -SIGUSR2 opencode.- In opencode (verified against v1.18.x binaries), only the interactive TUI registers
SIGUSR2 handlers (config reload + rescan of
~/.config/opencode/themes/*.json). Headless processes —opencode run, servers, spawned agents — have no handler and are killed by the default disposition. - Notably, omarchy ships no generated theme artifact for opencode at all (no opencode
template under
default/themed/, nothing in stock themes). So the signal delivers no Omarchy colors; unless a user maintains their own~/.config/opencode/themes/*.json, this call has no upside and only interrupts running work.
Reproduction
- Start a task that takes a while:
opencode run "Write the numbers from 1 to 80, one per line" - While it is mid-run, from another terminal:
omarchy theme set <any-theme> - The run dies immediately.
Targeted-signal confirmation of what the broadcast does:
$ opencode run "Write the numbers from 1 to 80, one per line" &
$ kill -USR2 <pid> # exactly what omarchy-restart-opencode does
User defined signal 2 exit code 140 (128+SIGUSR2), task produced nothing
Interactive TUI sessions survive the signal itself but get their active generation interrupted by the forced server reload.
For comparison: omarchy-theme-set-claude writes ~/.claude/themes/omarchy.json, which
Claude Code hot-reloads by file watch — running sessions retint without any signal.
Codex isn't signaled at all. Only opencode gets the kill-the-process treatment.
Expected
Changing themes should not terminate or disrupt running coding-agent sessions.
Suggested fix
Drop omarchy-restart-opencode from post_theme_commands in bin/omarchy-theme-set.
Since omarchy generates no opencode theme data today, removing it changes no visual
behavior. If opencode integration is wanted later, the Claude pattern is the model:
generate a theme file opencode can pick up passively rather than signaling processes.
Notes
- PR #4566 touched this same script but only silenced the "no process found" error.
- Local stopgap for affected users: shadow
omarchy-restart-opencodewith a no-op earlier in PATH (e.g. via a prepended dir in~/.bash_profile, sincepost_theme_commandsrun throughbash -lc).
Attachments
- Full repro transcript and exit codes available on request (captured locally).
Confirmed on quattro and reproduced on a fresh Omarchy worker with opencode 1.18.35. Running the stock omarchy-restart-opencode killed a running opencode serve with exit 140. An interactive TUI survived, but its log recorded "disposing all instances", the step that aborts in-flight tool calls in #8389.
This has two separate causes in opencode's source:
- Headless processes die. Plain
opencode runandopencode serveregister no SIGUSR2 handler, so the broadcast terminates them. - The TUI aborts work. Its handler does two things. It re-reads the terminal palette, which Omarchy relies on:
config/opencode/opencode.jsonsets"theme": "system", so the signal does recolour the TUI, contrary to the report. It also calls the worker'sreload, which disposes every instance and cancels running sessions.
#14640 fixes the first: it signals only opencode processes whose /proc/<pid>/status shows a SIGUSR2 handler. On the worker, opencode serve survived a theme change with it, and the TUI still received the signal. ./test/cli and the theme-set shell tests pass on the worker.
It does not fix the second. Omarchy can't get the retint without the reload until opencode separates the two upstream. Dropping the call entirely would stop the interruptions and lose the live retint. That trade-off is the maintainer's call, so this issue stays open.
Reviewed by Claude Opus 5.5 and, as a second opinion, Codex at medium effort. It agreed with the mechanism; independence is not guaranteed. It added that --mini and attach handle the signal without the destructive reload, and it favours removing the call outright. Waiting on the maintainer.