Skip to content

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

test(web_chat): cover voice note request id binding to exact row

Steven Enamakela2657a600881
diff --git a/crates/openhuman-core/src/web_chat/ops/start_chat_tests.rs b/crates/openhuman-core/src/web_chat/ops/start_chat_tests.rs
index 5b30ec6dc7..3662e488c4 100644
--- a/crates/openhuman-core/src/web_chat/ops/start_chat_tests.rs
+++ b/crates/openhuman-core/src/web_chat/ops/start_chat_tests.rs
@@ -75,3 +75,69 @@ fn plain_string_conversions_build_other_variant() {
let from_borrowed: StartChatError = "message is required".into();
assert!(matches!(from_borrowed, StartChatError::Other(ref m) if m == "message is required"));
}
+
+#[tokio::test]
+async fn voice_note_turn_id_is_bound_to_its_exact_user_row_before_admission() {
+ use crate::core::runtime::{ContextOverlay, CoreContext, DispatchCtx, DomainSet};
+ use crate::threads::store::{ConversationMessage, CreateConversationThread, blocking};
+ use crate::tools::toolpacks::ToolGroups;
+ use serde_json::json;
+
+ let dir = tempfile::tempdir().unwrap();
+ let workspace = dir.path().to_path_buf();
+ let config = crate::config::Config {
+ workspace_dir: workspace.clone(),
+ ..crate::config::Config::default()
+ };
+ let ctx = DispatchCtx::new(
+ CoreContext::for_test(DomainSet::full(), None)
+ .derive_with(ContextOverlay::new(config, DomainSet::kernel(), ToolGroups::none())),
+ );
+ blocking::ensure_thread(
+ ctx.clone(),
+ workspace.clone(),
+ CreateConversationThread {
+ id: "voice-thread".into(),
+ title: "Voice note".into(),
+ created_at: "2026-10-20T00:00:00Z".into(),
+ parent_thread_id: None,
+ labels: None,
+ personality_id: None,
+ working_dir: None,
+ },
+ )
+ .await
+ .unwrap();
+ for (id, note_id) in [("voice-row", "note-1"), ("plain-row", "note-2")] {
+ blocking::append_message(
+ ctx.clone(),
+ workspace.clone(),
+ "voice-thread".into(),
+ ConversationMessage {
+ id: id.into(),
+ content: "same transcription".into(),
+ message_type: "text".into(),
+ extra_metadata: json!({"voiceNote": {"noteId": note_id}}),
+ sender: "user".into(),
+ created_at: "2026-10-20T00:00:01Z".into(),
+ },
+ )
+ .await
+ .unwrap();
+ }
+
+ bind_voice_note_request_id(
+ &ctx,
+ "voice-thread",
+ "same transcription",
+ "note-1",
+ "request-1",
+ )
+ .await
+ .unwrap();
+ let rows = blocking::get_messages(ctx, workspace, "voice-thread".into())
+ .await
+ .unwrap();
+ assert_eq!(rows[0].extra_metadata["requestId"], "request-1");
+ assert!(rows[1].extra_metadata.get("requestId").is_none());
+}