Skip to content

feat(code-review): Add custom actions for collapse, update_and_collapse#72

Merged
suejungshin merged 6 commits into
mainfrom
sshin/cw-1371
May 21, 2026
Merged

feat(code-review): Add custom actions for collapse, update_and_collapse#72
suejungshin merged 6 commits into
mainfrom
sshin/cw-1371

Conversation

@suejungshin
Copy link
Copy Markdown
Contributor

@suejungshin suejungshin commented May 18, 2026

Add custom actions for some behavior in code review:

  1. collapse_pull_request_comment

    • For code review, we collapse PR comments made by our bot when they are no longer relevant.
    • Historically, the sentry GitHub app was missing the permissions to call the api to "resolve" the thread via graphql, so we instead called the api to "minimize" the thread (uglier UX).
    • We have since requested the additional necessary permission (contents:write) from orgs, but not all have accepted it yet (and may never accept it).
    • So we have a fallback of if the "resolve" doesn't work, do the "minimize". We pre-check the permissions of the app to see if the contents:write is there to determine whether to call "resolve" vs. "minimize".
    • In this PR, add an "action" encapsulating this custom behavior. By contrast, in GitLab, we can just call the "resolve" endpoint because we don't have this historical lack-of-permissions problem.
  2. update_and_collapse_pull_request_comment

    • For code review, say commit1 resulted in a PR comment predicted bug. When commit2 is pushed up and contains a fix for the bug, we edit the body of the comment to say at the top "Resolved in commit1" (example), and also collapse (via resolve or minimize) the old comment.
    • This behavior to edit the body and collapse (via resolve or minimize) was contained in a single GraphQL mutation in code review to minimize calls to GitHub.
    • Add this custom action in this PR to have the combined GraphQL mutation for code review, but since GitLab doesn't have a corresponding concept, just call 2 apis there.

Closes CW-1371

results of running smoketests

github
collapse_pull_request_review_comment
https://github.com/getsentry/seer-test-sandbox/pull/122#discussion_r3204396926

bin/github-client collapse-pull-request-comment 122 PRRT_kwDORgZygc6Ab1v_ PRRC_kwDORgZygc6-_zd-
DEBUG:urllib3.connectionpool:Starting new HTTP connection (1): 127.0.0.1:8080
DEBUG:urllib3.connectionpool:http://127.0.0.1:8080 "GET /api/0/internal/scm-rpc/ HTTP/1.1" 200 None
DEBUG:urllib3.connectionpool:Starting new HTTP connection (1): 127.0.0.1:8080
DEBUG:urllib3.connectionpool:http://127.0.0.1:8080 "POST /api/0/internal/scm-rpc/ HTTP/1.1" 200 None
DEBUG:urllib3.connectionpool:Starting new HTTP connection (1): 127.0.0.1:8080
DEBUG:urllib3.connectionpool:http://127.0.0.1:8080 "POST /api/0/internal/scm-rpc/ HTTP/1.1" 200 None

update_and_collapse_pull_request_review_comment
https://github.com/getsentry/seer-test-sandbox/pull/122#discussion_r3204396926

