Skip to content

pr-review: multi-line suggestion removes correct code along with the bug #1310

Description

@worktrunk-bot

Problem

In PR #1309 (run 22768248402), the review bot correctly identified a PowerShell syntax error — a partially-applied suggestion left two else blocks in docs/static/install.ps1. However, the bot's fix suggestion was wrong: it covered too many lines (start_line: 18, line: 22) and would remove the legitimate git-wt fallback branch along with the duplicate.

Evidence

The current file (lines 16-22):

if ((Get-Command wt -ErrorAction SilentlyContinue) -and (wt --version 2>&1 | Select-String 'worktrunk')) {
    wt config shell install
} elseif (Get-Command git-wt -ErrorAction SilentlyContinue) {   # line 18
    git-wt config shell install                                   # line 19
} else {                                                          # line 20 ← duplicate
    git-wt config shell install                                   # line 21 ← duplicate
} else {                                                          # line 22

The bot's suggestion targets lines 18-22, replacing all five lines with just } else {. This would turn the code into:

if ((Get-Command wt -ErrorAction SilentlyContinue) -and (wt --version 2>&1 | Select-String 'worktrunk')) {
    wt config shell install
} else {
    Write-Host ""
    Write-Host "Warning: ..."

The git-wt fallback (the elseif branch) is completely removed. If the author clicks "Apply suggestion", the script would skip git-wt detection and go straight to the warning — a functional regression.

Correct fix

The suggestion should only cover lines 20-21 (the duplicate } else { git-wt config shell install block), or lines 20-22 replacing them with just } else {:

} elseif (Get-Command git-wt -ErrorAction SilentlyContinue) {
    git-wt config shell install
} else {
    Write-Host ""
    ...

Root Cause

When the bot constructed the multi-line suggestion range, it set start_line to the beginning of the elseif block (line 18) instead of just the duplicate lines (line 20). The bot's analysis text correctly describes the problem ("two else blocks") but the code range was too aggressive.

Suggested Fix

The review skill should validate suggestion ranges more carefully — specifically, when removing duplicate/erroneous code, the range should be as narrow as possible and not encompass correctly-functioning adjacent code. Consider adding guidance to the review skill that multi-line suggestion ranges should be minimized to only the lines that need changing.

Metadata

Metadata

Assignees

No one assigned

    Labels

    claude-behaviorIssues with Claude CI bot behavior

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions