Skip to content

Commit bed12d3

Browse files
feat(flaky-unit-test-analysis): enhance suggestedFix schema and update task prompt
- Updated the `suggestedFix` field in `finalize-schema.json` to include a description for formatting TypeScript snippets. - Modified `task-prompt.md` to clarify that `suggestedFix` must be a properly formatted code snippet, ensuring no prose is included. - Refactored `flaky-sticky-comment.ts` to handle multi-line suggested fixes correctly, preserving indentation and formatting in the output. - Introduced support for dynamic window counts in the history table, improving the representation of flaky test data.
1 parent 809548e commit bed12d3

3 files changed

Lines changed: 13 additions & 3 deletions

File tree

.ai-pr-analyzer/modes/flaky-unit-test-analysis/finalize-schema.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,10 @@
3535
},
3636
"snippet": { "type": "string" },
3737
"explanation": { "type": "string" },
38-
"suggestedFix": { "type": "string" },
38+
"suggestedFix": {
39+
"type": "string",
40+
"description": "The corrected code snippet ONLY, formatted as real TypeScript with line breaks (use \\n between lines and preserve indentation). Do NOT write prose sentences here — keep all explanation in the `explanation` field."
41+
},
3942
"historicalHintUsed": { "type": "boolean" }
4043
},
4144
"required": [

.ai-pr-analyzer/modes/flaky-unit-test-analysis/task-prompt.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ For each file:
1818
3. Check .ai-pr-analyzer/flaky-history.json (read_file) for a historical hint on this file.
1919
4. Match against the J1-J10 patterns from the loaded skill.
2020
5. For every match, record: file, line, patternId, patternName, severity, snippet, explanation, suggestedFix, and whether the historical hint was used.
21+
- `suggestedFix` MUST be the corrected code snippet ONLY, formatted as real TypeScript with actual line breaks (`\n`) and indentation — never a single-line prose paragraph. Keep all reasoning and instructions in `explanation`.
2122

2223
If a file has no matches, do not invent findings — omit it from findings.
2324

.github/scripts/flaky-sticky-comment.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,14 @@ function buildFindingsSection(findings: Finding[]): string {
118118
const hint = f.historicalHintUsed ? ' _(matches historical failure signal)_' : '';
119119
out += `- **${f.patternId}${f.patternName}** (${f.severity})${hint}${f.line ? ` — line ${f.line}` : ''}\n`;
120120
out += ` - ${f.explanation}\n`;
121-
// Fenced block so multi-line fixes render correctly in GitHub Markdown.
122-
out += ` - Suggested fix:\n \`\`\`ts\n ${f.suggestedFix}\n \`\`\`\n`;
121+
// Every line of the fix must carry the 4-space indent that keeps the
122+
// fenced block nested inside this list item; indenting only the first
123+
// line would push the rest out of the list and collapse the code block.
124+
const indentedFix = f.suggestedFix
125+
.split('\n')
126+
.map((line) => ` ${line}`)
127+
.join('\n');
128+
out += ` - Suggested fix:\n \`\`\`ts\n${indentedFix}\n \`\`\`\n`;
123129
}
124130
out += '\n';
125131
}

0 commit comments

Comments
 (0)