fix(comments): disallow posting threads GitHub cannot show - #180
Draft
moritzwilksch wants to merge 6 commits into
Draft
moritzwilksch wants to merge 6 commits into
moritzwilksch wants to merge 6 commits into
Conversation
shownRanges(patch, side, context) walks each hunk body and keeps only the lines within `context` of a change, as a diff generated with that much context would show them. GitHub's pull request diff has three context lines; diffle's default is five, so the two disagree on the outer lines.
A thread on a file opened from the tree, or on a line past GitHub's three context lines, was not stale, so the export posted it into a pending review where GitHub never displays it. Relocation now derives `githubBlocker` alongside `stale`: set for every stale thread, for a thread on an unchanged file, and for a line thread outside the pull request diff. Imports get it from the start through the same ReviewView, which replaces AnchorSource. buildReview skips on the blocker and reports its reason instead of checking `stale`. Fixes #168
The card's GitHub button is disabled with the server's reason, and the panel's all-threads button when no open thread can be shown.
With diff.suppressBlankEmpty=true git writes an empty context line as '' instead of ' '; shownRanges' hunk-body walk then overruns into the next header and drops that hunk, flagging every later thread stale.
A stale thread carried 'lines outside the pull request diff' whatever made it stale; it now carries 'stale'. Fresh threads keep the diff-based reasons, and the blocker helper no longer takes a nullable side view.
placeImport quoted a range and derived its GitHub blocker without asking whether the diff shows it, while relocateAll flags exactly such a range stale. A thread posted on a line outside every hunk was therefore fresh with 'lines outside the pull request diff' until the next relocation turned it stale with 'stale'. Both paths now share one predicate, `shows`: relocation flags a range stale when it leaves what the diff shows, and an import there is refused as UnquotableError (400), like a line past the end or a file outside the review. A new thread never starts where the next relocation would flag it stale.
moritzwilksch
force-pushed
the
fix/168-guard-github-post
branch
from
September 14, 2026 11:19
9d53d24 to
59ebac5
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
GitHub accepts a review comment on a file the PR does not change, or on a line past its three context lines, and then shows it nowhere. diffle let such threads into a pending review. Now a thread GitHub cannot show carries a
githubBlocker: its Add button and the sidebar's Add all are disabled with the reason, andbuildReviewskips it and reports why.Per-thread blocker.
CommentStorederivesgithubBlockernext tostale, at relocation and import, from aReviewViewthat now exposesinDiffand a side'sonGithubranges.buildReviewskips by the field alone; the client only reads it.export const CommentThreadSchema = z.object({ stale: z.boolean(), staleFromLine: z.number().optional(), + githubBlocker: z.string().optional(), }); export interface SideView { shown: LineRange[] | null; + onGithub: LineRange[]; } export interface ReviewView { hasFile(path: string): boolean; + inDiff(path: string): boolean; }Narrowing to a context.
shownRanges(patch, side, context)keeps the lines withincontextof a change, as a diff generated with that context would show them.GITHUB_CONTEXT_LINES = 3feedsonGithub.Two bugs on the way.
GitRepopinsdiff.suppressBlankEmpty=false: with it on, an empty context line loses its leading space, and the hunk-body walk overran into the next hunk header and dropped later hunks. Import now places a line by the sameshowspredicate as relocation, so a line the diff does not show gets a 400 instead of going stale on the next refresh.Open decision. Lines reached by expanding context or the full-file view of a changed file are outside the hunks, so commenting there now fails immediately; before, it was accepted and went stale on the next refresh. Allowing such comments instead, fresh with a GitHub blocker, is a product call.
Closes #168
Screenshots
Fixture:
main..featurewith a real GitHub PR mocked viagh, one open thread inside the hunk (L5–6) and one three lines past GitHub's context (L12) or on a file outside the diff (README.md).