Skip to content

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

refactor(web_chat): decouple voice note metadata from viseme frame type

Steven Enamakel8c66281bcd88
diff --git a/crates/openhuman-core/src/web_chat/reply_persistence_tests.rs b/crates/openhuman-core/src/web_chat/reply_persistence_tests.rs
index 852b353794..ae1b9b16e7 100644
--- a/crates/openhuman-core/src/web_chat/reply_persistence_tests.rs
+++ b/crates/openhuman-core/src/web_chat/reply_persistence_tests.rs
@@ -111,15 +111,13 @@ fn an_empty_reply_is_not_stored() {
)
.expect("no error");
assert!(!stored, "an empty reply reports that nothing was stored");
- assert!(
- conversations::get_messages(
- &crate::core::runtime::DispatchCtx::ambient(),
- ws.clone(),
- "t-3"
- )
- .expect("messages")
- .is_empty()
- );
+ assert!(conversations::get_messages(
+ &crate::core::runtime::DispatchCtx::ambient(),
+ ws.clone(),
+ "t-3"
+ )
+ .expect("messages")
+ .is_empty());
}
#[test]
@@ -234,7 +232,13 @@ fn a_spoken_reply_row_points_at_its_stored_audio() {
seed_thread(&ws, "t-voice");
let ctx = crate::core::runtime::DispatchCtx::ambient();
- crate::web_chat::voice_notes::store_synthesized_reply(&ws, "req-v", "YWJj", "audio/mpeg", &[]);
+ crate::web_chat::voice_notes::store_synthesized_reply(
+ &ws,
+ "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/voice_notes.rs b/crates/openhuman-core/src/web_chat/voice_notes.rs
index af1985f3a5..9b03ed52b7 100644
--- a/crates/openhuman-core/src/web_chat/voice_notes.rs
+++ b/crates/openhuman-core/src/web_chat/voice_notes.rs
@@ -141,9 +141,7 @@ pub(crate) fn reply_note_metadata(workspace: &Path, request_id: &str) -> Option<
let mut metadata = json!({ "noteId": id, "mime": mime });
let viseme_path = root.join(format!("{id}.visemes.json"));
if let Ok(bytes) = std::fs::read(viseme_path) {
- if let Ok(frames) =
- serde_json::from_slice::<Vec<tinyinference_voice::VisemeFrame>>(&bytes)
- {
+ if let Ok(frames) = serde_json::from_slice::<Vec<Value>>(&bytes) {
if !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.rs
index eb9453807f..60d987d88e 100644
--- a/crates/openhuman-core/src/web_chat/voice_notes_tests.rs
+++ b/crates/openhuman-core/src/web_chat/voice_notes_tests.rs
@@ -62,8 +62,16 @@ fn synthesized_reply_metadata_preserves_its_viseme_timeline() {
"YWJj",
"audio/mpeg",
&[
- tinyinference_voice::VisemeFrame { viseme: "aa".into(), start_ms: 0, end_ms: 120 },
- tinyinference_voice::VisemeFrame { viseme: "PP".into(), start_ms: 120, end_ms: 220 },
+ tinyinference_voice::VisemeFrame {
+ viseme: "aa".into(),
+ start_ms: 0,
+ end_ms: 120
+ },
+ tinyinference_voice::VisemeFrame {
+ viseme: "PP".into(),
+ start_ms: 120,
+ end_ms: 220
+ },
]
));
@@ -92,20 +100,26 @@ fn rpc_round_trip_and_bad_base64() {
#[test]
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",
+ &[] as &[serde_json::Value]
+ ));
assert!(!store_synthesized_reply(
tmp.path(),
"r1",
"***",
"audio/mpeg",
- &[]
+ &[] as &[serde_json::Value]
));
assert!(store_synthesized_reply(
tmp.path(),
"r1",
"YWJj",
"audio/mpeg",
- &[]
+ &[] as &[serde_json::Value]
));
assert!(reply_note_metadata(tmp.path(), "r1").is_some());
}