nikivdev/code · error

Session not found

Error message

Session not found

What it means

Thrown by the interactive cross-project session picker: the user selected (or the input resolved to) a display string that does not match any directory entry in the entries list, so the find() over entries fails. It is a guard that the chosen selection corresponds to a real stored session directory before loading its context.

Source

Thrown at src/ai.rs:15611

            writeln!(stdin, "{}", display)?;
        }
    }

    let output = child.wait_with_output()?;
    if !output.status.success() {
        return Ok(());
    }

    let selection = String::from_utf8(output.stdout).context("fzf output was not valid UTF-8")?;
    let selection = selection.trim();

    if selection.is_empty() {
        return Ok(());
    }

    // Find selected session
    let Some((_, session)) = entries.iter().find(|(d, _)| d == selection) else {
        bail!("Session not found");
    };

    // Get context since last consumed checkpoint (or full if --full)
    let context = get_cross_project_context(session, opts.count, opts.full)?;

    if context.is_empty() {
        if opts.full {
            println!("No context found in session.");
        } else {
            println!("No new context since last consumption. Use --full for entire session.");
        }
        return Ok(());
    }

    let output = if opts.handoff {
        summarize_handoff_with_gemini(&context)?
    } else {
        context

View on GitHub (pinned to a747e741ae)

Solutions

  1. Re-run the picker command so the entry list is refreshed and select from the fresh list
  2. Select an entry from the list rather than typing free-form input
  3. Verify the cross-project sessions directory still exists and contains session folders
  4. Clear stale session directories and regenerate the list

Example fix

// before
f ai context --pick   # picks stale entry deleted earlier
// after
rm -rf stale-session-dir; f ai context --pick   # fresh listing, valid selection
Defensive patterns

Strategy: validation

Validate before calling

# shell: refresh listing immediately before selecting, and match exactly
entries=$(ls "${CROSS_PROJECT_DIR:?}")
grep -Fxq "$SELECTION" <<<"$entries" || { echo "selection not in current list"; exit 1; }

Try / catch

// re-list and retry once when selection misses
match pick_and_load() {
    Err(e) if e.to_string() == "Session not found" => {
        refresh_entries();
        pick_and_load().context("selection stale after re-list")
    }
    other => other,
}

Prevention

When it happens

Trigger: The selection prompt returns an empty-matched non-empty string — e.g. stale entries listed, user typing a custom value into a fuzzy/select prompt, or entries mutated between listing and selection so the chosen display string no longer matches.

Common situations: Sessions were deleted by another process between listing and selection; custom prompt input that isn't an exact directory name; unicode/whitespace differences between displayed label and the underlying directory name.

Related errors


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