{"record":{"id":"f38649d690473464","repo":"nikivdev/code","slug":"session-file-not-found-for-cursor-session","errorCode":null,"errorMessage":"Session file not found for Cursor session {}","messagePattern":"Session file not found for Cursor session (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/ai.rs","lineNumber":15913,"sourceCode":"        let session_file = session\n            .session_path\n            .clone()\n            .or_else(|| find_codex_session_file(&session.session_id));\n        let Some(session_file) = session_file else {\n            bail!(\n                \"Session file not found for Codex session {}\",\n                session.session_id\n            );\n        };\n        return read_codex_cross_project_context(session, &session_file, since_ts, max_count);\n    }\n    if session.provider == Provider::Cursor {\n        let session_file = session\n            .session_path\n            .clone()\n            .or_else(|| find_cursor_session_file(&session.session_id));\n        let Some(session_file) = session_file else {\n            bail!(\n                \"Session file not found for Cursor session {}\",\n                session.session_id\n            );\n        };\n        return read_cursor_cross_project_context(session, &session_file, since_ts, max_count);\n    }\n\n    let projects_dir = match session.provider {\n        Provider::Claude | Provider::All => get_claude_projects_dir(),\n        Provider::Codex => get_codex_projects_dir(),\n        Provider::Cursor => get_cursor_projects_dir(),\n    };\n\n    let project_folder = session.project_path.to_string_lossy().replace('/', \"-\");\n    let session_file = projects_dir\n        .join(&project_folder)\n        .join(format!(\"{}.jsonl\", session.session_id));\n","sourceCodeStart":15895,"sourceCodeEnd":15931,"githubUrl":"https://github.com/nikivdev/code/blob/a747e741ae92c09071d0ae946ab48488adcff1ce/src/ai.rs#L15895-L15931","documentation":"Same pattern as the Codex case but for Cursor-provider sessions: cross-project context needs the Cursor session file, resolved first from session.session_path then via find_cursor_session_file(). If both fail, this error names the session id that could not be located on disk.","triggerScenarios":"Cross-project context requested for provider == Cursor where session_path is None and find_cursor_session_file(session_id) finds no matching file under the Cursor storage root (e.g. ~/.cursor projects state).","commonSituations":"Cursor's workspaceStorage/state.vscdb cleaned or migrated after an app update; machine mismatch (session recorded elsewhere); Cursor data directory moved or HOME changed; session id from an old Cursor version no longer present.","solutions":["Verify the Cursor session/state file exists under the Cursor data directory for that id","Update the saved session's session_path to point directly at the file","Check for Cursor app updates that relocated storage and re-link sessions accordingly","Delete the stale saved session and capture a new one from a live Cursor session"],"exampleFix":"// before\nf ai context --session cur-9f2   # Cursor storage wiped by update\n// after\nls ~/.cursor/**/cur-9f2*         # locate or recreate\nf ai sessions remove cur-9f2     # then re-save from a live Cursor session","handlingStrategy":"validation","validationCode":"# shell: locate the Cursor session artifact before requesting context\nFILE=$(find ~/.cursor -name \"*${SESSION_ID}*\" -print -quit)\n[ -n \"$FILE\" ] || { echo \"no Cursor file for $SESSION_ID\"; exit 1; }\nf ai context --session \"$SESSION_ID\"","typeGuard":null,"tryCatchPattern":"// degrade gracefully when Cursor storage moved\nmatch cross_context(session) {\n    Err(e) if e.to_string().contains(\"Session file not found for Cursor\") => {\n        eprintln!(\"cursor transcript unavailable; skipping context\");\n        Ok(default_context())\n    }\n    other => other,\n}","preventionTips":["Pin session_path when saving Cursor sessions instead of relying on lookup","Re-link sessions after Cursor app updates that relocate storage","Don't wipe ~/.cursor workspace storage while sessions are saved","Check HOME consistency (same user) when consuming saved sessions"],"tags":["session","cursor","file-not-found"],"backgroundTag":"session-file-missing","analyzedSha":"a747e741ae92c09071d0ae946ab48488adcff1ce","analyzedAt":"2026-09-01T22:43:55.719Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}