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
feat(threads): attach voice-note metadata to transcript pages
Steven Enamakelb599f034316e
diff --git a/crates/openhuman-core/src/threads/ops/transcript.rs b/crates/openhuman-core/src/threads/ops/transcript.rsindex 48b65c0efc..ab449a558b 100644--- a/crates/openhuman-core/src/threads/ops/transcript.rs+++ b/crates/openhuman-core/src/threads/ops/transcript.rs@@ -3,7 +3,8 @@use super::support::{counts, envelope, transcript_store};use crate::core::runtime::DispatchCtx;use crate::core::Outcome;-use crate::threads::{ApiEnvelope, PaginationMeta};+use crate::threads::{store as conversations, ApiEnvelope, PaginationMeta};+use tinyagents_session::transcript::view::DisplayItem;/// Request for [`transcript_get`]: the thread to project, plus newest-first/// pagination controls. `cursor` is the opaque token from a prior page's@@ -33,7 +34,7 @@ pub async fn transcript_get(let locator = transcript_store(ctx, &thread_id).await?.locator();let cursor = request.cursor.clone();let limit = request.limit;- let page = tokio::task::spawn_blocking(move || {+ let mut page = tokio::task::spawn_blocking(move || {tinyagents_session::transcript::view::get_page_in(locator.as_ref(),&thread_id,@@ -44,6 +45,7 @@ pub async fn transcript_get(}).await.map_err(|e| format!("transcript page task: {e}"))?;+ attach_voice_note_metadata(ctx, &thread_id, &mut page.items).await?;let counts = counts([("items", page.items.len()),("total", page.total),@@ -63,6 +65,74 @@ pub async fn transcript_get(Ok(envelope(page, Some(counts), pagination))}+/// Add voice-note references from the thread's durable UI rows to the+/// transcript projection. Conversation rows own UI-only metadata; copying it+/// into TinyAgents' transcript would change the frozen model history.+async fn attach_voice_note_metadata(+ ctx: &DispatchCtx,+ thread_id: &str,+ items: &mut [DisplayItem],+) -> Result<(), String> {+ let workspace_dir = ctx+ .load_config()+ .await+ .map_err(|error| format!("load config for voice-note projection: {error}"))?+ .workspace_dir;+ let rows = conversations::blocking::get_messages(+ ctx.clone(),+ workspace_dir,+ thread_id.to_string(),+ )+ .await?;++ for item in items {+ let (content, sender, request_id, projected_metadata) = match item {+ DisplayItem::UserMessage {+ content,+ request_id,+ extra_metadata,+ ..+ } => (content.as_str(), "user", request_id.as_deref(), extra_metadata),+ DisplayItem::AssistantMessage {+ content,+ request_id,+ extra_metadata,+ ..+ } => (content.as_str(), "agent", request_id.as_deref(), extra_metadata),+ _ => continue,+ };++ let matching_rows = rows+ .iter()+ .filter(|row| row.sender == sender && row.content == content)+ .filter(|row| {+ let row_request_id = row+ .extra_metadata+ .get("requestId")+ .and_then(serde_json::Value::as_str);+ match (request_id, row_request_id) {+ (Some(projected), Some(stored)) => projected == stored,+ // User rows are durably written before the core returns its+ // request id. Exact text is safe only when unique in this+ // thread; repeated messages are left unlabelled.+ _ => true,+ }+ })+ .collect::<Vec<_>>();+ if matching_rows.len() != 1 {+ continue;+ }+ let Some(voice_note) = matching_rows[0].extra_metadata.get("voiceNote") else {+ continue;+ };+ let metadata = projected_metadata.get_or_insert_with(|| serde_json::json!({}));+ if let Some(object) = metadata.as_object_mut() {+ object.insert("voiceNote".into(), voice_note.clone());+ }+ }+ Ok(())+}+#[cfg(test)]#[path = "transcript_tests.rs"]mod tests;diff --git a/crates/openhuman-core/src/threads/ops/transcript_tests.rs b/crates/openhuman-core/src/threads/ops/transcript_tests.rsindex ef0744879a..790ab8c8e4 100644--- a/crates/openhuman-core/src/threads/ops/transcript_tests.rs+++ b/crates/openhuman-core/src/threads/ops/transcript_tests.rs@@ -144,9 +144,9 @@ async fn transcript_projection_includes_voice_metadata_from_persisted_thread_row).await.unwrap();- for (id, content, sender, note_id) in [- ("user-voice", "hello", "user", "recording-1"),- ("assistant-voice", "hi there", "agent", "reply-1"),+ for (id, content, sender, note_id, request_id) in [+ ("user-voice", "hello", "user", "recording-1", None),+ ("assistant-voice", "hi there", "agent", "reply-1", Some("req-1")),] {blocking::append_message(ctx.clone(),@@ -156,7 +156,13 @@ async fn transcript_projection_includes_voice_metadata_from_persisted_thread_rowid: id.into(),content: content.into(),message_type: "text".into(),- extra_metadata: json!({"voiceNote": {"noteId": note_id, "durationMs": 5000}}),+ extra_metadata: {+ let mut metadata = json!({"voiceNote": {"noteId": note_id, "durationMs": 5000}});+ if let Some(request_id) = request_id {+ metadata["requestId"] = json!(request_id);+ }+ metadata+ },sender: sender.into(),created_at: "2026-10-15T00:00:02Z".into(),},