aboutsummaryrefslogtreecommitdiffstats
path: root/crates/turtle/src
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--crates/turtle/src/client/mod.rs9
-rw-r--r--crates/turtle/src/history/builder.rs4
-rw-r--r--crates/turtle/src/history/mod.rs24
-rw-r--r--crates/turtle/src/lib.rs2
4 files changed, 9 insertions, 30 deletions
diff --git a/crates/turtle/src/client/mod.rs b/crates/turtle/src/client/mod.rs
index 07f01e6c..ec97c994 100644
--- a/crates/turtle/src/client/mod.rs
+++ b/crates/turtle/src/client/mod.rs
@@ -54,12 +54,12 @@ pub fn history_entry_to_history(entry: HistoryEntry) -> History {
}
#[must_use]
-pub fn daemon_matches_expected(version: &str, protocol: u32) -> bool {
+pub fn daemon_matches_expected(protocol: u32) -> bool {
protocol == DAEMON_PROTOCOL_VERSION
}
#[must_use]
-pub fn daemon_mismatch_message(version: &str, protocol: u32) -> String {
+pub fn daemon_mismatch_message(protocol: u32) -> String {
if protocol == DAEMON_PROTOCOL_VERSION {
unreachable!()
} else {
@@ -110,10 +110,10 @@ pub async fn probe(path: String) -> Probe {
match client.status().await {
Ok(status) => {
- if daemon_matches_expected(&status.version, status.protocol) {
+ if daemon_matches_expected(status.protocol) {
Probe::Ready(client)
} else {
- Probe::NeedsRestart(daemon_mismatch_message(&status.version, status.protocol))
+ Probe::NeedsRestart(daemon_mismatch_message(status.protocol))
}
}
Err(err) => Probe::Unreachable(err),
@@ -129,6 +129,7 @@ pub struct HistoryClient {
client: HistoryServiceClient<Channel>,
}
+#[derive(Clone, Copy, Debug)]
pub struct Range {
pub start: OffsetDateTime,
pub end: OffsetDateTime,
diff --git a/crates/turtle/src/history/builder.rs b/crates/turtle/src/history/builder.rs
index 7eca0491..08d26f7f 100644
--- a/crates/turtle/src/history/builder.rs
+++ b/crates/turtle/src/history/builder.rs
@@ -68,8 +68,8 @@ impl From<HistoryDaemonCapture> for History {
captured.cwd,
-1,
-1,
- Some(captured.session),
- Some(captured.hostname),
+ captured.session,
+ captured.hostname,
captured.author,
captured.intent,
None,
diff --git a/crates/turtle/src/history/mod.rs b/crates/turtle/src/history/mod.rs
index 10e74d8e..27755bbe 100644
--- a/crates/turtle/src/history/mod.rs
+++ b/crates/turtle/src/history/mod.rs
@@ -30,22 +30,6 @@ impl From<String> for HistoryId {
}
}
-pub(crate) fn get_hostname() -> String {
- env::var("ATUIN_HOST_NAME")
- .unwrap_or_else(|_| whoami::hostname().unwrap_or_else(|_| "unknown-host".to_string()))
-}
-
-pub(crate) fn get_username() -> String {
- env::var("ATUIN_HOST_USER")
- .unwrap_or_else(|_| whoami::username().unwrap_or_else(|_| "unknown-user".to_string()))
-}
-
-/// Returns a pair of the hostname and username, separated by a colon.
-#[must_use]
-pub fn get_host_user() -> String {
- format!("{}:{}", get_hostname(), get_username())
-}
-
/// Client-side history entry.
///
/// Client stores data unencrypted, and only encrypts it before sending to the server.
@@ -123,16 +107,12 @@ impl History {
cwd: String,
exit: i64,
duration: i64,
- session: Option<String>,
- hostname: Option<String>,
+ session: String,
+ hostname: String,
author: Option<String>,
intent: Option<String>,
deleted_at: Option<OffsetDateTime>,
) -> Self {
- let session = session
- .or_else(|| env::var("ATUIN_SESSION").ok())
- .unwrap_or_else(|| uuid_v7().as_simple().to_string());
- let hostname = hostname.unwrap_or_else(get_host_user);
let author = Self::normalize_optional_field(author)
.or_else(|| Self::normalize_optional_field(env::var(HISTORY_AUTHOR_ENV).ok()))
.unwrap_or_else(|| Self::author_from_hostname(hostname.as_str()));
diff --git a/crates/turtle/src/lib.rs b/crates/turtle/src/lib.rs
index c78b0475..fbee6761 100644
--- a/crates/turtle/src/lib.rs
+++ b/crates/turtle/src/lib.rs
@@ -1,5 +1,3 @@
-#![expect(unused_crate_dependencies)]
-
pub mod client;
pub mod generated;
pub mod history;