From a605e35409c14108bf2c846a00ac7ccf356acd47 Mon Sep 17 00:00:00 2001 From: DanS Date: Sun, 7 Jun 2026 14:25:43 -0500 Subject: [PATCH] fix(ui): consistent hashrate units, full-address tooltips, drop dead vars MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Balance card hashrate now uses the shared FormatHashrate() (TH/GH/MH/KH/H) instead of a bespoke two-tier KH/s formatter. - Recent-tx rows show the full untruncated address on hover — two z-addresses can truncate to the same first/last window — and the truncate helpers guard maxLen<=3. - Remove the unused viewTop/viewBot "viewport culling" locals in the tx list (pagination already bounds per-frame work). Co-Authored-By: Claude Opus 4.8 --- src/ui/windows/balance_recent_tx.cpp | 2 +- src/ui/windows/balance_tab.cpp | 15 +++++++-------- src/ui/windows/balance_tab_helpers.cpp | 2 +- src/ui/windows/transactions_tab.cpp | 6 +----- 4 files changed, 10 insertions(+), 15 deletions(-) diff --git a/src/ui/windows/balance_recent_tx.cpp b/src/ui/windows/balance_recent_tx.cpp index a46ed34..d25799d 100644 --- a/src/ui/windows/balance_recent_tx.cpp +++ b/src/ui/windows/balance_recent_tx.cpp @@ -11,7 +11,7 @@ namespace ui { namespace { std::string truncateRecentAddress(const std::string& address, int maxLen) { - if (address.length() <= static_cast(maxLen)) return address; + if (maxLen <= 3 || address.length() <= static_cast(maxLen)) return address; int half = (maxLen - 3) / 2; return address.substr(0, half) + "..." + address.substr(address.length() - half); } diff --git a/src/ui/windows/balance_tab.cpp b/src/ui/windows/balance_tab.cpp index 2453968..f110ab8 100644 --- a/src/ui/windows/balance_tab.cpp +++ b/src/ui/windows/balance_tab.cpp @@ -6,6 +6,7 @@ #include "balance_address_list.h" #include "balance_tab_helpers.h" #include "balance_recent_tx.h" +#include "mining_tab_helpers.h" // FormatHashrate (consistent MH/GH/.. scaling) #include "key_export_dialog.h" #include "qr_popup_dialog.h" #include "address_label_dialog.h" @@ -430,10 +431,7 @@ static void RenderBalanceClassic(App* app) dl->AddCircleFilled(ImVec2(cx + 4 * dp, cy + capFont->LegacySize * 0.5f), S.drawElement("tabs.balance.classic", "mining-dot-radius").sizeOr(3.0f), mineCol); double hr = state.mining.localHashrate; - if (hr >= 1000.0) - snprintf(buf, sizeof(buf), " Mining %.1f KH/s", hr / 1000.0); - else - snprintf(buf, sizeof(buf), " Mining %.0f H/s", hr); + snprintf(buf, sizeof(buf), " Mining %s", FormatHashrate(hr).c_str()); dl->AddText(capFont, capFont->LegacySize, ImVec2(cx + 12 * dp, cy), WithAlpha(Success(), 200), buf); @@ -1175,6 +1173,10 @@ static void RenderBalanceClassic(App* app) dl->AddRectFilled(rowPos, rowEnd, IM_COL32(255, 255, 255, 15), S.drawElement("tabs.balance", "row-hover-rounding").sizeOr(4.0f)); ImGui::SetMouseCursor(ImGuiMouseCursor_Hand); + // Show the full, untruncated address — two z-addresses can truncate to the + // same first/last window, so the truncated text alone can't disambiguate. + if (!tx.address.empty()) + ImGui::SetTooltip("%s", tx.address.c_str()); if (ImGui::IsMouseClicked(0)) app->setCurrentPage(NavPage::History); } @@ -3202,10 +3204,7 @@ static void RenderBalanceTwoRow(App* app) { } if (state.mining.generate) { double hr = state.mining.localHashrate; - if (hr >= 1000.0) - snprintf(buf, sizeof(buf), "Mining %.1f KH/s", hr / 1000.0); - else - snprintf(buf, sizeof(buf), "Mining %.0f H/s", hr); + snprintf(buf, sizeof(buf), "Mining %s", FormatHashrate(hr).c_str()); Type().textColored(TypeStyle::Caption, WithAlpha(Success(), 200), buf); ImGui::SameLine(); } diff --git a/src/ui/windows/balance_tab_helpers.cpp b/src/ui/windows/balance_tab_helpers.cpp index 89aefa2..d0d2b76 100644 --- a/src/ui/windows/balance_tab_helpers.cpp +++ b/src/ui/windows/balance_tab_helpers.cpp @@ -46,7 +46,7 @@ std::string timeAgo(int64_t timestamp) std::string truncateAddress(const std::string& address, int maxLen) { - if (address.length() <= static_cast(maxLen)) return address; + if (maxLen <= 3 || address.length() <= static_cast(maxLen)) return address; int half = (maxLen - 3) / 2; return address.substr(0, half) + "..." + address.substr(address.length() - half); } diff --git a/src/ui/windows/transactions_tab.cpp b/src/ui/windows/transactions_tab.cpp index 55185ab..1ace8f5 100644 --- a/src/ui/windows/transactions_tab.cpp +++ b/src/ui/windows/transactions_tab.cpp @@ -626,11 +626,7 @@ void RenderTransactionsTab(App* app) scrollY = ImGui::GetScrollY(); scrollMaxY = ImGui::GetScrollMaxY(); - // Viewport culling bounds - float viewTop = scrollY; - float viewBot = scrollY + ImGui::GetWindowHeight(); - - // Render only the current page slice + // Render only the current page slice (pagination already bounds per-frame work) for (int fi = pageStart; fi < pageEnd; fi++) { size_t i = filtered_indices[fi]; const auto& tx = display_txns[i];