mirror of
https://github.com/anomalyco/opentui.git
synced 2026-04-24 20:45:56 +03:00
[PR #654] [CLOSED] feat(renderer): add Mode 2031 dark/light theme detection #687
Labels
No labels
bug
core
documentation
feature
good first issue
help wanted
pull-request
question
react
solid
tmux
windows
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/opentui#687
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/anomalyco/opentui/pull/654
Author: @kavhnr
Created: 2/9/2026
Status: ❌ Closed
Base:
main← Head:feat/mode-2031-theme-detection📝 Commits (2)
15225a2feat(renderer): add Mode 2031 dark/light theme detection1a34130refactor(terminal): move Mode 2031 setup/shutdown to terminal.zig📊 Changes
3 files changed (+39 additions, -2 deletions)
View changed files
📝
packages/core/src/renderer.ts(+24 -0)📝
packages/core/src/types.ts(+3 -0)📝
packages/core/src/zig/terminal.zig(+12 -2)📄 Description
ResponsiveTUI
https://github.com/user-attachments/assets/dd2351a8-0925-4228-8cf3-10579a61a741
Summary
Adds support for the Mode 2031 terminal protocol, enabling automatic dark/light theme detection and live reactivity to OS appearance changes.
What this does
CSI ? 2031 h) duringsetupTerminal()CSI ? 996 n) on startupCSI ? 997 ; 1 n(dark) /CSI ? 997 ; 2 n(light) responses via a newthemeModeHandlerin the input handler pipelinetheme_modeevent on the renderer when the mode changesthemeModegetter returning"dark" | "light" | nullCSI ? 2031 l) on destroy, before other cleanupThemeModetype fromtypes.tsSupported terminals
Unsupported terminals silently ignore the escape sequences — no fallback needed.
Usage
Design decisions
The implementation follows patterns established by Neovim (PR #31350) and Helix (PR #14356):
CSI ? 996 nqueryfinalizeDestroy()terminfo_stoppattern — prevents stale notifications to subsequent processeswriteOut()interceptStdoutWritewhich captures but doesn't forward to the terminalfocusHandler, before key handlernullChanges
packages/core/src/renderer.ts—_themeModeproperty,themeModeHandler, subscribe/unsubscribe lifecycle,themeModegetterpackages/core/src/types.ts—ThemeModetype,theme_modeevent inRendererEventsReferences
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.