feat: add theme hot-reload functionality #4879
Open
+190
−66
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Adds the ability to reload themes without restarting opencode. Provides multiple reload triggers to support different workflows:
/reload-themecommandAlso makes "system" theme background transparent to support terminal opacity.
Changes
Architecture
flowchart LR subgraph Triggers A[Command] B[File change] C[Resize] D[Signal] end A & B & C & D --> E[reloadTheme] E --> F[Re-query colors] F --> G[Update store] G --> H[UI re-renders]Key Decisions
Why move
getTerminalBackgroundColorto theme.tsx?Needed by both initial detection (app.tsx) and reload (theme.tsx). Moving it eliminates duplication.
Why
fs.watch()instead of@parcel/watcher?Simpler API, no extra dependencies, sufficient for watching 2 files.
Why transparent background for "system" theme?
Allows terminal opacity/blur to show through while keeping panel/menu backgrounds solid.
Why SIGWINCH handler?
Event-driven color re-detection without polling. Only active for "system" theme.
Testing
Checklist
Fixes #815