Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Comments appear on the wrong lines #79

Open
proivk opened this issue Feb 26, 2023 · 1 comment
Open

Comments appear on the wrong lines #79

proivk opened this issue Feb 26, 2023 · 1 comment

Comments

@proivk
Copy link

proivk commented Feb 26, 2023

Whenever I call GHCreateThread on a particular line, comment appears in a different line.
It happens mostly after GHStartReview. If I add comment w/o starting a review, comments appear on the right positions.

I saw this thread #66. It looks similar but I didn't get what was the solution for the issue.

How to reproduce:

  1. git worktree add ../review_dir
  2. cd ../review_dir
  3. nvim
  4. GHOpenPR. PR contains several commits.
  5. GHStartReview
  6. Go to any commit (the last one, for instance) and try to add a comment. GHCreateThread

Expected result:

  1. Comment appears on the right position

Actual result:

  1. Comment appears on a completely different line

Note: if I don't start review, comment most likely appears on the right position.

Env:
nvim v0.8.0
gh.nvim latest
macos latest
iterm2 latest

@proivk
Copy link
Author

proivk commented Mar 10, 2023

Adding some debug info.
Adding comment for the same code, same PR, same line (18th line) but after GHStartReview and w.o GHStartReview

  1. Debug info for the case after GHStartReview
[info] [gh] cmd: "gh api graphql -F pull=\"PR_kwDOIkxU8c5LxKOy\" -F review=\"PRR_kwDOIkxU8c5PmQ9h\" -F body='Comment on 18th line after StartReview' -F path=\"pkg/checks/test.go\" -F pos=18 -F sha=\"2168d255022aba12890a9a96bd8a0a0e21554f9f\" -f query='mutation ($pull: ID!, $review: ID!, $body: String!, $path: String!, $pos: Int!, $sha: GitObjectID!) {\n  addPullRequestReviewComment(\n    input: {pullRequestId: $pull, pullRequestReviewId: $review, body: $body, path: $path, position: $pos, commitOID: $sha}\n  ) {\n    clientMutationId\n  }\n}\n'" out:
'{"data":{"addPullRequestReviewComment":{"clientMutationId":null}}}'

As the result comment appears on line 26 but should be on line 18th

 out:
{
  data = {
    repository = {
      pullRequest = {
        reviewThreads = {
          edges = { {
              node = {
                comments = {
                  edges = { {
                      node = {
                        author = {
...
                        },
                        body = "Comment on 18th line after StartReview",
                        commit = {
                          oid = "05c0258f3bf3e50b5a3bf19d240197bf6b216fdd",
                          parents = {
                            edges = { {
                                node = {
                                  id = "C_kwDOIkxU8doAKDdhNzExMjlmOTljY2VmZjYwODZmYzFkNmYwNzMwZjY4NDQ5YjJjNjM",
                                  oid = "7a71129f99cceff6086fc1d6f0730f68449b2c63"
                                }
                              } }
                          }
                        },
                        createdAt = "2023-03-10T18:46:40Z",
                        diffHunk = "...",
                        id = "PRRC_kwDOIkxU8c5DhHXQ",
                        originalCommit = {
                          oid = "2168d255022aba12890a9a96bd8a0a0e21554f9f",
                          parents = {
                            edges = { {
                                node = {
                                  id = "C_kwDOIkxU8doAKDE3ZjRlNDBhMzI0MTNhZDgzNzE1ZDU0ZWQ4MjUyZDI3NzdhNjA1NTg",
                                  oid = "17f4e40a32413ad83715d54ed8252d2777a60558"
                                }
                              } }
                          }
                        },
                        originalPosition = 18,
                        path = "pkg/checks/test.go",
                        position = 24,
                        publishedAt = vim.NIL,
                        pullRequestReview = {
                          id = "PRR_kwDOIkxU8c5PmQ9h"
                        },
                        reactions = {
                          edges = {}
                        },
                        replyTo = vim.NIL,
                        state = "PENDING",
                        updatedAt = "2023-03-10T18:46:40Z",
                        url = "...",
                        viewerCanDelete = true,
                        viewerCanMinimize = false,
                        viewerCanReact = true,
                        viewerCanUpdate = true,
                        viewerCannotUpdateReasons = {},
                        viewerDidAuthor = true
                      }
                    } }
                },
                diffSide = "RIGHT",
                id = "PRRT_kwDOIkxU8c4rLLvq",
                isOutdated = false,
                isResolved = false,
                line = 26,
                originalLine = 26,
                originalStartLine = vim.NIL,
                path = "pkg/checks/test.go",
                resolvedBy = vim.NIL,
                startDiffSide = vim.NIL,
                startLine = 26,
                viewerCanReply = true,
                viewerCanResolve = false,
                viewerCanUnresolve = false
              }
            } },
          pageInfo = {
            endCursor = "...",
            hasNextPage = false
          }
        }
      }
    }
  }
}

  1. Debug info w/o GHStartReview
