Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.
TypeScript agentaiai-agentsall-in-onecrmcrm-systememaillinearmcpmessagingnotesnotionofficerustslackslack-alternativestartupstartup-toolstypescriptworkspace
fix(import): let tracker imports create projects (#9174)
Wolf Mermelstein20f3c8e84c58
diff --git a/Cargo.lock b/Cargo.lockindex ff28d0b3da..78b25fc44b 100644--- a/Cargo.lock+++ b/Cargo.lock@@ -1231,6 +1231,7 @@ dependencies = ["tokio","tokio-util","tracing",+ "unicode-segmentation","utoipa","uuid","workspace-hack",diff --git a/crates/ai_tools/Cargo.toml b/crates/ai_tools/Cargo.tomlindex b1d732ee36..84a00dd359 100644--- a/crates/ai_tools/Cargo.toml+++ b/crates/ai_tools/Cargo.toml@@ -118,6 +118,7 @@ thiserror.workspace = truetokio.workspace = truetokio-util = { workspace = true, features = ["rt"] }tracing.workspace = true+unicode-segmentation.workspace = trueutoipa.workspace = trueuuid.workspace = trueremote_env_var = { path = "../remote_env_var" }diff --git a/crates/ai_tools/src/import_trackers.rs b/crates/ai_tools/src/import_trackers.rsindex 2df421f52c..fa147ffe84 100644--- a/crates/ai_tools/src/import_trackers.rs+++ b/crates/ai_tools/src/import_trackers.rs@@ -8,12 +8,22 @@ use entity_access::domain::{models::EditAccessLevel, ports::EntityAccessService}use import::domain::ports::{ImportedDocumentProperties, ImportedTaskProperties, TrackerTaskRelations,};-use initiative::domain::models::{CreateInitiativeRequest, InitiativeId};+use initiative::domain::models::{+ CreateInitiativeRequest, InitiativeId, MAX_INITIATIVE_NAME_GRAPHEMES,+};use macro_user_id::user_id::MacroUserIdStr;+use model::document::MAX_DOCUMENT_NAME_GRAPHEMES;use models_properties::{EntityReference, EntityType, api::SetPropertyValue};use system_properties::SystemPropertyKey;+use unicode_segmentation::UnicodeSegmentation;use uuid::Uuid;+/// `name` cut to `max` graphemes; source trackers allow longer titles than+/// Macro, and the body links back to the full source item.+fn capped_name(name: &str, max: usize) -> String {+ name.trim().graphemes(true).take(max).collect::<String>()+}+impl ToolEntityCreator {#[tracing::instrument(skip_all, fields(project_id = %id), err)]pub(crate) async fn create_tracker_project_impl(@@ -29,7 +39,7 @@ impl ToolEntityCreator {.create_imported(user,CreateInitiativeRequest {- name: name.to_string(),+ name: capped_name(name, MAX_INITIATIVE_NAME_GRAPHEMES),description: Some(markdown.to_string()),member_ids: None,share_with_team: Some(shared),@@ -56,7 +66,7 @@ impl ToolEntityCreator {.create_imported_task(user,Some(id),- name,+ &capped_name(name, MAX_DOCUMENT_NAME_GRAPHEMES),ImportedContent::Markdown(markdown.to_string()),properties,None,diff --git a/crates/import/src/domain/service/tracker_workspace/test.rs b/crates/import/src/domain/service/tracker_workspace/test.rsindex 60d881e2dc..3a02aa6e5b 100644--- a/crates/import/src/domain/service/tracker_workspace/test.rs+++ b/crates/import/src/domain/service/tracker_workspace/test.rs@@ -114,3 +114,13 @@ fn maps_task_fields_and_keeps_unmapped_details_in_markdown() {assert!(body.contains("Estimate: 3"));assert!(body.contains("Labels: bug"));}++#[test]+fn target_ids_are_stable_random_uuids() {+ let ledger = Uuid::now_v7();+ let id = values::target_id(ledger);+ assert_eq!(id, values::target_id(ledger));+ assert_ne!(id, values::target_id(Uuid::now_v7()));+ // Project descriptions are collab surfaces, which reject non-random ids.+ assert_eq!(id.get_version(), Some(uuid::Version::Random));+}diff --git a/crates/import/src/domain/service/tracker_workspace/values.rs b/crates/import/src/domain/service/tracker_workspace/values.rsindex 3e49361d1d..b4e685728b 100644--- a/crates/import/src/domain/service/tracker_workspace/values.rs+++ b/crates/import/src/domain/service/tracker_workspace/values.rs@@ -1,8 +1,12 @@//! Mapping tracker task fields and preserving all source content.use super::*;+/// The id written for ledger row `ledger`, stable across replays. Stamped as+/// a random (v4) UUID because project descriptions are collab surfaces, which+/// only accept random ids; the bytes come from the random ledger id.pub(in crate::domain::service) fn target_id(ledger: Uuid) -> Uuid {- Uuid::new_v5(&ledger, b"tracker-target")+ let derived = Uuid::new_v5(&ledger, b"tracker-target");+ uuid::Builder::from_random_bytes(*derived.as_bytes()).into_uuid()}pub(in crate::domain::service) fn properties(issue: &Issue) -> ImportedTaskProperties {