fix(ui): only toast "Blockchain rescan complete" for user-initiated rescans
The daemon-output parser treats autonomous background witness rebuilds as a rescan (they set state_.sync.rescanning via the foundWitness branch), so one completing fired "Blockchain rescan complete" even though the user never started a rescan — most visibly after a minimize, where a whole rebuild's start+finish arrives in one batch. Add user_initiated_rescan_ (atomic — some triggers run on worker threads), set it at the wallet's real rescan triggers (the Rescan button, a -rescan/salvage/zap/reindex restart, key import, seed migration), and gate the three "rescan complete" toasts on it, clearing it when shown. The rescan/witness progress state machine is untouched — only the toast is gated — so background rebuilds no longer announce a completed rescan while genuine user rescans still do (and can't double-toast). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
+9
-2
@@ -988,7 +988,10 @@ void App::update()
|
||||
// saw the rescan running. Without the confirmed-active gate, the first
|
||||
// poll (which hits the still-running pre-restart daemon, rescanning=false)
|
||||
// would fire a false "complete" the instant rescan was clicked.
|
||||
ui::Notifications::instance().success("Blockchain rescan complete");
|
||||
if (user_initiated_rescan_) {
|
||||
ui::Notifications::instance().success("Blockchain rescan complete");
|
||||
user_initiated_rescan_ = false; // surfaced once; not for background rebuilds
|
||||
}
|
||||
resetWitnessRescanProgress();
|
||||
state_.sync.rescan_progress = 1.0f;
|
||||
}
|
||||
@@ -1091,8 +1094,9 @@ void App::update()
|
||||
// Apply results directly — we are already on the main thread.
|
||||
const std::string& status = scan.lastStatus;
|
||||
if (scan.finished) {
|
||||
if (state_.sync.rescanning) {
|
||||
if (state_.sync.rescanning && user_initiated_rescan_) {
|
||||
ui::Notifications::instance().success("Blockchain rescan complete");
|
||||
user_initiated_rescan_ = false; // surfaced once; not for background rebuilds
|
||||
}
|
||||
// Witness rebuild finishes with the rescan it's part of.
|
||||
resetWitnessRescanProgress();
|
||||
@@ -5464,6 +5468,7 @@ void App::rescanBlockchain()
|
||||
// pre-restart daemon and see rescanning=false) can't be misread as instant completion.
|
||||
state_.sync.rescanning = true;
|
||||
rescan_confirmed_active_ = false;
|
||||
user_initiated_rescan_ = true; // user-triggered rescan → its completion should toast
|
||||
state_.sync.rescan_progress = 0.0f;
|
||||
state_.sync.rescan_status = decision.status;
|
||||
transactions_dirty_ = true;
|
||||
@@ -5515,6 +5520,7 @@ void App::repairWallet()
|
||||
// confirmed-active gating as rescan: the first poll may still reach the pre-restart daemon.
|
||||
state_.sync.rescanning = true;
|
||||
rescan_confirmed_active_ = false;
|
||||
user_initiated_rescan_ = true; // user-triggered repair (implies rescan) → completion should toast
|
||||
state_.sync.rescan_progress = 0.0f;
|
||||
state_.sync.rescan_status = decision.status;
|
||||
transactions_dirty_ = true;
|
||||
@@ -6930,6 +6936,7 @@ void App::reindexBlockDatabase()
|
||||
}
|
||||
if (!daemon_controller_) return;
|
||||
daemon_controller_->setReindexOnNextStart(true);
|
||||
user_initiated_rescan_ = true; // reindex implies a rescan → its completion should toast
|
||||
daemon_controller_->resetCrashCount(); // the abort no longer counts against the restart budget
|
||||
show_block_db_reindex_confirm_ = false;
|
||||
block_db_reindex_available_ = false; // un-gate → the connect loop restarts the node with -reindex
|
||||
|
||||
Reference in New Issue
Block a user