Skip to content

CAMEL-23830: camel-jbang - Make TUI shell ANSI colors readable on dark terminals#24237

Merged
davsclaus merged 1 commit into
apache:mainfrom
ammachado:CAMEL-23830-tui-shell-readable-colors
Jun 25, 2026
Merged

CAMEL-23830: camel-jbang - Make TUI shell ANSI colors readable on dark terminals#24237
davsclaus merged 1 commit into
apache:mainfrom
ammachado:CAMEL-23830-tui-shell-readable-colors

Conversation

@ammachado

@ammachado ammachado commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

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: x rendered as a dim literal RGB(136,0,0), barely legible on a dark background. The prompt itself was fine (camel orange, version green, > white).

Screenshot 2026-06-24 at 2 53 50 PM

Root cause

JLine's ScreenTerminal flattens named ANSI colors into a 12-bit (4-bit-per-channel) value stored in the cell attribute. ShellPanel.convertAttrToStyle expanded 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 dim RGB(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 how TuiHelper.applySgr already maps SGR codes elsewhere in the TUI. True-color cells (such as the prompt's orange 0xF69123) 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 via ScreenTerminal.col24 (the top nibble of each channel), e.g. red 0x800000 -> 0x800, bright red 0xff0000 -> 0xf00, white 0xc0c0c0 -> 0xccc.

Tests

  • New ShellPanelColorTest: pins all 16 ANSI encodings to their AnsiColor, asserts true-color values (e.g. the prompt orange 0xf92) stay unmapped, and includes a regression guard that ANSI red resolves to a themed Color.ansi(RED) rather than the old dim RGB.

Docs

  • No documentation change: camel-jbang-tui.adoc has 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

  • I checked that the commit is targeting the correct branch (Camel 4 uses the main branch)

Tracking

  • If this is a large change, bug fix, or code improvement, I checked there is a JIRA issue filed for the change (usually before you start working on it).

Apache Camel coding standards and style

  • I checked that each commit in the pull request has a meaningful subject line and body.
  • I have run mvn clean install -DskipTests locally from root folder and I have committed all auto-generated changes.

Submitted by Claude Code on behalf of Adriano Machado.

…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>
@github-actions github-actions Bot added the dsl label Jun 24, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🌟 Thank you for your contribution to the Apache Camel project! 🌟
🤖 CI automation will test this PR automatically.

🐫 Apache Camel Committers, please review the following items:

  • First-time contributors require MANUAL approval for the GitHub Actions to run
  • You can use the command /component-test (camel-)component-name1 (camel-)component-name2.. to request a test from the test bot although they are normally detected and executed by CI.
  • You can label PRs using skip-tests and test-dependents to fine-tune the checks executed by this PR.
  • Build and test logs are available in the summary page. Only Apache Camel committers have access to the summary.

⚠️ Be careful when sharing logs. Review their contents before sharing them publicly.

@github-actions

Copy link
Copy Markdown
Contributor

🧪 CI tested the following changed modules:

  • dsl/camel-jbang/camel-jbang-plugin-tui
All tested modules (2 modules)
  • Camel :: JBang :: Plugin :: TUI
  • Camel :: Launcher :: Container

⚙️ View full build and test results

@ammachado ammachado marked this pull request as ready for review June 24, 2026 18:57
@davsclaus davsclaus merged commit 9730682 into apache:main Jun 25, 2026
5 checks passed
@ammachado ammachado deleted the CAMEL-23830-tui-shell-readable-colors branch June 25, 2026 04:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants