Elffuss BraidHub

kikocis/continue public

Merge pull request #7735 from continuedev/nate/fix-github-workflow-comment-handling

fix: improve GitHub workflow comment handling with special characters
Changeset473175b1d332fa0644811a30f61a9d79b3764c1ce8dfbc57f9924e9095fca0d3
AuthorNate Sesti <33237525+sestinj@users.noreply.github.com> · 2025-09-14 17:40 -07:00
CommitterGitHub <noreply@github.com> · 2025-09-14 17:40 -07:00
Parents991ff92b576b, fbf24da2248c

Browse the files at this changeset

1 file changed

modified .github/workflows/respond-to-cubic.yaml +37 −12
@@ -21,7 +21,12 @@
2121 - name: Check if comment contains @continuedev
2222 id: check-mention
2323 run: |
24- if echo "${{ github.event.comment.body }}" | grep -q "@continuedev"; then
24+ # Create a temporary file to safely handle comment body with special characters
25+ cat > /tmp/comment.txt << 'COMMENT_EOF'
26+ ${{ github.event.comment.body }}
27+ COMMENT_EOF
28+
29+ if grep -q "@continuedev" /tmp/comment.txt; then
2530 echo "contains_mention=true" >> $GITHUB_OUTPUT
2631 else
2732 echo "contains_mention=false" >> $GITHUB_OUTPUT
@@ -83,15 +88,22 @@
8388 env:
8489 CONTINUE_API_KEY: ${{ secrets.CONTINUE_API_KEY }}
8590 run: |
86- # Create the prompt for remote session
87- PROMPT="Please help with the following request from @${{ github.event.comment.user.login }} on PR #${{ github.event.issue.number }}:
91+ # Create a temporary file for the prompt to handle special characters and newlines properly
92+ cat > /tmp/prompt.txt << 'PROMPT_EOF'
93+ Please help with the following request from @${{ github.event.comment.user.login }} on PR #${{ github.event.issue.number }}:
8894
8995 ${{ github.event.comment.body }}
9096
91- Please analyze the current PR, understand the request, implement the necessary changes, and commit them to this branch."
97+ Please analyze the current PR, understand the request, implement the necessary changes, and commit them to this branch.
98+ PROMPT_EOF
99+
100+ # Debug output
101+ echo "PROMPT content:"
102+ cat /tmp/prompt.txt
92103
93104 # Start remote session and capture JSON output
94- SESSION_OUTPUT=$(echo "$PROMPT" | cn remote -s --config continuedev/address-code-review --branch ${{ steps.pr-info.outputs.head_ref }})
105+ echo "Starting cn with prompt..."
106+ SESSION_OUTPUT=$(cat /tmp/prompt.txt | cn remote -s --config continuedev/address-code-review --branch ${{ steps.pr-info.outputs.head_ref }})
95107 echo "Raw session output: $SESSION_OUTPUT"
96108
97109 # Extract URL from JSON output
@@ -108,10 +120,13 @@
108120 - name: Comment with session URL
109121 if: steps.check-mention.outputs.contains_mention == 'true' && steps.remote-session.outputs.session_url
110122 uses: actions/github-script@v8
123+ env:
124+ ORIGINAL_COMMENT: ${{ github.event.comment.body }}
111125 with:
112126 script: |
113- const commentBody = `I've started [a remote session](${{ steps.remote-session.outputs.session_url }}) to help with your request:
114- > ${{ github.event.comment.body }}`;
127+ const sessionUrl = '${{ steps.remote-session.outputs.session_url }}';
128+ const originalComment = process.env.ORIGINAL_COMMENT;
129+ const commentBody = "I've started [a remote session](" + sessionUrl + ") to help with your request:\n> " + originalComment;
115130
116131 await github.rest.issues.createComment({
117132 owner: context.repo.owner,
@@ -125,7 +140,8 @@
125140 run: |
126141 echo "✅ Successfully started remote session for comment from ${{ github.event.comment.user.login }} on PR #${{ github.event.issue.number }}"
127142 echo "Session URL: ${{ steps.remote-session.outputs.session_url }}"
128- echo "Original comment: ${{ github.event.comment.body }}"
143+ echo "Original comment:"
144+ cat /tmp/comment.txt
129145
130146 respond-to-review-comment:
131147 # Only run on pull request review comments
@@ -136,7 +152,12 @@
136152 - name: Check if comment contains @continuedev
137153 id: check-mention
138154 run: |
139- if echo "${{ github.event.comment.body }}" | grep -q "@continuedev"; then
155+ # Create a temporary file to safely handle comment body with special characters
156+ cat > /tmp/review_comment.txt << 'COMMENT_EOF'
157+ ${{ github.event.comment.body }}
158+ COMMENT_EOF
159+
160+ if grep -q "@continuedev" /tmp/review_comment.txt; then
140161 echo "contains_mention=true" >> $GITHUB_OUTPUT
141162 else
142163 echo "contains_mention=false" >> $GITHUB_OUTPUT
@@ -250,10 +271,13 @@
250271 - name: Comment with session URL
251272 if: steps.check-mention.outputs.contains_mention == 'true' && steps.remote-session.outputs.session_url
252273 uses: actions/github-script@v8
274+ env:
275+ ORIGINAL_COMMENT: ${{ github.event.comment.body }}
253276 with:
254277 script: |
255- const commentBody = `I've started [a remote session](${{ steps.remote-session.outputs.session_url }}) to help with your request:
256- > ${{ github.event.comment.body }}`;
278+ const sessionUrl = '${{ steps.remote-session.outputs.session_url }}';
279+ const originalComment = process.env.ORIGINAL_COMMENT;
280+ const commentBody = "I've started [a remote session](" + sessionUrl + ") to help with your request:\n> " + originalComment;
257281
258282 const commentParams = {
259283 owner: context.repo.owner,
@@ -274,4 +298,5 @@
274298 echo "Session URL: ${{ steps.remote-session.outputs.session_url }}"
275299 echo "File: ${{ github.event.comment.path }}"
276300 echo "Line: ${{ github.event.comment.line }}"
277- echo "Original comment: ${{ github.event.comment.body }}"
301+ echo "Original comment:"
302+ cat /tmp/review_comment.txt