//! History component. //! //! Handles command history lifecycle (start/end) and provides the History gRPC service. use crate::{ aclient::{history::store::HistoryStore, settings::Settings}, api::server::history::HistoryGrpcService, }; use eyre::Result; use crate::{ daemon::{Component, DaemonHandle}, events::DaemonEvent, }; #[tonic::async_trait] impl Component for HistoryGrpcService { fn name(&self) -> &'static str { "history" } async fn start(&mut self, handle: DaemonHandle) -> Result<()> { // Create the history store let host_id = Settings::host_id().await?; let history_store = HistoryStore::new(handle.store().clone(), host_id, *handle.encryption_key()); *self.history_store.write().await = Some(history_store); *self.handle.write().await = Some(handle); tracing::info!("history component started"); Ok(()) } async fn handle_event(&mut self, _event: &DaemonEvent) -> Result<()> { // History component produces events but doesn't need to react to them Ok(()) } async fn stop(&mut self) -> Result<()> { tracing::info!("history component stopped"); Ok(()) } }