diff --git a/.github/workflows/coderabbit-auto-fix.yml b/.github/workflows/coderabbit-auto-fix.yml index 156a1ac..12bdcaa 100644 --- a/.github/workflows/coderabbit-auto-fix.yml +++ b/.github/workflows/coderabbit-auto-fix.yml @@ -281,6 +281,9 @@ jobs: /^[[:space:]]*\n[[:space:]]*$/D }') + DETAILS_MARKERS=$(printf '%s\n' "$CLEAN_COMMENT" | grep -cEi ']*>[^<]*(Suggested|Proposed|Prompt for AI Agents)' || true) + MARKDOWN_PROMPT_BLOCKS=$(printf '%s\n' "$CLEAN_COMMENT" | grep -cE 'Prompt for AI Agents' || true) + # Keep only Suggested fix + Prompt for AI Agents per issue; render as ClickUp-friendly fenced /code blocks. cat > /tmp/cu_cr_clickup.pl <<'ENDPERL' use strict; @@ -327,8 +330,11 @@ jobs: my @parts = split(/\n\n---\n\n/, $input); my @blocks; my $issue = 0; + my $total_chunks = 0; + my $fallback_chunks = 0; for my $chunk (@parts) { next unless $chunk =~ /\S/; + $total_chunks++; my $fix = ''; my $prompt = ''; if ($chunk =~ m{]*>\s*]*>[^<]*(?:Suggested\s+fix|Proposed\s+fix|Suggested\s+patch|💡\s*Proposed|🔧\s*Suggested|🐛\s*Proposed|♻️\s*Proposed)[^<]*(.*?)}is) { @@ -337,9 +343,23 @@ jobs: if ($chunk =~ m{]*>\s*]*>[^<]*(?:🤖\s*)?Prompt for AI Agents[^<]*(.*?)}is) { $prompt = $1; } + # Fallback for markdown-only bodies (no
/ wrapper). + if ($fix eq '' && $chunk =~ m{(?:^|\n)\h*(?:🛠️|💡|🔧|🐛|♻️)?\h*(?:Proposed|Suggested)\h+(?:fix|patch)\h*\n+\h*```(?:diff)?\n(.*?)\n\h*```}is) { + $fix = $1; + } + if ($prompt eq '' && $chunk =~ m{(?:^|\n)\h*(?:🤖\h*)?Prompt for AI Agents\h*\n+\h*```\n(.*?)\n\h*```}is) { + $prompt = $1; + } my $piece = ''; $piece .= fence('Suggested fix', $fix) if $fix ne ''; $piece .= fence('Prompt for AI Agents', $prompt) if $prompt ne ''; + if ($piece !~ /\S/) { + my $raw = strip_inner_html($chunk); + if ($raw ne '') { + $fallback_chunks++; + $piece .= fence('Review note (raw fallback)', $raw); + } + } if ($piece =~ /\S/) { $issue++; push @blocks, "### Issue $issue\n\n" . $piece; @@ -347,6 +367,8 @@ jobs: } my $out = join("\n---\n\n", @blocks); $out =~ s/\n{4,}/\n\n\n/g; + my $meta = "__PARSER_META__ total_chunks=$total_chunks fallback_chunks=$fallback_chunks issue_count=$issue"; + print $meta . "\n"; print $out; ENDPERL sed -i 's/^[[:space:]]*//' /tmp/cu_cr_clickup.pl @@ -360,16 +382,23 @@ jobs: fi fi + PARSER_META=$(printf '%s\n' "$CLEAN_COMMENT" | grep -m1 '^__PARSER_META__' || true) + if [ -n "$PARSER_META" ]; then + CLEAN_COMMENT=$(printf '%s\n' "$CLEAN_COMMENT" | sed '/^__PARSER_META__/d') + fi + ISSUE_COUNT=$(printf '%s\n' "$CLEAN_COMMENT" | grep -oE '### Issue [0-9]+' | wc -l | tr -d '[:space:]') echo "issue_count=${ISSUE_COUNT}" >> "$GITHUB_OUTPUT" echo "Formatted ClickUp payload: ${ISSUE_COUNT} issue block(s) (### Issue headings)." - { echo "## CodeRabbit → ClickUp" echo "" echo "| Metric | Value |" echo "|--------|-------|" echo "| CodeRabbit PR comments matched (this review) | ${CLICKUP_MATCH_COUNT:-0} |" + echo "| `` markers in source text | ${DETAILS_MARKERS:-0} |" + echo "| `Prompt for AI Agents` mentions in source text | ${MARKDOWN_PROMPT_BLOCKS:-0} |" + echo "| Parser meta | ${PARSER_META:-n/a} |" echo "| Issues formatted for ClickUp (\`### Issue N\`) | ${ISSUE_COUNT} |" echo "" echo "Multiple findings from one CodeRabbit submission should appear as separate \`### Issue 1\`, \`### Issue 2\`, … in a single task comment." diff --git a/frontend/src/coderabbitManualPrProbe.js b/frontend/src/coderabbitManualPrProbe.js new file mode 100644 index 0000000..ab51817 --- /dev/null +++ b/frontend/src/coderabbitManualPrProbe.js @@ -0,0 +1,37 @@ +/** + * TEMPORARY — manual PR probe only: intentional bad patterns so CodeRabbit can surface multiple findings. + * Delete this file after you finish testing the CodeRabbit → ClickUp workflow. + */ + +import { useMemo } from 'react'; + +const UNUSED_PROBE_CONST = 'never-read'; + +function validateProbeLabelA(label) { + if (!label || typeof label !== 'string') return false; + return label.trim().length > 0; +} + +function validateProbeLabelB(label) { + if (!label || typeof label !== 'string') return false; + return label.trim().length > 0; +} + +export async function fetchUserBadgeWrong(userId) { + console.log('probe: fetching badge', userId); + + const api_key = 'pk_live_000000000000000000000000'; + + const res = await fetch(`https://example.invalid/api/badge/${userId}?key=${api_key}`); + const data = await res.json(); + + return data; +} + +export function renderProbeRows(rows) { + return rows.map((row) => { + const okA = validateProbeLabelA(row.name); + const okB = validateProbeLabelB(row.slug); + return { label: row.name, okA, okB }; + }); +}