feat(tui): add Mode 2031 theme detection with tri-state appearance mode#15089
Open
kavhnr wants to merge 1 commit intoanomalyco:devfrom
Open
feat(tui): add Mode 2031 theme detection with tri-state appearance mode#15089kavhnr wants to merge 1 commit intoanomalyco:devfrom
kavhnr wants to merge 1 commit intoanomalyco:devfrom
Conversation
1c78a6c to
daa9a8a
Compare
Contributor
Author
|
@RhysSullivan this is similar to your PR#7162 so might be up your ally to review/hopefully merge for people that use different modes. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
mode-2031-theme-detection.mp4
Issue for this PR
Closes #13232
Supersedes #13233 (closed to rebase on current
dev).Type of change
What does this PR do?
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 (16/16 packages, zero errors)"theme": "opencode"works,"theme": { "light": "github", "dark": "catppuccin" }worksauraandayu(single-palette) unaffected by mode changesChecklist