nikivdev/code · error
Session '{}' not found in saved sessions
Error message
Session '{}' not found in saved sessions What it means
Thrown by the session-remove command when the given session name is not a key in the saved-sessions index. The code only reaches this bail when the lookup branch found no matching session entry, so the removal target does not exist. Note this specific message covers a lookup miss even though a notes file may exist on disk.
Source
Thrown at src/ai.rs:15156
}
/// Remove a saved session from tracking.
fn remove_session(session: &str) -> Result<()> {
let mut index = load_index()?;
if index.sessions.remove(session).is_some() {
save_index(&index)?;
println!("Removed session '{}'", session);
// Also remove notes if they exist
let notes_dir = get_notes_dir()?;
let note_file = notes_dir.join(format!("{}.md", session));
if note_file.exists() {
fs::remove_file(¬e_file)?;
println!("Removed notes file");
}
} else {
bail!("Session '{}' not found in saved sessions", session);
}
Ok(())
}
/// Initialize the .ai folder structure.
fn init_ai_folder() -> Result<()> {
let ai_dir = std::env::current_dir()?.join(".ai");
let internal_dir = ai_dir.join("internal");
let sessions_dir = internal_dir.join("sessions").join("claude");
let notes_dir = sessions_dir.join("notes");
fs::create_dir_all(¬es_dir)?;
// Create empty index.json if it doesn't exist
let index_path = sessions_dir.join("index.json");
if !index_path.exists() {
let index = SessionIndex::default();View on GitHub (pinned to a747e741ae)
Solutions
- Run `f ai sessions list` to see exact saved session names and use one verbatim
- Correct the spelling of the session name argument
- If already removed, treat the operation as a no-op and skip
- Check you are in the project directory whose .ai/ index contains the session
Example fix
// before f ai sessions remove mysesion # typo // after f ai sessions list f ai sessions remove mysession
Defensive patterns
Strategy: validation
Validate before calling
# shell: confirm the session exists before removing f ai sessions list | grep -qxF "$SESSION" && f ai sessions remove "$SESSION" \ || echo "session '$SESSION' not saved"
Try / catch
// make remove idempotent for the caller
if let Err(e) = remove_session(name) {
if e.to_string().contains("not found in saved sessions") {
eprintln!("already removed: {name}");
return Ok(());
}
return Err(e);
} Prevention
- Copy names verbatim from `f ai sessions list`
- Run remove commands from the same project directory whose .ai/ index holds the session
- Script removals against the list output, not memorized names
- Treat 'not found' on remove as success in automation
When it happens
Trigger: Calling session remove with a name string that is not present in the loaded sessions index (typo, already removed, or saved under a different name).
Common situations: Typos in session names; the session was removed in another checkout/machine where the index lives in .ai/; stale memory of old session names; running the remove command from a different project directory with a different index.
Related errors
- failed to resume {} session {}
- Session not found
- Project not found. Create it with `f env push` first.
- Key '{}' not found
- No running process found for task '{}'
AI-assisted analysis of nikivdev/code@a747e741ae (2026-09-01).
Data as JSON: /api/errors/4f67adb871c8d63c.
Report an issue: GitHub.