feat(console): add an "App" toggle to show/hide [app] log lines

The console mixed RPC traces, daemon output, and the wallet's own "[app] ..."
log lines with no way to hide the latter. Add an "App" checkbox alongside the
existing Daemon/Errors/RPC toggles. Since [app] lines share COLOR_INFO with
other info text, the filter matches them by their "[app] " prefix rather than by
color. Default on; unit test + i18n added.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-06-13 12:52:42 -05:00
parent e7d11f620a
commit 5167b52cbd
6 changed files with 40 additions and 4 deletions

View File

@@ -21,6 +21,8 @@ bool consoleLinePassesFilter(const std::string& lineText,
{
if (!filter.daemonMessagesEnabled && lineColor == filter.daemonColor) return false;
if (!filter.rpcTraceEnabled && lineColor == filter.rpcTraceColor) return false;
// "[app] ..." lines share COLOR_INFO with other info text, so match them by prefix.
if (!filter.appMessagesEnabled && lineText.rfind("[app] ", 0) == 0) return false;
if (filter.errorsOnly && lineColor != filter.errorColor) return false;
if (!filter.text.empty()) {
std::string needle = lowerCopy(filter.text);

View File

@@ -12,6 +12,7 @@ struct ConsoleOutputFilter {
bool daemonMessagesEnabled = true;
bool errorsOnly = false;
bool rpcTraceEnabled = false;
bool appMessagesEnabled = true; // "[app] ..." wallet log lines (matched by prefix, not color)
ImU32 daemonColor = 0;
ImU32 errorColor = 0;
ImU32 rpcTraceColor = 0;

View File

@@ -46,6 +46,7 @@ float ConsoleTab::s_console_zoom = 1.0f;
bool ConsoleTab::s_daemon_messages_enabled = true;
bool ConsoleTab::s_errors_only_enabled = false;
bool ConsoleTab::s_rpc_trace_enabled = false;
bool ConsoleTab::s_app_messages_enabled = true;
namespace {
@@ -531,11 +532,28 @@ void ConsoleTab::renderToolbar(daemon::EmbeddedDaemon* daemon)
if (ImGui::IsItemHovered()) {
ImGui::SetTooltip("%s", TR("console_show_rpc_trace"));
}
ImGui::SameLine();
ImGui::Spacing();
ImGui::SameLine();
// App messages toggle — "[app] ..." wallet log lines
{
static bool s_prev_app_enabled = true;
ImGui::Checkbox(TR("console_app"), &s_app_messages_enabled);
if (s_prev_app_enabled != s_app_messages_enabled && auto_scroll_) {
scroll_to_bottom_ = true;
}
s_prev_app_enabled = s_app_messages_enabled;
}
if (ImGui::IsItemHovered()) {
ImGui::SetTooltip("%s", TR("console_show_app_output"));
}
ImGui::SameLine();
ImGui::Spacing();
ImGui::SameLine();
// Clear button
if (TactileButton(TR("console_clear"), ImVec2(0, 0), schema::UI().resolveFont("button"))) {
clear();
@@ -651,10 +669,12 @@ void ConsoleTab::renderOutput()
// Build filtered line index list BEFORE mouse handling (so screenToTextPos works)
ConsoleOutputFilter outputFilter{filter_text_, s_daemon_messages_enabled,
s_errors_only_enabled, s_rpc_trace_enabled,
s_app_messages_enabled,
COLOR_DAEMON, COLOR_ERROR, COLOR_RPC};
bool has_text_filter = !outputFilter.text.empty();
bool has_filter = has_text_filter || !outputFilter.daemonMessagesEnabled ||
!outputFilter.rpcTraceEnabled || outputFilter.errorsOnly;
!outputFilter.rpcTraceEnabled || !outputFilter.appMessagesEnabled ||
outputFilter.errorsOnly;
visible_indices_.clear();
if (has_filter) {
for (int i = 0; i < static_cast<int>(lines_.size()); i++) {

View File

@@ -73,6 +73,9 @@ public:
// Show app RPC calls made through RPCClient (method/source only)
static bool s_rpc_trace_enabled;
// Show "[app] ..." wallet log lines
static bool s_app_messages_enabled;
/// Refresh console text colors for current theme (call after theme switch)
static void refreshColors();

View File

@@ -945,6 +945,8 @@ void I18n::loadBuiltinEnglish()
strings_["console_not_connected"] = "Error: Not connected to daemon";
strings_["console_rpc_reference"] = "RPC Command Reference";
strings_["console_rpc_trace"] = "RPC";
strings_["console_app"] = "App";
strings_["console_show_app_output"] = "Show [app] wallet log lines";
strings_["console_search_commands"] = "Search commands...";
strings_["console_select_all"] = "Select All";
strings_["console_show_daemon_output"] = "Show daemon output";

View File

@@ -2298,7 +2298,7 @@ void testRendererHelpers()
EXPECT_FALSE(dragonx::ui::IsPoolMiningActive(true, false, true));
EXPECT_TRUE(dragonx::ui::IsPoolMiningActive(false, false, true));
dragonx::ui::ConsoleOutputFilter filter{"error", false, false, false, 10, 20, 30};
dragonx::ui::ConsoleOutputFilter filter{"error", false, false, false, true, 10, 20, 30};
EXPECT_TRUE(dragonx::ui::consoleLinePassesFilter("RPC Error", 20, filter));
EXPECT_FALSE(dragonx::ui::consoleLinePassesFilter("daemon line", 10, filter));
filter.text.clear();
@@ -2311,6 +2311,14 @@ void testRendererHelpers()
EXPECT_TRUE(dragonx::ui::consoleLinePassesFilter("error line", 20, filter));
EXPECT_FALSE(dragonx::ui::consoleLinePassesFilter("info line", 30, filter));
// "[app] ..." lines are filtered by prefix (they share the info color), not by color.
filter.errorsOnly = false;
filter.appMessagesEnabled = false;
EXPECT_FALSE(dragonx::ui::consoleLinePassesFilter("[app] Price updated", 30, filter));
EXPECT_TRUE(dragonx::ui::consoleLinePassesFilter("[rpc] trace", 30, filter));
filter.appMessagesEnabled = true;
EXPECT_TRUE(dragonx::ui::consoleLinePassesFilter("[app] Price updated", 30, filter));
std::vector<dragonx::AddressInfo> poolAddresses;
poolAddresses.push_back({"R-transparent", 0.0, "transparent", true});
poolAddresses.push_back({"zs-default-worker", 0.0, "shielded", true});