Skip to content

Commit a65a7f9

Browse files
Sbussisoclaude
andcommitted
fix(main): pause-on-error before exit so the user can read the diagnosis
User-visible bug from the start of the v0.1.20 saga: every time something fails after main() returns, the Start-menu-launched console closes the moment the process exits. The error message printed to stderr scrolls past in a fraction of a second and the window vanishes before the user can read what went wrong. We've been GUESSING at root causes for two days because we couldn't see the actual diagnostic output. Fix: on Windows, the existing `pause_on_exit` helper now fires on every error path that wasn't already a "displayed via TUI" flow (`AlreadyReported` / `ResetRequested` skip the pause because the TUI already showed the user what happened — pausing again would be redundant). Operators launching from PowerShell / cmd / a shell they own hit Enter once and continue; the small friction is the price for never again losing diagnostic info to a window-close vacuum. Operators launching from Start menu / Explorer / MSI Finish dialog get exactly what they need: the error stays on screen until they press Enter. Also adds a "Loading SourceBox Sentry CloudNode..." banner before `run_cloudnode` is called from the bare-invocation (None) path. Node::new can take 1-3 seconds (tokio runtime build + SQLite open + Command Center registration HTTP call) during which the console is blank — feels like the binary hung. The banner gives the user visual feedback that the binary is doing real work. Bumps version to 0.1.38. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent b6e3d5e commit a65a7f9

3 files changed

Lines changed: 36 additions & 4 deletions

File tree

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# should reflect that. Going from `opensentry-cloudnode` to
66
# `sourcebox-sentry-cloudnode` keeps the binary name explicit + branded.
77
name = "sourcebox-sentry-cloudnode"
8-
version = "0.1.37"
8+
version = "0.1.38"
99
edition = "2021"
1010
authors = ["SourceBox LLC"]
1111
description = "SourceBox Sentry CloudNode — turns a USB webcam into a cloud-connected security camera."

src/main.rs

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ enum Commands {
118118
}
119119

120120
fn main() -> ExitCode {
121-
match run() {
121+
let exit_code = match run() {
122122
Ok(()) => ExitCode::SUCCESS,
123123
// Already-reported errors came through a formatted TUI path
124124
// (e.g. show_registration_error); do not print a second debug line.
@@ -128,9 +128,28 @@ fn main() -> ExitCode {
128128
eprintln!();
129129
eprintln!(" {} {}", "Error:".red().bold(), e);
130130
eprintln!();
131+
// CRITICAL: on Windows, the binary may be running in a
132+
// console window owned by us (Start menu shortcut, MSI
133+
// Finish-dialog cmd /c start, Explorer double-click).
134+
// When main returns, that console closes immediately —
135+
// the user never sees the error message printed above.
136+
//
137+
// Pause for input on Windows so the operator can actually
138+
// read what went wrong before the window vanishes. PowerShell
139+
// / cmd users (who own their own shell) hit Enter once
140+
// and move on; that minor friction is the price for not
141+
// throwing diagnostic info into a window-close vacuum.
142+
//
143+
// Skip the pause for AlreadyReported / ResetRequested
144+
// because those are intentional flows (the TUI already
145+
// showed the user what happened; we're just exiting with
146+
// code 1 to signal the outer launcher).
147+
#[cfg(target_os = "windows")]
148+
pause_on_exit();
131149
ExitCode::from(1)
132150
}
133-
}
151+
};
152+
exit_code
134153
}
135154

136155
fn run() -> Result<()> {
@@ -373,6 +392,19 @@ fn run() -> Result<()> {
373392
// run the node in the foreground. Same path as cargo-build
374393
// / Linux / Docker installs already use. The TUI dashboard
375394
// takes over the console.
395+
//
396+
// Print a clear "starting" banner before run_cloudnode so
397+
// the user has visual feedback that the binary is doing
398+
// something, even if Node::new takes a couple seconds to
399+
// build the tokio runtime + open the SQLite DB + register
400+
// with Command Center. Without this, the console is
401+
// blank for ~1-3 seconds before the dashboard takes over,
402+
// which feels like the binary hung.
403+
use colored::Colorize;
404+
println!();
405+
println!(" {} Loading SourceBox Sentry CloudNode...", "📡".cyan());
406+
println!(" {}", "Configuration found. Starting camera node...".dimmed());
407+
println!();
376408
run_cloudnode(args.node_id, args.api_key, args.api_url, args.once, args.config)?;
377409
}
378410
}

0 commit comments

Comments
 (0)