{"record":{"id":"4f67adb871c8d63c","repo":"nikivdev/code","slug":"session-not-found-in-saved-sessions","errorCode":null,"errorMessage":"Session '{}' not found in saved sessions","messagePattern":"Session '(.+?)' not found in saved sessions","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/ai.rs","lineNumber":15156,"sourceCode":"}\n\n/// Remove a saved session from tracking.\nfn remove_session(session: &str) -> Result<()> {\n    let mut index = load_index()?;\n\n    if index.sessions.remove(session).is_some() {\n        save_index(&index)?;\n        println!(\"Removed session '{}'\", session);\n\n        // Also remove notes if they exist\n        let notes_dir = get_notes_dir()?;\n        let note_file = notes_dir.join(format!(\"{}.md\", session));\n        if note_file.exists() {\n            fs::remove_file(&note_file)?;\n            println!(\"Removed notes file\");\n        }\n    } else {\n        bail!(\"Session '{}' not found in saved sessions\", session);\n    }\n\n    Ok(())\n}\n\n/// Initialize the .ai folder structure.\nfn init_ai_folder() -> Result<()> {\n    let ai_dir = std::env::current_dir()?.join(\".ai\");\n    let internal_dir = ai_dir.join(\"internal\");\n    let sessions_dir = internal_dir.join(\"sessions\").join(\"claude\");\n    let notes_dir = sessions_dir.join(\"notes\");\n\n    fs::create_dir_all(&notes_dir)?;\n\n    // Create empty index.json if it doesn't exist\n    let index_path = sessions_dir.join(\"index.json\");\n    if !index_path.exists() {\n        let index = SessionIndex::default();","sourceCodeStart":15138,"sourceCodeEnd":15174,"githubUrl":"https://github.com/nikivdev/code/blob/a747e741ae92c09071d0ae946ab48488adcff1ce/src/ai.rs#L15138-L15174","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","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"],"exampleFix":"// before\nf ai sessions remove mysesion   # typo\n// after\nf ai sessions list\nf ai sessions remove mysession","handlingStrategy":"validation","validationCode":"# shell: confirm the session exists before removing\nf ai sessions list | grep -qxF \"$SESSION\" && f ai sessions remove \"$SESSION\" \\\n  || echo \"session '$SESSION' not saved\"","typeGuard":null,"tryCatchPattern":"// make remove idempotent for the caller\nif let Err(e) = remove_session(name) {\n    if e.to_string().contains(\"not found in saved sessions\") {\n        eprintln!(\"already removed: {name}\");\n        return Ok(());\n    }\n    return Err(e);\n}","preventionTips":["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"],"tags":["session","not-found","cli"],"backgroundTag":"session-not-found","analyzedSha":"a747e741ae92c09071d0ae946ab48488adcff1ce","analyzedAt":"2026-09-01T22:43:55.719Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}