refactor(console): unify lite + full-node console behind a pluggable executor

The two consoles were separate implementations (the rich full-node ConsoleTab and a
minimal RenderLiteConsoleTab). Introduce ConsoleCommandExecutor to abstract the only
real differences — command execution + log source — so both variants share the one rich
terminal (the lite console now gains selection, zoom, copy, and JSON-colored output).

- console_command_executor.{h,cpp}: interface + FullNodeConsoleExecutor (dragonxd log
  ingestion + RPC command execution, result queue) and LiteConsoleExecutor (lite
  diagnostics ring + backend runConsoleCommand/takeConsoleResult, connection/sync status).
- ConsoleTab::render() now takes a ConsoleCommandExecutor&; log ingestion, command
  submission, and command results flow through it. The RPC command-reference popup and
  the daemon/errors/rpc-trace/app filter toggles are gated on the executor's capabilities;
  the toolbar status dot + a status header come from the executor.
- Safety preserved: `clear`/`cls` is intercepted as a view-only clear in the shared UI so
  it is NEVER forwarded (the lite backend's `clear` wipes tx history); command output is
  not persisted to diagnostics.
- App owns the executor (created per variant) and routes both NavPages to console_tab_;
  lite_console_tab.{h,cpp} deleted.

Needs runtime verification of BOTH consoles (full-node RPC + lite: clear, seed/export
secrecy, sync status, command results).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-07-01 15:59:17 -05:00
parent 1266b6e68e
commit b5001ad4db
10 changed files with 594 additions and 570 deletions

View File

@@ -31,7 +31,7 @@
#include "ui/windows/mining_tab.h"
#include "ui/windows/peers_tab.h"
#include "ui/windows/network_tab.h"
#include "ui/windows/lite_console_tab.h"
#include "ui/windows/console_command_executor.h"
#include "ui/windows/explorer_tab.h"
#include "ui/windows/market_tab.h"
#include "ui/windows/settings_window.h"
@@ -205,6 +205,25 @@ std::string App::poolMiningInstalledVersion()
return daemon::XmrigManager::installedVersion();
}
// Console backend accessors — prefer the fast-lane RPC connection (so console commands
// don't queue behind the refresh batch), falling back to the main connection.
rpc::RPCClient* App::consoleRpc()
{
return (fast_rpc_ && fast_rpc_->isConnected()) ? fast_rpc_.get() : rpc_.get();
}
rpc::RPCWorker* App::consoleWorker()
{
return (fast_rpc_ && fast_rpc_->isConnected() && fast_worker_) ? fast_worker_.get() : worker_.get();
}
daemon::EmbeddedDaemon* App::consoleDaemon()
{
return daemon_controller_ ? daemon_controller_->daemon() : nullptr;
}
daemon::XmrigManager* App::consoleXmrig()
{
return xmrig_manager_.get();
}
bool App::sendStopCommandSafely(rpc::RPCClient& client, const char* context)
{
const char* label = context ? context : "App";
@@ -1814,23 +1833,23 @@ void App::render()
case ui::NavPage::LiteNetwork:
ui::RenderLiteNetworkTab(this);
break;
case ui::NavPage::LiteConsole:
ui::RenderLiteConsoleTab(this);
break;
case ui::NavPage::Explorer:
ui::RenderExplorerTab(this);
break;
case ui::NavPage::Market:
ui::RenderMarketTab(this);
break;
// One console UI for both variants; the executor supplies the backend (full-node
// RPC vs lite). The two NavPages are mutually exclusive per build.
case ui::NavPage::LiteConsole:
case ui::NavPage::Console:
// Use fast-lane worker for console commands to avoid head-of-line
// blocking behind the consolidated refreshData() batch.
// Fall back to main rpc/worker if fast-lane hasn't connected yet.
console_tab_.render(daemon_controller_ ? daemon_controller_->daemon() : nullptr,
(fast_rpc_ && fast_rpc_->isConnected()) ? fast_rpc_.get() : rpc_.get(),
(fast_rpc_ && fast_rpc_->isConnected() && fast_worker_) ? fast_worker_.get() : worker_.get(),
xmrig_manager_.get());
if (!console_exec_) {
if (isLiteBuild())
console_exec_ = std::make_unique<ui::LiteConsoleExecutor>(this);
else
console_exec_ = std::make_unique<ui::FullNodeConsoleExecutor>(this);
}
console_tab_.render(*console_exec_);
break;
case ui::NavPage::Settings:
ui::RenderSettingsPage(this);