Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

style: reformat notification and task source store code

Steven Enamakelf6ae6c972444
diff --git a/crates/openhuman-core/src/desktop/notifications/store.rs b/crates/openhuman-core/src/desktop/notifications/store.rs
index ab9b28bbab..48edf771cf 100644
--- a/crates/openhuman-core/src/desktop/notifications/store.rs
+++ b/crates/openhuman-core/src/desktop/notifications/store.rs
@@ -182,7 +182,11 @@ pub fn list_core_notifications(
limit: usize,
) -> Result<Vec<CoreNotificationEvent>> {
if let Some(docs) = super::store_documents::current()? {
- return docs.list_core_notifications(&config.workspace_dir.to_string_lossy(), only_unread, limit);
+ return docs.list_core_notifications(
+ &config.workspace_dir.to_string_lossy(),
+ only_unread,
+ limit,
+ );
}
with_connection(config, |conn| {
let sql = if only_unread {
diff --git a/crates/openhuman-core/src/desktop/notifications/store_documents_tests.rs b/crates/openhuman-core/src/desktop/notifications/store_documents_tests.rs
index 2f06c88eba..5de61b2832 100644
--- a/crates/openhuman-core/src/desktop/notifications/store_documents_tests.rs
+++ b/crates/openhuman-core/src/desktop/notifications/store_documents_tests.rs
@@ -95,9 +95,14 @@ fn content_older_than_the_window_is_not_a_duplicate() {
store
.0
.run(|docs| async move {
- docs.put(DEDUP, &dedup, json!({ "last_ms": stale }), Precondition::Absent)
- .await
- .map(|_| ())
+ docs.put(
+ DEDUP,
+ &dedup,
+ json!({ "last_ms": stale }),
+ Precondition::Absent,
+ )
+ .await
+ .map(|_| ())
})
.unwrap();
assert!(!store
@@ -111,39 +116,71 @@ fn dedup_follows_arrival_not_the_notifications_own_timestamp() {
let store = docs();
// A delayed event (stamped two minutes ago) and a future-dated one both
// arrived now, so identical content right after is a duplicate either way.
- assert!(store.insert(&note("a", "slack", "late", 120), true).unwrap());
+ assert!(store
+ .insert(&note("a", "slack", "late", 120), true)
+ .unwrap());
assert!(!store.insert(&note("b", "slack", "late", 0), true).unwrap());
- assert!(store.insert(&note("c", "slack", "future", -3600), true).unwrap());
- assert!(!store.insert(&note("d", "slack", "future", 0), true).unwrap());
+ assert!(store
+ .insert(&note("c", "slack", "future", -3600), true)
+ .unwrap());
+ assert!(!store
+ .insert(&note("d", "slack", "future", 0), true)
+ .unwrap());
}
#[test]
fn a_failed_insert_releases_its_dedup_claim() {
let store = docs();
- store.insert(&note("taken", "slack", "first", 0), false).unwrap();
+ store
+ .insert(&note("taken", "slack", "first", 0), false)
+ .unwrap();
// Same id, new content: the claim succeeds, the notification put fails.
- assert!(store.insert(&note("taken", "slack", "second", 0), true).is_err());
+ assert!(store
+ .insert(&note("taken", "slack", "second", 0), true)
+ .is_err());
assert!(
!store
.exists_recent("slack", Some("acct"), "New message", "second")
.unwrap(),
"the claim was rolled back"
);
- assert!(store.insert(&note("fresh", "slack", "second", 0), true).unwrap());
+ assert!(store
+ .insert(&note("fresh", "slack", "second", 0), true)
+ .unwrap());
}
#[test]
fn workspaces_keep_core_notifications_apart() {
let store = docs();
- assert!(store.insert_core_notification("/workspace/a", &event("e", 1)).unwrap());
- assert!(store.insert_core_notification("/workspace/b", &event("e", 2)).unwrap());
- let a = store.list_core_notifications("/workspace/a", false, 10).unwrap();
+ assert!(store
+ .insert_core_notification("/workspace/a", &event("e", 1))
+ .unwrap());
+ assert!(store
+ .insert_core_notification("/workspace/b", &event("e", 2))
+ .unwrap());
+ let a = store
+ .list_core_notifications("/workspace/a", false, 10)
+ .unwrap();
assert_eq!(a.len(), 1);
assert_eq!(a[0].timestamp_ms, 1);
- assert!(store.mark_core_notification_read("/workspace/a", "e").unwrap());
- assert_eq!(store.unread_core_notification_count("/workspace/a").unwrap(), 0);
- assert_eq!(store.unread_core_notification_count("/workspace/b").unwrap(), 1);
- assert!(!store.mark_core_notification_read("/workspace/c", "e").unwrap());
+ assert!(store
+ .mark_core_notification_read("/workspace/a", "e")
+ .unwrap());
+ assert_eq!(
+ store
+ .unread_core_notification_count("/workspace/a")
+ .unwrap(),
+ 0
+ );
+ assert_eq!(
+ store
+ .unread_core_notification_count("/workspace/b")
+ .unwrap(),
+ 1
+ );
+ assert!(!store
+ .mark_core_notification_read("/workspace/c", "e")
+ .unwrap());
}
#[test]
@@ -241,13 +278,18 @@ fn core_notifications_persist_once_and_mark_read() {
["a"]
);
assert_eq!(store.unread_core_notification_count(WS).unwrap(), 1);
- assert!(store.list_core_notifications(WS, false, 0).unwrap().is_empty());
+ assert!(store
+ .list_core_notifications(WS, false, 0)
+ .unwrap()
+ .is_empty());
}
#[test]
fn a_corrupt_core_payload_is_skipped() {
let store = docs();
- store.insert_core_notification(WS, &event("good", 1)).unwrap();
+ store
+ .insert_core_notification(WS, &event("good", 1))
+ .unwrap();
store
.0
.run(|docs| async move {
diff --git a/crates/openhuman-core/src/integrations/task_sources/store_documents_tests.rs b/crates/openhuman-core/src/integrations/task_sources/store_documents_tests.rs
index 3e16b3ecc7..55dcb6f573 100644
--- a/crates/openhuman-core/src/integrations/task_sources/store_documents_tests.rs
+++ b/crates/openhuman-core/src/integrations/task_sources/store_documents_tests.rs
@@ -164,7 +164,9 @@ fn ledger_lists_refs_oldest_first_and_tasks_newest_first() {
store
.mark_ingested_at("s", &task("1", "one"), base - chrono::Duration::seconds(10))
.unwrap();
- store.mark_ingested_at("s", &task("2", "two"), base).unwrap();
+ store
+ .mark_ingested_at("s", &task("2", "two"), base)
+ .unwrap();
store.add_source(&source("other")).unwrap();
store.mark_ingested("other", &task("9", "nine")).unwrap();
let refs: Vec<String> = store