Hmbown/CodeWhale · warning · anyhow::Error

No session selected.

Error message

No session selected.

What it means

The session picker prints a numbered list and reads a line; submitting an empty line bails with "No session selected." rather than picking a default. It exits non-zero like any anyhow failure, but semantically it is a user cancellation, not a fault. Adjacent outcomes are "Invalid input" (non-numeric) and "Selection out of range".

Source

Thrown at crates/tui/src/lib.rs:7917

fn pick_session_id() -> Result<String> {
    let manager = SessionManager::default_location()?;
    let sessions = manager.list_sessions()?;
    if sessions.is_empty() {
        bail!("No saved sessions found.");
    }

    println!("Select a session to resume:");
    for (idx, session) in sessions.iter().enumerate() {
        println!("  {:>2}. {} ({})", idx + 1, session.title, session.id);
    }
    print!("Enter a number (or press Enter to cancel): ");
    io::stdout().flush()?;

    let mut input = String::new();
    io::stdin().read_line(&mut input)?;
    let input = input.trim();
    if input.is_empty() {
        bail!("No session selected.");
    }
    let idx: usize = input
        .parse()
        .map_err(|_| anyhow::anyhow!("Invalid input"))?;
    let session = sessions
        .get(idx.saturating_sub(1))
        .ok_or_else(|| anyhow::anyhow!("Selection out of range"))?;
    Ok(session.id.clone())
}

async fn run_review(config: &Config, args: ReviewArgs) -> Result<()> {
    use crate::client::DeepSeekClient;

    let diff = collect_diff(&args)?;
    if diff.trim().is_empty() {
        bail!("No diff to review.");
    }
    validate_review_receipt_args(&args)?;

View on GitHub (pinned to 0c42157ee5)

Solutions

  1. Type a listed number and press Enter, or re-run with an explicit session id to skip the picker
  2. In wrappers, classify this specific message as a clean cancellation (exit 0)
  3. Avoid piping blank lines into interactive pickers

Example fix

// before: scripts die on a benign cancel
$ codewhale resume; echo $?
Error: No session selected.  (exit 1)

// after: treat the cancel message as success
$ codewhale resume 2>err || { grep -q 'No session selected.' err && exit 0; cat err >&2; exit 1; }
Defensive patterns

Strategy: try-catch

Try / catch

codewhale resume 2>/tmp/pick.err || {
  if grep -q 'No session selected.' /tmp/pick.err; then exit 0; fi  # user cancel
  cat /tmp/pick.err >&2; exit 1
}

Prevention

When it happens

Trigger: Running the interactive picker and pressing Enter without typing anything (input.trim().is_empty()). Also hit when blank lines are piped into the prompt.

Common situations: Users backing out of the picker; scripts that invoke the interactive command without a tty input strategy; automation piping empty input.

Related errors


AI-assisted analysis of Hmbown/CodeWhale@0c42157ee5 (2026-08-20). Data as JSON: /api/errors/58e2daa5d45e49ba. Report an issue: GitHub.