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): improve voice note metadata retrieval logic
Steven Enamakelc9cf27cba620
diff --git a/crates/openhuman-core/src/web_chat/voice_notes.rs b/crates/openhuman-core/src/web_chat/voice_notes.rsindex cfdc956875..5c5b785c3f 100644--- a/crates/openhuman-core/src/web_chat/voice_notes.rs+++ b/crates/openhuman-core/src/web_chat/voice_notes.rs@@ -242,7 +242,7 @@ pub(crate) fn reply_note_metadata(if !root.join(format!("{id}.{ext}")).is_file() {return None;}- let mut metadata = json!({ "noteId": id, "mime": mime });+ let mut metadata = json!({ "noteId": id.clone(), "mime": mime });let timeline = viseme_repo(ctx, workspace).ok().and_then(|repo| {repo.run(|docs| {let id = id.clone();@@ -251,20 +251,22 @@ pub(crate) fn reply_note_metadata(.ok().flatten()});- let frames = timeline- .and_then(|record| serde_json::from_value::<ReplyVisemeTimeline>(record.doc).ok())- .filter(|record| {- crate::core::runtime::tenant::tenant_in(- crate::core::runtime::is_saas(),- ctx.resolved().as_deref(),- )- .is_ok_and(|tenant| tenant == record.tenant)- })- .map(|record| record.frames)- .or_else(|| {- let bytes = std::fs::read(root.join(format!("{id}.visemes.json"))).ok()?;- serde_json::from_slice::<Vec<Value>>(&bytes).ok()- });+ let frames = match timeline {+ Some(record) => serde_json::from_value::<ReplyVisemeTimeline>(record.doc)+ .ok()+ .filter(|record| {+ crate::core::runtime::tenant::tenant_in(+ crate::core::runtime::is_saas(),+ ctx.resolved().as_deref(),+ )+ .is_ok_and(|tenant| tenant == record.tenant)+ })+ .map(|record| record.frames),+ None => {+ let bytes = std::fs::read(root.join(format!("{id}.visemes.json"))).ok();+ bytes.and_then(|bytes| serde_json::from_slice::<Vec<Value>>(&bytes).ok())+ }+ };if let Some(frames) = frames.filter(|frames| !frames.is_empty()) {metadata["visemes"] = json!(frames);}diff --git a/crates/openhuman-core/src/web_chat/voice_notes_tests.rs b/crates/openhuman-core/src/web_chat/voice_notes_tests.rsindex 2691c19b57..a32fa92e3e 100644--- a/crates/openhuman-core/src/web_chat/voice_notes_tests.rs+++ b/crates/openhuman-core/src/web_chat/voice_notes_tests.rs@@ -94,6 +94,24 @@ fn synthesized_reply_metadata_preserves_its_viseme_timeline() {);}+#[test]+fn legacy_viseme_timeline_remains_readable() {+ let tmp = tempfile::tempdir().unwrap();+ let id = reply_note_id("legacy");+ store_note(tmp.path(), &id, "audio/mpeg", b"audio").unwrap();+ std::fs::write(+ tmp.path()+ .join("voice_notes")+ .join(format!("{id}.visemes.json")),+ serde_json::to_vec(&serde_json::json!([{"viseme": "aa", "start_ms": 0, "end_ms": 100}]))+ .unwrap(),+ )+ .unwrap();+ let ctx = crate::core::runtime::DispatchCtx::ambient();+ let meta = reply_note_metadata(&ctx, tmp.path(), "legacy").unwrap();+ assert_eq!(meta["visemes"][0]["viseme"], "aa");+}+#[test]fn rpc_round_trip_and_bad_base64() {let tmp = tempfile::tempdir().unwrap();