fix(tui): defer named-theme palette detection - #48570
Merged
Merged
Conversation
rekram1-node
force-pushed
the
palette-fast-boot
branch
3 times, most recently
from
September 12, 2026 02:02
3de3a8a to
5abb912
Compare
Named themes do not depend on terminal palette colors, but startup waited for the shared system-theme palette request before marking the theme ready. Some terminals answer palette support without answering every color query, adding a roughly 300ms idle timeout before the useful frame. Keep palette detection on the critical path for the explicit system theme. For named themes, paint immediately and prepare the system palette after the first frame so later theme switching remains available. Compiled warm-server startup to Ask anything improves from 538ms to 215ms for the default opencode theme. Explicit system theme startup remains flat at 554ms to 546ms.
rekram1-node
force-pushed
the
palette-fast-boot
branch
from
September 12, 2026 02:05
5abb912 to
85fa267
Compare
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.
Summary
Terminal palette detection already starts before
ThemeProvidermounts. Previously, startup always waited for that request before making the selected theme ready—even when a named theme such asopencodedoes not use terminal palette colors.This keeps palette discovery exactly where it is and changes only what startup waits for:
systemtheme: wait for terminal colors, unchangedThe production diff is one five-line change in
ThemeProvider; there are no timers, new public APIs, or cross-component lifecycle coordination.Performance
Final formulation, 15 interleaved exact Bun 1.4.2 compiled runs through a non-backpressured PTY against the same warm server:
The result varies with machine/load, but consistently removes the terminal palette detector's roughly 300ms timeout from named-theme readiness.
A separate corrected 30-run benchmark confirmed explicit
systemis flat (prompt bytes 445.1ms before vs 446.7ms after).The PTY harness drains until
EAGAIN; a one-call 5,502-byte frame arrives in 0.112ms median, avoiding terminal-control recorder backpressure that affected early measurements.UX verification
opencodesystemsystemBaseline and changed binaries were also captured after settling at narrow width for default and system configurations; stable visual output matched aside from randomized placeholder text.
Verification
No new tests are added by this PR.