Keep OpenCode sessions alive during theme changes - #7502
Conversation
There was a problem hiding this comment.
Copilot wasn't able to review any files in this pull request.
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
Been running locally since this PR was made. Works well. |
Theme switching no longer runs this command, so `omarchy restart opencode` was advertising itself under a job it no longer does. It stays as the manual configuration reload it now is. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Redirections are applied left to right, so `>"$tty" 2>/dev/null` sends the failed open to the caller's stderr before the discard takes effect. A pts that disappears between readlink and the write then prints a bash error into whatever terminal ran the theme change. Discarding stderr first makes the guard the line already carries actually cover the open. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Co-Authored-By: Codex XHigh <noreply@openai.com>
|
Reviewed. The approach holds up and the mechanism does what the description claims — two small fixes pushed to the branch, one thing left that is your call. What was checked. Read the diff and the surrounding theme-set path, ran The refresh mechanism. OpenCode's Mid-request sessions. No signal is sent at all now, so nothing disposes an instance mid-generation. The concurrent write from Leaked sessions. None. Pushed to the branch:
Still open, low, and yours to decide. The Related. #8004, #8264 and #8684 all cover this ground, and #8264 and #8684 add a file at the same path, Reviewed by Claude Opus 5 in Claude Code with a second opinion from Codex at xhigh reasoning. Codex agreed on the stale summary, which had already been written down here, so that agreement is worth less than it looks — its read scope is not currently confined, so its independence is not guaranteed. The redirection-ordering defect is its own find, and it is credited on that commit. |
Why
Omarchy sends
SIGUSR2to every running OpenCode process after a theme change. OpenCode uses this signal to reload its configuration. The reload disposes active instances, which can stop model requests and tool calls.What changed
omarchy-restart-opencodeduring theme changes.omarchy-theme-set-opencode.systemtheme without reloading its worker.omarchy-restart-opencodeavailable for manual configuration reloads.Existing Alacritty, Kitty, Ghostty, Foot, and tmux theme paths remain unchanged.
Tests
./test/clibash -n bin/omarchy-theme-set bin/omarchy-theme-set-opencode bin/omarchy-theme-osc bin/omarchy-theme-set-foot