feat(tui): implement status bar with connection and turn state indicators feat(tui): create workflow panel for agent status and progress visualization feat(web): introduce web frontend interface with static file serving feat(ws): add WebSocket interface for real-time communication and session management
35 lines
1.1 KiB
Rust
35 lines
1.1 KiB
Rust
//! JSON file–backed `ConversationRepository`.
|
||
//! Stores `Conversation` at `<session_dir>/conversation.json`.
|
||
|
||
use std::path::Path;
|
||
|
||
use zesdex_domain::cms::{Conversation, ConversationRepository, RepositoryError};
|
||
|
||
use crate::utils::write_json_atomic;
|
||
|
||
/// File-based `ConversationRepository` that reads/writes `conversation.json`.
|
||
#[derive(Debug, Clone, Default)]
|
||
pub struct JsonConversationRepository;
|
||
|
||
impl JsonConversationRepository {
|
||
pub fn new() -> Self {
|
||
Self
|
||
}
|
||
}
|
||
|
||
impl ConversationRepository for JsonConversationRepository {
|
||
fn load(&self, session_dir: &Path) -> Result<Conversation, RepositoryError> {
|
||
let path = session_dir.join("conversation.json");
|
||
let data = std::fs::read_to_string(&path)?;
|
||
let conv: Conversation = serde_json::from_str(&data)?;
|
||
Ok(conv)
|
||
}
|
||
|
||
fn save(&self, session_dir: &Path, conversation: &Conversation) -> Result<(), RepositoryError> {
|
||
std::fs::create_dir_all(session_dir)?;
|
||
let path = session_dir.join("conversation.json");
|
||
write_json_atomic(&path, conversation, None)?;
|
||
Ok(())
|
||
}
|
||
}
|