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

feat: add octo review browse to browse a pull request #830

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ldelossa
Copy link
Contributor

@ldelossa ldelossa commented Jan 29, 2025

Add a new command Octo review browse which opens the review layout for a PR but does not start a review.

This is handy when you want to look over the changes in a PR but do not necessary want to review it.

When you are in a Review layout initiated by Octo review browse you can intuitively convert it into an active review session with Octo review start.

Its invalid to call Octo review browse after Octo review start and the user must either submit or discard the active review to enter the browse state again.

Closes: #829

Describe what this PR does / why we need it

Provides the ability to browse a PR but not enter a review

A big reason to do this is say, you already submitted a review, but you want to use the (very nice) Review layout to continue looking at other contributor's comments.

Does this pull request fix one issue?

#829

Describe how you did it

Copied the patterns used for Octo review start but instead of submitting graphql mutations to start a review, we simply just get the review threads and initialize the review layout. The abstractions are well done, so this was clean and done without much trouble.

Describe how to verify it

Open a PR with Octo pr edit|list and issue Octo review browse you can then ensure starting a review from the browse state is working with Octo review start.

Special notes for reviews

Checklist

  • Passing tests and linting standards
  • Documentation updates in README.md and doc/octo.txt

Add a new command `Octo review browse` which opens the review layout for
a PR but does not start a review.

This is handy when you want to look over the changes in a PR but do not
necessary want to review it.

When you are in a Review layout initiated by `Octo review browse` you
can intuitively convert it into an active review session with `Octo
review start`.

Its invalid to call `Octo review browse` after `Octo review start` and
the user must either submit or discard the active review to enter the
browse state again.

Closes: pwntester#829

Signed-off-by: ldelossa <[email protected]>
@ldelossa ldelossa force-pushed the ldelossa/octo-review-browse branch from 18cdd1a to 6c2f501 Compare January 29, 2025 21:25
@ldelossa ldelossa marked this pull request as draft January 30, 2025 00:08
@ldelossa
Copy link
Contributor Author

ldelossa commented Jan 30, 2025

going to convert this to draft.

needs docs update and I want to handle this:

image

A bit better.

Any early comments are appreciated however.

@phdah
Copy link
Contributor

phdah commented Jan 30, 2025

Tested the draft version out. It's great, but agree about the commenting issue. Expected behavior would be for it to be just a non-review comment, or less expected but that it triggers first Octo review start if comment/suggestion is invoked.

@wd60622
Copy link
Collaborator

wd60622 commented Jan 30, 2025

Very cool. What is the behavior when you (try to) add a comment while browsing? Does that automatically start a review? Or cause an error?

Also, can Octo review start be called while browsing?

Comment on lines +63 to +73
gh.run {
args = { "api", "graphql", "-f", string.format("query=%s", query) },
cb = function(output, stderr)
if stderr and not utils.is_blank(stderr) then
utils.error(stderr)
elseif output then
local resp = vim.fn.json_decode(output)
callback(resp)
end
end,
}
Copy link
Collaborator

@wd60622 wd60622 Jan 30, 2025

Choose a reason for hiding this comment

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

Interested in using the new pattern?

gh.api.graphql {
  query = query,
  opts = {
      cb = cb,
  }, 
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Definitely, that is very nice. Will update.

Comment on lines +59 to +61
local file = io.open("/tmp/query", "w")
file:write(query)
file:close()
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this just for testing?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yup 🤦

forgot about that. Ill remove.

@wd60622 wd60622 added enhancement New feature or request command Dealing with Octo commands labels Jan 30, 2025
@ldelossa
Copy link
Contributor Author

ldelossa commented Jan 30, 2025

@phdah @wd60622

as far as creating a comment via in "browse" state.

For now, I think it will just create a notification asking you to start a review. Or, if we want, start a review automatically, but youd need to do a "Octo comment add" once again, since starting a review reloads the layout, and puts you at the first changed file. This maybe not where you wanted to comment.

As a follow up, id like this to add a non-review commit! Theres some nuance to this however, since it, iirc from when I worked on this, requires the use of a separate set of APIs. So we need to work in some logic to say "hey is this a non-review commit, if so, use this api and not the review comments api".

Id like this, but probably in a follow up pr? Thoughts?

Re:

Also, can Octo review start be called while browsing?

yup, that use case is implemented. From browse you can go right to start. From within a review, you cant go to browse. Youll need to submit or discard the current review. This makes things a bit simpler.

@GuillaumeLagrange
Copy link
Collaborator

GuillaumeLagrange commented Jan 30, 2025

I like the idea of not having to start a review in order to post a comment or browse diffs, very much so!

I can't think of a good UX in the current octo way of doing things to seemlessly allow users to start reviews while creating comment, i'd like to avoid being prompted everytime we add a comment.

The best idea I have right now is that when a user runs Octo command add

  • If no review is in progress, add the comment in a standalone way, just like when one clicks here
    image
  • If a review is in progress, add the comment to the review

And let the user start a review if they wish to do so using Octo review

WDYT ?

While we're touching this part of the code, do you think this can address #823 ?

@ldelossa
Copy link
Contributor Author

@GuillaumeLagrange

I totally agree.

Ultimately I think 'Octo command add' in the 'browse' state should add a non-review commit.
I was originally thinking of implementing this in a second PR since I need to dig into the API changes required for this.

I was thinking of this PR just providing the initial implementation of the feature, and then following up with API changes to handle "browse state comments".

Would you rather see it all done in one PR here? I'm not too opposed, would just take a bit longer to get the Octo pr browse feature out to users.

@GuillaumeLagrange
Copy link
Collaborator

GuillaumeLagrange commented Jan 31, 2025

I am fine with iterating, as long as we do not hurt existing UX, which is not the case here.
Feel free to submit the PR without the comment management first!

Btw it's still in draft but let me know if you want a review

@ldelossa
Copy link
Contributor Author

ldelossa commented Feb 1, 2025

@GuillaumeLagrange sounds good. Yeah if we do not mind, ill probably submit this one without "non-review" comments, and then start working on making that work in a immediate subsequent PR.

@phdah
Copy link
Contributor

phdah commented Feb 14, 2025

@ldelossa, would you like to convert the PR from draft to ready? I've been using this for two weeks, and really appreciate the feature. Pushing the non-review sounds good.

@ldelossa
Copy link
Contributor Author

@phdah I want to handle some error conditions when trying to apply comments when in browse mode. I'm a bit busy with day job right now, but will follow up on this next week.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
command Dealing with Octo commands enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Quick look into PRs
4 participants