From 7e47f4df6ceb0fe7e32c166776e4e3b960039b67 Mon Sep 17 00:00:00 2001 From: Ellie Huxtable Date: Sat, 11 Apr 2026 01:32:24 +0100 Subject: feat: add history tail for live monitoring view (#3389) Useful for watching what agents are doing, or viewing live info from other machines. Regardless I am liking it for debugging ## Checks - [ ] I am happy for maintainers to push small adjustments to this PR, to speed up the review cycle - [ ] I have checked that there are no existing pull requests for the same thing --- crates/atuin-daemon/tests/lifecycle.rs | 50 ++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) (limited to 'crates/atuin-daemon/tests') diff --git a/crates/atuin-daemon/tests/lifecycle.rs b/crates/atuin-daemon/tests/lifecycle.rs index 3b6952de..4a91e5cb 100644 --- a/crates/atuin-daemon/tests/lifecycle.rs +++ b/crates/atuin-daemon/tests/lifecycle.rs @@ -145,6 +145,56 @@ mod unix { assert!(!end_reply.id.is_empty()); } + #[tokio::test] + async fn test_tail_history_streams_started_and_ended_events() { + use atuin_client::history::History; + use atuin_daemon::history::HistoryEventKind; + + let (mut client, _handle, _tmp) = start_test_daemon().await; + let mut stream = client.tail_history().await.unwrap(); + + let history = History::daemon() + .timestamp(time::OffsetDateTime::now_utc()) + .command("git status".to_string()) + .cwd("/tmp/repo".to_string()) + .session("tail-session".to_string()) + .hostname("test-host:ellie".to_string()) + .author("claude".to_string()) + .intent("inspect repository state".to_string()) + .build() + .into(); + + let start_reply = client.start_history(history).await.unwrap(); + + let started = stream.message().await.unwrap().unwrap(); + assert_eq!( + HistoryEventKind::try_from(started.kind).unwrap(), + HistoryEventKind::Started + ); + let started_history = started.history.unwrap(); + assert_eq!(started_history.id, start_reply.id); + assert_eq!(started_history.command, "git status"); + assert_eq!(started_history.cwd, "/tmp/repo"); + assert_eq!(started_history.hostname, "test-host:ellie"); + assert_eq!(started_history.author, "claude"); + assert_eq!(started_history.intent, "inspect repository state"); + + client + .end_history(start_reply.id.clone(), 1_000_000, 0) + .await + .unwrap(); + + let ended = stream.message().await.unwrap().unwrap(); + assert_eq!( + HistoryEventKind::try_from(ended.kind).unwrap(), + HistoryEventKind::Ended + ); + let ended_history = ended.history.unwrap(); + assert_eq!(ended_history.id, start_reply.id); + assert_eq!(ended_history.exit, 0); + assert_eq!(ended_history.duration, 1_000_000); + } + #[tokio::test] async fn test_end_unknown_history_fails() { let (mut client, _handle, _tmp) = start_test_daemon().await; -- cgit v1.3.1