Skip to main content

Module session_store

Module session_store 

Source
Expand description

Session persistence for devshell.

  • Workspace session (preferred): ENV_DEVSHELL_WORKSPACE_ROOT — metadata at $DEVSHELL_WORKSPACE_ROOT/.cargo-devshell/session.json (see docs/requirements.md §1.1). On Unix, crate::devshell::vm::export_devshell_workspace_root_env sets this before REPL.
  • Mode S: legacy .dev_shell.bin via crate::devshell::serialization when applicable.
  • Mode P (guest-primary): no legacy bin on exit; JSON holds logical_cwd only.
  • Fallback (no DEVSHELL_WORKSPACE_ROOT): ./.cargo-devshell/session.json under std::env::current_dir when it succeeds (local dev / tests).
  • Legacy (migration only): {stem}.session.json beside the bin path (e.g. .dev_shell.bin.dev_shell.session.json); still read on load, no longer preferred for new saves.
  • Load order: workspace env path → cwd workspace path → legacy beside bin_path.

Structs§

GuestPrimarySessionV1
Serialize / deserialize guest-primary session file under ENV_DEVSHELL_WORKSPACE_ROOT.

Constants§

ENV_DEVSHELL_WORKSPACE_ROOT
Environment variable: host directory aligned with guest workspace (Lima γ).
FORMAT_DEVSHELL_SESSION_V1
JSON format field for GuestPrimarySessionV1.

Functions§

apply_guest_primary_startup
On guest-primary startup: if a v1 session file exists, reset VFS to empty and restore logical_cwd (creating directories as needed so crate::devshell::vfs::Vfs::set_cwd succeeds).
cwd_session_metadata_path
Same layout as workspace_session_metadata_path, but rooted at std::env::current_dir.
load_guest_primary
Load guest-primary metadata: workspace env path, then cwd .cargo-devshell/session.json, then legacy beside bin_path.
save_guest_primary
Save guest-primary session metadata (JSON). Does not write .dev_shell.bin.
session_metadata_path
Resolved path to write guest-primary session JSON: workspace env → cwd .cargo-devshell/ → legacy beside bin_path.
session_path_for_bin
Companion path for guest-primary metadata next to a legacy .bin snapshot path.
workspace_session_metadata_path
Session file under $DEVSHELL_WORKSPACE_ROOT/.cargo-devshell/session.json when the env var is set.