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(web_chat): update context passing in voice note persistence
Steven Enamakel548c6a3f3193
diff --git a/crates/openhuman-core/src/web_chat/reply_persistence.rs b/crates/openhuman-core/src/web_chat/reply_persistence.rsindex 5d48eeacf8..8f0dc3175a 100644--- a/crates/openhuman-core/src/web_chat/reply_persistence.rs+++ b/crates/openhuman-core/src/web_chat/reply_persistence.rs@@ -72,7 +72,7 @@ pub(crate) fn persist_delivered_reply(extra_metadata["citations"] = json!(citations);}// The audio a spoken reply was synthesized into, if the turn stored any.- if let Some(note) = super::voice_notes::reply_note_metadata(workspace_dir, request_id) {+ if let Some(note) = super::voice_notes::reply_note_metadata(ctx, workspace_dir, request_id) {extra_metadata["voiceNote"] = note;}conversations::append_message(diff --git a/crates/openhuman-core/src/web_chat/reply_persistence_tests.rs b/crates/openhuman-core/src/web_chat/reply_persistence_tests.rsindex ae1b9b16e7..797bdb1c60 100644--- a/crates/openhuman-core/src/web_chat/reply_persistence_tests.rs+++ b/crates/openhuman-core/src/web_chat/reply_persistence_tests.rs@@ -237,7 +237,6 @@ fn a_spoken_reply_row_points_at_its_stored_audio() {"req-v","YWJj","audio/mpeg",- &[] as &[serde_json::Value],);persist_delivered_reply(&ctx, &ws, "t-voice", "req-v", "Hello", &[]).expect("append");persist_delivered_reply(&ctx, &ws, "t-no-audio", "req-w", "Hi", &[]).ok();diff --git a/crates/openhuman-core/src/web_chat/turn_host.rs b/crates/openhuman-core/src/web_chat/turn_host.rsindex 99cd574f02..161410a5d2 100644--- a/crates/openhuman-core/src/web_chat/turn_host.rs+++ b/crates/openhuman-core/src/web_chat/turn_host.rs@@ -348,7 +348,7 @@ impl WebHost {let turn_elapsed = turn_started.elapsed();if let Ok(task_result) = result.as_ref() {- speak_and_publish(&config, request, task_result).await;+ speak_and_publish(&ctx, &config, request, task_result).await;}// TinyMemes: remix the final reply (slang + memes) when the flag puts@@ -481,6 +481,7 @@ impl WebHost {/// Speak the reply when the request, the thread or the voice mode asks for it,/// and tell a push-to-talk session what was committed.async fn speak_and_publish(+ ctx: &crate::core::runtime::DispatchCtx,config: &crate::config::Config,request: &TurnRequest<QueuedPayload>,task_result: &WebChatTaskResult,@@ -514,8 +515,20 @@ async fn speak_and_publish(&request.request_id,&outcome.value.audio_base64,&outcome.value.audio_mime,- &outcome.value.visemes,);+ if stored {+ if let Err(err) = super::voice_notes::persist_reply_visemes(+ ctx,+ &config.workspace_dir,+ &request.request_id,+ &outcome.value.visemes,+ ) {+ log::warn!(+ "[web_channel][voice_note] could not store reply timeline request_id={}: {err}",+ request.request_id+ );+ }+ }log::debug!("[web_channel] reply_speech dispatched chars={} stored={stored} client_id={} thread_id={thread_id} request_id={}",task_result.full_response.len(),diff --git a/crates/openhuman-core/src/web_chat/voice_notes_tests.rs b/crates/openhuman-core/src/web_chat/voice_notes_tests.rsindex d747c1b5ff..6ff9780eb4 100644--- a/crates/openhuman-core/src/web_chat/voice_notes_tests.rs+++ b/crates/openhuman-core/src/web_chat/voice_notes_tests.rs@@ -46,9 +46,10 @@ fn empty_and_oversized_audio_are_rejected() {#[test]fn reply_metadata_exists_only_after_the_reply_audio_is_stored() {let tmp = tempfile::tempdir().unwrap();- assert!(reply_note_metadata(tmp.path(), "req/1").is_none());+ let ctx = crate::core::runtime::DispatchCtx::ambient();+ assert!(reply_note_metadata(&ctx, tmp.path(), "req/1").is_none());store_note(tmp.path(), &reply_note_id("req/1"), "audio/mpeg", b"mp3").unwrap();- let meta = reply_note_metadata(tmp.path(), "req/1").unwrap();+ let meta = reply_note_metadata(&ctx, tmp.path(), "req/1").unwrap();assert_eq!(meta["noteId"], "reply-req_1");assert_eq!(meta["mime"], "audio/mpeg");}@@ -56,11 +57,17 @@ fn reply_metadata_exists_only_after_the_reply_audio_is_stored() {#[test]fn synthesized_reply_metadata_preserves_its_viseme_timeline() {let tmp = tempfile::tempdir().unwrap();+ let ctx = crate::core::runtime::DispatchCtx::ambient();assert!(store_synthesized_reply(tmp.path(),"request-1","YWJj","audio/mpeg",+ ));+ persist_reply_visemes(+ &ctx,+ tmp.path(),+ "request-1",&[tinyinference_voice::VisemeFrame {viseme: "aa".into(),@@ -73,9 +80,9 @@ fn synthesized_reply_metadata_preserves_its_viseme_timeline() {end_ms: 220},]- ));+ ).unwrap();- let meta = reply_note_metadata(tmp.path(), "request-1").unwrap();+ let meta = reply_note_metadata(&ctx, tmp.path(), "request-1").unwrap();assert_eq!(meta["visemes"],serde_json::json!([@@ -127,22 +134,19 @@ fn synthesized_reply_is_stored_only_with_decodable_audio() {tmp.path(),"r1","",- "audio/mpeg",- &[] as &[serde_json::Value]+ "audio/mpeg"));assert!(!store_synthesized_reply(tmp.path(),"r1","***",- "audio/mpeg",- &[] as &[serde_json::Value]+ "audio/mpeg"));assert!(store_synthesized_reply(tmp.path(),"r1","YWJj",- "audio/mpeg",- &[] as &[serde_json::Value]+ "audio/mpeg"));assert!(reply_note_metadata(tmp.path(), "r1").is_some());}