Skip to content

Always use aixterm bright color codes for bright colors - #42

Merged
alexey-milovidov merged 1 commit into
ClickHouse:masterfrom
sdairs:fix-bright-colors-term-detection
Jul 7, 2026
Merged

alexey-milovidov merged 1 commit into
ClickHouse:masterfrom
sdairs:fix-bright-colors-term-detection

Conversation

@sdairs

@sdairs sdairs commented Jul 7, 2026 •

Copy link
Copy Markdown

Bright foreground colors (GRAY through WHITE, codes 8-15) were emitted as aixterm bright color codes (90-97) only when TERM contained the substring "256", falling back to bold + dark color (e.g. \e[0;1;30m for GRAY) otherwise.

The check is misguided: codes 90-97 belong to the basic 16-color set and are unrelated to 256-color support. Meanwhile the fallback breaks on terminals with TERM values like xterm-ghostty, xterm-kitty, alacritty or foot, because modern terminals do not render bold as bright by default: GRAY (bold black) degrades to plain black. In ClickHouse this makes the as-you-type autocompletion hints, which default to GRAY, unreadable on dark backgrounds in Ghostty (while the same build looks fine under TERM=xterm-256color).

This change emits the bright color codes unconditionally.

Verified by linking ansi_color into a small harness with TERM=xterm-ghostty:

Color Before After
GRAY \e[0;1;30m (bold black) \e[0;90m (bright black)
BRIGHTRED \e[0;1;31m \e[0;91m
WHITE \e[0;1;37m \e[0;97m
RED \e[0;22;31m \e[0;22;31m (unchanged)
DEFAULT \e[0m \e[0m (unchanged)

🤖 Generated with Claude Code

Backward compatibility

  • No change for TERM values containing "256" (e.g. xterm-256color, the default on desktop Linux terminals since ~2010) — they already received codes 90-97.
  • Codes 90-97 are the aixterm extension of the basic 16-color set, supported for decades by xterm (since the late 1990s), PuTTY, rxvt, GNU screen, tmux, Konsole and all VTE-based terminals.
  • Terminals that do not implement 90-97 (e.g. the physical Linux console on kernels before ~4.17, monochrome hardware terminals) ignore the unrecognized SGR parameter per ECMA-48; the leading 0 in \e[0;9Xm still resets attributes, so text renders in the default foreground — readable, merely uncolored. The failure mode of the old code was worse: bold black rendered as invisible text on dark backgrounds.
  • Only interactive TTY rendering is affected: replxx checks is_a_tty before emitting attributes, so piped output never contains these sequences.
  • replxx does not consult terminfo; all of its escape sequences (dark colors, cursor movement, \e[J) are hardcoded ANSI, so this change stays within the library's existing ECMA-48 assumption.

Bright foreground colors (GRAY through WHITE, codes 8-15) were emitted
as aixterm bright color codes (90-97) only when TERM contained the
substring "256", falling back to bold + dark color (e.g. "\e[0;1;30m"
for GRAY) otherwise.

The check is misguided: codes 90-97 belong to the basic 16-color set
and are unrelated to 256-color support. Meanwhile the fallback breaks
on terminals with TERM values like xterm-ghostty, xterm-kitty,
alacritty or foot, because modern terminals do not render bold as
bright by default: GRAY (bold black) degrades to plain black. In
ClickHouse this made the as-you-type autocompletion hints, which
default to GRAY, unreadable on dark backgrounds in Ghostty.

Emit the bright color codes unconditionally, and update the
regression-test escape-sequence mapping accordingly.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@sdairs
sdairs force-pushed the fix-bright-colors-term-detection branch from 2da04e9 to 93b667e Compare July 7, 2026 10:30
@alexey-milovidov alexey-milovidov self-assigned this Jul 7, 2026
@alexey-milovidov
alexey-milovidov merged commit c2de583 into ClickHouse:master Jul 7, 2026
1 check passed
@sdairs
sdairs deleted the fix-bright-colors-term-detection branch July 7, 2026 11:58
huldarchen pushed a commit to huldarchen/ClickHouse that referenced this pull request Jul 20, 2026
Pulls in ClickHouse/replxx#42: bright foreground colors (GRAY through
WHITE) were emitted as aixterm bright color codes (90-97) only when
TERM contained the substring "256", falling back to bold + dark color
otherwise. Modern terminals do not render bold as bright by default,
so on terminals with TERM values like xterm-ghostty, xterm-kitty,
alacritty or foot the as-you-type autocompletion hints (GRAY, i.e.
bold black under the fallback) were unreadable on dark backgrounds.

Related: ClickHouse/replxx#42

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
zeekay pushed a commit to hanzoai/datastore that referenced this pull request Sep 11, 2026
Pulls in ClickHouse/replxx#42: bright foreground colors (GRAY through
WHITE) were emitted as aixterm bright color codes (90-97) only when
TERM contained the substring "256", falling back to bold + dark color
otherwise. Modern terminals do not render bold as bright by default,
so on terminals with TERM values like xterm-ghostty, xterm-kitty,
alacritty or foot the as-you-type autocompletion hints (GRAY, i.e.
bold black under the fallback) were unreadable on dark backgrounds.

Related: ClickHouse/replxx#42

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants