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): add persist queued user message functionality
Steven Enamakelbdef11060052
diff --git a/crates/openhuman-core/src/threads/ops/crud.rs b/crates/openhuman-core/src/threads/ops/crud.rsindex 3b86cc9aa2..b496c044a9 100644--- a/crates/openhuman-core/src/threads/ops/crud.rs+++ b/crates/openhuman-core/src/threads/ops/crud.rs@@ -196,6 +196,73 @@ pub async fn message_append(message_append_with_config(ctx, request, &config, origin.as_ref(), &persistence_dir).await}+/// Persist an admitted queued web user message under its stable request ID.+///+/// This is called from the trusted turn runner with the same scoped dispatch+/// context used to admit and resolve the queued attachments. The row is+/// appended once in turn order; retries return it only when its text and+/// opaque attachment references match exactly.+pub(crate) async fn persist_queued_user_message(+ ctx: &DispatchCtx,+ thread_id: &str,+ request_id: &str,+ text: &str,+ opaque_parts: &[tinychannels_bus::ContentPart],+) -> Result<ConversationMessageRecord, String> {+ if thread_id.trim().is_empty() || request_id.trim().is_empty() {+ return Err("queued message thread and request IDs must be non-empty".into());+ }+ if !opaque_parts.is_empty() {+ crate::threads::attachments::validate_opaque_parts(opaque_parts)?;+ }+ let config = ctx+ .load_config()+ .await+ .map_err(|error| format!("load queued message configuration: {error}"))?;+ let row_id = format!("user:{request_id}");+ let existing = conversations::get_messages(ctx, config.workspace_dir.clone(), thread_id)?+ .into_iter()+ .find(|message| message.id == row_id);+ if let Some(existing) = existing {+ let stored_parts = crate::threads::attachments::public_refs(&existing.extra_metadata);+ if existing.sender != "user"+ || existing.content != text+ || stored_parts != opaque_parts+ {+ return Err("queued message request ID conflicts with an existing row".into());+ }+ return Ok(message_to_record(existing));+ }++ let origin = ctx.turn_origin_or_scoped();+ let request = AppendConversationMessageRequest {+ thread_id: thread_id.to_string(),+ message: ConversationMessageRecord {+ id: row_id,+ content: text.to_string(),+ attachments: Vec::new(),+ message_type: "text".into(),+ extra_metadata: serde_json::json!({}),+ sender: "user".into(),+ created_at: chrono::Utc::now().to_rfc3339(),+ },+ attachments: opaque_parts.to_vec(),+ };+ let outcome = message_append_with_config(+ ctx,+ request,+ &config,+ origin.as_ref(),+ &config.workspace_dir,+ )+ .await+ .map_err(|error| error.to_string())?;+ outcome+ .value+ .data+ .ok_or_else(|| "queued message append returned no row".into())+}+async fn message_append_with_config(ctx: &DispatchCtx,mut request: AppendConversationMessageRequest,