From 9cdc575666faad4c162f4b4cf519bfdd1fd528dc Mon Sep 17 00:00:00 2001 From: Benedikt Peetz Date: Fri, 24 Jul 2026 17:56:36 +0200 Subject: feat: Finalize design for fish-shell integration --- crates/turtle/src/history/builder.rs | 11 +++++++++-- crates/turtle/src/history/mod.rs | 17 ++++++++++++----- 2 files changed, 21 insertions(+), 7 deletions(-) (limited to 'crates/turtle/src/history') diff --git a/crates/turtle/src/history/builder.rs b/crates/turtle/src/history/builder.rs index 08d26f7f..57970301 100644 --- a/crates/turtle/src/history/builder.rs +++ b/crates/turtle/src/history/builder.rs @@ -1,3 +1,5 @@ +use std::time::Duration; + use typed_builder::TypedBuilder; use super::History; @@ -12,7 +14,7 @@ pub struct HistoryFromDb { command: String, cwd: String, exit: i64, - duration: i64, + duration: Duration, session: String, hostname: String, author: String, @@ -48,14 +50,19 @@ pub struct HistoryDaemonCapture { timestamp: time::OffsetDateTime, #[builder(setter(into))] command: String, + #[builder(setter(into))] cwd: String, + #[builder(setter(into))] session: String, + #[builder(setter(into))] hostname: String, + #[builder(default, setter(strip_option, into))] author: Option, + #[builder(default, setter(strip_option, into))] intent: Option, } @@ -67,7 +74,7 @@ impl From for History { captured.command, captured.cwd, -1, - -1, + Duration::from_nanos(0), captured.session, captured.hostname, captured.author, diff --git a/crates/turtle/src/history/mod.rs b/crates/turtle/src/history/mod.rs index 27755bbe..3617bc54 100644 --- a/crates/turtle/src/history/mod.rs +++ b/crates/turtle/src/history/mod.rs @@ -2,6 +2,8 @@ use core::fmt::Formatter; use regex::RegexSet; use std::env; use std::fmt::Display; +use std::time::Duration; +use uuid::Uuid; use turtle_common::utils::uuid_v7; @@ -15,8 +17,8 @@ mod secrets; const HISTORY_AUTHOR_ENV: &str = "ATUIN_HISTORY_AUTHOR"; const HISTORY_INTENT_ENV: &str = "ATUIN_HISTORY_INTENT"; -#[derive(Clone, Debug, Eq, PartialEq, Hash)] -pub struct HistoryId(pub String); +#[derive(Clone, Debug, Eq, PartialEq, Hash, Copy)] +pub struct HistoryId(Uuid); impl Display for HistoryId { fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { @@ -26,7 +28,12 @@ impl Display for HistoryId { impl From for HistoryId { fn from(s: String) -> Self { - Self(s) + Self(Uuid::parse_str(&s).expect("should be a valid uuid")) + } +} +impl From<&str> for HistoryId { + fn from(s: &str) -> Self { + Self(Uuid::parse_str(s).expect("should be a valid uuid")) } } @@ -54,7 +61,7 @@ pub struct History { pub timestamp: OffsetDateTime, /// How long the command took to run. - pub duration: i64, + pub duration: Duration, /// The exit code of the command. pub exit: i64, @@ -106,7 +113,7 @@ impl History { command: String, cwd: String, exit: i64, - duration: i64, + duration: Duration, session: String, hostname: String, author: Option, -- cgit v1.3.1