aboutsummaryrefslogtreecommitdiffstats
path: root/crates/turtle/src/atuin_client/history.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/turtle/src/atuin_client/history.rs')
-rw-r--r--crates/turtle/src/atuin_client/history.rs51
1 files changed, 8 insertions, 43 deletions
diff --git a/crates/turtle/src/atuin_client/history.rs b/crates/turtle/src/atuin_client/history.rs
index 6bc0bc38..5e2f89f2 100644
--- a/crates/turtle/src/atuin_client/history.rs
+++ b/crates/turtle/src/atuin_client/history.rs
@@ -18,24 +18,6 @@ use time::OffsetDateTime;
mod builder;
pub(crate) mod store;
-/// Known AI agent author values. Used to expand `$all-agent` and `$all-user` filters.
-pub(crate) const KNOWN_AGENTS: &[&str] = &["claude-code", "codex", "copilot", "pi"];
-pub(crate) const AUTHOR_FILTER_ALL_USER: &str = "$all-user";
-pub(crate) const AUTHOR_FILTER_ALL_AGENT: &str = "$all-agent";
-
-pub(crate) fn is_known_agent(author: &str) -> bool {
- KNOWN_AGENTS.contains(&author)
-}
-
-pub(crate) fn author_matches_filters(author: &str, filters: &[String]) -> bool {
- filters.is_empty()
- || filters.iter().any(|filter| match filter.as_str() {
- AUTHOR_FILTER_ALL_USER => !is_known_agent(author),
- AUTHOR_FILTER_ALL_AGENT => is_known_agent(author),
- literal => author == literal,
- })
-}
-
pub(crate) const HISTORY_VERSION_V0: &str = "v0";
pub(crate) const HISTORY_VERSION_V1: &str = "v1";
const HISTORY_RECORD_VERSION_V0: u16 = 0;
@@ -527,8 +509,7 @@ impl History {
}
pub(crate) fn should_save(&self, settings: &Settings) -> bool {
- !(self.command.starts_with(' ')
- || self.command.is_empty()
+ !(self.command.is_empty()
|| settings.history_filter.is_match(&self.command)
|| settings.cwd_filter.is_match(&self.cwd)
|| (settings.secrets_filter && SECRET_PATTERNS_RE.is_match(&self.command)))
@@ -540,12 +521,9 @@ mod tests {
use regex::RegexSet;
use time::macros::datetime;
- use crate::{
- history::{AUTHOR_FILTER_ALL_AGENT, AUTHOR_FILTER_ALL_USER, HISTORY_VERSION},
- settings::Settings,
- };
+ use crate::atuin_client::{history::HISTORY_VERSION, settings::Settings};
- use super::{History, author_matches_filters, is_known_agent};
+ use super::History;
// Test that we don't save history where necessary
#[test]
@@ -553,7 +531,7 @@ mod tests {
let settings = Settings {
cwd_filter: RegexSet::new(["^/supasecret"]).unwrap(),
history_filter: RegexSet::new(["^psql"]).unwrap(),
- ..Settings::utc()
+ ..Settings::default()
};
let normal_command: History = History::capture()
@@ -607,19 +585,6 @@ mod tests {
}
#[test]
- fn known_agents_include_pi() {
- assert!(is_known_agent("pi"));
- assert!(author_matches_filters(
- "pi",
- &[AUTHOR_FILTER_ALL_AGENT.to_string()]
- ));
- assert!(!author_matches_filters(
- "pi",
- &[AUTHOR_FILTER_ALL_USER.to_string()]
- ));
- }
-
- #[test]
fn disable_secrets() {
let settings = Settings {
secrets_filter: false,
@@ -641,7 +606,7 @@ mod tests {
let history = History {
id: "66d16cbee7cd47538e5c5b8b44e9006e".to_owned().into(),
timestamp: datetime!(2023-05-28 18:35:40.633872 +00:00),
- duration: 49206000,
+ duration: 49_206_000,
exit: 0,
command: "git status".to_owned(),
cwd: "/Users/conrad.ludgate/Documents/code/atuin".to_owned(),
@@ -669,7 +634,7 @@ mod tests {
let history = History {
id: "66d16cbee7cd47538e5c5b8b44e9006e".to_owned().into(),
timestamp: datetime!(2023-05-28 18:35:40.633872 +00:00),
- duration: 49206000,
+ duration: 49_206_000,
exit: 0,
command: "git status".to_owned(),
cwd: "/Users/conrad.ludgate/Documents/code/atuin".to_owned(),
@@ -693,7 +658,7 @@ mod tests {
let history = History {
id: "66d16cbee7cd47538e5c5b8b44e9006e".to_owned().into(),
timestamp: datetime!(2023-05-28 18:35:40.633872 +00:00),
- duration: 49206000,
+ duration: 49_206_000,
exit: 0,
command: "git status".to_owned(),
cwd: "/Users/conrad.ludgate/Documents/code/atuin".to_owned(),
@@ -735,7 +700,7 @@ mod tests {
let current = History {
id: "66d16cbee7cd47538e5c5b8b44e9006e".to_owned().into(),
timestamp: datetime!(2023-05-28 18:35:40.633872 +00:00),
- duration: 49206000,
+ duration: 49_206_000,
exit: 0,
command: "git status".to_owned(),
cwd: "/Users/conrad.ludgate/Documents/code/atuin".to_owned(),