From 33c6570e082605da1bcfe2228ac63acdff4bc6f6 Mon Sep 17 00:00:00 2001 From: bincxz <16399091+binaricat@users.noreply.github.com> Date: Fri, 31 Jul 2026 19:26:50 +0800 Subject: [PATCH] fix: recheck deleted simple follow-ups --- .github/workflows/cursor-automation.yml | 23 ++++++++++++----------- scripts/cursor-automation.test.cjs | 7 ++++++- 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/.github/workflows/cursor-automation.yml b/.github/workflows/cursor-automation.yml index 16282d2d5..922aecf3d 100644 --- a/.github/workflows/cursor-automation.yml +++ b/.github/workflows/cursor-automation.yml @@ -1361,6 +1361,16 @@ jobs: const auto = require(`${process.env.RUNNER_TEMP}/cursor-automation.cjs`); const issueNumber = Number(process.env.ISSUE_NUMBER); const pullNumber = Number(process.env.PULL_NUMBER) || null; + const queuePullReadinessCheck = async () => { + if (!pullNumber) return; + await github.rest.actions.createWorkflowDispatch({ + ...context.repo, + workflow_id: 'cursor-automation.yml', + ref: context.payload.repository.default_branch, + inputs: { pull_number: String(pullNumber) }, + }); + core.info(`Queued a readiness check for PR #${pullNumber}.`); + }; const { data: issue } = await github.rest.issues.get({ ...context.repo, issue_number: issueNumber, @@ -1378,6 +1388,7 @@ jobs: const liveKind = auto.classifySimpleIssueFollowup(livePending); if (changed.length || !liveKind) { if (!livePending.length) { + await queuePullReadinessCheck(); core.info('The simple follow-up was removed before reply; nothing to process.'); return; } @@ -1408,17 +1419,7 @@ jobs: pullNumber, }), }); - if (pullNumber) { - await github.rest.actions.createWorkflowDispatch({ - ...context.repo, - workflow_id: 'cursor-automation.yml', - ref: context.payload.repository.default_branch, - inputs: { pull_number: String(pullNumber) }, - }); - core.info( - `Queued a readiness check for PR #${pullNumber} after the simple follow-up reply.`, - ); - } + await queuePullReadinessCheck(); - name: Pause linked pull request during follow-up review if: steps.prepare.outputs.should_run == 'true' && steps.prepare.outputs.has_pull == 'true' diff --git a/scripts/cursor-automation.test.cjs b/scripts/cursor-automation.test.cjs index baf053ebd..a28bcd31d 100644 --- a/scripts/cursor-automation.test.cjs +++ b/scripts/cursor-automation.test.cjs @@ -877,10 +877,15 @@ test('simple follow-ups immediately recheck linked clean pull requests', () => { /- name: Handle simple resolution or acknowledgement[\s\S]*?(?=\n\s{6}- name:)/, )?.[0] || ''; const recordReply = simpleStep.indexOf('await github.rest.issues.createComment'); - const recheckPull = simpleStep.indexOf('await github.rest.actions.createWorkflowDispatch', recordReply); + const recheckPull = simpleStep.indexOf('await queuePullReadinessCheck()', recordReply); + const removedBranch = simpleStep.match( + /if \(!livePending\.length\) \{[\s\S]*?return;/, + )?.[0] || ''; assert.ok(recordReply >= 0); assert.ok(recheckPull > recordReply); + assert.match(removedBranch, /await queuePullReadinessCheck\(\)/); + assert.match(simpleStep, /await github\.rest\.actions\.createWorkflowDispatch/); assert.match(simpleStep, /inputs: \{ pull_number: String\(pullNumber\) \}/); assert.match(simpleStep, /Queued a readiness check for PR/); });