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
style(web_chat): reformat voice note code and tests
Steven Enamakele111c2166292
diff --git a/crates/openhuman-core/src/web_chat/reply_persistence_tests.rs b/crates/openhuman-core/src/web_chat/reply_persistence_tests.rsindex 1d53b46d60..e236379367 100644--- a/crates/openhuman-core/src/web_chat/reply_persistence_tests.rs+++ b/crates/openhuman-core/src/web_chat/reply_persistence_tests.rs@@ -237,6 +237,12 @@ fn a_spoken_reply_row_points_at_its_stored_audio() {persist_delivered_reply(&ctx, &ws, "t-no-audio", "req-w", "Hi", &[]).ok();let messages = conversations::get_messages(&ctx, ws.clone(), "t-voice").expect("messages");- assert_eq!(messages[0].extra_metadata["voiceNote"]["noteId"], "reply-req-v");- assert_eq!(messages[0].extra_metadata["voiceNote"]["mime"], "audio/mpeg");+ assert_eq!(+ messages[0].extra_metadata["voiceNote"]["noteId"],+ "reply-req-v"+ );+ assert_eq!(+ messages[0].extra_metadata["voiceNote"]["mime"],+ "audio/mpeg"+ );}diff --git a/crates/openhuman-core/src/web_chat/schemas.rs b/crates/openhuman-core/src/web_chat/schemas.rsindex 348eb3553a..d23623a8c5 100644--- a/crates/openhuman-core/src/web_chat/schemas.rs+++ b/crates/openhuman-core/src/web_chat/schemas.rs@@ -14,7 +14,8 @@ use super::ops::{channel_web_queue_status,};use super::types::{- ChatRequestMetadata, VoiceNoteReadParams, VoiceNoteStoreParams, WebCancelParams, WebChatParams, WebQueueParams, WebQueueRemoveParams,+ ChatRequestMetadata, VoiceNoteReadParams, VoiceNoteStoreParams, WebCancelParams, WebChatParams,+ WebQueueParams, WebQueueRemoveParams,};pub fn all_web_channel_controller_schemas() -> Vec<ControllerSchema> {diff --git a/crates/openhuman-core/src/web_chat/voice_notes.rs b/crates/openhuman-core/src/web_chat/voice_notes.rsindex f9f44da7aa..0dbdf670fc 100644--- a/crates/openhuman-core/src/web_chat/voice_notes.rs+++ b/crates/openhuman-core/src/web_chat/voice_notes.rs@@ -34,7 +34,13 @@ const KNOWN: &[(&str, &str)] = &[pub(crate) fn reply_note_id(request_id: &str) -> String {let safe: String = request_id.chars()- .map(|c| if c.is_ascii_alphanumeric() || c == '-' { c } else { '_' })+ .map(|c| {+ if c.is_ascii_alphanumeric() || c == '-' {+ c+ } else {+ '_'+ }+ }).collect();format!("reply-{safe}")}@@ -49,7 +55,12 @@ pub(crate) fn is_valid_note_id(id: &str) -> bool {}fn extension_for_mime(mime: &str) -> &'static str {- let base = mime.split(';').next().unwrap_or("").trim().to_ascii_lowercase();+ let base = mime+ .split(';')+ .next()+ .unwrap_or("")+ .trim()+ .to_ascii_lowercase();match base.as_str() {"audio/ogg" => "ogg","audio/mp4" | "audio/x-m4a" | "audio/aac" => "m4a",@@ -88,8 +99,15 @@ pub(crate) fn store_note(}std::fs::write(root.join(format!("{id}.{ext}")), bytes).map_err(|e| format!("write voice note: {e}"))?;- log::debug!("{LOG_PREFIX} stored id={id} ext={ext} bytes={}", bytes.len());- Ok(KNOWN.iter().find(|(e, _)| *e == ext).map(|(_, m)| *m).unwrap_or("audio/webm"))+ log::debug!(+ "{LOG_PREFIX} stored id={id} ext={ext} bytes={}",+ bytes.len()+ );+ Ok(KNOWN+ .iter()+ .find(|(e, _)| *e == ext)+ .map(|(_, m)| *m)+ .unwrap_or("audio/webm"))}/// Reads note `id`; `Ok(None)` when no file exists.diff --git a/crates/openhuman-core/src/web_chat/voice_notes_tests.rs b/crates/openhuman-core/src/web_chat/voice_notes_tests.rsindex ea5e7c1c36..a43f6e929e 100644--- a/crates/openhuman-core/src/web_chat/voice_notes_tests.rs+++ b/crates/openhuman-core/src/web_chat/voice_notes_tests.rs@@ -68,8 +68,18 @@ fn rpc_round_trip_and_bad_base64() {fn synthesized_reply_is_stored_only_with_decodable_audio() {let tmp = tempfile::tempdir().unwrap();assert!(!store_synthesized_reply(tmp.path(), "r1", "", "audio/mpeg"));- assert!(!store_synthesized_reply(tmp.path(), "r1", "***", "audio/mpeg"));- assert!(store_synthesized_reply(tmp.path(), "r1", "YWJj", "audio/mpeg"));+ assert!(!store_synthesized_reply(+ tmp.path(),+ "r1",+ "***",+ "audio/mpeg"+ ));+ assert!(store_synthesized_reply(+ tmp.path(),+ "r1",+ "YWJj",+ "audio/mpeg"+ ));assert!(reply_note_metadata(tmp.path(), "r1").is_some());}@@ -79,10 +89,23 @@ fn reply_mode_decides_when_the_reply_is_spoken() {let mut config = crate::config::Config::default();// Default is mirror: only a voice-note turn is answered aloud.assert!(!should_speak_reply(&config, "t", None, Some("keyboard")));- assert!(should_speak_reply(&config, "t", None, Some(VOICE_NOTE_SOURCE)));+ assert!(should_speak_reply(+ &config,+ "t",+ None,+ Some(VOICE_NOTE_SOURCE)+ ));assert!(should_speak_reply(&config, "t", Some(true), None));config.channel_voice.reply_mode = VoiceReplyMode::Always;assert!(should_speak_reply(&config, "t", None, None));- config.channel_voice.threads.insert("t".into(), VoiceReplyMode::Never);- assert!(!should_speak_reply(&config, "t", None, Some(VOICE_NOTE_SOURCE)));+ config+ .channel_voice+ .threads+ .insert("t".into(), VoiceReplyMode::Never);+ assert!(!should_speak_reply(+ &config,+ "t",+ None,+ Some(VOICE_NOTE_SOURCE)+ ));}