Skip to main content

stint_core/models/
session.rs

1//! Shell session domain model.
2
3use std::path::PathBuf;
4use time::OffsetDateTime;
5
6use super::types::{ProjectId, SessionId};
7
8/// A shell session tracked by the hook.
9///
10/// Each terminal gets a session record. The hook updates `last_heartbeat`
11/// on every prompt render and sets `ended_at` when the shell exits.
12#[derive(Debug, Clone, PartialEq)]
13pub struct ShellSession {
14    /// Unique identifier.
15    pub id: SessionId,
16    /// Shell process PID.
17    pub pid: u32,
18    /// Shell type (e.g., "bash", "zsh", "fish").
19    pub shell: Option<String>,
20    /// Last known working directory.
21    pub cwd: PathBuf,
22    /// The project currently active in this session.
23    pub current_project_id: Option<ProjectId>,
24    /// When this session started.
25    pub started_at: OffsetDateTime,
26    /// Last heartbeat from the shell hook.
27    pub last_heartbeat: OffsetDateTime,
28    /// When this session ended (None if still active).
29    pub ended_at: Option<OffsetDateTime>,
30}