fix(cli): Interaction progress review - #7
Closed
thebrandonlucas wants to merge 3 commits into
Closed
thebrandonlucas wants to merge 3 commits into
thebrandonlucas wants to merge 3 commits into
Conversation
Confirmation and hidden API-key prompts blocked the thread that listens for Ctrl-C, so interrupting at a prompt hung or died by raw signal without the exit-130 report. Terminal reads now run on a detached thread that reports back over a channel. Record any non-GET write, not only payments, immediately before it is sent, so an interrupted delete reports an uncertain submission instead of "before a payment submission". The write record is now a write-once OnceLock owned by api rather than an Arc<Mutex> in startup. Pass one Terminal built from the global flags instead of threading quiet/no_input bools, keep the checkout projection status from nesting with request status, and mark Progress #[must_use]. Tests share an env-scrubbed process helper, wait on request arrival through a notification instead of sleep polling, signal with kill instead of unsafe libc::kill, document each openpty unsafe block, and cover Ctrl-C at the prompt and during a non-payment write.
announced, error_report, and the Notify import are used only by cfg(unix) process tests, so Windows clippy rejected them as dead code.
thebrandonlucas
force-pushed
the
fix/cli-interaction-progress-review
branch
from
September 25, 2026 18:32
7cad498 to
f21eeb3
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR review: noninteractive controls and interrupt-safe progress
Branch:
fix/cli-interaction-progress-review(533605cfeature +f3afd02review fixes) →masterVerdict: ✅ Ready to merge once the PR description explains the exceptions listed below.
Gate: fmt ✅ · clippy
-D warnings✅ · tests 72 unit + 48 integration ✅ ·check-coverage.py✅ ·cargo machetenot run (not installed here; no new dependencies)The samples below are real runs of
target/debug/voltageagainst a local server that delays every response by 30 s. Paths are shortened to~/.config/voltageand repeated confirmation summaries are shortened to{…}.Usage walkthrough
1.
--no-inputwithout--yesstops before any network call✅ The CLI prints the summary and then fails. It makes no credential refresh, no wallet check and writes no journal entry. The integration test asserts the server received zero requests.
2.
--yesnever supplies a secret3. Ctrl-C during a read makes no submission claim
4. Ctrl-C during a payment keeps the recovery ID
✅ The payment is not resent. The journal entry is written before the request goes out. The error detail has the same shape as the one for a dropped connection (exit 4), so scripts can handle both the same way.
5. Ctrl-C during a non-payment write (fixed in review)
Before the fix: this printed
"Interrupted before a payment submission; no payment was sent by this command". The DELETE was already in flight, so "before" was wrong. The error also had no detail, which dropped the uncertainty.6.
--quietkeeps what you need to recover✅ Quiet mode hides only progress and routine notices, like
Payment … status: pending.7. Progress only appears on a terminal
progress_is_terminal_only_and_cleared_on_completionruns this on a real PTY. It asserts the terminal output ends with the clear sequence.8. Ctrl-C at the confirmation prompt (fixed in review)
The cause:
stdin().read_line()blocked the same thread that listens for Ctrl-C. Whether the listener was registered first was random, and when it was, the signal was captured but never handled. The new testinterrupt_at_the_confirmation_prompt_exits_130_without_submittingfails against the pre-fix code.Findings, fixed in
f3afd02Proceed?or the hidden API-key prompt hangs (sample 8)Terminal::confirmandread_hiddenread on a detached thread and report back over aoneshotchannelSubmissionStatewas anArc<Mutex<Option<…>>>instartupthatapiimported, so the dependency pointed backwardsOnceLock, owned byapiquiet: boolwas passed throughlock,revoke,refresh,logoutandprofiles;Terminal::new(false)was built ad hocTerminalvalue built from the global flagscrate::terminal::…path inside a function, splituseblocks,drop(_progress)Progressis#[must_use]VOLTAGE_*, waited in 20 ms sleep loops, usedunsafe libc::kill(… as i32)process_athelper, request-arrival notification,kill -INTas in the existing tests,SAFETY:comment on eachopenptyblockExceptions the PR description must explain
The quality guide's Review exceptions section requires these three:
std::threadfor terminal reads. A blocked read can't be cancelled, and the runtime waits forspawn_blockingwork when it shuts down. The channel reports completion, and the process exit ends the thread.syncfeature. It providesoneshotfor the reads above andNotifyin the tests. It is not a new crate.unsafelibc::openptyin tests. Rust's standard library has no way to open a PTY, and the terminal-only progress needs a real terminal to test.Open questions and follow-ups (existed before this PR)
-q --yesstill prints the full confirmation summary (sample 6). This follows the plan's rule that confirmation information is mandatory. In CI logs it adds about 15 lines per payment. Should--yescombined with--quietshorten it to one line?rpasswordonly restores it when its read returns. The workaround isstty sane.