Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 7 additions & 8 deletions design/github.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,13 @@ also wake a Conversation or run an Event automation.
- Images in PRs, issues, and comments are links to public Junior images.
- Junior can review a PR and request changes.
- When the requester requests changes on a Junior PR, the PR asks for
their review again, in the Inbox and on GitHub, when Junior acts after
them and the required checks pass. Junior acts when it pushes commits,
comments, replies to a review comment, or marks the change request
addressed. When the requester comments or reviews, Junior acts next, and
the Inbox stops asking. A requester who approved since is not asked.
their review again, in the Inbox and on GitHub, only when Junior marks
each comment of that change request addressed or declined and the
required checks pass. Pushes, merges of the base branch, comments, and
replies do not ask. When the requester comments or reviews, Junior acts
next, and the Inbox stops asking. A requester who approved since is not
asked. The Inbox item says why it asks: every comment is handled, or the
checks now pass.
- Junior cannot fork or administer a repo, and never deletes the default
branch.
- Junior reaches only repos where its App is installed.
Expand All @@ -53,9 +55,6 @@ also wake a Conversation or run an Event automation.

## Gaps

- Junior asks the requester to review again as soon as it acts after their
change request, before the required checks pass. This breaks "asks for a
review only when the required checks pass" (Attention).
- A pull request that Junior opens ready for review asks for a review at
once, before the required checks pass. This breaks "asks for a review
only when the required checks pass" (Attention).
Expand Down
2 changes: 1 addition & 1 deletion packages/junior-github/src/events/pull-request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ const STACK_CONFLICT_STEPS =
* sets comment_id only when it has a body.
*/
const PULL_REQUEST_FEEDBACK =
'When Verified details include comment_id, call github_updatePullRequestFeedback after acting on actionable feedback, with the exact repo, pull_request, comment_id, and comment_kind from Verified details, and status "addressed" or "declined".';
'When Verified details include comment_id, call github_updatePullRequestFeedback after acting on actionable feedback or answering a question, with the exact repo, pull_request, comment_id, and comment_kind from Verified details, and status "addressed" or "declined".';

const GITHUB_PULL_REQUEST_EVENT_GUIDANCE: Partial<
Record<GitHubPullRequestEvent, string>
Expand Down
65 changes: 58 additions & 7 deletions packages/junior-github/src/graphql-documents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -232,16 +232,15 @@ export const PULL_REQUEST_CONFLICT_HISTORY = githubGraphql(`

/**
* Read what decides the requester's next action on one pull request: its
* state, merge state, review requests, latest reviews, head commit, and
* latest comments and review requests. A review comment reply is a review,
* so `reviews` holds it too.
* state, merge state, review requests, latest reviews, and latest comments
* and review requests. A review comment reply is a review, so `reviews`
* holds it too.
*/
export const PULL_REQUEST_NEXT_ACTION = githubGraphql(`
query PullRequestNextAction($owner: String!, $name: String!, $number: Int!) {
repository(owner: $owner, name: $name) {
pullRequest(number: $number) {
autoMergeRequest { enabledAt }
headRefOid
isDraft
mergeStateStatus
state
Expand All @@ -254,7 +253,6 @@ export const PULL_REQUEST_NEXT_ACTION = githubGraphql(`
pageInfo { hasPreviousPage startCursor }
nodes { ...NextActionReview }
}
commits(last: 1) { nodes { commit { committedDate } } }
timelineItems(last: 100, itemTypes: [ISSUE_COMMENT, REVIEW_REQUESTED_EVENT]) {
nodes {
__typename
Expand All @@ -273,7 +271,61 @@ export const PULL_REQUEST_NEXT_ACTION = githubGraphql(`
state
submittedAt
author { __typename login }
commit { oid }
}
`);

/**
* Read what decides whether a reviewer's change request is ready for their
* review again: whether GitHub asks them, their latest review with the
* reactors of its body and each of its comments, the checks of the head
* commit, and the branch protection's required checks of the base branch.
*/
export const PULL_REQUEST_REVIEW_AGAIN = githubGraphql(`
query PullRequestReviewAgain($owner: String!, $name: String!, $number: Int!, $reviewer: String!) {
repository(owner: $owner, name: $name) {
pullRequest(number: $number) {
baseRefName
baseRef { refUpdateRule { requiredStatusCheckContexts } }
reviewRequests(first: 100) {
nodes { requestedReviewer { __typename ... on User { login } } }
}
reviews(last: 1, author: $reviewer, states: [APPROVED, CHANGES_REQUESTED, DISMISSED]) {
nodes {
databaseId
state
body
...FeedbackReactors
comments(first: 100) {
totalCount
nodes { databaseId ...FeedbackReactors }
}
}
}
commits(last: 1) {
nodes {
commit {
statusCheckRollup {
contexts(first: 100) {
pageInfo { hasNextPage }
nodes {
__typename
... on CheckRun { name status conclusion }
... on StatusContext { context state }
}
}
}
}
}
}
}
}
}

fragment FeedbackReactors on Reactable {
reactionGroups {
content
reactors(first: 100) { nodes { ... on Bot { databaseId } } }
}
}
`);

Expand All @@ -294,7 +346,6 @@ export const PULL_REQUEST_REVIEWS_BEFORE = githubGraphql(`
state
submittedAt
author { __typename login }
commit { oid }
}
`);

Expand Down
Loading
Loading