Hmbown/CodeWhale · warning · anyhow::Error

No saved sessions found for workspace {}. Use `codewhale ses

Error message

No saved sessions found for workspace {}. Use `codewhale sessions` to list all sessions, or `codewhale resume <SESSION_ID>` to resume one explicitly.

What it means

codewhale resume --last resolves the most recent session recorded for the current workspace via latest_session_id_for_workspace. If the workspace has no recorded sessions, the lookup returns None and resolution stops with this message, which names the workspace and points at 'codewhale sessions' and 'codewhale resume <SESSION_ID>'.

Source

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

    println!("Cleared saved API key.");
    Ok(())
}

async fn run_xai_device_auth(config_path: Option<&Path>) -> Result<()> {
    let pending = xai_oauth::device_code_login().await?;
    let activation = xai_oauth::activate_device_login(pending, config_path, None)?;
    println!(
        "xAI OAuth is ready; activated {} via {}",
        codewhale_config::quote_os_path(&activation.auth_path),
        codewhale_config::quote_os_path(&activation.config_path)
    );
    Ok(())
}

fn resolve_session_id(session_id: Option<String>, last: bool, workspace: &Path) -> Result<String> {
    if last {
        return latest_session_id_for_workspace(workspace)?.ok_or_else(|| {
            anyhow!(
                "No saved sessions found for workspace {}. Use `codewhale sessions` to list all sessions, or `codewhale resume <SESSION_ID>` to resume one explicitly.",
                workspace.display()
            )
        });
    }
    if let Some(id) = session_id {
        return Ok(id);
    }
    pick_session_id()
}

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))
}

View on GitHub (pinned to 8880682c63)

Solutions

  1. Run codewhale sessions to list all sessions, then resume by explicit ID
  2. Start a new session in this workspace once; afterwards --last resolves
  3. Run from the same workspace directory used when the sessions were created
  4. If sessions were expected, verify they were not removed by a cache or session cleanup step

Example fix

# before
codewhale resume --last

# after
codewhale sessions
codewhale resume <SESSION_ID>
Defensive patterns

Strategy: validation

Validate before calling

# List sessions for this workspace before scripting resume --last
codewhale sessions > /dev/null 2>&1 || echo "no session store yet; start a session first"
codewhale sessions | grep -q "$(pwd)" || echo "no sessions recorded for this workspace path"

Prevention

When it happens

Trigger: Running resume --last in a fresh clone or a directory where Codewhale has never persisted a session; the workspace-keyed session store has no entry for this path; sessions were cleared by cleanup.

Common situations: First run on a new machine or clone; after clearing session storage; running from a different directory than where sessions were created — workspace identity is path-based.

Related errors


AI-assisted analysis of Hmbown/CodeWhale@8880682c63 (2026-08-16). Data as JSON: /api/errors/ebbba32bcfb709ec. Report an issue: GitHub.