Skip to content

Commit cff37e7

Browse files
committed
fix: auto-adopt the only candidate instead of popping a single-option picker
When there's exactly one tunnel to resume, inquire still rendered the prompt with a forced '>' marker on the lone row and arrow keys were no-ops. The terminal cursor sat on the '? Resume which tunnel?' line — visually it looked like the selector hadn't moved 'to the correct line' because there was no other line to move to. The picker only earns its keep when there's a choice to make. Short-circuit at one candidate: print 'Resuming the only tunnel ...' naming the hostname and id, return it directly. The >1 case still pops the picker, where arrow-key movement was verified working under pty with cursor-position+selected-index alignment.
1 parent c39d9ee commit cff37e7

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

cli/src/main.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -987,6 +987,22 @@ async fn pick_tunnel_interactive(
987987
if candidates.is_empty() {
988988
return Ok(None);
989989
}
990+
991+
// Single candidate: no point prompting. The selection marker would sit
992+
// on the only row and arrow keys would be no-ops, which looks like a
993+
// wedge from the user's perspective (terminal cursor still on the
994+
// prompt line). Just adopt it and tell the user what happened.
995+
if candidates.len() == 1 {
996+
let only = candidates.remove(0);
997+
let host = only
998+
.hostnames
999+
.first()
1000+
.map(String::as_str)
1001+
.unwrap_or(only.id.as_str());
1002+
println!("Resuming the only tunnel in this project: {host} (id: {})", only.id);
1003+
return Ok(Some(only));
1004+
}
1005+
9901006
// Most-likely-relevant first: tunnels you previously enabled (have an
9911007
// advertisement) bubble up before disabled ones.
9921008
candidates.sort_by(|a, b| {

0 commit comments

Comments
 (0)