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(github): do not auto-close task if PR is closed (#3362)
Will Hutchinsonbc1c1e035520
diff --git a/rust/cloud-storage/github/src/domain/models/sync.rs b/rust/cloud-storage/github/src/domain/models/sync.rsindex 9f61d9c6ec..6618108891 100644--- a/rust/cloud-storage/github/src/domain/models/sync.rs+++ b/rust/cloud-storage/github/src/domain/models/sync.rs@@ -126,7 +126,8 @@ impl ValidatedGithubWebhookEvent {/// Derive the task status string based on the event, if applicable.////// For `pull_request` events: `opened`/`reopened` → `"In Review"`,- /// `closed` + merged → `"Completed"`, `closed` → `"Canceled"`.+ /// `closed` + merged → `"Completed"`, `closed` without merge →+ /// `"Not Started"` (the TODO status).////// For comment/review events that newly associate a task with an open PR,/// returns `"In Review"`.@@ -137,7 +138,7 @@ impl ValidatedGithubWebhookEvent {GithubWebhookEventType::PullRequest => match self.action() {Some("opened" | "reopened" | "edited") => Some("In Review"),Some("closed") if self.is_merged() => Some("Completed"),- Some("closed") => Some("Canceled"),+ Some("closed") => Some("Not Started"),_ => None,},GithubWebhookEventType::IssueCommentdiff --git a/rust/cloud-storage/github/src/domain/service/sync/handle_pr.rs b/rust/cloud-storage/github/src/domain/service/sync/handle_pr.rsindex da66e9edb3..65c6ca292c 100644--- a/rust/cloud-storage/github/src/domain/service/sync/handle_pr.rs+++ b/rust/cloud-storage/github/src/domain/service/sync/handle_pr.rs@@ -170,8 +170,11 @@ impl<D: DocumentService, R: GithubSyncRepo, C: GithubSyncClient> GithubSyncServi/// Handle `pull_request` events with action `closed`.///- /// Gathers all tracked task IDs from the repo plus any from PR text,- /// then updates status to "Completed" (if merged) or "Canceled".+ /// Gathers all tracked task IDs from the repo plus any from PR text.+ ///+ /// If the PR was merged, updates their status to "Completed". If the PR was+ /// closed without being merged, moves associated tasks back to "Not Started"+ /// (the TODO status) instead of canceling them./// Does NOT post a new bot comment.#[tracing::instrument(skip(self, event), err)]pub(crate) async fn handle_pr_close(@@ -227,7 +230,11 @@ impl<D: DocumentService, R: GithubSyncRepo, C: GithubSyncClient> GithubSyncServilet resolved = self.resolve_tasks(&all_task_ids).await;// No bot comment on close- let status = if is_merged { "Completed" } else { "Canceled" };+ let status = if is_merged {+ "Completed"+ } else {+ "Not Started"+ };tracing::trace!(status,doc_count = resolved.doc_ids.len(),diff --git a/rust/cloud-storage/github/src/domain/service/sync/test.rs b/rust/cloud-storage/github/src/domain/service/sync/test.rsindex 424c56c18a..226eb8a2d3 100644--- a/rust/cloud-storage/github/src/domain/service/sync/test.rs+++ b/rust/cloud-storage/github/src/domain/service/sync/test.rs@@ -879,7 +879,7 @@ async fn pr_merged_sets_task_status_completed() {}#[tokio::test]-async fn pr_closed_without_merge_sets_task_status_canceled() {+async fn pr_closed_without_merge_sets_task_status_todo() {let (service, doc_service) = make_sync_service_with_doc_service();let event = ValidatedGithubWebhookEvent::new("pull_request".to_string(),@@ -905,7 +905,59 @@ async fn pr_closed_without_merge_sets_task_status_canceled() {let status_calls = doc_service.task_status_calls();assert_eq!(status_calls.len(), 1);assert_eq!(status_calls[0].entity_id, KNOWN_TASK_UUID);- assert_eq!(status_calls[0].status, "Canceled");+ assert_eq!(status_calls[0].status, "Not Started");+}++#[tokio::test]+async fn pr_closed_without_merge_sets_previously_tracked_task_status_todo() {+ let (service, doc_service) = make_sync_service_with_doc_service();++ let opened_event = ValidatedGithubWebhookEvent::new(+ "pull_request".to_string(),+ serde_json::json!({+ "action": "opened",+ "pull_request": {+ "number": 42,+ "title": "fixes MACRO-2BuyvtY3aeEvHx4uG8iD51",+ "body": null,+ "head": { "ref": "feature/some-branch" },+ "merged": false+ },+ "repository": {+ "name": "my-repo",+ "owner": { "login": "my-org" }+ },+ "installation": { "id": 12345 }+ }),+ );+ service.process_webhook_event(&opened_event).await.unwrap();++ let closed_event = ValidatedGithubWebhookEvent::new(+ "pull_request".to_string(),+ serde_json::json!({+ "action": "closed",+ "pull_request": {+ "number": 42,+ "title": "fixes MACRO-2BuyvtY3aeEvHx4uG8iD51",+ "body": null,+ "head": { "ref": "feature/some-branch" },+ "merged": false+ },+ "repository": {+ "name": "my-repo",+ "owner": { "login": "my-org" }+ },+ "installation": { "id": 12345 }+ }),+ );+ service.process_webhook_event(&closed_event).await.unwrap();++ let status_calls = doc_service.task_status_calls();+ assert_eq!(status_calls.len(), 2);+ assert_eq!(status_calls[0].entity_id, KNOWN_TASK_UUID);+ assert_eq!(status_calls[0].status, "In Review");+ assert_eq!(status_calls[1].entity_id, KNOWN_TASK_UUID);+ assert_eq!(status_calls[1].status, "Not Started");}#[tokio::test]