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
feat(tasks): pretty branch names (#3495)
Will Hutchinson7460f4f7e016
diff --git a/rust/cloud-storage/.sqlx/query-03d9c7e2c8988471423626370441600e47fbaf2a4e9ce6bb287b116679248db8.json b/rust/cloud-storage/.sqlx/query-03d9c7e2c8988471423626370441600e47fbaf2a4e9ce6bb287b116679248db8.jsondeleted file mode 100644index 2c294472f3..0000000000--- a/rust/cloud-storage/.sqlx/query-03d9c7e2c8988471423626370441600e47fbaf2a4e9ce6bb287b116679248db8.json+++ /dev/null@@ -1,28 +0,0 @@-{- "db_name": "PostgreSQL",- "query": "\n SELECT team_id, team_role::text as \"role!\"\n FROM team_user\n WHERE user_id = $1\n ORDER BY team_role DESC\n LIMIT 1\n ",- "describe": {- "columns": [- {- "ordinal": 0,- "name": "team_id",- "type_info": "Uuid"- },- {- "ordinal": 1,- "name": "role!",- "type_info": "Text"- }- ],- "parameters": {- "Left": [- "Text"- ]- },- "nullable": [- false,- null- ]- },- "hash": "03d9c7e2c8988471423626370441600e47fbaf2a4e9ce6bb287b116679248db8"-}diff --git a/rust/cloud-storage/.sqlx/query-1250ece710fe7b331de87620f60fde712254a69e033e4135dc64d2a14acd8071.json b/rust/cloud-storage/.sqlx/query-1250ece710fe7b331de87620f60fde712254a69e033e4135dc64d2a14acd8071.jsondeleted file mode 100644index 71e31cfdb5..0000000000--- a/rust/cloud-storage/.sqlx/query-1250ece710fe7b331de87620f60fde712254a69e033e4135dc64d2a14acd8071.json+++ /dev/null@@ -1,22 +0,0 @@-{- "db_name": "PostgreSQL",- "query": "\n INSERT INTO crm_companies (team_id, name)\n VALUES ($1, 'TODO')\n RETURNING id\n ",- "describe": {- "columns": [- {- "ordinal": 0,- "name": "id",- "type_info": "Uuid"- }- ],- "parameters": {- "Left": [- "Uuid"- ]- },- "nullable": [- false- ]- },- "hash": "1250ece710fe7b331de87620f60fde712254a69e033e4135dc64d2a14acd8071"-}diff --git a/rust/cloud-storage/.sqlx/query-2b0bd67ac9cce9b0698818204cf404ae3e408b20117fa9e3664d19b0a9ef8f8d.json b/rust/cloud-storage/.sqlx/query-2b0bd67ac9cce9b0698818204cf404ae3e408b20117fa9e3664d19b0a9ef8f8d.jsondeleted file mode 100644index cd65d53f6b..0000000000--- a/rust/cloud-storage/.sqlx/query-2b0bd67ac9cce9b0698818204cf404ae3e408b20117fa9e3664d19b0a9ef8f8d.json+++ /dev/null@@ -1,47 +0,0 @@-{- "db_name": "PostgreSQL",- "query": "\n SELECT c.id, c.team_id, dd.name, c.email_sync, c.created_at\n FROM crm_companies c\n JOIN crm_domains d ON d.company_id = c.id\n LEFT JOIN crm_domain_directory dd ON LOWER(dd.domain) = LOWER(d.domain)\n WHERE c.team_id = $1\n AND LOWER(d.domain) = $2\n LIMIT 1\n ",- "describe": {- "columns": [- {- "ordinal": 0,- "name": "id",- "type_info": "Uuid"- },- {- "ordinal": 1,- "name": "team_id",- "type_info": "Uuid"- },- {- "ordinal": 2,- "name": "name",- "type_info": "Text"- },- {- "ordinal": 3,- "name": "email_sync",- "type_info": "Bool"- },- {- "ordinal": 4,- "name": "created_at",- "type_info": "Timestamptz"- }- ],- "parameters": {- "Left": [- "Uuid",- "Text"- ]- },- "nullable": [- false,- false,- true,- false,- false- ]- },- "hash": "2b0bd67ac9cce9b0698818204cf404ae3e408b20117fa9e3664d19b0a9ef8f8d"-}diff --git a/rust/cloud-storage/.sqlx/query-2f3232d6e4e86e77133d03ada2a4b3f438594de6abdfbebb41209e2541acf54b.json b/rust/cloud-storage/.sqlx/query-2f3232d6e4e86e77133d03ada2a4b3f438594de6abdfbebb41209e2541acf54b.jsondeleted file mode 100644index 5ac9f00f89..0000000000--- a/rust/cloud-storage/.sqlx/query-2f3232d6e4e86e77133d03ada2a4b3f438594de6abdfbebb41209e2541acf54b.json+++ /dev/null@@ -1,15 +0,0 @@-{- "db_name": "PostgreSQL",- "query": "INSERT INTO entity_access (entity_id, entity_type, source_id, source_type, access_level)\n VALUES ($1, 'call', $2, 'team', 'view')",- "describe": {- "columns": [],- "parameters": {- "Left": [- "Uuid",- "Text"- ]- },- "nullable": []- },- "hash": "2f3232d6e4e86e77133d03ada2a4b3f438594de6abdfbebb41209e2541acf54b"-}diff --git a/rust/cloud-storage/.sqlx/query-3115f8be3dd48c06ee8fc8262edc5ba54935753a9e5eebdd49ba0ba86f371e34.json b/rust/cloud-storage/.sqlx/query-3115f8be3dd48c06ee8fc8262edc5ba54935753a9e5eebdd49ba0ba86f371e34.jsondeleted file mode 100644index 2fb8652d13..0000000000--- a/rust/cloud-storage/.sqlx/query-3115f8be3dd48c06ee8fc8262edc5ba54935753a9e5eebdd49ba0ba86f371e34.json+++ /dev/null@@ -1,41 +0,0 @@-{- "db_name": "PostgreSQL",- "query": "\n SELECT c.id, c.team_id, c.email_sync, c.created_at\n FROM crm_companies c\n JOIN crm_domains d ON d.company_id = c.id\n WHERE c.team_id = $1\n AND LOWER(d.domain) = $2\n LIMIT 1\n ",- "describe": {- "columns": [- {- "ordinal": 0,- "name": "id",- "type_info": "Uuid"- },- {- "ordinal": 1,- "name": "team_id",- "type_info": "Uuid"- },- {- "ordinal": 2,- "name": "email_sync",- "type_info": "Bool"- },- {- "ordinal": 3,- "name": "created_at",- "type_info": "Timestamptz"- }- ],- "parameters": {- "Left": [- "Uuid",- "Text"- ]- },- "nullable": [- false,- false,- false,- false- ]- },- "hash": "3115f8be3dd48c06ee8fc8262edc5ba54935753a9e5eebdd49ba0ba86f371e34"-}diff --git a/rust/cloud-storage/.sqlx/query-432155b7428b328b1dc27cc799bb984b826b69108a323af157537027d59368a5.json b/rust/cloud-storage/.sqlx/query-432155b7428b328b1dc27cc799bb984b826b69108a323af157537027d59368a5.jsondeleted file mode 100644index 969fa5e099..0000000000--- a/rust/cloud-storage/.sqlx/query-432155b7428b328b1dc27cc799bb984b826b69108a323af157537027d59368a5.json+++ /dev/null@@ -1,14 +0,0 @@-{- "db_name": "PostgreSQL",- "query": "UPDATE calls SET share_with_team = false WHERE id = $1",- "describe": {- "columns": [],- "parameters": {- "Left": [- "Uuid"- ]- },- "nullable": []- },- "hash": "432155b7428b328b1dc27cc799bb984b826b69108a323af157537027d59368a5"-}diff --git a/rust/cloud-storage/.sqlx/query-472e132fc9b3df044b4f267507ab146a3631e9fb26323cae0e49e9d25d7d0767.json b/rust/cloud-storage/.sqlx/query-472e132fc9b3df044b4f267507ab146a3631e9fb26323cae0e49e9d25d7d0767.jsonnew file mode 100644index 0000000000..be450e8629--- /dev/null+++ b/rust/cloud-storage/.sqlx/query-472e132fc9b3df044b4f267507ab146a3631e9fb26323cae0e49e9d25d7d0767.json@@ -0,0 +1,41 @@+{+ "db_name": "PostgreSQL",+ "query": "\n SELECT\n COALESCE(u.email, NULLIF(split_part(request_user.user_id, '|', 2), ''), request_user.user_id) AS \"user_email!\",\n gl.github_username AS \"github_username?\",\n t.slug AS \"team_slug?\",\n tt.task_num AS \"team_task_id?\"\n FROM (SELECT $1::text AS user_id) request_user\n LEFT JOIN \"User\" u ON u.id = request_user.user_id\n LEFT JOIN LATERAL (\n SELECT github_username\n FROM github_links\n WHERE macro_id = request_user.user_id\n ORDER BY updated_at DESC\n LIMIT 1\n ) gl ON true\n LEFT JOIN LATERAL (\n SELECT team_id\n FROM team_user\n WHERE user_id = request_user.user_id\n ORDER BY team_id\n LIMIT 1\n ) tu ON true\n LEFT JOIN team t ON t.id = tu.team_id\n LEFT JOIN team_task tt ON tt.team_id = tu.team_id AND tt.document_id = $2\n ",+ "describe": {+ "columns": [+ {+ "ordinal": 0,+ "name": "user_email!",+ "type_info": "Text"+ },+ {+ "ordinal": 1,+ "name": "github_username?",+ "type_info": "Varchar"+ },+ {+ "ordinal": 2,+ "name": "team_slug?",+ "type_info": "Varchar"+ },+ {+ "ordinal": 3,+ "name": "team_task_id?",+ "type_info": "Int4"+ }+ ],+ "parameters": {+ "Left": [+ "Text",+ "Text"+ ]+ },+ "nullable": [+ null,+ true,+ true,+ true+ ]+ },+ "hash": "472e132fc9b3df044b4f267507ab146a3631e9fb26323cae0e49e9d25d7d0767"+}diff --git a/rust/cloud-storage/.sqlx/query-4bc26e583a28d41c4bffc91388a876106b2b6cb446540e36ccb65b6180585840.json b/rust/cloud-storage/.sqlx/query-4bc26e583a28d41c4bffc91388a876106b2b6cb446540e36ccb65b6180585840.jsondeleted file mode 100644index 2c0c60989f..0000000000--- a/rust/cloud-storage/.sqlx/query-4bc26e583a28d41c4bffc91388a876106b2b6cb446540e36ccb65b6180585840.json+++ /dev/null@@ -1,14 +0,0 @@-{- "db_name": "PostgreSQL",- "query": "\n DELETE FROM crm_contact_sources\n WHERE contact_id IN (\n SELECT id FROM crm_contacts WHERE company_id = $1\n )\n ",- "describe": {- "columns": [],- "parameters": {- "Left": [- "Uuid"- ]- },- "nullable": []- },- "hash": "4bc26e583a28d41c4bffc91388a876106b2b6cb446540e36ccb65b6180585840"-}diff --git a/rust/cloud-storage/.sqlx/query-56b93f5576bd8863529bec3ee7cb1fd26d228a082f3b68346810321639a3d2ae.json b/rust/cloud-storage/.sqlx/query-56b93f5576bd8863529bec3ee7cb1fd26d228a082f3b68346810321639a3d2ae.jsondeleted file mode 100644index d65be3c20b..0000000000--- a/rust/cloud-storage/.sqlx/query-56b93f5576bd8863529bec3ee7cb1fd26d228a082f3b68346810321639a3d2ae.json+++ /dev/null@@ -1,23 +0,0 @@-{- "db_name": "PostgreSQL",- "query": "\n SELECT LOWER(domain) AS \"domain!\"\n FROM crm_domains\n WHERE company_id = $1 AND team_id = $2\n ORDER BY LOWER(domain) ASC\n ",- "describe": {- "columns": [- {- "ordinal": 0,- "name": "domain!",- "type_info": "Text"- }- ],- "parameters": {- "Left": [- "Uuid",- "Uuid"- ]- },- "nullable": [- null- ]- },- "hash": "56b93f5576bd8863529bec3ee7cb1fd26d228a082f3b68346810321639a3d2ae"-}diff --git a/rust/cloud-storage/.sqlx/query-57f0a600c647584f8f9ae3a4200bf0508328d9a492f6f6ba13d4dcc725b201c0.json b/rust/cloud-storage/.sqlx/query-57f0a600c647584f8f9ae3a4200bf0508328d9a492f6f6ba13d4dcc725b201c0.jsondeleted file mode 100644index e03de11b5b..0000000000--- a/rust/cloud-storage/.sqlx/query-57f0a600c647584f8f9ae3a4200bf0508328d9a492f6f6ba13d4dcc725b201c0.json+++ /dev/null@@ -1,23 +0,0 @@-{- "db_name": "PostgreSQL",- "query": "\n SELECT LOWER(domain)\n FROM crm_domains\n WHERE company_id = $1 AND team_id = $2\n ORDER BY LOWER(domain) ASC\n ",- "describe": {- "columns": [- {- "ordinal": 0,- "name": "lower",- "type_info": "Text"- }- ],- "parameters": {- "Left": [- "Uuid",- "Uuid"- ]- },- "nullable": [- null- ]- },- "hash": "57f0a600c647584f8f9ae3a4200bf0508328d9a492f6f6ba13d4dcc725b201c0"-}diff --git a/rust/cloud-storage/.sqlx/query-5c2fdb7637f08974099f179223cfd6c084c78e83cbfc53c24d973a12dc50fd17.json b/rust/cloud-storage/.sqlx/query-5c2fdb7637f08974099f179223cfd6c084c78e83cbfc53c24d973a12dc50fd17.jsondeleted file mode 100644index 97f5839323..0000000000--- a/rust/cloud-storage/.sqlx/query-5c2fdb7637f08974099f179223cfd6c084c78e83cbfc53c24d973a12dc50fd17.json+++ /dev/null@@ -1,24 +0,0 @@-{- "db_name": "PostgreSQL",- "query": "\n INSERT INTO call_records (id, channel_id, room_name, created_by, started_at, ended_at, duration_ms, egress_id, recording_key, recording_started_at, share_permission_id)\n VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11)\n ",- "describe": {- "columns": [],- "parameters": {- "Left": [- "Uuid",- "Uuid",- "Text",- "Text",- "Timestamptz",- "Timestamptz",- "Int8",- "Text",- "Text",- "Timestamptz",- "Text"- ]- },- "nullable": []- },- "hash": "5c2fdb7637f08974099f179223cfd6c084c78e83cbfc53c24d973a12dc50fd17"-}diff --git a/rust/cloud-storage/.sqlx/query-5cc14a0cfb5a12ade0a35b3492e2a67bc3653e98e5fc5769d0189583e63a2bc8.json b/rust/cloud-storage/.sqlx/query-5cc14a0cfb5a12ade0a35b3492e2a67bc3653e98e5fc5769d0189583e63a2bc8.jsondeleted file mode 100644index 335e18cc3c..0000000000--- a/rust/cloud-storage/.sqlx/query-5cc14a0cfb5a12ade0a35b3492e2a67bc3653e98e5fc5769d0189583e63a2bc8.json+++ /dev/null@@ -1,23 +0,0 @@-{- "db_name": "PostgreSQL",- "query": "\n SELECT name\n FROM email_contacts\n WHERE LOWER(email_address) = LOWER($1)\n AND link_id = $2\n LIMIT 1\n ",- "describe": {- "columns": [- {- "ordinal": 0,- "name": "name",- "type_info": "Varchar"- }- ],- "parameters": {- "Left": [- "Text",- "Uuid"- ]- },- "nullable": [- true- ]- },- "hash": "5cc14a0cfb5a12ade0a35b3492e2a67bc3653e98e5fc5769d0189583e63a2bc8"-}diff --git a/rust/cloud-storage/.sqlx/query-625647495ec63c951181a5aad2e295875f274892253d2cd1ae925e6898a70466.json b/rust/cloud-storage/.sqlx/query-625647495ec63c951181a5aad2e295875f274892253d2cd1ae925e6898a70466.jsondeleted file mode 100644index 48b4157687..0000000000--- a/rust/cloud-storage/.sqlx/query-625647495ec63c951181a5aad2e295875f274892253d2cd1ae925e6898a70466.json+++ /dev/null@@ -1,23 +0,0 @@-{- "db_name": "PostgreSQL",- "query": "\n SELECT hidden\n FROM crm_companies\n WHERE id = $1 AND team_id = $2\n ",- "describe": {- "columns": [- {- "ordinal": 0,- "name": "hidden",- "type_info": "Bool"- }- ],- "parameters": {- "Left": [- "Uuid",- "Uuid"- ]- },- "nullable": [- false- ]- },- "hash": "625647495ec63c951181a5aad2e295875f274892253d2cd1ae925e6898a70466"-}diff --git a/rust/cloud-storage/.sqlx/query-626f582f62f31f4e1ad7fe155af220675ece4abffb0e2f3d0435199827900624.json b/rust/cloud-storage/.sqlx/query-626f582f62f31f4e1ad7fe155af220675ece4abffb0e2f3d0435199827900624.jsondeleted file mode 100644index 3eba84ad53..0000000000--- a/rust/cloud-storage/.sqlx/query-626f582f62f31f4e1ad7fe155af220675ece4abffb0e2f3d0435199827900624.json+++ /dev/null@@ -1,88 +0,0 @@-{- "db_name": "PostgreSQL",- "query": "\n SELECT id, channel_id, room_name, created_by, started_at, ended_at, duration_ms, egress_id, recording_key, recording_started_at, custom_name, summary\n FROM call_records\n WHERE id = $1\n ",- "describe": {- "columns": [- {- "ordinal": 0,- "name": "id",- "type_info": "Uuid"- },- {- "ordinal": 1,- "name": "channel_id",- "type_info": "Uuid"- },- {- "ordinal": 2,- "name": "room_name",- "type_info": "Text"- },- {- "ordinal": 3,- "name": "created_by",- "type_info": "Text"- },- {- "ordinal": 4,- "name": "started_at",- "type_info": "Timestamptz"- },- {- "ordinal": 5,- "name": "ended_at",- "type_info": "Timestamptz"- },- {- "ordinal": 6,- "name": "duration_ms",- "type_info": "Int8"- },- {- "ordinal": 7,- "name": "egress_id",- "type_info": "Text"- },- {- "ordinal": 8,- "name": "recording_key",- "type_info": "Text"- },- {- "ordinal": 9,- "name": "recording_started_at",- "type_info": "Timestamptz"- },- {- "ordinal": 10,- "name": "custom_name",- "type_info": "Text"- },- {- "ordinal": 11,- "name": "summary",- "type_info": "Text"- }- ],- "parameters": {- "Left": [- "Uuid"- ]- },- "nullable": [- false,- false,- false,- false,- false,- false,- false,- true,- true,- true,- true,- true- ]- },- "hash": "626f582f62f31f4e1ad7fe155af220675ece4abffb0e2f3d0435199827900624"-}diff --git a/rust/cloud-storage/.sqlx/query-6595308af9962787ede1073451f3ad5a89769b6881f547898ac09a06db9aeb95.json b/rust/cloud-storage/.sqlx/query-6595308af9962787ede1073451f3ad5a89769b6881f547898ac09a06db9aeb95.jsondeleted file mode 100644index fc6517d3fb..0000000000--- a/rust/cloud-storage/.sqlx/query-6595308af9962787ede1073451f3ad5a89769b6881f547898ac09a06db9aeb95.json+++ /dev/null@@ -1,47 +0,0 @@-{- "db_name": "PostgreSQL",- "query": "\n SELECT c.id, c.team_id, c.name, c.email_sync, c.created_at\n FROM crm_companies c\n JOIN crm_domains d ON d.company_id = c.id\n WHERE c.team_id = $1\n AND LOWER(d.domain) = $2\n LIMIT 1\n ",- "describe": {- "columns": [- {- "ordinal": 0,- "name": "id",- "type_info": "Uuid"- },- {- "ordinal": 1,- "name": "team_id",- "type_info": "Uuid"- },- {- "ordinal": 2,- "name": "name",- "type_info": "Text"- },- {- "ordinal": 3,- "name": "email_sync",- "type_info": "Bool"- },- {- "ordinal": 4,- "name": "created_at",- "type_info": "Timestamptz"- }- ],- "parameters": {- "Left": [- "Uuid",- "Text"- ]- },- "nullable": [- false,- false,- false,- false,- false- ]- },- "hash": "6595308af9962787ede1073451f3ad5a89769b6881f547898ac09a06db9aeb95"-}diff --git a/rust/cloud-storage/.sqlx/query-668d2494990d4f281575d7261bec1f4ad8cd78266d7f725b6035bb95b9ad567e.json b/rust/cloud-storage/.sqlx/query-668d2494990d4f281575d7261bec1f4ad8cd78266d7f725b6035bb95b9ad567e.jsondeleted file mode 100644index 85ceafa3e5..0000000000--- a/rust/cloud-storage/.sqlx/query-668d2494990d4f281575d7261bec1f4ad8cd78266d7f725b6035bb95b9ad567e.json+++ /dev/null@@ -1,24 +0,0 @@-{- "db_name": "PostgreSQL",- "query": "\n UPDATE crm_companies\n SET hidden = $3\n WHERE id = $1 AND team_id = $2\n RETURNING id\n ",- "describe": {- "columns": [- {- "ordinal": 0,- "name": "id",- "type_info": "Uuid"- }- ],- "parameters": {- "Left": [- "Uuid",- "Uuid",- "Bool"- ]- },- "nullable": [- false- ]- },- "hash": "668d2494990d4f281575d7261bec1f4ad8cd78266d7f725b6035bb95b9ad567e"-}diff --git a/rust/cloud-storage/.sqlx/query-6852fb9f96ae7ed17fd27c08412598b0383b0da562e63ecae81472b14ba21640.json b/rust/cloud-storage/.sqlx/query-6852fb9f96ae7ed17fd27c08412598b0383b0da562e63ecae81472b14ba21640.jsondeleted file mode 100644index 1360bf281b..0000000000--- a/rust/cloud-storage/.sqlx/query-6852fb9f96ae7ed17fd27c08412598b0383b0da562e63ecae81472b14ba21640.json+++ /dev/null@@ -1,22 +0,0 @@-{- "db_name": "PostgreSQL",- "query": "\n SELECT id\n FROM email_labels\n WHERE link_id = $1 AND name = 'TRASH'\n LIMIT 1\n ",- "describe": {- "columns": [- {- "ordinal": 0,- "name": "id",- "type_info": "Uuid"- }- ],- "parameters": {- "Left": [- "Uuid"- ]- },- "nullable": [- false- ]- },- "hash": "6852fb9f96ae7ed17fd27c08412598b0383b0da562e63ecae81472b14ba21640"-}diff --git a/rust/cloud-storage/.sqlx/query-6d1cee49d39040d520161e32305111731ff89b4c279c24101875afaaa6cceeee.json b/rust/cloud-storage/.sqlx/query-6d1cee49d39040d520161e32305111731ff89b4c279c24101875afaaa6cceeee.jsondeleted file mode 100644index e5f41785cf..0000000000--- a/rust/cloud-storage/.sqlx/query-6d1cee49d39040d520161e32305111731ff89b4c279c24101875afaaa6cceeee.json+++ /dev/null@@ -1,64 +0,0 @@-{- "db_name": "PostgreSQL",- "query": "\n SELECT id, channel_id, room_name, created_by, created_at, egress_id, recording_key, recording_started_at\n FROM calls\n WHERE id = $1\n ",- "describe": {- "columns": [- {- "ordinal": 0,- "name": "id",- "type_info": "Uuid"- },- {- "ordinal": 1,- "name": "channel_id",- "type_info": "Uuid"- },- {- "ordinal": 2,- "name": "room_name",- "type_info": "Text"- },- {- "ordinal": 3,- "name": "created_by",- "type_info": "Text"- },- {- "ordinal": 4,- "name": "created_at",- "type_info": "Timestamptz"- },- {- "ordinal": 5,- "name": "egress_id",- "type_info": "Text"- },- {- "ordinal": 6,- "name": "recording_key",- "type_info": "Text"- },- {- "ordinal": 7,- "name": "recording_started_at",- "type_info": "Timestamptz"- }- ],- "parameters": {- "Left": [- "Uuid"- ]- },- "nullable": [- false,- false,- false,- false,- false,- true,- true,- true- ]- },- "hash": "6d1cee49d39040d520161e32305111731ff89b4c279c24101875afaaa6cceeee"-}diff --git a/rust/cloud-storage/.sqlx/query-6ea476e8245e7216dab1393cd8f0da3d51a68f4e1240540fe06c72fc75ff8006.json b/rust/cloud-storage/.sqlx/query-6ea476e8245e7216dab1393cd8f0da3d51a68f4e1240540fe06c72fc75ff8006.jsondeleted file mode 100644index 0136a4dd0c..0000000000--- a/rust/cloud-storage/.sqlx/query-6ea476e8245e7216dab1393cd8f0da3d51a68f4e1240540fe06c72fc75ff8006.json+++ /dev/null@@ -1,15 +0,0 @@-{- "db_name": "PostgreSQL",- "query": "\n UPDATE crm_companies\n SET name = $1\n WHERE id = $2 AND name IS NULL\n ",- "describe": {- "columns": [],- "parameters": {- "Left": [- "Text",- "Uuid"- ]- },- "nullable": []- },- "hash": "6ea476e8245e7216dab1393cd8f0da3d51a68f4e1240540fe06c72fc75ff8006"-}diff --git a/rust/cloud-storage/.sqlx/query-7cc7f1a3502e8b8522d3ca1756a38fe884107f8d404296388797b6685278fa4e.json b/rust/cloud-storage/.sqlx/query-7cc7f1a3502e8b8522d3ca1756a38fe884107f8d404296388797b6685278fa4e.jsondeleted file mode 100644index 803c48f35c..0000000000--- a/rust/cloud-storage/.sqlx/query-7cc7f1a3502e8b8522d3ca1756a38fe884107f8d404296388797b6685278fa4e.json+++ /dev/null@@ -1,22 +0,0 @@-{- "db_name": "PostgreSQL",- "query": "SELECT share_with_team FROM call_records WHERE id = $1",- "describe": {- "columns": [- {- "ordinal": 0,- "name": "share_with_team",- "type_info": "Bool"- }- ],- "parameters": {- "Left": [- "Uuid"- ]- },- "nullable": [- false- ]- },- "hash": "7cc7f1a3502e8b8522d3ca1756a38fe884107f8d404296388797b6685278fa4e"-}diff --git a/rust/cloud-storage/.sqlx/query-85c2f0bf2436f55cacf260a16b215803b469829ffe73f13210dc6899a5f352d1.json b/rust/cloud-storage/.sqlx/query-85c2f0bf2436f55cacf260a16b215803b469829ffe73f13210dc6899a5f352d1.jsondeleted file mode 100644index bdd58aa2c3..0000000000--- a/rust/cloud-storage/.sqlx/query-85c2f0bf2436f55cacf260a16b215803b469829ffe73f13210dc6899a5f352d1.json+++ /dev/null@@ -1,30 +0,0 @@-{- "db_name": "PostgreSQL",- "query": "\n SELECT ct.id AS contact_id, co.id AS company_id\n FROM crm_contacts ct\n JOIN crm_companies co ON co.id = ct.company_id\n JOIN crm_domains d ON d.company_id = co.id\n WHERE co.team_id = $1\n AND LOWER(ct.email) = $2\n AND LOWER(d.domain) = $3\n LIMIT 1\n ",- "describe": {- "columns": [- {- "ordinal": 0,- "name": "contact_id",- "type_info": "Uuid"- },- {- "ordinal": 1,- "name": "company_id",- "type_info": "Uuid"- }- ],- "parameters": {- "Left": [- "Uuid",- "Text",- "Text"- ]- },- "nullable": [- false,- false- ]- },- "hash": "85c2f0bf2436f55cacf260a16b215803b469829ffe73f13210dc6899a5f352d1"-}diff --git a/rust/cloud-storage/.sqlx/query-8b108dfc93000693ed7304ba54279a1381c53b51d012ea135fcaae0f013bdf76.json b/rust/cloud-storage/.sqlx/query-8b108dfc93000693ed7304ba54279a1381c53b51d012ea135fcaae0f013bdf76.jsondeleted file mode 100644index 5229808bab..0000000000--- a/rust/cloud-storage/.sqlx/query-8b108dfc93000693ed7304ba54279a1381c53b51d012ea135fcaae0f013bdf76.json+++ /dev/null@@ -1,23 +0,0 @@-{- "db_name": "PostgreSQL",- "query": "\n INSERT INTO crm_companies (team_id, name)\n VALUES ($1, $2)\n RETURNING id\n ",- "describe": {- "columns": [- {- "ordinal": 0,- "name": "id",- "type_info": "Uuid"- }- ],- "parameters": {- "Left": [- "Uuid",- "Text"- ]- },- "nullable": [- false- ]- },- "hash": "8b108dfc93000693ed7304ba54279a1381c53b51d012ea135fcaae0f013bdf76"-}diff --git a/rust/cloud-storage/.sqlx/query-9d603c81c30c562a69a53297e62fadec99a097e85feedfeea7c74383b6e1c302.json b/rust/cloud-storage/.sqlx/query-9d603c81c30c562a69a53297e62fadec99a097e85feedfeea7c74383b6e1c302.jsondeleted file mode 100644index 314d689c22..0000000000--- a/rust/cloud-storage/.sqlx/query-9d603c81c30c562a69a53297e62fadec99a097e85feedfeea7c74383b6e1c302.json+++ /dev/null@@ -1,47 +0,0 @@-{- "db_name": "PostgreSQL",- "query": "\n SELECT o.id, o.team_id, o.name, o.email_sync, o.created_at\n FROM crm_organization o\n JOIN crm_organization_domain d ON d.crm_organization_id = o.id\n WHERE o.team_id = $1\n AND LOWER(d.domain) = $2\n LIMIT 1\n ",- "describe": {- "columns": [- {- "ordinal": 0,- "name": "id",- "type_info": "Uuid"- },- {- "ordinal": 1,- "name": "team_id",- "type_info": "Uuid"- },- {- "ordinal": 2,- "name": "name",- "type_info": "Text"- },- {- "ordinal": 3,- "name": "email_sync",- "type_info": "Bool"- },- {- "ordinal": 4,- "name": "created_at",- "type_info": "Timestamptz"- }- ],- "parameters": {- "Left": [- "Uuid",- "Text"- ]- },- "nullable": [- false,- false,- false,- false,- false- ]- },- "hash": "9d603c81c30c562a69a53297e62fadec99a097e85feedfeea7c74383b6e1c302"-}diff --git a/rust/cloud-storage/.sqlx/query-c55a8270d85d85cd73e1468cfed63223fe781efb943d080e79998dff5500cfbb.json b/rust/cloud-storage/.sqlx/query-c55a8270d85d85cd73e1468cfed63223fe781efb943d080e79998dff5500cfbb.jsondeleted file mode 100644index 17d7e7e14f..0000000000--- a/rust/cloud-storage/.sqlx/query-c55a8270d85d85cd73e1468cfed63223fe781efb943d080e79998dff5500cfbb.json+++ /dev/null@@ -1,22 +0,0 @@-{- "db_name": "PostgreSQL",- "query": "\n SELECT DISTINCT LOWER(c.email_address) AS \"email!\"\n FROM email_messages m\n JOIN email_message_recipients r ON r.message_id = m.id\n JOIN email_contacts c ON c.id = r.contact_id\n WHERE m.link_id = $1\n AND m.is_sent = true\n ",- "describe": {- "columns": [- {- "ordinal": 0,- "name": "email!",- "type_info": "Text"- }- ],- "parameters": {- "Left": [- "Uuid"- ]- },- "nullable": [- null- ]- },- "hash": "c55a8270d85d85cd73e1468cfed63223fe781efb943d080e79998dff5500cfbb"-}diff --git a/rust/cloud-storage/.sqlx/query-d0e2c3d2bb2a42f3655e52bf8c4f92142542c3a0a9759d9729d8272e3f93edbe.json b/rust/cloud-storage/.sqlx/query-d0e2c3d2bb2a42f3655e52bf8c4f92142542c3a0a9759d9729d8272e3f93edbe.jsondeleted file mode 100644index 2a2787dbe2..0000000000--- a/rust/cloud-storage/.sqlx/query-d0e2c3d2bb2a42f3655e52bf8c4f92142542c3a0a9759d9729d8272e3f93edbe.json+++ /dev/null@@ -1,40 +0,0 @@-{- "db_name": "PostgreSQL",- "query": "\n SELECT id, crm_organization_id, domain, created_at\n FROM crm_organization_domain\n WHERE crm_organization_id = $1\n ORDER BY created_at ASC\n ",- "describe": {- "columns": [- {- "ordinal": 0,- "name": "id",- "type_info": "Uuid"- },- {- "ordinal": 1,- "name": "crm_organization_id",- "type_info": "Uuid"- },- {- "ordinal": 2,- "name": "domain",- "type_info": "Text"- },- {- "ordinal": 3,- "name": "created_at",- "type_info": "Timestamptz"- }- ],- "parameters": {- "Left": [- "Uuid"- ]- },- "nullable": [- false,- false,- false,- false- ]- },- "hash": "d0e2c3d2bb2a42f3655e52bf8c4f92142542c3a0a9759d9729d8272e3f93edbe"-}diff --git a/rust/cloud-storage/.sqlx/query-e2c56203be986cfddced6fdc1dad55e15f226bd72a17498c501b273762ca201c.json b/rust/cloud-storage/.sqlx/query-e2c56203be986cfddced6fdc1dad55e15f226bd72a17498c501b273762ca201c.jsondeleted file mode 100644index 953e991ed2..0000000000--- a/rust/cloud-storage/.sqlx/query-e2c56203be986cfddced6fdc1dad55e15f226bd72a17498c501b273762ca201c.json+++ /dev/null@@ -1,100 +0,0 @@-{- "db_name": "PostgreSQL",- "query": "\n WITH user_source_ids AS (\n SELECT cp.channel_id::text AS source_id\n FROM comms_channel_participants cp\n WHERE cp.user_id = $1 AND cp.left_at IS NULL\n UNION ALL\n SELECT t.team_id::text AS source_id\n FROM team_user t\n WHERE t.user_id = $1\n UNION ALL\n SELECT $1 AS source_id\n )\n SELECT\n id as \"call_id!\",\n channel_id as \"channel_id!\",\n room_name as \"room_name!\",\n created_by as \"created_by!\",\n created_at as \"started_at!\",\n NULL::timestamptz as \"ended_at\",\n NULL::bigint as \"duration_ms\",\n egress_id,\n recording_key,\n recording_started_at,\n NULL::text as \"custom_name\",\n NULL::text as \"summary\",\n true as \"is_active!\"\n FROM calls c\n WHERE EXISTS (\n SELECT 1 FROM entity_access ea\n JOIN user_source_ids u ON u.source_id = ea.source_id\n WHERE ea.entity_id = c.id\n AND ea.entity_type = 'call'\n )\n AND ($3::bool IS FALSE OR c.channel_id = ANY($4))\n AND ($5::bool IS NULL OR EXISTS (\n SELECT 1 FROM call_participants cp\n WHERE cp.call_id = c.id AND cp.user_id = $1\n ) = $5)\n AND ($6::bool IS FALSE OR c.id = ANY($7))\n UNION ALL\n SELECT\n id as \"call_id!\",\n channel_id as \"channel_id!\",\n room_name as \"room_name!\",\n created_by as \"created_by!\",\n started_at as \"started_at!\",\n ended_at as \"ended_at\",\n duration_ms as \"duration_ms\",\n egress_id,\n recording_key,\n recording_started_at,\n custom_name,\n summary,\n false as \"is_active!\"\n FROM call_records cr\n WHERE EXISTS (\n SELECT 1 FROM entity_access ea\n JOIN user_source_ids u ON u.source_id = ea.source_id\n WHERE ea.entity_id = cr.id\n AND ea.entity_type = 'call'\n )\n AND ($3::bool IS FALSE OR cr.channel_id = ANY($4))\n AND ($5::bool IS NULL OR EXISTS (\n SELECT 1 FROM call_record_participants crp\n WHERE crp.call_record_id = cr.id AND crp.user_id = $1\n ) = $5)\n AND ($6::bool IS FALSE OR cr.id = ANY($7))\n ORDER BY \"started_at!\" DESC\n LIMIT $2\n ",- "describe": {- "columns": [- {- "ordinal": 0,- "name": "call_id!",- "type_info": "Uuid"- },- {- "ordinal": 1,- "name": "channel_id!",- "type_info": "Uuid"- },- {- "ordinal": 2,- "name": "room_name!",- "type_info": "Text"- },- {- "ordinal": 3,- "name": "created_by!",- "type_info": "Text"- },- {- "ordinal": 4,- "name": "started_at!",- "type_info": "Timestamptz"- },- {- "ordinal": 5,- "name": "ended_at",- "type_info": "Timestamptz"- },- {- "ordinal": 6,- "name": "duration_ms",- "type_info": "Int8"- },- {- "ordinal": 7,- "name": "egress_id",- "type_info": "Text"- },- {- "ordinal": 8,- "name": "recording_key",- "type_info": "Text"- },- {- "ordinal": 9,- "name": "recording_started_at",- "type_info": "Timestamptz"- },- {- "ordinal": 10,- "name": "custom_name",- "type_info": "Text"- },- {- "ordinal": 11,- "name": "summary",- "type_info": "Text"- },- {- "ordinal": 12,- "name": "is_active!",- "type_info": "Bool"- }- ],- "parameters": {- "Left": [- "Text",- "Int8",- "Bool",- "UuidArray",- "Bool",- "Bool",- "UuidArray"- ]- },- "nullable": [- null,- null,- null,- null,- null,- null,- null,- null,- null,- null,- null,- null,- null- ]- },- "hash": "e2c56203be986cfddced6fdc1dad55e15f226bd72a17498c501b273762ca201c"-}diff --git a/rust/cloud-storage/.sqlx/query-e617879c8a87f29fd7aefc87549f8e2867a9c395519fa6ecda6232daa31069bf.json b/rust/cloud-storage/.sqlx/query-e617879c8a87f29fd7aefc87549f8e2867a9c395519fa6ecda6232daa31069bf.jsondeleted file mode 100644index 4401ca872c..0000000000--- a/rust/cloud-storage/.sqlx/query-e617879c8a87f29fd7aefc87549f8e2867a9c395519fa6ecda6232daa31069bf.json+++ /dev/null@@ -1,23 +0,0 @@-{- "db_name": "PostgreSQL",- "query": "\n INSERT INTO crm_contacts (company_id, email)\n VALUES ($1, $2)\n ON CONFLICT (company_id, email) DO UPDATE SET email = EXCLUDED.email\n RETURNING id\n ",- "describe": {- "columns": [- {- "ordinal": 0,- "name": "id",- "type_info": "Uuid"- }- ],- "parameters": {- "Left": [- "Uuid",- "Text"- ]- },- "nullable": [- false- ]- },- "hash": "e617879c8a87f29fd7aefc87549f8e2867a9c395519fa6ecda6232daa31069bf"-}diff --git a/rust/cloud-storage/.sqlx/query-eb3f310b68951e5fccde74c2390e6d53b23291547a16b19036161d5120d87a0d.json b/rust/cloud-storage/.sqlx/query-eb3f310b68951e5fccde74c2390e6d53b23291547a16b19036161d5120d87a0d.jsondeleted file mode 100644index 1351d065a4..0000000000--- a/rust/cloud-storage/.sqlx/query-eb3f310b68951e5fccde74c2390e6d53b23291547a16b19036161d5120d87a0d.json+++ /dev/null@@ -1,29 +0,0 @@-{- "db_name": "PostgreSQL",- "query": "\n SELECT id, LOWER(email_address) AS \"email_lower!\"\n FROM email_contacts\n WHERE link_id = $1 AND LOWER(email_address) = ANY($2)\n ",- "describe": {- "columns": [- {- "ordinal": 0,- "name": "id",- "type_info": "Uuid"- },- {- "ordinal": 1,- "name": "email_lower!",- "type_info": "Text"- }- ],- "parameters": {- "Left": [- "Uuid",- "TextArray"- ]- },- "nullable": [- false,- null- ]- },- "hash": "eb3f310b68951e5fccde74c2390e6d53b23291547a16b19036161d5120d87a0d"-}diff --git a/rust/cloud-storage/.sqlx/query-eef43a75c11964f0fd8429e0dd1018d758bfb2e302070eb7d4ba2733d94477df.json b/rust/cloud-storage/.sqlx/query-eef43a75c11964f0fd8429e0dd1018d758bfb2e302070eb7d4ba2733d94477df.jsondeleted file mode 100644index a635cc2c88..0000000000--- a/rust/cloud-storage/.sqlx/query-eef43a75c11964f0fd8429e0dd1018d758bfb2e302070eb7d4ba2733d94477df.json+++ /dev/null@@ -1,14 +0,0 @@-{- "db_name": "PostgreSQL",- "query": "UPDATE call_records SET share_with_team = false WHERE id = $1",- "describe": {- "columns": [],- "parameters": {- "Left": [- "Uuid"- ]- },- "nullable": []- },- "hash": "eef43a75c11964f0fd8429e0dd1018d758bfb2e302070eb7d4ba2733d94477df"-}diff --git a/rust/cloud-storage/.sqlx/query-f0209df09903abdf1a18b48b4af612281be8c96ae49dae847c93a4218a54b900.json b/rust/cloud-storage/.sqlx/query-f0209df09903abdf1a18b48b4af612281be8c96ae49dae847c93a4218a54b900.jsondeleted file mode 100644index 4bc3bd3174..0000000000--- a/rust/cloud-storage/.sqlx/query-f0209df09903abdf1a18b48b4af612281be8c96ae49dae847c93a4218a54b900.json+++ /dev/null@@ -1,22 +0,0 @@-{- "db_name": "PostgreSQL",- "query": "SELECT COUNT(*) as \"count!\" FROM entity_access WHERE entity_id = $1 AND source_type = 'team'",- "describe": {- "columns": [- {- "ordinal": 0,- "name": "count!",- "type_info": "Int8"- }- ],- "parameters": {- "Left": [- "Uuid"- ]- },- "nullable": [- null- ]- },- "hash": "f0209df09903abdf1a18b48b4af612281be8c96ae49dae847c93a4218a54b900"-}diff --git a/rust/cloud-storage/documents/src/domain/branch_name.rs b/rust/cloud-storage/documents/src/domain/branch_name.rsindex e866804b54..aa697f589b 100644--- a/rust/cloud-storage/documents/src/domain/branch_name.rs+++ b/rust/cloud-storage/documents/src/domain/branch_name.rs@@ -30,32 +30,153 @@ pub fn slugify(name: &str) -> String {result.trim_matches('-').to_string()}-/// Build the full task branch name from the document's short id and title.+/// Build the user path component for a generated branch name.///-/// Format: `{slug}-macro-{short_id}`, capped at [`MAX_BRANCH_LENGTH`]-/// characters. If the slug must be truncated to fit, it's cut at the-/// last hyphen boundary so words aren't split mid-string.-pub fn build_task_branch_name(short_id: &str, document_name: &str) -> String {- let suffix = format!("macro-{short_id}");- let slug = slugify(document_name);- let max_slug_len = MAX_BRANCH_LENGTH.saturating_sub(suffix.len() + 1);+/// Prefer the linked GitHub username when present; otherwise use the local+/// part of the user's email address.+pub fn user_branch_prefix(github_username: Option<&str>, user_email: &str) -> String {+ let raw_prefix = github_username+ .and_then(non_empty_trimmed)+ .unwrap_or_else(|| email_local_part(user_email));+ let prefix = sanitize_branch_component(raw_prefix);- // slugify output is pure ASCII, so byte-indexing is safe.- let truncated = if slug.len() > max_slug_len {- let cut = &slug[..max_slug_len];- match cut.rfind('-').filter(|&i| i > 0) {- Some(boundary) => &cut[..boundary],- None => cut,+ if prefix.is_empty() {+ "macro".to_string()+ } else {+ prefix+ }+}++fn non_empty_trimmed(value: &str) -> Option<&str> {+ let trimmed = value.trim();+ (!trimmed.is_empty()).then_some(trimmed)+}++fn email_local_part(email: &str) -> &str {+ let email = email.trim();+ .split_once('@')+ .map(|(local_part, _)| local_part)+ .filter(|local_part| !local_part.is_empty())+ .unwrap_or(email)+}++fn sanitize_branch_component(component: &str) -> String {+ let mut result = String::with_capacity(component.len());+ let mut prev_hyphen = false;++ for c in component.trim().chars() {+ let to_push = if c.is_ascii_alphanumeric() || matches!(c, '_' | '.') {+ c+ } else if c == '-' || c.is_whitespace() || matches!(c, '/' | '\\') {+ '-'+ } else {+ continue;+ };++ if to_push == '-' {+ if !prev_hyphen {+ result.push('-');+ prev_hyphen = true;+ }+ } else {+ result.push(to_push);+ prev_hyphen = false;}+ }++ result+ .trim_matches(|c| matches!(c, '-' | '.' | '/'))+ .to_string()+}++fn team_branch_slug(team_slug: Option<&str>) -> String {+ let slug = team_slug+ .and_then(non_empty_trimmed)+ .map(str::to_ascii_lowercase)+ .unwrap_or_else(|| "macro".to_string());+ let slug = sanitize_branch_component(&slug);++ if slug.is_empty() {+ "macro".to_string()+ } else {+ slug+ }+}++fn task_reference(team_task_id: Option<i32>, short_id: &str) -> String {+ team_task_id+ .filter(|id| *id > 0)+ .map(|id| id.to_string())+ .unwrap_or_else(|| sanitize_branch_component(short_id))+}++fn truncate_slug_at_boundary(slug: &str, max_len: usize) -> &str {+ if max_len == 0 {+ return "";+ }++ if slug.len() <= max_len {+ return slug;+ }++ // slugify output is pure ASCII, so byte-indexing is safe.+ let cut = &slug[..max_len];+ match cut.rfind('-').filter(|&i| i > 0) {+ Some(boundary) => &cut[..boundary],+ None => cut,+ }+}++fn truncate_branch_at_limit(branch: String) -> String {+ if branch.len() <= MAX_BRANCH_LENGTH {+ return branch;+ }++ // All components passed to this function have been sanitized to ASCII.+ branch[..MAX_BRANCH_LENGTH]+ .trim_end_matches(['-', '.', '/'])+ .to_string()+}++/// Build the full task branch name.+///+/// Format:+/// `{github_username_or_email_prefix}/{lowercase_team_slug_or_macro}-{team_task_id_or_short_uuid}-{document-name-slug}`.+///+/// The branch is capped at [`MAX_BRANCH_LENGTH`] characters. If the document+/// slug must be truncated to fit, it is cut at the last hyphen boundary so+/// words aren't split mid-string.+pub fn build_task_branch_name(+ user_prefix: &str,+ team_slug: Option<&str>,+ team_task_id: Option<i32>,+ short_id: &str,+ document_name: &str,+) -> String {+ let user_prefix = sanitize_branch_component(user_prefix);+ let user_prefix = if user_prefix.is_empty() {+ "macro".to_string()} else {- slug.as_str()+ user_prefix};+ let team_slug = team_branch_slug(team_slug);+ let task_reference = task_reference(team_task_id, short_id);+ let branch_prefix = format!("{user_prefix}/{team_slug}-{task_reference}");++ let document_slug = slugify(document_name);+ if document_slug.is_empty() {+ return truncate_branch_at_limit(branch_prefix);+ }++ let max_document_slug_len = MAX_BRANCH_LENGTH.saturating_sub(branch_prefix.len() + 1);+ let truncated_document_slug =+ truncate_slug_at_boundary(&document_slug, max_document_slug_len).trim_end_matches('-');- let truncated = truncated.trim_end_matches('-');- if truncated.is_empty() {- suffix+ if truncated_document_slug.is_empty() {+ truncate_branch_at_limit(branch_prefix)} else {- format!("{truncated}-{suffix}")+ truncate_branch_at_limit(format!("{branch_prefix}-{truncated_document_slug}"))}}diff --git a/rust/cloud-storage/documents/src/domain/branch_name/test.rs b/rust/cloud-storage/documents/src/domain/branch_name/test.rsindex 1f225697ff..77acb04504 100644--- a/rust/cloud-storage/documents/src/domain/branch_name/test.rs+++ b/rust/cloud-storage/documents/src/domain/branch_name/test.rs@@ -1,4 +1,4 @@-use super::{build_task_branch_name, slugify};+use super::{build_task_branch_name, slugify, user_branch_prefix};#[test]fn strips_brackets_and_special_chars() {@@ -41,39 +41,80 @@ fn keeps_existing_hyphens() {}#[test]-fn builds_full_branch_name() {+fn user_prefix_prefers_github_username() {assert_eq!(- build_task_branch_name("abcd1234", "[search] fix bug"),- "search-fix-bug-macro-abcd1234"+ user_branch_prefix(Some("octocat"), "[email protected]"),+ "octocat");}#[test]-fn falls_back_to_suffix_when_slug_empty() {- assert_eq!(build_task_branch_name("abcd1234", "!!!"), "macro-abcd1234");+fn user_prefix_falls_back_to_email_local_part() {+ assert_eq!(user_branch_prefix(None, "[email protected]"), "user");+}++#[test]+fn user_prefix_sanitizes_branch_component() {+ assert_eq!(+ user_branch_prefix(Some(" user/name "), "[email protected]"),+ "user-name"+ );+}++#[test]+fn builds_full_branch_name_with_short_id_fallback() {+ assert_eq!(+ build_task_branch_name("user", None, None, "abcd1234", "[search] fix bug"),+ "user/macro-abcd1234-search-fix-bug"+ );+}++#[test]+fn builds_full_branch_name_with_team_task_id() {+ assert_eq!(+ build_task_branch_name(+ "octocat",+ Some("ENG"),+ Some(42),+ "abcd1234",+ "[search] fix bug"+ ),+ "octocat/eng-42-search-fix-bug"+ );+}++#[test]+fn falls_back_to_prefix_when_slug_empty() {+ assert_eq!(+ build_task_branch_name("user", None, None, "abcd1234", "!!!"),+ "user/macro-abcd1234"+ );}#[test]fn caps_branch_name_at_max_length() {let title = "word ".repeat(60);- let result = build_task_branch_name("abcd1234", &title);+ let result = build_task_branch_name("user", None, None, "abcd1234", &title);assert!(result.len() <= 200);- assert!(result.ends_with("-macro-abcd1234"));+ assert!(result.starts_with("user/macro-abcd1234-"));// Truncation happens at a hyphen boundary, so no trailing partial word.- assert!(!result.contains("-w-macro-"));+ let slug_portion = result.trim_start_matches("user/macro-abcd1234-");+ for segment in slug_portion.split('-') {+ assert_eq!(segment, "word", "found partial word: {segment}");+ }}#[test]fn truncates_at_hyphen_boundary() {- // Short id "id" → suffix "macro-id" (8 chars). Available slug = 200 - 9 = 191.let mut slug_input = String::new();for _ in 0..30 {slug_input.push_str("longword ");}- let result = build_task_branch_name("id", &slug_input);+ let result = build_task_branch_name("user", Some("ENG"), Some(42), "id", &slug_input);assert!(result.len() <= 200);- // The slug portion should not end with a partial "longword".- let slug_portion = result.trim_end_matches("-macro-id");+ assert!(result.starts_with("user/eng-42-"));++ let slug_portion = result.trim_start_matches("user/eng-42-");for segment in slug_portion.split('-') {assert_eq!(segment, "longword", "found partial word: {segment}");}diff --git a/rust/cloud-storage/documents/src/domain/models.rs b/rust/cloud-storage/documents/src/domain/models.rsindex c991114128..3c29fd4ed3 100644--- a/rust/cloud-storage/documents/src/domain/models.rs+++ b/rust/cloud-storage/documents/src/domain/models.rs@@ -81,6 +81,28 @@ pub struct TeamTaskMetadata {pub task_num: i32,}+/// User/team information needed to build a task branch name.+#[derive(Eq, PartialEq, Debug, Clone)]+pub struct BranchNameContext {+ /// The user's email address, used when no GitHub username is linked.+ pub user_email: String,+ /// Linked GitHub username for the user, when present.+ pub github_username: Option<String>,+ /// Slug for the user's team, when the user belongs to a team.+ pub team_slug: Option<String>,+ /// Task number for the document within the user's team, when present.+ pub team_task_id: Option<i32>,+}++/// A fully generated task branch name plus its short document id.+#[derive(Eq, PartialEq, Debug, Clone)]+pub struct TaskBranchName {+ /// The short id of the document.+ pub short_id: String,+ /// The generated branch name.+ pub branch_name: String,+}+/// Request body for copying a document.#[derive(serde::Serialize, serde::Deserialize, Eq, PartialEq, Debug)]#[cfg_attr(feature = "axum", derive(utoipa::ToSchema))]diff --git a/rust/cloud-storage/documents/src/domain/ports/mod.rs b/rust/cloud-storage/documents/src/domain/ports/mod.rsindex 6ac89dc16b..3cc3f34a1c 100644--- a/rust/cloud-storage/documents/src/domain/ports/mod.rs+++ b/rust/cloud-storage/documents/src/domain/ports/mod.rs@@ -24,8 +24,9 @@ use model::sync_service::SyncServiceVersionID;use model_entity::Entity;use super::models::{- CommentThread, CopyDocumentRepoArgs, CreateDocumentRepoArgs, CreateTaskRequest, DocumentError,- EditDocumentRepoArgs, EditDocumentServiceArgs, LocationQueryParams, TeamTaskMetadata,+ BranchNameContext, CommentThread, CopyDocumentRepoArgs, CreateDocumentRepoArgs,+ CreateTaskRequest, DocumentError, EditDocumentRepoArgs, EditDocumentServiceArgs,+ LocationQueryParams, TaskBranchName, TeamTaskMetadata,};/// Repository for accessing document data from the database.@@ -171,6 +172,13 @@ pub trait DocumentRepo: Send + Sync + 'static {document_id: &str,) -> impl Future<Output = Result<Option<TeamTaskMetadata>, Self::Err>> + Send;+ /// Get user/team data needed to build a branch name for this user and task.+ fn get_branch_name_context(+ &self,+ document_id: &str,+ user_id: &str,+ ) -> impl Future<Output = Result<BranchNameContext, Self::Err>> + Send;+/// Share a document with the given team.fn share_with_team(&self,@@ -342,6 +350,13 @@ pub trait DocumentService: Send + Sync + 'static {entity_access_receipt: EntityAccessReceipt<ViewAccessLevel>,) -> impl Future<Output = Result<String, DocumentError>> + Send;+ /// Build the branch name for a task document for the authenticated user.+ fn get_task_branch_name(+ &self,+ entity_access_receipt: EntityAccessReceipt<ViewAccessLevel>,+ document_name: String,+ ) -> impl Future<Output = Result<TaskBranchName, DocumentError>> + Send;+/// Edit a document's metadata and share permissions.////// Validates permissions, updates the document, sends invalidation event,diff --git a/rust/cloud-storage/documents/src/domain/service.rs b/rust/cloud-storage/documents/src/domain/service.rsindex 1fb9cc6d7f..e1ebd96d10 100644--- a/rust/cloud-storage/documents/src/domain/service.rs+++ b/rust/cloud-storage/documents/src/domain/service.rs@@ -34,11 +34,12 @@ use crate::domain::models::{ASSIGNEES_PROPERTY_ID, NOT_STARTED_STATUS_OPTION_ID, PropertyInput, STATUS_PROPERTY_ID,};+use super::branch_name::{build_task_branch_name, user_branch_prefix};use super::content::{DocumentContent, DocumentContentLocation, DocumentContentState};use super::models::{CloudFrontConfig, CommentThread, CopyDocumentRepoArgs, CreateDocumentRepoArgs,CreateTaskRequest, DocumentError, EditDocumentRepoArgs, EditDocumentServiceArgs,- FileTypeUpdate, LocationQueryParams, TeamTaskMetadata,+ FileTypeUpdate, LocationQueryParams, TaskBranchName, TeamTaskMetadata,};#[cfg(feature = "document_create")]use super::ports::create::DocumentCreationService;@@ -105,6 +106,12 @@ fn pending_content_for_file_type(file_type: Option<FileType>) -> DocumentContent}}+fn short_id_for_entity_id(entity_id: &str) -> Result<String, DocumentError> {+ let uuid = macro_uuid::string_to_uuid(entity_id)+ .map_err(|e| DocumentError::BadRequest(format!("invalid entity_id: {e}")))?;+ Ok(macro_uuid::ShortUuidConverter::default().from_uuid(&uuid))+}+impl<R: DocumentRepo,U: PresignedUploadUrlPort,@@ -674,11 +681,46 @@ impl<&self,entity_access_receipt: EntityAccessReceipt<ViewAccessLevel>,) -> Result<String, DocumentError> {- let entity_id = &entity_access_receipt.entity().entity_id;- let uuid = macro_uuid::string_to_uuid(entity_id)- .map_err(|e| DocumentError::BadRequest(format!("invalid entity_id: {e}")))?;- let short_id = macro_uuid::ShortUuidConverter::default().from_uuid(&uuid);- Ok(short_id)+ short_id_for_entity_id(&entity_access_receipt.entity().entity_id)+ }++ async fn get_task_branch_name(+ &self,+ entity_access_receipt: EntityAccessReceipt<ViewAccessLevel>,+ document_name: String,+ ) -> Result<TaskBranchName, DocumentError> {+ let document_id = &entity_access_receipt.entity().entity_id;+ let short_id = short_id_for_entity_id(document_id)?;+ let (user_prefix, team_slug, team_task_id) = match entity_access_receipt.auth() {+ EntityAccessAuth::Authenticated(user_id) => {+ let context = self+ .repo+ .get_branch_name_context(document_id, user_id.as_ref())+ .await+ .map_err(|e| DocumentError::Internal(e.into()))?;+ (+ user_branch_prefix(context.github_username.as_deref(), &context.user_email),+ context.team_slug,+ context.team_task_id,+ )+ }+ EntityAccessAuth::Unauthenticated | EntityAccessAuth::Internal => {+ ("macro".to_string(), None, None)+ }+ };++ let branch_name = build_task_branch_name(+ &user_prefix,+ team_slug.as_deref(),+ team_task_id,+ &short_id,+ &document_name,+ );++ Ok(TaskBranchName {+ short_id,+ branch_name,+ })}#[tracing::instrument(err, skip(self, document_context))]diff --git a/rust/cloud-storage/documents/src/inbound/axum_router.rs b/rust/cloud-storage/documents/src/inbound/axum_router.rsindex 8c7b46f35c..4dded6aa1b 100644--- a/rust/cloud-storage/documents/src/inbound/axum_router.rs+++ b/rust/cloud-storage/documents/src/inbound/axum_router.rs@@ -4,7 +4,7 @@//! - `POST /` — create a new document//! - `GET /{document_id}` — get document metadata//! - `GET /{document_id}/location_v3` — get document content location (presigned URL)-//! - `GET /{document_id}/branch_name` — get short ID + git branch name (when the document is a task)+//! - `GET /{document_id}/branch_name` — get short ID + task-aware git branch name (when the document is a task)//! - `GET /{document_id}/short_id` — get document short ID//! - `POST /create_markdown` — create and initialize a markdown document//! - `DELETE /{document_id}` — soft-delete a documentdiff --git a/rust/cloud-storage/documents/src/inbound/axum_router/get_branch_name.rs b/rust/cloud-storage/documents/src/inbound/axum_router/get_branch_name.rsindex 50d61486d4..376f75b5ca 100644--- a/rust/cloud-storage/documents/src/inbound/axum_router/get_branch_name.rs+++ b/rust/cloud-storage/documents/src/inbound/axum_router/get_branch_name.rs@@ -9,7 +9,6 @@ use entity_access::inbound::axum_extractors::DocumentAccessExtractor;use models_permissions::share_permission::access_level::ViewAccessLevel;use super::{DocumentRouterState, Params};-use crate::domain::branch_name::build_task_branch_name;use crate::domain::models::DocumentError;use crate::domain::ports::DocumentService;use document_sub_type::DocumentSubType;@@ -53,17 +52,19 @@ pub async fn get_branch_name_handler<T: DocumentService, Svc: EntityAccessServiclet receipt = access.entity_access_receipt;let document = state.service.get_document(receipt.clone()).await?;- let short_id = state.service.get_short_id(receipt).await?;match document.document_metadata.metadata.sub_type {Some(DocumentSubType::Task) => {- let branch_name = build_task_branch_name(- &short_id,- &document.document_metadata.metadata.document_name,- );+ let task_branch_name = state+ .service+ .get_task_branch_name(+ receipt,+ document.document_metadata.metadata.document_name.clone(),+ )+ .await?;Ok(Json(BranchNameResponse {- short_id,- branch_name,+ short_id: task_branch_name.short_id,+ branch_name: task_branch_name.branch_name,}))}None => Err(DocumentError::BadRequest(format!(diff --git a/rust/cloud-storage/documents/src/inbound/toolset/read_metadata.rs b/rust/cloud-storage/documents/src/inbound/toolset/read_metadata.rsindex 544bafe1bb..92eae5568a 100644--- a/rust/cloud-storage/documents/src/inbound/toolset/read_metadata.rs+++ b/rust/cloud-storage/documents/src/inbound/toolset/read_metadata.rs@@ -13,7 +13,6 @@ use serde::{Deserialize, Serialize};use uuid::Uuid;use super::DocumentToolContext;-use crate::domain::branch_name::build_task_branch_name;#[derive(Debug, Serialize, JsonSchema)]#[serde(rename_all = "camelCase")]@@ -86,19 +85,19 @@ wherelet branch_name = if let Some(sub_type) = result.document_metadata.metadata.sub_type {match sub_type {document_sub_type::DocumentSubType::Task => {- let short_id = service_context+ let task_branch_name = service_context.service- .get_short_id(entity_access_receipt)+ .get_task_branch_name(+ entity_access_receipt,+ result.document_metadata.metadata.document_name.clone(),+ ).await.map_err(|e| ToolCallError {- description: "unable to get the short id".to_string(),+ description: "unable to get the branch name".to_string(),internal_error: e.into(),})?;- Some(build_task_branch_name(- &short_id,- &result.document_metadata.metadata.document_name,- ))+ Some(task_branch_name.branch_name)}}} else {diff --git a/rust/cloud-storage/documents/src/outbound/pg_document_repo.rs b/rust/cloud-storage/documents/src/outbound/pg_document_repo.rsindex 67fb9633b4..aba76ceb21 100644--- a/rust/cloud-storage/documents/src/outbound/pg_document_repo.rs+++ b/rust/cloud-storage/documents/src/outbound/pg_document_repo.rs@@ -21,8 +21,8 @@ use sqlx::Row;use crate::domain::content::{DocumentContent, DocumentContentState};use crate::domain::models::{- Comment, CommentThread, CopyDocumentRepoArgs, CreateDocumentRepoArgs, EditDocumentRepoArgs,- TeamTaskMetadata, Thread,+ BranchNameContext, Comment, CommentThread, CopyDocumentRepoArgs, CreateDocumentRepoArgs,+ EditDocumentRepoArgs, TeamTaskMetadata, Thread,};use crate::domain::ports::DocumentRepo;@@ -697,6 +697,52 @@ impl DocumentRepo for PgDocumentRepo {}))}+ #[tracing::instrument(err, skip(self))]+ async fn get_branch_name_context(+ &self,+ document_id: &str,+ user_id: &str,+ ) -> Result<BranchNameContext, Self::Err> {+ let row = sqlx::query!(+ r#"+ SELECT+ COALESCE(u.email, NULLIF(split_part(request_user.user_id, '|', 2), ''), request_user.user_id) AS "user_email!",+ gl.github_username AS "github_username?",+ t.slug AS "team_slug?",+ tt.task_num AS "team_task_id?"+ FROM (SELECT $1::text AS user_id) request_user+ LEFT JOIN "User" u ON u.id = request_user.user_id+ LEFT JOIN LATERAL (+ SELECT github_username+ FROM github_links+ WHERE macro_id = request_user.user_id+ ORDER BY updated_at DESC+ LIMIT 1+ ) gl ON true+ LEFT JOIN LATERAL (+ SELECT team_id+ FROM team_user+ WHERE user_id = request_user.user_id+ ORDER BY team_id+ LIMIT 1+ ) tu ON true+ LEFT JOIN team t ON t.id = tu.team_id+ LEFT JOIN team_task tt ON tt.team_id = tu.team_id AND tt.document_id = $2+ "#,+ user_id,+ document_id,+ )+ .fetch_one(&self.pool)+ .await?;++ Ok(BranchNameContext {+ user_email: row.user_email,+ github_username: row.github_username,+ team_slug: row.team_slug,+ team_task_id: row.team_task_id,+ })+ }+#[tracing::instrument(err, skip(self))]async fn share_with_team(&self,diff --git a/rust/cloud-storage/documents/src/outbound/pg_document_repo/tests.rs b/rust/cloud-storage/documents/src/outbound/pg_document_repo/tests.rsindex 46cedc63f1..4ffd1cec8f 100644--- a/rust/cloud-storage/documents/src/outbound/pg_document_repo/tests.rs+++ b/rust/cloud-storage/documents/src/outbound/pg_document_repo/tests.rs@@ -850,6 +850,69 @@ async fn test_copying_task_allocates_new_team_task_number(pool: Pool<Postgres>)assert_eq!(team_task_numbers(&pool, TEST_TEAM_ID).await, vec![1, 2]);}+#[sqlx::test(+ migrator = "MACRO_DB_MIGRATIONS",+ fixtures(path = "../../../fixtures", scripts("documents_test_data"))+)]+async fn test_get_branch_name_context_prefers_github_and_team_task(pool: Pool<Postgres>) {+ let repo = PgDocumentRepo::new(pool.clone());+ sqlx::query!(+ r#"+ UPDATE team+ SET slug = 'ENG'+ WHERE id = $1+ "#,+ TEST_TEAM_ID,+ )+ .execute(&pool)+ .await+ .unwrap();++ sqlx::query!(+ r#"+ INSERT INTO github_links (id, macro_id, fusionauth_user_id, github_username, github_user_id)+ VALUES ($1, 'macro|[email protected]', $2, 'octocat', '12345')+ "#,+ uuid::uuid!("b0000000-0000-0000-0000-000000000001"),+ uuid::uuid!("b0000000-0000-0000-0000-000000000002"),+ )+ .execute(&pool)+ .await+ .unwrap();++ let task = create_task_for_team(&repo, "macro|[email protected]", TEST_TEAM_ID).await;+ let context = repo+ .get_branch_name_context(&task.document_id, "macro|[email protected]")+ .await+ .unwrap();++ assert_eq!(context.user_email, "[email protected]");+ assert_eq!(context.github_username, Some("octocat".to_string()));+ assert_eq!(context.team_slug, Some("ENG".to_string()));+ assert_eq!(context.team_task_id, Some(1));+}++#[sqlx::test(+ migrator = "MACRO_DB_MIGRATIONS",+ fixtures(path = "../../../fixtures", scripts("documents_test_data"))+)]+async fn test_get_branch_name_context_falls_back_for_unknown_user(pool: Pool<Postgres>) {+ let repo = PgDocumentRepo::new(pool);++ let context = repo+ .get_branch_name_context(+ "d0000000-0000-0000-0000-000000000001",+ "macro|[email protected]",+ )+ .await+ .unwrap();++ assert_eq!(context.user_email, "[email protected]");+ assert_eq!(context.github_username, None);+ assert_eq!(context.team_slug, None);+ assert_eq!(context.team_task_id, None);+}+#[sqlx::test(migrator = "MACRO_DB_MIGRATIONS",fixtures(path = "../../../fixtures", scripts("documents_test_data"))diff --git a/rust/cloud-storage/github/src/domain/service/sync/test.rs b/rust/cloud-storage/github/src/domain/service/sync/test.rsindex 4ebc2851d1..0a322923c7 100644--- a/rust/cloud-storage/github/src/domain/service/sync/test.rs+++ b/rust/cloud-storage/github/src/domain/service/sync/test.rs@@ -120,6 +120,13 @@ impl DocumentService for StubDocumentService {) -> Result<String, DocumentError> {unimplemented!()}+ async fn get_task_branch_name(+ &self,+ _receipt: EntityAccessReceipt<ViewAccessLevel>,+ _document_name: String,+ ) -> Result<documents::domain::models::TaskBranchName, DocumentError> {+ unimplemented!()+ }async fn get_project_children(&self,_project_id: &str,