Files
storkit/server/src/state.rs
dave f610ef6046 Restore codebase deleted by bad auto-commit e4227cf
Commit e4227cf (a story creation auto-commit) erroneously deleted 175
files from master's tree, likely due to a race condition between
concurrent git operations. This commit re-adds all files from the
working directory.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-22 19:07:07 +00:00

37 lines
1.0 KiB
Rust

use std::path::PathBuf;
use std::sync::Mutex;
use tokio::sync::watch;
pub struct SessionState {
pub project_root: Mutex<Option<PathBuf>>,
pub cancel_tx: watch::Sender<bool>,
pub cancel_rx: watch::Receiver<bool>,
}
impl Default for SessionState {
fn default() -> Self {
let (cancel_tx, cancel_rx) = watch::channel(false);
Self {
project_root: Mutex::new(None),
cancel_tx,
cancel_rx,
}
}
}
impl SessionState {
pub fn get_project_root(&self) -> Result<PathBuf, String> {
let root_guard = self.project_root.lock().map_err(|e| e.to_string())?;
let root = root_guard.as_ref().ok_or_else(|| {
// TRACE:MERGE-DEBUG — remove once root cause is found
crate::slog_error!(
"[MERGE-DEBUG] get_project_root() called but project_root is None! \
Backtrace hint: check caller in MCP tool handler."
);
"No project is currently open.".to_string()
})?;
Ok(root.clone())
}
}