The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
refactor(notifications): move notification row import into its own module
Steven Enamakel404a92b6b069
diff --git a/crates/openhuman-core/src/agent/orchestration/running_subagents/task_ledger.rs b/crates/openhuman-core/src/agent/orchestration/running_subagents/task_ledger.rsindex ea70c2f596..ffec82d723 100644--- a/crates/openhuman-core/src/agent/orchestration/running_subagents/task_ledger.rs+++ b/crates/openhuman-core/src/agent/orchestration/running_subagents/task_ledger.rs@@ -7,9 +7,7 @@//! orchestration down. What stays here is the record shape and the//! reconciliation of orphaned tasks on boot.-use std::path::Path;-#[cfg(test)]-use std::path::PathBuf;+use std::path::{Path, PathBuf};use std::sync::{Arc, OnceLock};use tinyagents_orchestration::subagent::{diff --git a/crates/openhuman-core/src/desktop/notifications/store_import.rs b/crates/openhuman-core/src/desktop/notifications/store_import.rsindex 90d1f07b2b..c3f2e65cc0 100644--- a/crates/openhuman-core/src/desktop/notifications/store_import.rs+++ b/crates/openhuman-core/src/desktop/notifications/store_import.rs@@ -19,6 +19,10 @@ use anyhow::{Context, Result};use rusqlite::Connection;use serde_json::json;+#[path = "store_import_rows.rs"]+mod store_rows;+use store_rows::rows_to_notifications;+use super::store_documents::{core_id, to_doc, CORE, LOCAL_WORKSPACE, NOTIFICATIONS, SETTINGS,};@@ -145,7 +149,7 @@ fn read_rows(conn: &Connection, workspace: &str) -> Result<Vec<ImportDoc>> {let rows = stmt.query(()).context("[notifications::import] query integration_notifications")?;- for notification in super::rows_to_notifications(rows)? {+ for notification in rows_to_notifications(rows)? {docs.push(ImportDoc {collection: NOTIFICATIONS,id: notification.id.clone(),diff --git a/crates/openhuman-core/src/desktop/notifications/store_import_rows.rs b/crates/openhuman-core/src/desktop/notifications/store_import_rows.rsnew file mode 100644index 0000000000..ffc7a12aa8--- /dev/null+++ b/crates/openhuman-core/src/desktop/notifications/store_import_rows.rs@@ -0,0 +1,72 @@+//! Row conversion for the SQLite notification store.++use crate::storage::rusqlite;+use anyhow::{Context, Result};+use chrono::{DateTime, Utc};++use super::super::types::{IntegrationNotification, NotificationStatus};++pub(super) fn rows_to_notifications(+ mut rows: rusqlite::Rows<'_>,+) -> Result<Vec<IntegrationNotification>> {+ let mut out = Vec::new();+ while let Some(row) = rows+ .next()+ .context("[notifications::store] row iteration failed")?+ {+ out.push(row_to_notification(row)?);+ }+ Ok(out)+}++fn row_to_notification(row: &rusqlite::Row<'_>) -> Result<IntegrationNotification> {+ let raw_payload_str: String = row.get(5)?;+ let raw_payload: serde_json::Value = serde_json::from_str(&raw_payload_str)+ .unwrap_or(serde_json::Value::String(raw_payload_str));++ let status_str: String = row.get(9)?;+ let status = match status_str.as_str() {+ "read" => NotificationStatus::Read,+ "acted" => NotificationStatus::Acted,+ "dismissed" => NotificationStatus::Dismissed,+ _ => NotificationStatus::Unread,+ };++ let received_at_str: String = row.get(10)?;+ let received_at: DateTime<Utc> = received_at_str.parse().unwrap_or_else(|e| {+ tracing::warn!(+ raw = %received_at_str,+ error = %e,+ "[notifications::store] invalid received_at, using now"+ );+ Utc::now()+ });++ let scored_at_str: Option<String> = row.get(11)?;+ let scored_at: Option<DateTime<Utc>> = scored_at_str.and_then(|s| match s.parse() {+ Ok(t) => Some(t),+ Err(e) => {+ tracing::warn!(+ raw = %s,+ error = %e,+ "[notifications::store] invalid scored_at, treating as unscored"+ );+ None+ }+ });++ Ok(IntegrationNotification {+ id: row.get(0)?,+ provider: row.get(1)?,+ account_id: row.get(2)?,+ title: row.get(3)?,+ body: row.get(4)?,+ raw_payload,+ importance_score: row.get(6)?,+ triage_action: row.get(7)?,+ triage_reason: row.get(8)?,+ status,+ received_at,+ scored_at,+ })+}diff --git a/crates/openhuman-core/src/integrations/task_sources/store_import_rows.rs b/crates/openhuman-core/src/integrations/task_sources/store_import_rows.rsindex 4d09d65318..017b35e212 100644--- a/crates/openhuman-core/src/integrations/task_sources/store_import_rows.rs+++ b/crates/openhuman-core/src/integrations/task_sources/store_import_rows.rs@@ -4,7 +4,7 @@ use crate::storage::rusqlite;use anyhow::{Context, Result};use chrono::{DateTime, Utc};-use super::types::{FilterSpec, ProviderSlug, SourceTarget, TaskSource};+use super::super::types::{FilterSpec, ProviderSlug, SourceTarget, TaskSource};pub(super) const SELECT_SOURCE_COLUMNS: &str ="SELECT id, provider, connection_id, name, enabled, filter, \