aboutsummaryrefslogtreecommitdiffstats
path: root/crates/turtle/src/atuin_daemon/client.rs
diff options
context:
space:
mode:
authorBenedikt Peetz <benedikt.peetz@b-peetz.de>2026-06-12 17:16:19 +0200
committerBenedikt Peetz <benedikt.peetz@b-peetz.de>2026-06-12 17:16:19 +0200
commit2ca7dd57b12861e8c9bbc9238cda612e0ff22ff3 (patch)
tree302a644f6a50d60cc8304c4498fe6bbb72ddaaa9 /crates/turtle/src/atuin_daemon/client.rs
parentfeat(server): Really make users stateless (with tests) (diff)
downloadatuin-2ca7dd57b12861e8c9bbc9238cda612e0ff22ff3.zip
chore(treewide): Cleanup themes
Diffstat (limited to 'crates/turtle/src/atuin_daemon/client.rs')
-rw-r--r--crates/turtle/src/atuin_daemon/client.rs83
1 files changed, 2 insertions, 81 deletions
diff --git a/crates/turtle/src/atuin_daemon/client.rs b/crates/turtle/src/atuin_daemon/client.rs
index a0a27741..325b21b8 100644
--- a/crates/turtle/src/atuin_daemon/client.rs
+++ b/crates/turtle/src/atuin_daemon/client.rs
@@ -29,8 +29,7 @@ use crate::atuin_daemon::search::{
search_client::SearchClient as SearchServiceClient,
};
use crate::atuin_daemon::semantic::{
- CommandCapture, CommandOutputReply, CommandOutputRequest, OutputRange, RecordCommandsReply,
- semantic_client::SemanticClient as SemanticServiceClient,
+ CommandCapture, RecordCommandsReply, semantic_client::SemanticClient as SemanticServiceClient,
};
pub(crate) struct HistoryClient {
@@ -112,7 +111,7 @@ impl HistoryClient {
duration: u64,
exit: i64,
) -> Result<EndHistoryReply> {
- let req = EndHistoryRequest { id, duration, exit };
+ let req = EndHistoryRequest { id, exit, duration };
Ok(self.client.end_history(req).await?.into_inner())
}
@@ -255,22 +254,6 @@ impl SemanticClient {
let stream = tokio_stream::iter(captures);
Ok(self.client.record_commands(stream).await?.into_inner())
}
-
- pub(crate) async fn command_output(
- &mut self,
- history_id: String,
- ranges: Vec<(i64, i64)>,
- ) -> Result<CommandOutputReply> {
- let request = CommandOutputRequest {
- history_id,
- ranges: ranges
- .into_iter()
- .map(|(start, end)| OutputRange { start, end })
- .collect(),
- };
-
- Ok(self.client.command_output(request).await?.into_inner())
- }
}
// ============================================================================
@@ -354,65 +337,3 @@ fn daemon_event_to_proto(
}
}
}
-
-// ============================================================================
-// Convenience Functions
-// ============================================================================
-
-/// Emit an event to the daemon.
-///
-/// This is a fire-and-forget helper for sending events to the daemon from
-/// external processes like CLI commands. If the daemon isn't running, this
-/// will silently succeed (returns Ok).
-///
-/// # Example
-///
-/// ```ignore
-/// // After pruning history
-/// emit_event(DaemonEvent::HistoryPruned).await?;
-///
-/// // After deleting specific history items
-/// emit_event(DaemonEvent::HistoryDeleted { ids: vec![...] }).await?;
-///
-/// // Request immediate sync
-/// emit_event(DaemonEvent::ForceSync).await?;
-/// ```
-pub(crate) async fn emit_event(event: DaemonEvent) -> Result<()> {
- emit_event_with_settings(event, None).await
-}
-
-/// Emit an event to the daemon with explicit settings.
-///
-/// If settings are not provided, they will be loaded from the default location.
-/// If the daemon isn't running, this will silently succeed.
-pub(crate) async fn emit_event_with_settings(
- event: DaemonEvent,
- settings: Option<&Settings>,
-) -> Result<()> {
- // Load settings if not provided
- let owned_settings;
- let settings = match settings {
- Some(s) => s,
- None => {
- owned_settings = Settings::new()?;
- &owned_settings
- }
- };
-
- // Try to connect - if daemon isn't running, that's fine
- let mut client = match ControlClient::from_settings(settings).await {
- Ok(c) => c,
- Err(e) => {
- tracing::debug!(?e, "daemon not running, skipping event emission");
- return Ok(());
- }
- };
-
- // Send the event
- if let Err(e) = client.send_event(event).await {
- tracing::debug!(?e, "failed to send event to daemon");
- // Don't fail - this is fire-and-forget
- }
-
- Ok(())
-}