ReviewOS

also looking at this

stacks/buddy

fix(review): read what publishing reported, honour reviewSuggestions, and un-strand two flags

#1435
Merged glennmichael123 wants to merge fix/review-low-tier into main
5 files +267 -10
src/review/poster.tsmodified+13-3
Changes to src/review/poster.ts
@@ -42,14 +42,22 @@ export interface PreparedReview {
4242 * as prose only, since a half-right suggestion costs more to undo than to
4343 * write by hand.
4444 *
45 * On a platform whose `reviewSuggestions` capability is false the block
46 * renders as a plain code fence instead: Bitbucket shows a literal
47 * suggestion fence as noise, and the one-click apply it promises does not
48 * exist there.
49 *
4550 * @param finding - Finding to render
51 * @param options - Whether the platform renders suggestion blocks (default: it does)
4652 */
47export function renderFinding(finding: ReviewFinding): string {
53export function renderFinding(finding: ReviewFinding, options?: { suggestions?: boolean }): string {
4854 const source = finding.tool ? ` \`[${finding.tool}]\`` : ''
4955 let body = `**${SEVERITY_BADGE[finding.severity]}** · \`${finding.category}\`${source}\n\n${finding.message}`
5056
5157 if (finding.suggestion) {
52 body += `\n\n\`\`\`suggestion\n${finding.suggestion}\n\`\`\``
58 body += options?.suggestions === false
59 ? `\n\nSuggested replacement:\n\n\`\`\`\n${finding.suggestion}\n\`\`\``
60 : `\n\n\`\`\`suggestion\n${finding.suggestion}\n\`\`\``
5361 }
5462
5563 return body
@@ -70,13 +78,15 @@ export function prepareReview(
7078 requestChangesOn?: 'never' | 'critical'
7179 /** Fingerprints already reported, carried forward into the new state */
7280 seenFingerprints?: string[]
81 /** Whether the platform renders suggestion blocks (default: it does) */
82 suggestions?: boolean
7383 },
7484): PreparedReview {
7585 const comments: InlineComment[] = result.findings.map(finding => ({
7686 path: finding.path,
7787 line: finding.line,
7888 side: 'RIGHT' as const,
79 body: renderFinding(finding),
89 body: renderFinding(finding, { suggestions: options.suggestions !== false }),
8090 }))
8191
8292 const counts = countBySeverity(result.findings)