Skip to content

fix: paginate comment lookup for sticky comments - #1782

Open
rioyu123 wants to merge 2 commits into
anthropics:mainfrom
rioyu123:fix/paginate-sticky-comment-lookup
Open

rioyu123 wants to merge 2 commits into
anthropics:mainfrom
rioyu123:fix/paginate-sticky-comment-lookup

Conversation

@rioyu123

@rioyu123 rioyu123 commented Sep 2, 2026 •

Copy link
Copy Markdown

Summary

With use_sticky_comment enabled, a PR with more than 30 comments can get a second tracking comment even though one already exists. This happens because the lookup only reads the first page of comments.

This change uses octokit.paginate (with per_page: 100) to search every page before deciding whether to update the existing comment or create a new one.

Closes #1781.

Tests

test/create-initial.test.ts uses the real Octokit client with an in-memory fetch that returns paged responses and honors page, per_page, and the Link header. No requests reach GitHub. It covers:

  • an existing sticky comment at position 33 (past GitHub's default 30 per page) and at position 103 (on the second page at per_page: 100)
  • creating a new comment only after reading every page when none exists
  • the non-sticky path, which creates a comment without listing existing ones

The sticky-comment and no-match cases also check the comment ID written to GITHUB_OUTPUT.

Validation:

  • On unchanged main (c0949c5), three of the four new tests fail and the non-sticky control passes. All four pass with the fix.
  • Linux, Bun 1.4.4 (the version CI uses): bun test (970 pass), bun run typecheck, and bun run format:check all pass.
  • Windows, Bun 1.3.11: the 7 tests in test/create-initial.test.ts and test/modes/tag.test.ts, typecheck, and format check pass. The full suite was not rerun on Windows.

The fix has not been tested end to end in a live workflow run.

createInitialComment looked for the existing sticky comment with a single
unpaginated issues.listComments call, which returns only the first 30
comments. On PRs with more than 30 comments the Claude comment on a later
page was never found, so use_sticky_comment created a new comment on every
run instead of reusing the existing one.

Fetch all comments with octokit.paginate (per_page: 100), matching how
fetcher.ts already lists issue events, before searching for the existing
comment.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

use_sticky_comment creates a new comment on PRs with more than 30 comments: the sticky lookup only reads the first page

1 participant