[PR #7162] fix: auto-detect system theme changes at runtime #12281

Open
opened 2026-02-16 18:17:12 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/7162

State: open
Merged: No


Another option other than polling is on focus if we want to do that instead, opus got this one to work but fair note it's AI generated and I'm not familiar enough with the render to know for accuracy atm - I can investigate this more deeply if needed

https://github.com/user-attachments/assets/ef0a9617-3147-4d46-90ba-4b94d9a5b99f

==== AI Generated Below ===

Summary

  • Polls terminal background color every 5 seconds to detect system theme changes
  • Updates theme mode (dark/light) automatically when terminal colors change
  • Works for both system theme and named themes with dark/light variants (like opencode)

Changes

  • Added detectMode() helper to calculate dark/light from terminal background color
  • Added polling interval that re-queries terminal palette and updates mode when changed
  • Updated resolveSystemTheme() to detect and apply the correct mode

Testing

  1. Set theme to opencode (or any theme with dark/light variants)
  2. Change system/terminal theme from light to dark (or vice versa)
  3. Wait ~5 seconds - opencode should automatically switch to match
**Original Pull Request:** https://github.com/anomalyco/opencode/pull/7162 **State:** open **Merged:** No --- Another option other than polling is on focus if we want to do that instead, opus got this one to work but fair note it's AI generated and I'm not familiar enough with the render to know for accuracy atm - I can investigate this more deeply if needed https://github.com/user-attachments/assets/ef0a9617-3147-4d46-90ba-4b94d9a5b99f ==== AI Generated Below === ## Summary - Polls terminal background color every 5 seconds to detect system theme changes - Updates theme mode (dark/light) automatically when terminal colors change - Works for both `system` theme and named themes with dark/light variants (like `opencode`) ## Changes - Added `detectMode()` helper to calculate dark/light from terminal background color - Added polling interval that re-queries terminal palette and updates mode when changed - Updated `resolveSystemTheme()` to detect and apply the correct mode ## Testing 1. Set theme to `opencode` (or any theme with dark/light variants) 2. Change system/terminal theme from light to dark (or vice versa) 3. Wait ~5 seconds - opencode should automatically switch to match
yindo added the pull-request label 2026-02-16 18:17:12 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#12281