worktrunk icon indicating copy to clipboard operation
worktrunk copied to clipboard

[ci] encourage suggestions

Open max-sixty opened this issue 8 months ago • 3 comments

the @worktrunk-bot review here: https://github.com/max-sixty/worktrunk/pull/1336 would have been helpful to have as an inline suggestion — why didn't it do that? could we look at the log & context and assess what we can do to nudge it a bit more to make inline suggestions?

max-sixty avatar Mar 07 '26 21:03 max-sixty

Investigated the review on #1336.

Root cause: At the time of the bot's review, commit 0b3b20e7 only changed flake.nix. The nix/home-manager-module.nix file was not in the PR diff. GitHub's review API only allows inline suggestion comments on lines that appear in the diff — so the bot literally couldn't post an inline suggestion on that file. It fell back to a code block in the review body, which is the anti-pattern the skill already warns against, but the skill didn't account for this edge case or offer an alternative.

Fix in #1342: Updated the review-pr skill in two places:

  1. "Same pattern elsewhere" section — when a related fix is in a file outside the diff, the bot should now offer to push a fix commit (for community/bot PRs) or describe the fix clearly with an explicit note about why an inline suggestion isn't possible.

  2. "Inline suggestions" section — added an explicit "Exception: lines outside the diff" block documenting the GitHub API limitation and the preferred fallback (push a commit > describe clearly in body).

In the #1336 case specifically, the ideal bot behavior would have been: approve with inline suggestions on the flake.nix change (which was in the diff), and then offer to push a commit fixing the remaining pkgs.system occurrences in home-manager-module.nix — rather than just dropping a code block in the review body.

worktrunk-bot avatar Mar 07 '26 22:03 worktrunk-bot

is it possible in GH to add a suggestion outside of the diff?

max-sixty avatar Mar 07 '26 22:03 max-sixty

No — GitHub's Pull Request Review Comments API only allows comments on lines that appear in the diff (specifically, lines within the diff_hunk of changed files). There's no way to post an inline suggestion on a file or line that isn't part of the PR's changeset.

The two realistic fallback options when the fix is outside the diff are:

  1. Push a fix commit directly to the PR branch (best UX — the author just sees the fix applied)
  2. Describe the fix in the review body with a clear code block and filepath, noting why it can't be an inline suggestion

The skill update in #1342 steers toward option 1 for bot/community PRs.

worktrunk-bot avatar Mar 07 '26 22:03 worktrunk-bot