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();