Hmbown/CodeWhale · error · anyhow::Error

No saved sessions found for workspace

Error message

No saved sessions found for workspace {}. Use `codewhale sessions` to list sessions, or pass `codewhale exec --resume <SESSION_ID> ...`.

What it means

With `--continue` (continue_session), codewhale resolves the most recent saved session id for the current workspace. If no saved sessions exist for that workspace, it bails with guidance to list sessions or use an explicit `--resume <SESSION_ID>`.

Solutions

  1. List saved sessions with `codewhale sessions` to see what exists
  2. Resume an explicit session with `codewhale exec --resume <SESSION_ID> ...`
  3. Start a fresh session without --continue if history isn't needed
  4. Verify you're in the same workspace directory where the original session ran

Example fix

// before
codewhale exec --continue 'do the thing'
// after
codewhale sessions
codewhale exec --resume <SESSION_ID> 'do the thing'
Defensive patterns

Strategy: fallback

Validate before calling

// check for sessions before using --continue
// run: codewhale sessions (non-empty output for this workspace) OR pass --resume <id>

Try / catch

match result { Err(e) if e.to_string().contains("No saved sessions found") => start_fresh_session(), other => other }

Prevention

When it happens

Trigger: Running `codewhale exec --continue ...` in a workspace where latest_session_id_for_workspace returns None — no session files were ever persisted for that directory.

Common situations: First run in a new/relocated project directory; sessions directory cleaned or on a different machine/container; path changed (workspace identity is the resolved directory) so old sessions don't match.

Understand the failure class

Background: EmptyResultError / "no results found": when an API or scraper succeeds but returns zero rows — this error's family across 9 libraries.

Related errors


AI-assisted analysis of Hmbown/CodeWhale@73e0f67d83 (2026-09-22). Data as JSON: /api/errors/342fc2f4dfd84cbd. Report an issue: GitHub.

Appendix: source

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

    {
        read()
    }
}

fn top_level_prompt_initial_input(parts: &[String]) -> Option<tui::InitialInput> {
    (!parts.is_empty()).then(|| tui::InitialInput::Submit(join_prompt_parts(parts)))
}

fn resolve_exec_resume_session_id(args: &ExecArgs, workspace: &Path) -> Result<Option<String>> {
    if let Some(id) = args.resume.as_ref().or(args.session_id.as_ref()) {
        return Ok(Some(id.clone()));
    }
    if !args.continue_session {
        return Ok(None);
    }
    latest_session_id_for_workspace(workspace)?.map_or_else(
        || {
            bail!(
                "No saved sessions found for workspace {}. Use `codewhale sessions` to list sessions, or pass `codewhale exec --resume <SESSION_ID> ...`.",
                workspace.display()
            )
        },
        |id| Ok(Some(id)),
    )
}

fn load_exec_resume_session(session_id: &str) -> Result<session_manager::SavedSession> {
    let session_ref = exec_stream_session_ref(session_id);
    SessionManager::default_location()
        .context("could not open session manager for resume")?
        .resume_session_by_prefix(session_id)
        .map(|recovery| recovery.session)
        .with_context(|| format!("could not load session {session_ref}"))
}

/// Select the route for `exec --resume` before any engine/client is built.

View on GitHub (pinned to 73e0f67d83)