use crate::{FileSessionStore, RuntimeError, session::SessionState};
use merry_core::SessionId;
pub struct LoadedSession {
state: SessionState,
}
impl LoadedSession {
pub async fn load(
store: &FileSessionStore,
session_id: &SessionId,
) -> Result<Self, RuntimeError> {
Ok(Self {
state: SessionState::load_from(store, session_id).await?,
})
}
pub(crate) fn into_state(self) -> SessionState {
self.state
}
pub(crate) fn transcript_items(&self) -> Vec<crate::SessionTranscriptItem> {
self.state
.full_transcript_snapshot()
.into_iter()
.map(crate::SessionTranscriptItem::from)
.collect()
}
}