World's first open-source enterprise world model.
Rust agent-memorybitemporalgraphragknowledge-baseknowledge-graphllmontologypgvectorpostgresqlragrustself-hostedsemantic-searchtemporal-knowledge-graphworld-model
Read qualifier strings without JSON escape artifacts (#810)
Maya Kiddc65205206c1
diff --git a/crates/utopia-server/src/api/mcp_tests.rs b/crates/utopia-server/src/api/mcp_tests.rsindex a55f73f7..6f9720db 100644--- a/crates/utopia-server/src/api/mcp_tests.rs+++ b/crates/utopia-server/src/api/mcp_tests.rs@@ -408,6 +408,41 @@ async fn search_chunks_returns_chunk_and_document_ids_with_the_same_excerpt() ->f.clean().await}+#[tokio::test]+async fn entity_fact_qualifier_text_preserves_the_stored_string() -> anyhow::Result<()> {+ let Some(f) = Fixture::new().await? else {+ return Ok(());+ };+ let value = json!({"value":"等级 \"A\" / C:\\reports\\a.txt\n第二行\""});+ sqlx::query("UPDATE fact_qualifiers SET value=$2 WHERE fact_id=$1")+ .bind(f.corrected)+ .bind(&value)+ .execute(&f.state.pool)+ .await?;+ let result = f+ .call("entity_facts", json!({"entity_id":f.subject}))+ .await?;+ assert_eq!(result["isError"], false);+ let text = result["content"][0]["text"].as_str().unwrap();+ assert!(+ text.contains(&format!("[weight: {}]", value["value"].as_str().unwrap())),+ "{text}"+ );+ let fact = result["structuredContent"]["facts"]+ .as_array()+ .unwrap()+ .iter()+ .find(|fact| fact["id"] == f.corrected.to_string())+ .unwrap();+ assert_eq!(fact["qualifiers"][0]["value"], value);+ let stored: Value = sqlx::query_scalar("SELECT value FROM fact_qualifiers WHERE fact_id=$1")+ .bind(f.corrected)+ .fetch_one(&f.state.pool)+ .await?;+ assert_eq!(stored, value);+ f.clean().await+}+#[tokio::test]async fn entity_facts_keeps_identity_values_filters_and_both_clocks() -> anyhow::Result<()> {let Some(f) = Fixture::new().await? else {diff --git a/crates/utopia-server/src/api/tools_graph.rs b/crates/utopia-server/src/api/tools_graph.rsindex 95a62fef..483b8ccd 100644--- a/crates/utopia-server/src/api/tools_graph.rs+++ b/crates/utopia-server/src/api/tools_graph.rs@@ -259,7 +259,10 @@ fn qualifiers_text(f: &EntityFact) -> String {.value.as_ref().and_then(|v| v.get("value"))- .map(|v| v.to_string().trim_matches('"').to_string())+ .map(|v| match v {+ Value::String(s) => s.clone(),+ other => other.to_string(),+ }).or_else(|| q.entity_name.clone()).unwrap_or_else(|| "?".to_string());let u = q@@ -1401,4 +1404,38 @@ mod tests {"Anthropic ←founder— Dario Amodei (2021 → now) [90%]; Dario Amodei ←employee— OpenAI (2021 → now) [90%]");}+ #[test]+ fn qualifier_strings_are_text_not_json_encodings() {+ use utopia_core::models::FactQualifier;+ let mut f = fact("out", "works_for", "Acme", None);+ assert_eq!(qualifiers_text(&f), "");+ for (value, expected) in [+ (json!({"value":"等级 \"A\""}), "等级 \"A\""),+ (json!({"value":"ends\""}), "ends\""),+ (json!({"value":"C:\\reports\\a.txt"}), "C:\\reports\\a.txt"),+ (json!({"value":"line one\n第二行"}), "line one\n第二行"),+ (json!({"value":"中文“引号”"}), "中文“引号”"),+ (json!({"value":10}), "10"),+ (json!({"value":true}), "true"),+ (json!({"value":false}), "false"),+ (json!({"value":10,"unit":"kg"}), "10 kg"),+ (json!({"value":null}), "null"),+ ] {+ f.qualifiers = vec![FactQualifier {+ qualifier_type_id: Uuid::now_v7(),+ key: "detail".into(),+ label: "Detail".into(),+ value: Some(value),+ entity_id: None,+ entity_name: None,+ }];+ assert_eq!(qualifiers_text(&f), format!(" [detail: {expected}]"));+ }+ f.qualifiers[0].value = None;+ f.qualifiers[0].entity_id = f.other_id;+ f.qualifiers[0].entity_name = Some("Acme".into());+ assert_eq!(qualifiers_text(&f), " [detail: Acme]");+ f.qualifiers[0].entity_name = None;+ assert_eq!(qualifiers_text(&f), " [detail: ?]");+ }}