feat(tui): add Mode 2031 theme detection with tri-state appearance mode#13233
feat(tui): add Mode 2031 theme detection with tri-state appearance mode#13233kavhnr wants to merge 2 commits intoanomalyco:devfrom
Conversation
|
The following comment was made by an LLM, it may be inaccurate: Based on the search results, I found 3 related PRs that address similar appearance/theme functionality:
Note: The current PR (#13233) explicitly compares itself against these older approaches, explaining why Mode 2031 is superior (event-driven vs. polling/platform-specific). These appear to be alternative/prior attempts at the same feature rather than exact duplicates. If any of these are still open, they may need to be closed in favor of this Mode 2031 implementation. |
|
@kavhnr any reason you closed this? I think this approach is more elegant than the polling approach explored by some other PRs? |
|
@mitchelljphayes our org (I think anyone using foundry/gotham) flagged opencode as not approved from some weird behavior on our VMs, so I ended up removing opencode and this PR to finish the clean up. Plus, this didn’t seem like a priority and would likely be stale by the time it’s reviewed and I didn’t want to add noise to an already busy team. |
What does this PR do?
Closes #13232
OpenTUI v0.1.78 added Mode 2031 dark/light theme detection (opentui#657). OpenCode is already on v0.1.79 (#13036) which includes these APIs, but doesn't use them. This PR integrates
renderer.themeMode/renderer.on("theme_mode", ...)into OpenCode's theme system.Three changes:
auto/dark/light) — replaces the binary toggle.autofollows OS via Mode 2031, falling back to OSC 11 luminance on unsupported terminals.dark/lightare manual overrides."theme": { "light": "github", "dark": "catppuccin" }alongside existing"theme": "opencode"(backward compatible).Mode 2031 is the same approach used by Neovim and Helix. Event-driven, zero overhead. Unsupported terminals silently ignore the sequences — no degradation.
Why Mode 2031 over the approaches in existing open PRs:
execSync("defaults read")/gsettingsevery 3sEdge cases handled:
detectedModestays at initial OSC 11 value. No degradation.activeThemeMode()falls back to"dark". Existing custom themes work identically.onCleanup(() => renderer.off("theme_mode", ...))prevents leaks.How did you verify your code works?
bun run typecheckpasses (12/12 packages, zero errors)"theme": "opencode"works,"theme": { "light": "github", "dark": "catppuccin" }worksauraandayu(single-palette) unaffected by mode changesDemo
mode-2031-theme-detection.mp4