diff --git a/.github/workflows/respond-to-cubic-dev-ai.yml b/.github/workflows/respond-to-cubic-dev-ai.yml index 7687bc838..b3a6eeb25 100644 --- a/.github/workflows/respond-to-cubic-dev-ai.yml +++ b/.github/workflows/respond-to-cubic-dev-ai.yml @@ -156,18 +156,24 @@ jobs: env: CONTINUE_API_KEY: ${{ secrets.CONTINUE_API_KEY }} run: | - # Create the prompt for remote session with file context - PROMPT="Please help with the following code review comment from @${{ github.event.comment.user.login }} on PR #${{ github.event.pull_request.number }}: + # Create a temporary file for the prompt to handle special characters and newlines properly + cat > /tmp/prompt.txt << 'PROMPT_EOF' + Please help with the following code review comment from @${{ github.event.comment.user.login }} on PR #${{ github.event.pull_request.number }}: **File:** ${{ github.event.comment.path }} - **Line:** ${{ github.event.comment.line }} + **Line:** ${{ github.event.comment.line || github.event.comment.original_line || 'N/A' }} **Comment:** ${{ github.event.comment.body }} - Please analyze the specific file and line mentioned, understand the review feedback, implement the necessary changes, and commit them to this branch." + Please analyze the specific file and line mentioned, understand the review feedback, implement the necessary changes, and commit them to this branch. + PROMPT_EOF + # Debug output + echo "PROMPT content:" + cat /tmp/prompt.txt + # Start remote session and capture JSON output - echo "Starting cn with prompt: $PROMPT" - SESSION_OUTPUT=$(echo "$PROMPT" | cn remote -s --branch ${{ github.event.pull_request.head.ref }}) + echo "Starting cn with prompt..." + SESSION_OUTPUT=$(cat /tmp/prompt.txt | cn remote -s --branch ${{ github.event.pull_request.head.ref }}) echo "Raw session output: $SESSION_OUTPUT" # Extract URL from JSON output @@ -186,22 +192,34 @@ jobs: uses: actions/github-script@v7 with: script: | + const line = ${{ github.event.comment.line || 'null' }}; + const originalLine = ${{ github.event.comment.original_line || 'null' }}; + const lineDisplay = line || originalLine || 'N/A'; + const commentBody = `I've started a remote session to help with your code review comment: > ${{ github.event.comment.body }} **📁 File:** \`${{ github.event.comment.path }}\` - **📍 Line:** ${{ github.event.comment.line }} + **📍 Line:** ${lineDisplay} **🔗 Remote Session:** ${{ steps.remote-session.outputs.session_url }}`; - await github.rest.pulls.createReviewComment({ + const commentParams = { owner: context.repo.owner, repo: context.repo.repo, pull_number: ${{ github.event.pull_request.number }}, body: commentBody, commit_id: '${{ github.event.pull_request.head.sha }}', - path: '${{ github.event.comment.path }}', - line: ${{ github.event.comment.line }} - }); + path: '${{ github.event.comment.path }}' + }; + + // Add line parameter only if it exists and is not null + if (line !== null) { + commentParams.line = line; + } else if (originalLine !== null) { + commentParams.original_line = originalLine; + } + + await github.rest.pulls.createReviewComment(commentParams); - name: Log session details if: steps.check-mention.outputs.contains_mention == 'true'