[info] [gh] cmd: "gh api --method POST -H \"Accept: application/vnd.github.v3+json\" /repos/{owner}/{repo}/pulls/21/comments -f commit_id=2168d255022aba12890a9a96bd8a0a0e21554f9f -f path=pkg/checks/test.go -f side=RIGHT -F position=10 -F line=18 -f body='Comment on 18th line w/o starting review'" out:
'{"url":"...","pull_request_review_id":1335466576,"id":1132775409,"node_id":"PRRC_kwDOIkxU8c5DhMfx","diff_hunk":"...","path":"pkg/checks/test.go","position":13,"original_position":12,"commit_id":"05c0258f3bf3e50b5a3bf19d240197bf6b216fdd","original_commit_id":"2168d255022aba12890a9a96bd8a0a0e21554f9f","user":{...},"body":"Comment on 18th line w/o starting review","created_at":"2023-03-10T19:06:10Z","updated_at":"2023-03-10T19:06:10Z","html_url":"...","pull_request_url":"...","author_association":"CONTRIBUTOR","_links":{...},"reactions":{"url":"...","total_count":0,"+1":0,"-1":0,"laugh":0,"hooray":0,"confused":0,"heart":0,"rocket":0,"eyes":0},"start_line":null,"original_start_line":null,"start_side":null,"line":18,"original_line":18,"side":"RIGHT"}'

As the result comment appears on the right line - 18th line.

[info] [gh] cmd: gh api graphql -F owner={owner} -F name={repo} -F pull_number=21 -f query=query ($name: String!, $owner: String!, $pull_number: Int!) {
  repository(name: $name, owner: $owner) {
    pullRequest(number: $pull_number) {
      reviewThreads(first: 50) {
        pageInfo {
          endCursor
          hasNextPage
        }
        edges {
          node {
            id
            diffSide
            isOutdated
            isResolved
            line
            originalLine
            originalStartLine
            path
            startDiffSide
            startLine
            viewerCanReply
            viewerCanResolve
            viewerCanUnresolve
            resolvedBy {
              login
            }
            comments(first: 100) {
              edges {
                node {
                  id
                  author {
                    login
                    avatarUrl
                    resourcePath
                    url
                  }
                  body
                  createdAt
                  path
                  position
                  originalPosition
                  publishedAt
                  replyTo {
                    id
                  }
                  pullRequestReview {
                    id
                  }
                  commit {
                    oid
                    parents(first: 1) {
                      edges {
                        node {
                          id
                          oid
                        }
                      }
                    }
                  }
                  originalCommit {
                    oid
                    parents(first: 1) {
                      edges {
                        node {
                          id
                          oid
                        }
                      }
                    }
                  }
                  reactions(first:20) {
                    edges {
                      node {
                        content
                        id
                        user {
                          login
                        }
                      }
                    }
                  }
                  state
                  updatedAt
                  viewerCanDelete
                  viewerCanMinimize
                  viewerCanReact
                  viewerCanUpdate
                  viewerCannotUpdateReasons
                  viewerDidAuthor
                  url
                  diffHunk
                }
              }
            }
          }
        }
      }
    }
  }
}
 out:
{
  data = {
    repository = {
      pullRequest = {
        reviewThreads = {
          edges = { {
              node = {
                comments = {
                  edges = { {
                      node = {
                        author = {
                         ...
                        },
                        body = "Comment on 18th line w/o starting review",
                        commit = {
                          oid = "05c0258f3bf3e50b5a3bf19d240197bf6b216fdd",
                          parents = {
                            edges = { {
                                node = {
                                  id = "C_kwDOIkxU8doAKDdhNzExMjlmOTljY2VmZjYwODZmYzFkNmYwNzMwZjY4NDQ5YjJjNjM",
                                  oid = "7a71129f99cceff6086fc1d6f0730f68449b2c63"
                                }
                              } }
                          }
                        },
                        createdAt = "2023-03-10T19:06:10Z",
                        diffHunk = '...',
                        id = "PRRC_kwDOIkxU8c5DhMfx",
                        originalCommit = {
                          oid = "2168d255022aba12890a9a96bd8a0a0e21554f9f",
                          parents = {
                            edges = { {
                                node = {
                                  id = "C_kwDOIkxU8doAKDE3ZjRlNDBhMzI0MTNhZDgzNzE1ZDU0ZWQ4MjUyZDI3NzdhNjA1NTg",
                                  oid = "17f4e40a32413ad83715d54ed8252d2777a60558"
                                }
                              } }
                          }
                        },
                        originalPosition = 12,
                        path = "pkg/checks/test.go",
                        position = 13,
                        publishedAt = "2023-03-10T19:06:11Z",
                        pullRequestReview = {
                          id = "PRR_kwDOIkxU8c5PmZpQ"
                        },
                        reactions = {
                          edges = {}
                        },
                        replyTo = vim.NIL,
                        state = "SUBMITTED",
                        updatedAt = "2023-03-10T19:06:11Z",
                        url = "...",
                        viewerCanDelete = true,
                        viewerCanMinimize = true,
                        viewerCanReact = true,
                        viewerCanUpdate = true,
                        viewerCannotUpdateReasons = {},
                        viewerDidAuthor = true
                      }
                    } }
                },
                diffSide = "RIGHT",
                id = "PRRT_kwDOIkxU8c4rLPFg",
                isOutdated = false,
                isResolved = false,
                line = 18,
                originalLine = 18,
                originalStartLine = vim.NIL,
                path = "pkg/checks/test.go",
                resolvedBy = vim.NIL,
                startDiffSide = vim.NIL,
                startLine = 18,
                viewerCanReply = true,
                viewerCanResolve = true,
                viewerCanUnresolve = false
              }
            } },
          pageInfo = {
            endCursor = "Y3Vyc29yOnYyOpK0MjAyMy0wMy0xMFQxOTowNjoxMFrOKyzxYA==",
            hasNextPage = false
          }
        }
      }
    }
  }
}

Feel free to contact me if you need some live demo or troubleshooting session.

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

No branches or pull requests

1 participant