bin/github-client update-and-collapse-pull-request-comment 122 PRRT_kwDORgZygc6Ab1v_ 3204396926 PRRC_kwDORgZygc6-_zd- edited
DEBUG:urllib3.connectionpool:Starting new HTTP connection (1): 127.0.0.1:8080
DEBUG:urllib3.connectionpool:http://127.0.0.1:8080 "GET /api/0/internal/scm-rpc/ HTTP/1.1" 200 None
DEBUG:urllib3.connectionpool:Starting new HTTP connection (1): 127.0.0.1:8080
DEBUG:urllib3.connectionpool:http://127.0.0.1:8080 "POST /api/0/internal/scm-rpc/ HTTP/1.1" 200 None
DEBUG:urllib3.connectionpool:Starting new HTTP connection (1): 127.0.0.1:8080
DEBUG:urllib3.connectionpool:http://127.0.0.1:8080 "POST /api/0/internal/scm-rpc/ HTTP/1.1" 200 None
INFO:__main__:{
  "data": {
    "author_association": null,
    "author": {
      "id": "seer-dev-testing",
      "username": "seer-dev-testing"
    },
    "body": "edited",
    "commit_sha": null,
    "created_at": "2026-05-07T20:10:28Z",
    "diff_hunk": null,
    "file_path": null,
    "head": null,
    "id": "3204396926",
    "review_id": "4247374314",
    "unique_id": "PRRC_kwDORgZygc6-_zd-",
    "url": null,
    "thread_id": null
  },
  "type": "github",
  "raw": {
    "data": {
      "updatePullRequestReviewComment": {
        "pullRequestReviewComment": {
          "id": "PRRC_kwDORgZygc6-_zd-",
          "fullDatabaseId": "3204396926",
          "body": "edited",
          "createdAt": "2026-05-07T20:10:28Z",
          "updatedAt": "2026-05-20T21:50:11Z",
          "author": {
            "__typename": "Bot",
            "login": "seer-dev-testing"
          },
          "pullRequestReview": {
            "databaseId": 4247374314
          }
        }
      },
      "resolveReviewThread": {
        "thread": {
          "isResolved": true
        }
      }
    },
    "headers": null
  },
  "meta": {}
}

gitlab
collapse_pull_request_review_comment
https://gitlab.com/seer-sandbox/seer-test-sandbox/-/merge_requests/1#note_3353092075

bin/gitlab-client collapse-pull-request-comment 1 e2f4577b21338ba5957a203e25c4a7e97f114c36 3352895200           
DEBUG:urllib3.connectionpool:Starting new HTTP connection (1): 127.0.0.1:8080
DEBUG:urllib3.connectionpool:http://127.0.0.1:8080 "GET /api/0/internal/scm-rpc/ HTTP/1.1" 200 None
DEBUG:urllib3.connectionpool:Starting new HTTP connection (1): 127.0.0.1:8080
DEBUG:urllib3.connectionpool:http://127.0.0.1:8080 "POST /api/0/internal/scm-rpc/ HTTP/1.1" 200 None

update_and_collapse_pull_request_review_comment
https://gitlab.com/seer-sandbox/seer-test-sandbox/-/merge_requests/1#note_3352895688

