Skip to content

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

chore: files changed crates/openhuman-tui/src/state.rs,crates/openhuman-tui/src/state_tests.rs

Steven Enamakel6ab9f9fed754
diff --git a/crates/openhuman-tui/src/state.rs b/crates/openhuman-tui/src/state.rs
index cac6e8a70e..16f944c78d 100644
--- a/crates/openhuman-tui/src/state.rs
+++ b/crates/openhuman-tui/src/state.rs
@@ -475,20 +475,17 @@ impl TranscriptState {
.or_else(|| item.get("content"))
.and_then(serde_json::Value::as_str)
.unwrap_or_default();
- let duration_ms = item
- .pointer("/extraMetadata/voiceNote/durationMs")
- .and_then(serde_json::Value::as_u64);
- let text = duration_ms
- .map(|ms| format!("[voice note {}] {content}", format_short_duration(ms)))
- .unwrap_or_else(|| content.to_string());
+ let text = label_voice_note(content, item);
self.entries.push(Entry::new(EntryKind::User, text));
}
- Some("assistantMessage") => self.entries.push(Entry::new(
- EntryKind::Assistant,
- item.get("content")
+ Some("assistantMessage") => {
+ let content = item
+ .get("content")
.and_then(serde_json::Value::as_str)
- .unwrap_or_default(),
- )),
+ .unwrap_or_default();
+ let text = label_voice_note(content, item);
+ self.entries.push(Entry::new(EntryKind::Assistant, text));
+ }
Some("reasoning") => self.entries.push(Entry::new(
EntryKind::Thinking,
item.get("text")
@@ -604,6 +601,27 @@ impl TranscriptState {
}
}
+fn label_voice_note(content: &str, item: &serde_json::Value) -> String {
+ let Some(voice_note) = item.pointer("/extraMetadata/voiceNote") else {
+ return content.to_string();
+ };
+ let has_note_id = voice_note
+ .get("noteId")
+ .and_then(serde_json::Value::as_str)
+ .is_some_and(|note_id| !note_id.is_empty());
+ if !has_note_id {
+ return content.to_string();
+ }
+
+ let label = voice_note
+ .get("durationMs")
+ .and_then(serde_json::Value::as_u64)
+ .map(format_short_duration)
+ .map(|duration| format!("[voice note {duration}]"))
+ .unwrap_or_else(|| "[voice note]".to_string());
+ format!("{label} {content}")
+}
+
fn format_short_duration(ms: u64) -> String {
let seconds = ms.saturating_add(500) / 1000;
format!("{}:{:02}", seconds / 60, seconds % 60)
diff --git a/crates/openhuman-tui/src/state_tests.rs b/crates/openhuman-tui/src/state_tests.rs
index a7fa469c96..597d89db9e 100644
--- a/crates/openhuman-tui/src/state_tests.rs
+++ b/crates/openhuman-tui/src/state_tests.rs
@@ -296,8 +296,14 @@ fn projected_spoken_replies_show_voice_note_and_known_duration_labels() {
}
]}}
}));
- assert_eq!(state.entries()[0].text, "[voice note 0:09] I will remind you.");
- assert_eq!(state.entries()[1].text, "[voice note] I can say that aloud.");
+ assert_eq!(
+ state.entries()[0].text,
+ "[voice note 0:09] I will remind you."
+ );
+ assert_eq!(
+ state.entries()[1].text,
+ "[voice note] I can say that aloud."
+ );
}
#[test]