davsclaus commented on code in PR #24322:
URL: https://github.com/apache/camel/pull/24322#discussion_r3496838622
##########
dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/MonitorContext.java:
##########
@@ -43,7 +45,17 @@
*/
class MonitorContext {
Review Comment:
This changed from yellow-on-default text to a black-on-orange "chip" style —
a significant visual change to all key hints across the TUI. Since it's a
static constant rather than a `Theme` token, it stays the same in both light
and dark modes. Is that intentional, or should this also resolve through
`Theme` for full theme-awareness?
##########
dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/Theme.java:
##########
@@ -0,0 +1,303 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.dsl.jbang.core.commands.tui;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Optional;
+import java.util.Set;
+
+import dev.tamboui.css.Styleable;
+import dev.tamboui.css.engine.StyleEngine;
+import dev.tamboui.style.Color;
+import dev.tamboui.style.Style;
+import org.apache.camel.dsl.jbang.core.common.CommandLineHelper;
+import org.apache.camel.dsl.jbang.core.common.Printer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Central semantic theme for the Camel TUI. Call sites reference intent
(accent, border, success, ...) so the concrete
+ * palette lives in one place. Values are resolved from CSS stylesheets
({@code dark.tcss} / {@code light.tcss}) through
+ * a shared {@link StyleEngine}; the active stylesheet can be switched at
runtime and is persisted to user config.
+ * <p/>
+ * Palette policy: the brand accent is Camel orange (truecolor), reserved for
accent and borders. Status colors use ANSI
+ * names in dark mode (so they respect the terminal) and explicit darker hex
in light mode. If a stylesheet is missing
+ * or malformed, the facade falls back to the built-in palette below and logs
once, so a cosmetic failure never crashes
+ * the TUI.
+ */
+final class Theme {
+
+ /** Camel brand orange. */
+ static final Color ACCENT = Color.rgb(0xF6, 0x91, 0x23);
+
+ private static final Logger LOG = LoggerFactory.getLogger(Theme.class);
+
+ private static final String PROP_KEY = "camel.tui.theme";
+ private static final String DARK = "dark";
+ private static final String LIGHT = "light";
+
+ // Fallback palette mirrors the dark stylesheet, used when CSS is
unavailable.
+ private static final Style FALLBACK_ACCENT_BG =
Style.EMPTY.fg(Color.WHITE).bg(ACCENT).bold();
+ private static final Style FALLBACK_BORDER =
Style.EMPTY.fg(Color.DARK_GRAY);
+ private static final Style FALLBACK_BORDER_FOCUSED =
Style.EMPTY.fg(ACCENT);
+ private static final Style FALLBACK_TITLE = Style.EMPTY.fg(ACCENT).bold();
+ private static final Style FALLBACK_SUCCESS =
Style.EMPTY.fg(Color.LIGHT_GREEN);
+ private static final Style FALLBACK_WARNING =
Style.EMPTY.fg(Color.LIGHT_YELLOW);
+ private static final Style FALLBACK_ERROR =
Style.EMPTY.fg(Color.LIGHT_RED);
+ private static final Style FALLBACK_MUTED = Style.EMPTY.dim();
+ private static final Style FALLBACK_SELECTION =
Style.EMPTY.fg(Color.WHITE).bold().onBlue();
+ private static final Style FALLBACK_INFO = Style.EMPTY.fg(Color.CYAN);
+ private static final Style FALLBACK_NOTICE = Style.EMPTY.fg(Color.MAGENTA);
+ private static final Style FALLBACK_MCP_ACTIVE =
Style.EMPTY.fg(Color.LIGHT_GREEN);
+ private static final Style FALLBACK_MCP_IDLE =
Style.EMPTY.fg(Color.DARK_GRAY);
+ private static final Style FALLBACK_MCP_DOWN =
Style.EMPTY.fg(Color.LIGHT_RED);
+ private static final Color FALLBACK_ZEBRA = Color.rgb(0x1C, 0x1C, 0x1C);
+
+ private static final Map<String, Style> CACHE = new HashMap<>();
+
+ private static boolean initialized;
+ private static boolean fallbackLogged;
+ private static StyleEngine engine;
+ private static String mode = DARK;
+
+ private Theme() {
+ }
+
+ static Color accent() {
+ StyleEngine e = engine();
+ if (e == null) {
+ return ACCENT;
+ }
+ try {
+ return e.resolve(new Token("accent")).foreground().orElse(ACCENT);
Review Comment:
Good resilience pattern — the `logFallbackOnce` guard ensures a cosmetic
failure (missing/malformed stylesheet) never spams logs or crashes the TUI. The
built-in fallback palette mirroring the dark theme is the right default.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]