Implementation:AI Shell Team Aish AishShell resume
| Knowledge Sources | |
|---|---|
| Domains | Session_Management, Shell |
| Last Updated | 2026-10-29 00:00 GMT |
Overview
Concrete tool for restoring a complete interactive shell session from persisted state provided by the aish-shell crate.
= Description
The AishShell::resume constructor creates a new shell instance and immediately calls resume_session_with_options, which loads the target session from the store, reconstructs the LLM session from stored credentials, seeds the context manager with the transcript, starts a PTY in the saved working directory, and wires up the security manager and session store.
The resume_session_with_options method handles the full flow: optionally persisting the current session before switching, loading the target session, seeding context, reconstructing the LLM session, starting the PTY, and optionally printing a resume confirmation. If the resume fails, the transient session is cleaned up.
Usage
Call AishShell::resume to create a shell instance from a saved session. Call resume_session_with_options on an existing shell to switch to a different session at runtime.
Code Reference
Source Location
- Repository: aish
- File: crates/aish-shell/src/app.rs
Signature
impl AishShell {
pub fn resume(config: ConfigModel, session_id: &str) -> aish_core::Result<Self>
fn resume_session_with_options(
&mut self,
session_id: &str,
persist_current: bool,
print_success: bool,
) -> aish_core::Result<()>
}
Import
use crate::app::AishShell;
use aish_config::ConfigModel;
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| config | ConfigModel | Yes | Runtime configuration |
| session_id | &str | Yes | Session UUID to resume |
| persist_current | bool | Yes (options) | Save current session before switching |
| print_success | bool | Yes (options) | Show resume confirmation |
Outputs
| Name | Type | Description |
|---|---|---|
| return | Result<AishShell> | Fully restored shell instance; Err if resume fails |
Usage Examples
Resuming a Session
use crate::app::AishShell;
use aish_config::ConfigModel;
let config = ConfigLoader::load(None)?;
let shell = AishShell::resume(config, &session_id)?;
// Shell is ready with restored LLM session, context, PTY
shell.run_event_loop().await?;
Switching Sessions at Runtime
// On an existing shell instance:
shell.resume_session_with_options(&new_session_id, true, true)?;
// Current session was saved, new session loaded