nikivdev/code · error

Session file not found for Cursor session {}

Error message

Session file not found for Cursor session {}

What it means

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.

Source

Thrown at src/ai.rs:15913

        let session_file = session
            .session_path
            .clone()
            .or_else(|| find_codex_session_file(&session.session_id));
        let Some(session_file) = session_file else {
            bail!(
                "Session file not found for Codex session {}",
                session.session_id
            );
        };
        return read_codex_cross_project_context(session, &session_file, since_ts, max_count);
    }
    if session.provider == Provider::Cursor {
        let session_file = session
            .session_path
            .clone()
            .or_else(|| find_cursor_session_file(&session.session_id));
        let Some(session_file) = session_file else {
            bail!(
                "Session file not found for Cursor session {}",
                session.session_id
            );
        };
        return read_cursor_cross_project_context(session, &session_file, since_ts, max_count);
    }

    let projects_dir = match session.provider {
        Provider::Claude | Provider::All => get_claude_projects_dir(),
        Provider::Codex => get_codex_projects_dir(),
        Provider::Cursor => get_cursor_projects_dir(),
    };

    let project_folder = session.project_path.to_string_lossy().replace('/', "-");
    let session_file = projects_dir
        .join(&project_folder)
        .join(format!("{}.jsonl", session.session_id));

View on GitHub (pinned to a747e741ae)

Solutions

  1. Verify the Cursor session/state file exists under the Cursor data directory for that id
  2. Update the saved session's session_path to point directly at the file
  3. Check for Cursor app updates that relocated storage and re-link sessions accordingly
  4. Delete the stale saved session and capture a new one from a live Cursor session

Example fix

// before
f ai context --session cur-9f2   # Cursor storage wiped by update
// after
ls ~/.cursor/**/cur-9f2*         # locate or recreate
f ai sessions remove cur-9f2     # then re-save from a live Cursor session
Defensive patterns

Strategy: validation

Validate before calling

# shell: locate the Cursor session artifact before requesting context
FILE=$(find ~/.cursor -name "*${SESSION_ID}*" -print -quit)
[ -n "$FILE" ] || { echo "no Cursor file for $SESSION_ID"; exit 1; }
f ai context --session "$SESSION_ID"

Try / catch

// degrade gracefully when Cursor storage moved
match cross_context(session) {
    Err(e) if e.to_string().contains("Session file not found for Cursor") => {
        eprintln!("cursor transcript unavailable; skipping context");
        Ok(default_context())
    }
    other => other,
}

Prevention

When it happens

Trigger: 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).

Common situations: 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.

Related errors


AI-assisted analysis of nikivdev/code@a747e741ae (2026-09-01). Data as JSON: /api/errors/f38649d690473464. Report an issue: GitHub.