@@ -46,9 +46,9 @@ const RawActorSchema = Schema.Struct({
4646 __typename : Schema . optional ( Schema . String ) ,
4747 is_bot : Schema . optional ( Schema . Boolean ) ,
4848 /**
49- * Optional because a review can be requested from a team or a mannequin, which the query has
50- * no fragment for and GraphQL answers with an empty object. A reviewer with no login names
51- * nobody to show, and must not fail the response the conversation travels in.
49+ * Optional because a requested team goes by its slug instead, and a mannequin, which no query
50+ * has a fragment for, arrives as an empty object. A reviewer with neither names nobody to show,
51+ * and must not fail the response the conversation travels in.
5252 */
5353 login : Schema . optional ( Schema . String ) ,
5454 /** The node id, which is how a listing's authors are resolved to avatars in one request. */
@@ -58,6 +58,16 @@ const RawActorSchema = Schema.Struct({
5858 avatarUrl : Schema . optional ( Schema . NullOr ( Schema . String ) ) ,
5959} ) ;
6060
61+ /**
62+ * A team answers with a slug where a user answers with a login. `combinedSlug` is the team's
63+ * `org/slug`, which is what a reviewer row shows for it.
64+ */
65+ const RawRequestedReviewerSchema = Schema . Struct ( {
66+ ...RawActorSchema . fields ,
67+ slug : Schema . optional ( Schema . NullOr ( Schema . String ) ) ,
68+ combinedSlug : Schema . optional ( Schema . NullOr ( Schema . String ) ) ,
69+ } ) ;
70+
6171const RawLabelSchema = Schema . Struct ( {
6272 name : Schema . String ,
6373 color : Schema . optional ( Schema . NullOr ( Schema . String ) ) ,
@@ -66,7 +76,9 @@ const RawLabelSchema = Schema.Struct({
6676const RawReviewRequestSchema = Schema . Struct ( {
6777 login : Schema . optional ( Schema . NullOr ( Schema . String ) ) ,
6878 slug : Schema . optional ( Schema . NullOr ( Schema . String ) ) ,
79+ combinedSlug : Schema . optional ( Schema . NullOr ( Schema . String ) ) ,
6980 name : Schema . optional ( Schema . NullOr ( Schema . String ) ) ,
81+ avatarUrl : Schema . optional ( Schema . NullOr ( Schema . String ) ) ,
7082} ) ;
7183
7284/** One reviewer's most recent review: the state is all the verdict needs, the author is for who. */
@@ -618,8 +630,8 @@ const RawReviewThreadsSchema = Schema.Struct({
618630 Schema . Struct ( {
619631 nodes : Schema . Array (
620632 Schema . Struct ( {
621- // Null for a team, which is a request nobody in particular owns .
622- requestedReviewer : Schema . optional ( Schema . NullOr ( RawActorSchema ) ) ,
633+ // Null where GitHub does not name who was asked .
634+ requestedReviewer : Schema . optional ( Schema . NullOr ( RawRequestedReviewerSchema ) ) ,
623635 } ) ,
624636 ) ,
625637 } ) ,
@@ -835,7 +847,7 @@ export const pullRequestCoreGraphQlQuery = (host: string) => {
835847 viewerCanUpdate viewerDidAuthor viewerCanUpdateBranch
836848 baseRef { compare(headRef: $headRef) { behindBy } }
837849 reviewRequests(first: 100) {
838- nodes { requestedReviewer { ... on User { login name } ... on Bot { login } ... on Team { slug name } } }
850+ nodes { requestedReviewer { ... on User { login name } ... on Bot { login } ... on Team { slug combinedSlug name avatarUrl } } }
839851 }
840852 labels(first: 100) { nodes { name color } }
841853 commits(last: 1) {
@@ -1006,8 +1018,8 @@ function pullRequestRowSelection(includeStacks: boolean, includeStats: boolean):
10061018 *
10071019 * Reviewers come from here rather than from `gh pr view --json reviewRequests` for two reasons:
10081020 * that field holds only requests still outstanding, so anyone who has already reviewed drops off
1009- * it, and neither it nor any other `gh` JSON field carries an avatar. A reviewer can be a person
1010- * or an app, and both are asked for by name because they are different GraphQL types.
1021+ * it, and neither it nor any other `gh` JSON field carries an avatar. A reviewer can be a person,
1022+ * an app, or a team, and each is asked for by name because they are different GraphQL types.
10111023 *
10121024 * `viewerCanUpdate` and `viewerDidAuthor` ride along here for the same reason: they belong to the
10131025 * pull request this query is already standing on, so what the reader may do with it arrives with
@@ -1052,6 +1064,7 @@ export const REVIEW_THREADS_GRAPHQL_QUERY = `query($owner: String!, $name: Strin
10521064 requestedReviewer {
10531065 ... on User { login name avatarUrl }
10541066 ... on Bot { __typename login avatarUrl }
1067+ ... on Team { combinedSlug name avatarUrl }
10551068 }
10561069 }
10571070 }
@@ -1413,6 +1426,22 @@ function toActor(raw: Schema.Schema.Type<typeof RawActorSchema> | null | undefin
14131426 } ;
14141427}
14151428
1429+ /**
1430+ * A requested team as a reviewer row. It goes by `org/slug`, the handle GitHub mentions it by.
1431+ * No GitHub login contains a slash, so a team never shares a row or a verdict with a user.
1432+ */
1433+ function toRequestedTeam (
1434+ raw :
1435+ | Pick < Schema . Schema . Type < typeof RawReviewRequestSchema > , "combinedSlug" | "name" | "avatarUrl" >
1436+ | null
1437+ | undefined ,
1438+ ) : PullRequestActor | null {
1439+ const login = trimmed ( raw ?. combinedSlug ) ;
1440+ return login === null
1441+ ? null
1442+ : { login, name : trimmed ( raw ?. name ) , avatarUrl : trimmed ( raw ?. avatarUrl ) } ;
1443+ }
1444+
14161445function toCommitActor (
14171446 raw : NonNullable < Schema . Schema . Type < typeof RawCommitSchema > [ "authors" ] > [ number ] ,
14181447) : PullRequestActor | null {
@@ -2302,6 +2331,8 @@ export function decodePullRequestWatchFingerprintsJson(
23022331}
23032332
23042333export interface GitHubPullRequestCore extends GitHubPullRequestDetail {
2334+ /** Teams asked for a review. `reviewRequestLogins` holds the people. */
2335+ readonly reviewRequestTeams : ReadonlyArray < PullRequestActor > ;
23052336 readonly viewerAccess : GitHubViewerAccess & GitHubRepositoryAccess ;
23062337 readonly comparison : GitHubBaseComparison | null ;
23072338 readonly checksTruncated : boolean ;
@@ -2316,6 +2347,9 @@ export function decodePullRequestCoreJson(
23162347 const pr = repository . pullRequest ;
23172348 const contexts = pr . commits . nodes [ 0 ] ?. commit . statusCheckRollup ?. contexts ;
23182349 return Result . succeed ( {
2350+ reviewRequestTeams : pr . reviewRequests . nodes . flatMap (
2351+ ( { requestedReviewer } ) => toRequestedTeam ( requestedReviewer ) ?? [ ] ,
2352+ ) ,
23192353 ...toDetail ( {
23202354 ...pr ,
23212355 reviewRequests : pr . reviewRequests . nodes . flatMap ( ( { requestedReviewer } ) =>
@@ -2772,7 +2806,7 @@ export function decodeReviewThreadsJson(
27722806 ...( pullRequest . reviewRequests ?. nodes ?? [ ] ) . map ( ( node ) => node . requestedReviewer ) ,
27732807 ...( pullRequest . latestReviews ?. nodes ?? [ ] ) . map ( ( node ) => node . author ) ,
27742808 ] ) {
2775- const actor = toActor ( raw ) ;
2809+ const actor = toActor ( raw ) ?? toRequestedTeam ( raw ) ;
27762810 // Keyed by login, so someone who was asked and then answered appears once.
27772811 if ( actor !== null && ! reviewers . has ( actor . login ) ) reviewers . set ( actor . login , actor ) ;
27782812 }
@@ -2932,7 +2966,7 @@ export const REVIEWER_CANDIDATES_GRAPHQL_QUERY = `query($owner: String!, $name:
29322966 nodes {
29332967 requestedReviewer {
29342968 ... on User { login name avatarUrl }
2935- ... on Team { slug name avatarUrl }
2969+ ... on Team { slug combinedSlug name avatarUrl }
29362970 ... on Bot { login avatarUrl }
29372971 }
29382972 }
@@ -2941,12 +2975,6 @@ export const REVIEWER_CANDIDATES_GRAPHQL_QUERY = `query($owner: String!, $name:
29412975 }
29422976}` ;
29432977
2944- /** A team answers with a slug where a user answers with a login, and nothing else differs. */
2945- const RawRequestedReviewerSchema = Schema . Struct ( {
2946- ...RawActorSchema . fields ,
2947- slug : Schema . optional ( Schema . NullOr ( Schema . String ) ) ,
2948- } ) ;
2949-
29502978const RawReviewerCandidatesSchema = Schema . Struct ( {
29512979 data : Schema . Struct ( {
29522980 repository : Schema . Struct ( {
@@ -3004,7 +3032,8 @@ export function decodeReviewerCandidatesJson(
30043032 candidates . set ( `${ slug === null ? "user" : "team" } ${ id } ` , {
30053033 id,
30063034 kind : slug === null ? "user" : "team" ,
3007- login : id ,
3035+ // The same `org/slug` the reviewer row shows, so taking the request back finds that row.
3036+ login : slug === null ? id : ( trimmed ( raw ?. combinedSlug ) ?? id ) ,
30083037 name : trimmed ( raw ?. name ) ,
30093038 avatarUrl : trimmed ( raw ?. avatarUrl ) ,
30103039 isRequested : true ,
0 commit comments