From d271ae77640b9102f2ff46ff82e2705b7771d59b Mon Sep 17 00:00:00 2001 From: Tomas Carnecky Date: Wed, 10 Jun 2026 21:34:36 +0200 Subject: [PATCH] Move issue to in progress, attach pull request as linkKind:closes --- bin/pudoxd/src/main.rs | 69 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 68 insertions(+), 1 deletion(-) diff --git a/bin/pudoxd/src/main.rs b/bin/pudoxd/src/main.rs index 56d945b..8258573 100644 --- a/bin/pudoxd/src/main.rs +++ b/bin/pudoxd/src/main.rs @@ -211,6 +211,65 @@ async fn task_history_handler( } } +async fn move_issue_to_in_progress(linear: &crate::linear::Linear, issue_id: &str) { + // Query the issue's team workflow states to find the first "started"-type state. + let states_res = linear + .send(serde_json::json!({ + "query": r#" + query IssueTeamStates($issueId: String!) { + issue(id: $issueId) { + team { + states { + nodes { id type } + } + } + } + } + "#, + "variables": { "issueId": issue_id } + })) + .await; + + let state_id = match states_res { + Ok(ref v) => v["data"]["issue"]["team"]["states"]["nodes"] + .as_array() + .and_then(|nodes| { + nodes + .iter() + .find(|n| n["type"].as_str() == Some("started")) + .and_then(|n| n["id"].as_str()) + .map(|s| s.to_string()) + }), + Err(e) => { + tracing::error!("Failed to query team states for issue {}: {}", issue_id, e); + return; + } + }; + + let Some(state_id) = state_id else { + tracing::warn!("No 'started'-type workflow state found for issue {}", issue_id); + return; + }; + + let res = linear + .send(serde_json::json!({ + "query": r#" + mutation IssueUpdate($id: String!, $stateId: String!) { + issueUpdate(id: $id, input: { stateId: $stateId }) { + success + } + } + "#, + "variables": { "id": issue_id, "stateId": state_id } + })) + .await; + + match res { + Ok(r) => tracing::info!("Issue {} moved to In Progress: {}", issue_id, r), + Err(e) => tracing::error!("Failed to move issue {} to In Progress: {}", issue_id, e), + } +} + async fn handle_task_result( linear: crate::linear::Linear, github: GitHub, @@ -357,7 +416,7 @@ async fn handle_task_result( .send(serde_json::json!({ "query": r#" mutation AttachmentLinkGitHubPR($issueId: String!, $url: String!) { - attachmentLinkGitHubPR(issueId: $issueId, url: $url) { + attachmentLinkGitHubPR(issueId: $issueId, url: $url, linkKind: closes) { success } } @@ -531,6 +590,14 @@ async fn webhook_handler(State(app): State, body: String) -> &'static str { let session_id = payload.agent_session.id.clone(); let issue_id = payload.agent_session.issue.as_ref().map(|i| i.id.clone()); + + if let Some(ref iid) = issue_id { + let linear = app.linear.clone(); + let iid = iid.clone(); + tokio::spawn(async move { + move_issue_to_in_progress(&linear, &iid).await; + }); + } let prompt_context = payload.prompt_context.clone(); let creator_name = payload .agent_session -- 2.51.2