Hmbown/CodeWhale · error · anyhow::Error

No saved sessions found for workspace

Error message

No saved sessions found for workspace {}.

What it means

Resuming with --last looks up the most recent saved session for the given workspace; if the SessionManager returns none, the TUI bails with this message naming the workspace path. It means no session has ever been persisted for that directory.

Solutions

  1. Run from the workspace directory where the sessions were created
  2. Use `resume` with an explicit session id instead of --last
  3. List sessions to find the right workspace/session

Example fix

// before
codewhale resume --last --workspace /tmp/new-project
// after
codewhale resume --workspace /tmp/existing-project  # or resume <session-id>
Defensive patterns

Strategy: fallback

Validate before calling

let has = manager.list_sessions()?.iter().any(|s| s.workspace == workspace); if !has { eprintln!("no sessions for {}"); }

Try / catch

match resume_result { Err(e) if e.to_string().starts_with("No saved sessions") => { /* start a new session or prompt for a workspace */ }, other => other? }

Prevention

When it happens

Trigger: Running resume --last (or equivalent) with a workspace path that has no recorded sessions — get_latest_session_for_workspace returned None.

Common situations: Running from a different directory than where sessions were saved; first run in a fresh checkout; workspace path changed (rename/move) so the stored workspace no longer matches.

Understand the failure class

Background: Record Not Found Errors: "not found", RecordNotFound, and "was not found" — what they mean and how to fix them — this error's family across 28 libraries.

Related errors


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

Appendix: source

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

}

fn latest_session_id_for_workspace(workspace: &Path) -> std::io::Result<Option<String>> {
    let manager = SessionManager::default_location()?;
    Ok(manager
        .get_latest_session_for_workspace(workspace)?
        .map(|session| session.id))
}

fn fork_session(
    config: &Config,
    session_id: Option<String>,
    last: bool,
    workspace: &Path,
) -> Result<String> {
    let manager = SessionManager::default_location()?;
    let saved = if last {
        let Some(meta) = manager.get_latest_session_for_workspace(workspace)? else {
            bail!(
                "No saved sessions found for workspace {}.",
                workspace.display()
            );
        };
        manager.load_session(&meta.id)?
    } else {
        let id = resolve_session_id(session_id, false, workspace)?;
        manager.load_session_by_prefix(&id)?
    };
    let saved_provider_identity = saved
        .metadata
        .model_provider_id
        .as_deref()
        .filter(|identity| !identity.trim().is_empty())
        .unwrap_or(&saved.metadata.model_provider);
    let provider_identity = config
        .resolve_persisted_provider_identity(
            Some(&saved.metadata.model_provider),

View on GitHub (pinned to 73e0f67d83)