fix(ui): consistent hashrate units, full-address tooltips, drop dead vars

- 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 <noreply@anthropic.com>
This commit is contained in:
2026-06-07 14:25:43 -05:00
parent 6ed80d2d79
commit a605e35409
4 changed files with 10 additions and 15 deletions

View File

@@ -11,7 +11,7 @@ namespace ui {
namespace {
std::string truncateRecentAddress(const std::string& address, int maxLen)
{
if (address.length() <= static_cast<size_t>(maxLen)) return address;
if (maxLen <= 3 || address.length() <= static_cast<size_t>(maxLen)) return address;
int half = (maxLen - 3) / 2;
return address.substr(0, half) + "..." + address.substr(address.length() - half);
}

View File

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

View File

@@ -46,7 +46,7 @@ std::string timeAgo(int64_t timestamp)
std::string truncateAddress(const std::string& address, int maxLen)
{
if (address.length() <= static_cast<size_t>(maxLen)) return address;
if (maxLen <= 3 || address.length() <= static_cast<size_t>(maxLen)) return address;
int half = (maxLen - 3) / 2;
return address.substr(0, half) + "..." + address.substr(address.length() - half);
}

View File

@@ -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];