bin/gitlab-client update-and-collapse-pull-request-comment 1 b5ae39860c9ea93f18bf91e2c335f9dca9ec3c44 b5ae39860c9ea93f18bf91e2c335f9dca9ec3c44:3352895688 3352895688 edited
DEBUG:urllib3.connectionpool:Starting new HTTP connection (1): 127.0.0.1:8080
DEBUG:urllib3.connectionpool:http://127.0.0.1:8080 "GET /api/0/internal/scm-rpc/ HTTP/1.1" 200 None
DEBUG:urllib3.connectionpool:Starting new HTTP connection (1): 127.0.0.1:8080
DEBUG:urllib3.connectionpool:http://127.0.0.1:8080 "POST /api/0/internal/scm-rpc/ HTTP/1.1" 200 None
DEBUG:urllib3.connectionpool:Starting new HTTP connection (1): 127.0.0.1:8080
DEBUG:urllib3.connectionpool:http://127.0.0.1:8080 "POST /api/0/internal/scm-rpc/ HTTP/1.1" 200 None
INFO:__main__:{
  "data": {
    "id": "b5ae39860c9ea93f18bf91e2c335f9dca9ec3c44:3352895688",
    "unique_id": "b5ae39860c9ea93f18bf91e2c335f9dca9ec3c44:3352895688",
    "url": null,
    "file_path": "README.md",
    "body": "edited",
    "author": {
      "id": "38229780",
      "username": "project_82098515_bot_b1424cb3c949a690cb30d10374095a37"
    },
    "created_at": "2026-05-15T17:40:50.487Z",
    "diff_hunk": null,
    "review_id": null,
    "author_association": null,
    "commit_sha": null,
    "head": null,
    "thread_id": "b5ae39860c9ea93f18bf91e2c335f9dca9ec3c44"
  },
  "type": "gitlab",
  "raw": {
    "data": {
      "id": 3352895688,
      "type": "DiffNote",
      "body": "edited",
      "author": {
        "id": 38229780,
        "username": "project_82098515_bot_b1424cb3c949a690cb30d10374095a37",
        "public_email": null,
        "name": "seer test sandbox",
        "state": "active",
        "locked": false,
        "avatar_url": "https://secure.gravatar.com/avatar/7ccf18550b6246ae586d100f66587cf7ae57002ff4b9c718358bb1bdacbeea2c?s=80&d=identicon",
        "web_url": "https://gitlab.com/project_82098515_bot_b1424cb3c949a690cb30d10374095a37"
      },
      "created_at": "2026-05-15T17:40:50.487Z",
      "updated_at": "2026-05-20T22:00:48.982Z",
      "system": false,
      "noteable_id": 485108133,
      "noteable_type": "MergeRequest",
      "project_id": 82098515,
      "commit_id": null,
      "position": {
        "base_sha": "7ef982b73184e9d2318cae71ec547bae84034d68",
        "start_sha": "7ef982b73184e9d2318cae71ec547bae84034d68",
        "head_sha": "24c0f00436d8a3e4cd33148c5b04414d9c613447",
        "old_path": "README.md",
        "new_path": "README.md",
        "position_type": "text",
        "old_line": null,
        "new_line": 1,
        "line_range": null
      },
      "resolvable": true,
      "resolved": false,
      "resolved_by": null,
      "resolved_at": null,
      "suggestions": [],
      "confidential": false,
      "internal": false,
      "imported": false,
      "imported_from": "none",
      "noteable_iid": 1,
      "commands_changes": {}
    },
    "headers": null
  },
  "meta": {}
}

@linear-code
Copy link
Copy Markdown

linear-code Bot commented May 18, 2026

CW-1371

@suejungshin suejungshin marked this pull request as ready for review May 18, 2026 23:38
@suejungshin suejungshin requested a review from a team as a code owner May 18, 2026 23:38
Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit d81cfae. Configure here.

Comment thread src/scm/providers/github/provider.py
Comment thread src/scm/providers/github/provider.py
Comment thread src/scm/providers/github/provider.py
@billyvg billyvg requested a review from cmanallen May 19, 2026 13:13
Copy link
Copy Markdown
Member

@cmanallen cmanallen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update the bin scripts and test your changes on a GitHub and GitLab app. You can ask AI to update the bin scripts.

Run bin/github-server in one window and bin/github-client collapse-pull-request <id> <id> <id> in another.

This is what my .credentials file looks like:

GITHUB_APP_ID=...
GITHUB_PRIVATE_KEY_PATH=...
GITHUB_INSTALLATION_ID=...
GITHUB_REPOSITORY_NAME=...
GITLAB_ACCESS_TOKEN=...
GITLAB_PROJECT_ID=...

@suejungshin
Copy link
Copy Markdown
Contributor Author

Update the bin scripts and test your changes on a GitHub and GitLab app. You can ask AI to update the bin scripts.

Run bin/github-server in one window and bin/github-client collapse-pull-request <id> <id> <id> in another.

This is what my .credentials file looks like:

GITHUB_APP_ID=...
GITHUB_PRIVATE_KEY_PATH=...
GITHUB_INSTALLATION_ID=...
GITHUB_REPOSITORY_NAME=...
GITLAB_ACCESS_TOKEN=...
GITLAB_PROJECT_ID=...

Thanks! Updated and posted the results in the updated PR description

@suejungshin suejungshin requested a review from cmanallen May 20, 2026 22:09
@suejungshin suejungshin merged commit 96afdf2 into main May 21, 2026
13 checks passed
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.

2 participants