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(github): store author and description in pr (#4041)
Will Hutchinsoncc64cd02ba25
diff --git a/js/app/packages/service-clients/service-auth/generated/schemas/enrichedGithubPullRequest.ts b/js/app/packages/service-clients/service-auth/generated/schemas/enrichedGithubPullRequest.tsindex 543ac1d8b9..9d2d206f93 100644--- a/js/app/packages/service-clients/service-auth/generated/schemas/enrichedGithubPullRequest.ts+++ b/js/app/packages/service-clients/service-auth/generated/schemas/enrichedGithubPullRequest.ts@@ -5,9 +5,12 @@* OpenAPI spec version: 0.1.0*/import type { EnrichedGithubPullRequestAdditions } from './enrichedGithubPullRequestAdditions';+import type { EnrichedGithubPullRequestAuthorId } from './enrichedGithubPullRequestAuthorId';+import type { EnrichedGithubPullRequestAuthorLogin } from './enrichedGithubPullRequestAuthorLogin';import type { EnrichedGithubPullRequestChecks } from './enrichedGithubPullRequestChecks';import type { EnrichedGithubPullRequestComments } from './enrichedGithubPullRequestComments';import type { EnrichedGithubPullRequestDeletions } from './enrichedGithubPullRequestDeletions';+import type { EnrichedGithubPullRequestDescription } from './enrichedGithubPullRequestDescription';import type { EnrichedGithubPullRequestName } from './enrichedGithubPullRequestName';import type { EnrichedGithubPullRequestParticipantGithubUserIds } from './enrichedGithubPullRequestParticipantGithubUserIds';import type { EnrichedGithubPullRequestStatus } from './enrichedGithubPullRequestStatus';@@ -21,6 +24,13 @@ export interface EnrichedGithubPullRequest {* @minimum 0*/additions?: EnrichedGithubPullRequestAdditions;+ /**+ * The stable numeric GitHub user id for the pull request author, when available.+ * @minimum 0+ */+ authorId?: EnrichedGithubPullRequestAuthorId;+ /** The GitHub login for the pull request author, when available. */+ authorLogin?: EnrichedGithubPullRequestAuthorLogin;/** Check runs collected from the pull request head commit, when enrichment includes them. */checks?: EnrichedGithubPullRequestChecks;/** Comments collected from the pull request, when enrichment includes them. */@@ -30,6 +40,8 @@ export interface EnrichedGithubPullRequest {* @minimum 0*/deletions?: EnrichedGithubPullRequestDeletions;+ /** The pull request description (body), when available. */+ description?: EnrichedGithubPullRequestDescription;/** A compact label suitable for display in the UI. */displayName: string;/** The stored GitHub association key, in `owner/repo/pull/number` format. */diff --git a/js/app/packages/service-clients/service-auth/generated/schemas/enrichedGithubPullRequestAuthorId.ts b/js/app/packages/service-clients/service-auth/generated/schemas/enrichedGithubPullRequestAuthorId.tsnew file mode 100644index 0000000000..1a2bddd1b1--- /dev/null+++ b/js/app/packages/service-clients/service-auth/generated/schemas/enrichedGithubPullRequestAuthorId.ts@@ -0,0 +1,12 @@+/**+ * Generated by orval v7.21.0 🍺+ * Do not edit manually.+ * authentication_service+ * OpenAPI spec version: 0.1.0+ */++/**+ * The stable numeric GitHub user id for the pull request author, when available.+ * @minimum 0+ */+export type EnrichedGithubPullRequestAuthorId = number | null;diff --git a/js/app/packages/service-clients/service-auth/generated/schemas/enrichedGithubPullRequestAuthorLogin.ts b/js/app/packages/service-clients/service-auth/generated/schemas/enrichedGithubPullRequestAuthorLogin.tsnew file mode 100644index 0000000000..04b3a431ae--- /dev/null+++ b/js/app/packages/service-clients/service-auth/generated/schemas/enrichedGithubPullRequestAuthorLogin.ts@@ -0,0 +1,11 @@+/**+ * Generated by orval v7.21.0 🍺+ * Do not edit manually.+ * authentication_service+ * OpenAPI spec version: 0.1.0+ */++/**+ * The GitHub login for the pull request author, when available.+ */+export type EnrichedGithubPullRequestAuthorLogin = string | null;diff --git a/js/app/packages/service-clients/service-auth/generated/schemas/enrichedGithubPullRequestDescription.ts b/js/app/packages/service-clients/service-auth/generated/schemas/enrichedGithubPullRequestDescription.tsnew file mode 100644index 0000000000..dda8f7cd65--- /dev/null+++ b/js/app/packages/service-clients/service-auth/generated/schemas/enrichedGithubPullRequestDescription.ts@@ -0,0 +1,11 @@+/**+ * Generated by orval v7.21.0 🍺+ * Do not edit manually.+ * authentication_service+ * OpenAPI spec version: 0.1.0+ */++/**+ * The pull request description (body), when available.+ */+export type EnrichedGithubPullRequestDescription = string | null;diff --git a/js/app/packages/service-clients/service-auth/generated/schemas/index.ts b/js/app/packages/service-clients/service-auth/generated/schemas/index.tsindex 3406d8b1c3..58d5a01607 100644--- a/js/app/packages/service-clients/service-auth/generated/schemas/index.ts+++ b/js/app/packages/service-clients/service-auth/generated/schemas/index.ts@@ -21,9 +21,12 @@ export * from './createUserRequest';export * from './emptyResponse';export * from './enrichedGithubPullRequest';export * from './enrichedGithubPullRequestAdditions';+export * from './enrichedGithubPullRequestAuthorId';+export * from './enrichedGithubPullRequestAuthorLogin';export * from './enrichedGithubPullRequestChecks';export * from './enrichedGithubPullRequestComments';export * from './enrichedGithubPullRequestDeletions';+export * from './enrichedGithubPullRequestDescription';export * from './enrichedGithubPullRequestName';export * from './enrichedGithubPullRequestParticipantGithubUserIds';export * from './enrichedGithubPullRequestStatus';diff --git a/js/app/packages/service-clients/service-auth/openapi.json b/js/app/packages/service-clients/service-auth/openapi.jsonindex c6f517f8b0..020204047f 100644--- a/js/app/packages/service-clients/service-auth/openapi.json+++ b/js/app/packages/service-clients/service-auth/openapi.json@@ -3460,6 +3460,16 @@"description": "The number of added lines reported by GitHub, when enrichment succeeds.","minimum": 0},+ "authorId": {+ "type": ["integer", "null"],+ "format": "int64",+ "description": "The stable numeric GitHub user id for the pull request author, when available.",+ "minimum": 0+ },+ "authorLogin": {+ "type": ["string", "null"],+ "description": "The GitHub login for the pull request author, when available."+ },"checks": {"type": ["array", "null"],"items": {@@ -3480,6 +3490,10 @@"description": "The number of deleted lines reported by GitHub, when enrichment succeeds.","minimum": 0},+ "description": {+ "type": ["string", "null"],+ "description": "The pull request description (body), when available."+ },"displayName": {"type": "string","description": "A compact label suitable for display in the UI."diff --git a/rust/cloud-storage/github/src/domain/models/pull_request.rs b/rust/cloud-storage/github/src/domain/models/pull_request.rsindex d49fbc64f7..eb64a9c8e9 100644--- a/rust/cloud-storage/github/src/domain/models/pull_request.rs+++ b/rust/cloud-storage/github/src/domain/models/pull_request.rs@@ -150,6 +150,15 @@ pub struct GithubPullRequestDetails {pub additions: u64,/// The number of deleted lines reported by GitHub.pub deletions: u64,+ /// The GitHub login for the pull request author, when available.+ #[serde(default, skip_serializing_if = "Option::is_none")]+ pub author_login: Option<String>,+ /// The stable numeric GitHub user id for the pull request author, when available.+ #[serde(default, skip_serializing_if = "Option::is_none")]+ pub author_id: Option<u64>,+ /// The pull request description (body), when available.+ #[serde(default, skip_serializing_if = "Option::is_none")]+ pub description: Option<String>,/// Comments collected from the pull request, when enrichment includes them.#[serde(default,@@ -206,6 +215,15 @@ pub struct EnrichedGithubPullRequest {pub additions: Option<u64>,/// The number of deleted lines reported by GitHub, when enrichment succeeds.pub deletions: Option<u64>,+ /// The GitHub login for the pull request author, when available.+ #[serde(default, skip_serializing_if = "Option::is_none")]+ pub author_login: Option<String>,+ /// The stable numeric GitHub user id for the pull request author, when available.+ #[serde(default, skip_serializing_if = "Option::is_none")]+ pub author_id: Option<u64>,+ /// The pull request description (body), when available.+ #[serde(default, skip_serializing_if = "Option::is_none")]+ pub description: Option<String>,/// Comments collected from the pull request, when enrichment includes them.#[serde(default, skip_serializing_if = "Option::is_none")]pub comments: Option<Vec<GithubPullRequestComment>>,@@ -233,6 +251,9 @@ impl EnrichedGithubPullRequest {status: None,additions: None,deletions: None,+ author_login: None,+ author_id: None,+ description: None,comments: None,checks: None,participant_github_user_ids: None,@@ -257,6 +278,9 @@ impl EnrichedGithubPullRequest {status: Some(status),additions: Some(details.additions),deletions: Some(details.deletions),+ author_login: details.author_login,+ author_id: details.author_id,+ description: details.description,comments: details.comments,checks: details.checks,participant_github_user_ids: details.participant_github_user_ids,@@ -267,6 +291,8 @@ impl EnrichedGithubPullRequest {////// Partial refreshes may omit `comments` or `checks`. When an omitted field exists as an array in/// `existing_metadata`, the existing array is copied forward so richer metadata is not discarded.+ /// The same applies to the scalar `authorLogin`, `authorId`, and `description` fields, which+ /// fallback write paths (such as comment webhooks without a `pull_request` payload) omit.pub fn foreign_entity_metadata(&self,existing_metadata: Option<&serde_json::Value>,@@ -291,6 +317,18 @@ impl EnrichedGithubPullRequest {}}+ for field in ["authorLogin", "authorId", "description"] {+ if metadata_object.contains_key(field) {+ continue;+ }++ if let Some(existing_value) = existing_object.get(field)+ && !existing_value.is_null()+ {+ metadata_object.insert(field.to_string(), existing_value.clone());+ }+ }+// Participants are unioned rather than carried forward or replaced: write paths produce// partial sets (a webhook fallback knows the author/reviewers/assignees but not the// commenters), so replacing would drop participants a richer earlier write discovered.diff --git a/rust/cloud-storage/github/src/domain/models/test.rs b/rust/cloud-storage/github/src/domain/models/test.rsindex 53b62238ca..c8856a2889 100644--- a/rust/cloud-storage/github/src/domain/models/test.rs+++ b/rust/cloud-storage/github/src/domain/models/test.rs@@ -28,6 +28,9 @@ fn pull_request_details(merged_at,additions: 42,deletions: 12,+ author_login: Some("octocat".to_string()),+ author_id: Some(583231),+ description: Some("Enrich pull requests with GitHub data".to_string()),comments: None,checks: None,participant_github_user_ids: None,@@ -151,6 +154,9 @@ fn pull_request_response_serializes_with_camel_case_fields() {status: Some(GithubPullRequestStatus::Merged),additions: Some(42),deletions: Some(12),+ author_login: Some("octocat".to_string()),+ author_id: Some(583231),+ description: Some("Enrich pull requests with GitHub data".to_string()),comments: Some(vec![pull_request_comment()]),checks: Some(vec![pull_request_check_run()]),participant_github_user_ids: None,@@ -174,6 +180,9 @@ fn pull_request_response_serializes_with_camel_case_fields() {"status": "merged","additions": 42,"deletions": 12,+ "authorLogin": "octocat",+ "authorId": 583231,+ "description": "Enrich pull requests with GitHub data","comments": [{"id": 101,@@ -249,12 +258,18 @@ fn pull_request_enrichment_preserves_reference_fields() {assert_eq!(enriched.status, None);assert_eq!(enriched.additions, None);assert_eq!(enriched.deletions, None);+ assert_eq!(enriched.author_login, None);+ assert_eq!(enriched.author_id, None);+ assert_eq!(enriched.description, None);assert_eq!(enriched.comments, None);assert_eq!(enriched.checks, None);let enriched_json = serde_json::to_value(&enriched).unwrap();assert!(enriched_json.get("comments").is_none());assert!(enriched_json.get("checks").is_none());+ assert!(enriched_json.get("authorLogin").is_none());+ assert!(enriched_json.get("authorId").is_none());+ assert!(enriched_json.get("description").is_none());}#[test]@@ -268,6 +283,9 @@ fn pull_request_enrichment_copies_details_fields() {merged_at: Some(utc_datetime("2026-05-25T18:54:21Z")),additions: 42,deletions: 12,+ author_login: Some("octocat".to_string()),+ author_id: Some(583231),+ description: Some("Enrich pull requests with GitHub data".to_string()),comments: Some(comments.clone()),checks: Some(checks.clone()),participant_github_user_ids: Some(vec!["42".to_string(), "583231".to_string()]),@@ -288,6 +306,12 @@ fn pull_request_enrichment_copies_details_fields() {assert_eq!(enriched.status, Some(GithubPullRequestStatus::Merged));assert_eq!(enriched.additions, Some(42));assert_eq!(enriched.deletions, Some(12));+ assert_eq!(enriched.author_login, Some("octocat".to_string()));+ assert_eq!(enriched.author_id, Some(583231));+ assert_eq!(+ enriched.description,+ Some("Enrich pull requests with GitHub data".to_string())+ );assert_eq!(enriched.comments, Some(comments));assert_eq!(enriched.checks, Some(checks));assert_eq!(@@ -310,6 +334,9 @@ fn pull_request_foreign_entity_metadata_serializes_enriched_pull_request() {merged_at: Some(utc_datetime("2026-05-25T18:54:21Z")),additions: 42,deletions: 12,+ author_login: Some("octocat".to_string()),+ author_id: Some(583231),+ description: Some("Enrich pull requests with GitHub data".to_string()),comments: Some(vec![pull_request_comment()]),checks: Some(vec![pull_request_check_run()]),participant_github_user_ids: None,@@ -331,6 +358,9 @@ fn pull_request_foreign_entity_metadata_serializes_enriched_pull_request() {"status": "merged","additions": 42,"deletions": 12,+ "authorLogin": "octocat",+ "authorId": 583231,+ "description": "Enrich pull requests with GitHub data","comments": [{"id": 101,@@ -396,6 +426,9 @@ fn pull_request_foreign_entity_metadata_preserves_existing_arrays_when_refresh_o"status": "open","additions": 42,"deletions": 12,+ "authorLogin": "octocat",+ "authorId": 583231,+ "description": "Enrich pull requests with GitHub data","comments": [{"id": 303,@@ -422,6 +455,9 @@ fn pull_request_foreign_entity_metadata_keeps_fresh_arrays() {merged_at: None,additions: 42,deletions: 12,+ author_login: None,+ author_id: None,+ description: None,comments: Some(comments.clone()),checks: Some(checks.clone()),participant_github_user_ids: None,@@ -442,6 +478,61 @@ fn pull_request_foreign_entity_metadata_keeps_fresh_arrays() {assert_eq!(metadata.get("checks"), Some(&fresh_checks));}+#[test]+fn pull_request_foreign_entity_metadata_carries_existing_author_and_description_forward() {+ let mut details = pull_request_details("open", None);+ details.author_login = None;+ details.author_id = None;+ details.description = None;+ let enriched = EnrichedGithubPullRequest::from_details(pull_request_reference(), details);+ let existing_metadata = serde_json::json!({+ "authorLogin": "octocat",+ "authorId": 583231,+ "description": "Existing description"+ });++ let metadata = enriched+ .foreign_entity_metadata(Some(&existing_metadata))+ .unwrap();++ assert_eq!(+ metadata.get("authorLogin"),+ Some(&serde_json::json!("octocat"))+ );+ assert_eq!(metadata.get("authorId"), Some(&serde_json::json!(583231)));+ assert_eq!(+ metadata.get("description"),+ Some(&serde_json::json!("Existing description"))+ );+}++#[test]+fn pull_request_foreign_entity_metadata_keeps_fresh_author_and_description() {+ let enriched = EnrichedGithubPullRequest::from_details(+ pull_request_reference(),+ pull_request_details("open", None),+ );+ let existing_metadata = serde_json::json!({+ "authorLogin": "stale-login",+ "authorId": 1,+ "description": "Stale description"+ });++ let metadata = enriched+ .foreign_entity_metadata(Some(&existing_metadata))+ .unwrap();++ assert_eq!(+ metadata.get("authorLogin"),+ Some(&serde_json::json!("octocat"))+ );+ assert_eq!(metadata.get("authorId"), Some(&serde_json::json!(583231)));+ assert_eq!(+ metadata.get("description"),+ Some(&serde_json::json!("Enrich pull requests with GitHub data"))+ );+}+#[test]fn pull_request_foreign_entity_metadata_unions_participants_with_existing() {let mut details = pull_request_details("open", None);diff --git a/rust/cloud-storage/github/src/domain/service/link_test.rs b/rust/cloud-storage/github/src/domain/service/link_test.rsindex 6fb6dffd53..844072cf95 100644--- a/rust/cloud-storage/github/src/domain/service/link_test.rs+++ b/rust/cloud-storage/github/src/domain/service/link_test.rs@@ -130,6 +130,9 @@ fn default_pull_request_details() -> GithubPullRequestDetails {merged_at: None,additions: 12,deletions: 3,+ author_login: None,+ author_id: None,+ description: None,comments: None,checks: None,participant_github_user_ids: None,diff --git a/rust/cloud-storage/github/src/domain/service/sync/mod.rs b/rust/cloud-storage/github/src/domain/service/sync/mod.rsindex 047fb1b6f3..a7e23df803 100644--- a/rust/cloud-storage/github/src/domain/service/sync/mod.rs+++ b/rust/cloud-storage/github/src/domain/service/sync/mod.rs@@ -221,6 +221,19 @@ impl<deletions: pull_request.and_then(|pr| pr.get("deletions")).and_then(|value| value.as_u64()),+ author_login: pull_request+ .and_then(|pr| pr.get("user"))+ .and_then(|user| user.get("login"))+ .and_then(|value| value.as_str())+ .map(str::to_string),+ author_id: pull_request+ .and_then(|pr| pr.get("user"))+ .and_then(|user| user.get("id"))+ .and_then(|value| value.as_u64()),+ description: pull_request+ .and_then(|pr| pr.get("body"))+ .and_then(|value| value.as_str())+ .map(str::to_string),comments: None,checks: None,participant_github_user_ids: Self::participant_ids_from_payload(pull_request),@@ -319,6 +332,9 @@ impl<status: Some(status),additions: Some(details.additions),deletions: Some(details.deletions),+ author_login: details.author_login.or(fallback.author_login),+ author_id: details.author_id.or(fallback.author_id),+ description: details.description.or(fallback.description),comments: details.comments,checks: details.checks,participant_github_user_ids: detailsdiff --git a/rust/cloud-storage/github/src/domain/service/sync/test.rs b/rust/cloud-storage/github/src/domain/service/sync/test.rsindex 8b4e9846d3..c55e4fa840 100644--- a/rust/cloud-storage/github/src/domain/service/sync/test.rs+++ b/rust/cloud-storage/github/src/domain/service/sync/test.rs@@ -1017,6 +1017,9 @@ fn expected_pull_request_metadata(status: Some(status),additions,deletions,+ author_login: None,+ author_id: None,+ description: None,comments: None,checks: None,participant_github_user_ids: None,@@ -1127,6 +1130,9 @@ fn backfilled_pull_request(title: &str) -> EnrichedGithubPullRequest {status: Some(GithubPullRequestStatus::Open),additions: None,deletions: None,+ author_login: None,+ author_id: None,+ description: None,comments: None,checks: None,participant_github_user_ids: None,@@ -1147,6 +1153,9 @@ fn expected_pull_request_metadata_from_details(status: Some(details.status()),additions: Some(details.additions),deletions: Some(details.deletions),+ author_login: details.author_login.clone(),+ author_id: details.author_id,+ description: details.description.clone(),comments: details.comments.clone(),checks: details.checks.clone(),participant_github_user_ids: details.participant_github_user_ids.clone(),@@ -1195,6 +1204,9 @@ fn pull_request_details(merged_at: None,additions,deletions,+ author_login: Some("octocat".to_string()),+ author_id: Some(583231),+ description: Some("Detailed pull request description".to_string()),comments,checks,participant_github_user_ids: None,diff --git a/rust/cloud-storage/github/src/outbound/pull_request_metadata.rs b/rust/cloud-storage/github/src/outbound/pull_request_metadata.rsindex 9ee9024a36..78d7b7c61b 100644--- a/rust/cloud-storage/github/src/outbound/pull_request_metadata.rs+++ b/rust/cloud-storage/github/src/outbound/pull_request_metadata.rs@@ -43,6 +43,11 @@ pub(crate) async fn fetch_pull_request_metadata(// metadata merges participants as a union, so partial sets are safe.let participant_github_user_ids =(!participant_ids.is_empty()).then(|| participant_ids.iter().map(u64::to_string).collect());+ let author_login = pull_request+ .user+ .as_ref()+ .and_then(|user| user.login.clone());+ let author_id = pull_request.user.as_ref().and_then(|user| user.id);Ok(GithubPullRequestDetails {title: pull_request.title,@@ -50,6 +55,9 @@ pub(crate) async fn fetch_pull_request_metadata(merged_at: pull_request.merged_at,additions: pull_request.additions,deletions: pull_request.deletions,+ author_login,+ author_id,+ description: pull_request.body,comments,checks,participant_github_user_ids,@@ -146,6 +154,7 @@ struct GithubOpenPullRequestResponse {number: u64,title: String,html_url: String,+ body: Option<String>,user: Option<GithubUserResponse>,#[serde(default)]requested_reviewers: Vec<GithubUserResponse>,@@ -160,6 +169,7 @@ struct GithubPullRequestResponse {merged_at: Option<chrono::DateTime<chrono::Utc>>,additions: u64,deletions: u64,+ body: Option<String>,head: GithubPullRequestHeadResponse,user: Option<GithubUserResponse>,#[serde(default)]@@ -559,6 +569,9 @@ impl GithubOpenPullRequestResponse {status: Some(GithubPullRequestStatus::Open),additions: None,deletions: None,+ author_login: self.user.as_ref().and_then(|user| user.login.clone()),+ author_id: self.user.as_ref().and_then(|user| user.id),+ description: self.body,comments: None,checks: None,participant_github_user_ids: (!participant_ids.is_empty())