feat(console): persist accent toggle + add monochrome-text toggle

Persist the two console output display preferences and add a second toolbar
toggle for monochrome text.

- Persistence: new Settings fields console_line_accents / console_text_color
  (both default true, matching the ConsoleTab statics so an upgrade re-save
  can't flip visible behavior). Restored into the statics at startup in the App
  constructor, and saved from a diff-and-save after the console renders (only
  when a value actually changed — save() is disk I/O). The startup restore also
  fixes a pre-existing bug: scanline was only synced from settings when the
  Settings page or first-run wizard ran, so an existing wallet ignored a saved
  scanline preference on launch.
- Monochrome text: a new toolbar toggle (FORMAT_COLOR_TEXT, dimmed when off)
  next to the accent toggle. channelTextColor() early-returns the neutral
  COLOR_RESULT for every channel (and JSON syntax role) when off, leaving the
  left accent bars independent. COLOR_RESULT is contrast-floored per theme, so
  text stays readable on light and dark terminals.

Adds console_toggle_text_color to the English source + all 8 translations.
Verified: both toggles independent, persistence round-trips across restart,
monochrome readable on light + dark skins.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-07-12 16:26:44 -05:00
parent d156dddcd0
commit c40c252c9a
14 changed files with 60 additions and 0 deletions

View File

@@ -307,6 +307,13 @@ bool App::init()
// Apply verbose logging preference from saved settings
util::Logger::instance().setVerbose(settings_->getVerboseLogging());
// Restore console display preferences into the ConsoleTab statics at startup. These are the only
// startup restore for these toggles — the Settings page / first-run wizard also sync scanline, but
// only when visited, so without this an existing wallet would ignore a saved preference on launch.
ui::ConsoleTab::s_scanline_enabled = settings_->getScanlineEnabled();
ui::ConsoleTab::s_line_accents_enabled = settings_->getConsoleLineAccents();
ui::ConsoleTab::s_line_text_color_enabled = settings_->getConsoleTextColor();
// Apply saved user font scale so fonts are correct on first reload
{
float fs = settings_->getFontScale();
@@ -1786,6 +1793,17 @@ void App::render()
console_exec_ = std::make_unique<ui::FullNodeConsoleExecutor>(this);
}
console_tab_.render(*console_exec_);
// Persist the console toolbar toggles (ConsoleTab has no settings pointer). Save only when
// a value actually changed — this runs every frame the console is visible and save() is
// disk I/O — and only here in the Console case where these statics can change.
if (settings_) {
if (ui::ConsoleTab::s_line_accents_enabled != settings_->getConsoleLineAccents() ||
ui::ConsoleTab::s_line_text_color_enabled != settings_->getConsoleTextColor()) {
settings_->setConsoleLineAccents(ui::ConsoleTab::s_line_accents_enabled);
settings_->setConsoleTextColor(ui::ConsoleTab::s_line_text_color_enabled);
settings_->save();
}
}
break;
case ui::NavPage::Settings:
ui::RenderSettingsPage(this);

View File

@@ -175,6 +175,8 @@ bool Settings::load(const std::string& path)
loadScalar(j, "portfolio_style", portfolio_style_);
if (portfolio_style_ < 0 || portfolio_style_ > 2) portfolio_style_ = 0;
loadScalar(j, "scanline_enabled", scanline_enabled_);
loadScalar(j, "console_line_accents", console_line_accents_);
loadScalar(j, "console_text_color", console_text_color_);
if (j.contains("hidden_addresses") && j["hidden_addresses"].is_array()) {
hidden_addresses_.clear();
for (const auto& a : j["hidden_addresses"])
@@ -425,6 +427,8 @@ bool Settings::save(const std::string& path)
j["balance_layout"] = balance_layout_; // saved as string ID
j["portfolio_style"] = portfolio_style_;
j["scanline_enabled"] = scanline_enabled_;
j["console_line_accents"] = console_line_accents_;
j["console_text_color"] = console_text_color_;
j["hidden_addresses"] = json::array();
for (const auto& addr : hidden_addresses_)
j["hidden_addresses"].push_back(addr);

View File

@@ -189,6 +189,13 @@ public:
bool getScanlineEnabled() const { return scanline_enabled_; }
void setScanlineEnabled(bool v) { scanline_enabled_ = v; }
// Console output appearance: per-line left color accent bars, and per-channel text coloring.
// (Defaults match the ConsoleTab statics so an upgrade re-save doesn't flip visible behavior.)
bool getConsoleLineAccents() const { return console_line_accents_; }
void setConsoleLineAccents(bool v) { console_line_accents_ = v; }
bool getConsoleTextColor() const { return console_text_color_; }
void setConsoleTextColor(bool v) { console_text_color_ = v; }
// Hidden addresses (addresses hidden from the UI by the user)
const std::set<std::string>& getHiddenAddresses() const { return hidden_addresses_; }
bool isAddressHidden(const std::string& addr) const { return hidden_addresses_.count(addr) > 0; }
@@ -482,6 +489,8 @@ private:
std::string balance_layout_ = "classic";
int portfolio_style_ = 0; // Market portfolio row style (0 single / 1 two-line / 2 hero)
bool scanline_enabled_ = true;
bool console_line_accents_ = true; // left color accent bars in console output
bool console_text_color_ = true; // per-channel text coloring in console output
std::set<std::string> hidden_addresses_;
std::set<std::string> favorite_addresses_;
std::map<std::string, AddressMeta> address_meta_;

View File

@@ -45,6 +45,7 @@ ImU32 ConsoleTab::COLOR_INFO = IM_COL32(191, 209, 229, 255);
ImU32 ConsoleTab::COLOR_RPC = IM_COL32(120, 180, 255, 210);
bool ConsoleTab::s_scanline_enabled = true;
bool ConsoleTab::s_line_accents_enabled = true;
bool ConsoleTab::s_line_text_color_enabled = true;
float ConsoleTab::s_console_zoom = 1.0f;
bool ConsoleTab::s_daemon_messages_enabled = true;
bool ConsoleTab::s_errors_only_enabled = false;
@@ -189,6 +190,10 @@ void ConsoleTab::refreshColors()
ImU32 ConsoleTab::channelTextColor(ConsoleChannel channel) const
{
using namespace material;
// Monochrome mode: collapse every channel (and JSON syntax role) to the neutral result-body
// color. COLOR_RESULT is theme-correct (contrast-floored on light terminals in refreshColors),
// so text stays readable. The left accent bars are gated separately and stay independent.
if (!s_line_text_color_enabled) return COLOR_RESULT;
switch (channel) {
// COLOR_* channels are already palette-derived + contrast-floored in refreshColors(). The
// roles below are computed live from the theme palette, so floor them to a readable contrast on
@@ -560,6 +565,18 @@ void ConsoleTab::renderToolbar(ConsoleCommandExecutor& exec)
if (ImGui::IsItemHovered()) material::Tooltip("%s", TR("console_toggle_accents"));
}
// Text-color toggle: colored per-channel text vs. monochrome (grouped with the accent toggle).
ImGui::SameLine();
{
float btnSz = ImGui::GetFrameHeight();
if (!s_line_text_color_enabled)
ImGui::PushStyleColor(ImGuiCol_Text, ImGui::ColorConvertU32ToFloat4(OnSurfaceDisabled()));
if (TactileButton(ICON_MD_FORMAT_COLOR_TEXT, ImVec2(btnSz, btnSz), Type().iconMed()))
s_line_text_color_enabled = !s_line_text_color_enabled;
if (!s_line_text_color_enabled) ImGui::PopStyleColor();
if (ImGui::IsItemHovered()) material::Tooltip("%s", TR("console_toggle_text_color"));
}
// Zoom +/- buttons (right side of toolbar)
ImGui::SameLine();
ImGui::Spacing();

View File

@@ -72,6 +72,9 @@ public:
// Draw the per-line left color accent bars (channel-colored). Toggled from the toolbar.
static bool s_line_accents_enabled;
// Color output text per channel. When false the console is monochrome text. Toolbar-toggled.
static bool s_line_text_color_enabled;
// Show/hide daemon output messages
static bool s_daemon_messages_enabled;

View File

@@ -1291,6 +1291,7 @@ void I18n::loadBuiltinEnglish()
strings_["console_zoom_in"] = "Zoom in";
strings_["console_zoom_out"] = "Zoom out";
strings_["console_toggle_accents"] = "Toggle line color accents";
strings_["console_toggle_text_color"] = "Toggle line text colors";
// --- Export All Keys Dialog ---
strings_["export_keys_btn"] = "Export Keys";