feat(server): agents can watch a PR and get woken when checks, reviews, or conflicts need them (#15057)

Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
This commit is contained in:
Theo BrowneandClaude Opus 5.5 authored and GitHub committed 2026-10-03 03:08:44 -07:00
1 parent e8545b293b
commit 18b21325c3
31 files changed
+1531 -39

No files matched your search

@@ -93,6 +93,8 @@ const RawCheckSchema = Schema.Struct({
workflowName: Schema.optional(Schema.NullOr(Schema.String)),
startedAt: Schema.optional(Schema.NullOr(Schema.String)),
completedAt: Schema.optional(Schema.NullOr(Schema.String)),
/** Branch protection requires this check; read by the detail query on github.com only. */
isRequired: Schema.optional(Schema.NullOr(Schema.Boolean)),
});
const RawListItemSchema = Schema.Struct({
@@ -706,8 +708,15 @@ export const PULL_REQUEST_LIST_JSON_FIELDS =
export const PULL_REQUEST_DETAIL_JSON_FIELDS = `${PULL_REQUEST_LIST_JSON_FIELDS},body,changedFiles,closedAt,isCrossRepository,headRepositoryOwner,headRefOid,autoMergeRequest`;
/** Pull refs let the comparison share the detail read without first resolving a fork branch. */
export const PULL_REQUEST_CORE_GRAPHQL_QUERY = `query($owner: String!, $name: String!, $number: Int!, $headRef: String!) {
/**
* Pull refs let the comparison share the detail read without first resolving a fork branch.
* `isRequired` is asked for on github.com only: an older Enterprise server may not know it, and
* an unknown field fails the whole read.
*/
export const pullRequestCoreGraphQlQuery = (host: string) => {
const required =
host.toLowerCase() === "github.com" ? " isRequired(pullRequestNumber: $number)" : "";
return `query($owner: String!, $name: String!, $number: Int!, $headRef: String!) {
repository(owner: $owner, name: $name) {
mergeCommitAllowed squashMergeAllowed rebaseMergeAllowed viewerPermission
pullRequest(number: $number) {
@@ -727,9 +736,9 @@ export const PULL_REQUEST_CORE_GRAPHQL_QUERY = `query($owner: String!, $name: St
nodes { commit { statusCheckRollup { contexts(first: 100) {
nodes {
__typename
... on StatusContext { context state targetUrl createdAt description }
... on StatusContext { context state targetUrl createdAt description${required} }
... on CheckRun {
name status conclusion startedAt completedAt detailsUrl
name status conclusion startedAt completedAt detailsUrl${required}
checkSuite { workflowRun { workflow { name } } }
}
}
@@ -739,6 +748,7 @@ export const PULL_REQUEST_CORE_GRAPHQL_QUERY = `query($owner: String!, $name: St
}
}
}`;
};
export const PULL_REQUEST_PREVIEW_GRAPHQL_QUERY = `query($owner: String!, $name: String!, $number: Int!) {
repository(owner: $owner, name: $name) {
@@ -1468,6 +1478,7 @@ function toCheckEntries(
status: toCheckStatus(check),
description: trimmed(check.description),
url: trimmed(check.detailsUrl) ?? trimmed(check.targetUrl),
...(typeof check.isRequired === "boolean" ? { required: check.isRequired } : {}),
},
workflowName: trimmed(check.workflowName),
at: realTimestamp(check.completedAt) ?? realTimestamp(check.startedAt),