Files
ObsidianDragon/src/ui/windows/bootstrap_completion.h
T
DanSandClaude Opus 4.8 c3ffc97b31 fix(ui): finish a stranded bootstrap even when its dialog is closed
A Settings bootstrap was only wrapped up inside the dialog's own draw
path. If the dialog finished downloading, verifying or extracting while
the user had clicked away or minimized the window, completion was never
processed: the connect and reconcile gate stayed held and the
post-bootstrap rescan was never armed.

- Completion is now a pure decision driven from a pump() that both the
  per-frame update and the dialog's render call, so a finished bootstrap
  is handled every tick whether or not the dialog is drawn.
- With the dialog open the behaviour is unchanged: it advances to the
  Done or Failed screen and those screens still own the gate. With the
  dialog closed, pump() releases the gate itself and shows a success or
  failure toast; a user-cancelled run is released silently.

User-visible: a bootstrap started from Settings now completes, arms its
rescan and reports its result even if the dialog is closed or the window
is minimized when it finishes.

Tests: the completion decision for an unfinished worker, a completed run
with the dialog open and closed, a failed run, and a user-cancelled run.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-10-12 21:42:23 -05:00

37 lines
1.2 KiB
C++

// DragonX Wallet - ImGui Edition
// Copyright 2024-2026 The Hush Developers
// Released under the GPLv3
//
// Pure decision for what to do when the Settings bootstrap worker finishes (C221).
#pragma once
#include "../../util/bootstrap.h"
namespace dragonx {
namespace ui {
struct BootstrapCompletion {
enum class Next { Pending, Done, Failed };
Next next = Next::Pending;
bool markRescan = false; // completed: reconcile the preserved wallet.dat against the new chain
bool releaseGate = false; // dialog not open: clear App::bootstrap_downloading_ ourselves
bool toast = false; // dialog not open (and not a user cancel): tell the user the outcome
};
inline BootstrapCompletion resolveBootstrapCompletion(bool workerDone, util::Bootstrap::State state,
bool dialogOpen, bool userCancelled)
{
BootstrapCompletion c;
if (!workerDone) return c;
const bool ok = (state == util::Bootstrap::State::Completed);
c.next = ok ? BootstrapCompletion::Next::Done : BootstrapCompletion::Next::Failed;
c.markRescan = ok;
c.releaseGate = !dialogOpen;
c.toast = !dialogOpen && !userCancelled;
return c;
}
} // namespace ui
} // namespace dragonx