Repository navigation
feat(cli): link the login URL, bold the code, and count down to expiry - #96
Conversation
tee8z
left a comment
There was a problem hiding this comment.
Requesting changes on 9296da7 (base #91 7b13df4). The presentation is safe:
- OSC 8 and bold appear only when stderr is a terminal, and anstream strips them with
NO_COLOR,--color neverorTERM=dumb. - The verification URL and the code pass through
scrub_line, and the link's visible text is its target. - The HTTPS-or-loopback check on the URL is kept.
- The countdown is hidden with
--quietor off a terminal, and its guard clears the line on Ctrl-C. - stdout and JSON are unchanged.
P2 (AGENTS.md: test every new early return): the plain paths have no tests. show_device_code (src/auth.rs:711) returns early on redirected stderr with the plain Open URL and Confirm this code: CODE lines. show_logged_in (:732) returns early off a terminal, and its line is hidden with --quiet. The only assertions on these lines run on the decorated terminal, so "Redirected stderr is unchanged" is unproven. Please add a redirected-stderr login that asserts the two plain lines and no closing line, and a terminal login with --quiet that asserts no closing line.
Nonblocking:
- The countdown overstates the time left. The poll gives up when
now + interval >= deadline(auth.rs:269), but the countdown runs todeadline. With the default 5-second interval, the user seesexpires in 0:05or less and thenLogin expired; run voltage login again, and afterslow_downthe gap grows. A user who approves at0:03gets "expired" while the code is still valid on the server. The countdown never reaches the0:00the description promises. Counting down todeadline - interval, or making a last poll at the deadline, fixes it. Withexpires_inover 600, the countdown is to the CLI's 600-second cap, not to the code's expiry as the docs say. - The
src/style.rsmodule doc still says that "Only static labels are painted", butstyled()now paints scrubbed untrusted text, andlink()writes OSC 8.
Validation on this head, in nix develop: cargo fmt --check, cargo clippy --locked --all-targets -- -D warnings, cargo machete --with-metadata, cargo test --locked (145 unit, 124 integration) and python3 scripts/check-coverage.py passed. CRAP: 668 measured functions, none at or above 20, highest endpoint at 18.00; 179 functions were unmeasured. CI is green.
9296da7 to
c71656d
Compare
On an interactive stderr, voltage login shows the verification URL as an OSC 8 link whose visible text is the whole URL, the device code in bold, a spinner that counts down to the code's expiry, and a closing "Logged in as" line. Redirected stderr keeps the plain "Open URL" and "Confirm this code" lines.
c71656d to
f9a1096
Compare
|
Review-body notes, in f9a1096:
|
tee8z
left a comment
There was a problem hiding this comment.
Approved f9a1096 against feat/cli-look-02-spinner (#91 2f36b1c). My findings are fixed:
- The countdown now ends at the last poll (
deadline - interval), so it no longer shows time left after the login has expired. The docs say that it counts to the code's expiry or the 10-minute cap. - New tests cover redirected stderr (plain
OpenandConfirm this codelines, with no closing line and no escape) and a--quietlogin on a terminal, which keeps the code and drops the closing line.
Validation on this head, in nix develop: cargo fmt --check, cargo clippy --locked --all-targets -- -D warnings, cargo machete --with-metadata, cargo test --locked (157 unit, 131 integration) and python3 scripts/check-coverage.py passed. CRAP: 698 measured functions, none at or above 20, highest wait_for_payment at 17.05. CRAP passed on its second run. On the first, the new a_quiet_login_on_a_terminal_still_shows_the_code_but_no_closing_line and #75's a_profile_saved_after_login_keeps_changes_made_while_its_prompt_was_open timed out in the instrumented suite. Both use the pseudo-terminal harness, whose 10-second limits #104 raises to 30 seconds, so this new test adds to that flakiness until #104 merges. CI is green.
Stack position: 3 of 13 in the look-and-feel stack. Base:
feat/cli-look-02-spinner(#91), whose progress line andstyle::Linethis PR extends.Problem
On a terminal,
voltage loginprinted two plain lines and a spinner that counted up. The person could not tell how long the code stayed valid. The output did not say who had signed in, except in the stdout table.Behavior
On an interactive stderr:
verification_url()and passes throughscrub_line. With color off, anstream strips the sequence and the plain URL remains.Role::Emphasis). The code is not respaced, so copying it still works.· expires in m:ssto the poll deadline (the server'sexpires_in, capped at the existing maximum). It rounds up, so it shows0:00only when time is up.✓ Logged in as EMAIL, adding(account: NAME)when the name differs. It appears only after the login is saved, and--quiethides it.Redirected stderr is unchanged:
Open URLandConfirm this code: CODE.Design notes
Progress::showtakes an optionalexpiresinstant, andTerminal::expiringpasses it.StatusLine::texttakes the time left as an argument, so tests can check exact output.style::Linegainsstyled(role, text)for scrubbed text in a style, andlink(url). Two new roles:Link(blue, underlined) andEmphasis(bold).show_device_codeandshow_logged_in, to keeplogin's complexity down (CRAP 14.20).Validation
cargo fmt --check,cargo clippy --locked --all-targets -- -D warnings,cargo machete --with-metadata,cargo test --locked(145 unit and 124 integration tests), andpython3 scripts/check-coverage.pyall pass.expires incountdown, and the closing✓ Logged in as person@example.test (account: person). All 22 login tests pass.10:00, and the closing line follows approval.src/cli.rsendpoint, untouched).Docs
docs/guides/login-and-profiles.md,docs/reference/output.md, andCHANGELOG.md.