use serde::Serialize;
use std::path::PathBuf;
#[derive(Clone, Debug, Eq, PartialEq, Serialize)]
pub struct Session {
pub id: String,
pub title: String,
pub directory: PathBuf,
pub path: Option<String>,
pub agent: Option<String>,
pub model: Option<String>,
pub project: Option<String>,
pub worktree: Option<PathBuf>,
pub updated: i64,
pub created: i64,
pub db: PathBuf,
pub preview: Option<String>,
}
impl Session {
pub fn haystack(&self) -> String {
[self.core(), self.paths()].join(" ").to_lowercase()
}
pub fn core(&self) -> String {
[
self.id.as_str(),
self.title.as_str(),
self.agent.as_deref().unwrap_or_default(),
self.model.as_deref().unwrap_or_default(),
self.project.as_deref().unwrap_or_default(),
self.preview.as_deref().unwrap_or_default(),
]
.join(" ")
.to_lowercase()
}
pub fn paths(&self) -> String {
[
self.directory.to_str().unwrap_or_default(),
self.path.as_deref().unwrap_or_default(),
self.worktree
.as_ref()
.and_then(|p| p.to_str())
.unwrap_or_default(),
]
.join(" ")
.to_lowercase()
}
}