CAMEL-23830: camel-jbang - Make TUI shell ANSI colors readable on dark terminals#24237
Merged
davsclaus merged 1 commit intoJun 25, 2026
Merged
Conversation
…k terminals In the embedded shell panel, ANSI-colored output rendered as a dim literal RGB value that was hard to read on dark terminal themes. For example the command highlighter (which colors unrecognized commands red) and error messages such as "Unknown command" came out as RGB(136,0,0). JLine's ScreenTerminal flattens named ANSI colors into a 12-bit (4-bit-per-channel) value in the cell attribute, and convertAttrToStyle expanded that straight back to a literal RGB color, bypassing the host terminal theme. Detect when the 12-bit value matches one of the 16 standard ANSI palette colors and emit a terminal-themed Color.ansi(...) instead, mirroring how TuiHelper.applySgr already maps SGR codes. True-color cells (such as the orange shell prompt, 0xF69123) do not match the palette and keep their literal RGB value. The encodings are JLine's xterm palette reduced to the top nibble of each channel (ScreenTerminal.col24), and are covered by unit tests including a regression guard that ANSI red resolves to a themed color rather than the old dim RGB. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Contributor
|
🌟 Thank you for your contribution to the Apache Camel project! 🌟 🐫 Apache Camel Committers, please review the following items:
|
Contributor
|
🧪 CI tested the following changed modules:
All tested modules (2 modules)
|
davsclaus
approved these changes
Jun 24, 2026
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.
Description
Makes ANSI-colored output in the embedded shell panel of the Camel TUI readable on dark terminal themes (see CAMEL-23830).
Problem
In the shell panel, text echoed while typing a command (the command highlighter colors unrecognized commands red) and error output such as
Unknown command: xrendered as a dim literalRGB(136,0,0), barely legible on a dark background. The prompt itself was fine (camelorange, version green,>white).Root cause
JLine's
ScreenTerminalflattens named ANSI colors into a 12-bit (4-bit-per-channel) value stored in the cell attribute.ShellPanel.convertAttrToStyleexpanded that value straight back into a literal RGB color, bypassing the host terminal's theme. Standard ANSI red (palette index 1,0x800000) therefore became a fixed dimRGB(136,0,0)instead of the terminal's themed, readable red.Fix
When the 12-bit value matches one of the 16 standard ANSI palette colors, emit a terminal-themed
Color.ansi(AnsiColor.X)instead of a literal RGB color, mirroring howTuiHelper.applySgralready maps SGR codes elsewhere in the TUI. True-color cells (such as the prompt's orange0xF69123) do not match the palette and keep their literal RGB value.The 16 encodings are derived from JLine's xterm palette (
Colors.DEFAULT_COLORS_256[0..15]) reduced viaScreenTerminal.col24(the top nibble of each channel), e.g. red0x800000->0x800, bright red0xff0000->0xf00, white0xc0c0c0->0xccc.Tests
ShellPanelColorTest: pins all 16 ANSI encodings to theirAnsiColor, asserts true-color values (e.g. the prompt orange0xf92) stay unmapped, and includes a regression guard that ANSI red resolves to a themedColor.ansi(RED)rather than the old dim RGB.Docs
camel-jbang-tui.adochas no shell-panel section, and this is a readability fix with no change to any default, option, or API, so it does not warrant an upgrade-guide entry.Target
mainbranch)Tracking
Apache Camel coding standards and style
mvn clean install -DskipTestslocally from root folder and I have committed all auto-generated changes.Submitted by Claude Code on behalf of Adriano Machado.