refactor(console): phase 2 — channel-as-semantic key; decouple executor from UI colors

Make ConsoleChannel the canonical semantic classification of every console
line. Producers (command executor, app log forwarders, result formatter) tag
each line with a channel; the UI derives both the text color and the left
accent-bar color from it at draw time, and the output filter keys off it.

This replaces the prior scheme of storing an ImU32 color per line and then
reverse-engineering the source from color-equality plus a "[daemon] "/"[xmrig] "
/"[app] "/"[rpc] " text prefix. Consequences:

- ConsoleLine now stores {text, ConsoleChannel} — no per-line color.
- addLine()/addRpcTraceLine() take a channel; the redundant text prefixes are
  gone (the accent bar carries the origin).
- The executor's ConsoleAddLineFn hands a channel, not an ImU32, so the backend
  no longer depends on ConsoleTab::COLOR_* — FullNode/Lite executors emit clean
  text + channel.
- The theme-remap loop that rewrote stored colors on light/dark flip is deleted;
  colors are resolved per-channel each frame (refreshColors on flip only).
- ConsoleOutputFilter drops its color fields; consoleLinePassesFilter() keys off
  the channel. Test updated to the channel-based API.
- Added a Warning channel (amber severity peer of Error/Success) so the
  notification + logger warning forwarders keep their color.

Full-node + lite build clean; ctest green; source hygiene clean.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-07-01 18:22:35 -05:00
parent 19e83eb12a
commit 33735b1d52
9 changed files with 219 additions and 175 deletions

View File

@@ -4,6 +4,7 @@
#pragma once
#include "console_channel.h"
#include "console_text_layout.h"
#include "../layout.h"
#include "../../daemon/embedded_daemon.h"
@@ -46,7 +47,7 @@ public:
/**
* @brief Add a line to the console output
*/
void addLine(const std::string& line, ImU32 color = IM_COL32(200, 200, 200, 255));
void addLine(const std::string& line, ConsoleChannel channel = ConsoleChannel::None);
void addRpcTraceLine(const std::string& source, const std::string& method);
/**
@@ -84,17 +85,17 @@ public:
static ImU32 COLOR_RPC;
private:
// Line source, for the left-edge channel accent bar. Inferred in addLine() from the
// color + any "[daemon]"/"[xmrig]"/"[app]" prefix (which is then stripped).
enum Channel { CH_NONE = 0, CH_COMMAND, CH_INFO, CH_ERROR, CH_RPC, CH_DAEMON, CH_XMRIG, CH_APP };
// Each line stores its semantic ConsoleChannel; the text color and left accent-bar
// color are both derived from it at draw time (channelTextColor / channelBarColor).
struct ConsoleLine {
std::string text;
ImU32 color;
int channel = CH_NONE;
std::string text;
ConsoleChannel channel = ConsoleChannel::None;
};
// Format + color a completed command result (JSON-aware) into console lines.
// Text color for a channel, resolved from the current theme (COLOR_* + material).
ImU32 channelTextColor(ConsoleChannel channel) const;
// Format a completed command result (JSON role -> channel) into console lines.
void addFormattedResult(const std::string& result, bool is_error);
void renderStatusHeader(ConsoleCommandExecutor& exec);
void renderToolbar(ConsoleCommandExecutor& exec);