@andrioid/paseo-attention-span 0.3.5 → 0.3.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -50,7 +50,7 @@ The tabs tell the story of my work, left to right: what I finished, what needs m
50
50
  |---|---|
51
51
  | History | The last `historyWeeks` (default 4) by week, newest first, in the device's time zone: issues assigned to me that closed, with the PRs that closed them, and my other merged PRs [HIS-01]. Per week, a collapsed "Reviewed (n)" lists others' merged PRs I reviewed [HIS-02]. The copy icon on a week's heading copies its finished items, not the reviews, as a Markdown list of links; an issue and the PRs that closed it are one line, linking the issue [HIS-03]. |
52
52
  | Doing | The sections below |
53
- | Waiting | My work where someone else has the next move [WAI-01]: *Waiting for review* (once a person or team is asked, or someone else has reviewed; with the requested reviewer or team), *Waiting for the reviewer* (after I replied or pushed), *CI running*, *Questions I asked* (threads where my comment is the last from a person; bots don't count): on my own issues however old, on others' only while my comment is within `mentionDays` [ATT-11] |
53
+ | Waiting | My work where someone else has the next move [WAI-01]: *Waiting for review* (once a person or team is asked, or someone else has reviewed; with the requested reviewer or team; or approved but blocked by a repo rule [PRS-13]), *Waiting for the reviewer* (after I replied or pushed), *CI running*, *Questions I asked* (threads where my comment is the last from a person; bots don't count): on my own issues however old, on others' only while my comment is within `mentionDays` [ATT-11] |
54
54
  | Next up | *Assigned to you* [NXT-06], then *Unclaimed* [NXT-01] |
55
55
 
56
56
  Every card in every tab is the same component, `CardRow` in `client/card.tsx` [ATT-05]: a tinted mark for what it is, a title of at most two lines, then "repo #number", when it happened and signal chips, then content only some lists have (tags, a quote, a stack line), and its actions: on the right on desktop, labelled under the text on phones. A change on GitHub asks first in a `ConfirmBar` on the card [SAFE-01]. Tabs differ only in what they pass in: each maps its data to the card's mark, meta, actions and slots. Marks and signals take a tone, never a raw theme color, because some themes draw `accent` close to white.
@@ -72,7 +72,7 @@ Top to bottom. Each item appears once, under its most urgent reason [ATT-02]. `s
72
72
  | Review requested | PRs requesting my review by name, not via a team [REV-01] |
73
73
  | CI failing | My PRs with failing checks [PRS-01] |
74
74
  | Changes requested | My PRs with requested changes or unresolved threads [PRS-02] |
75
- | Ready to merge | My approved, mergeable PRs [PRS-03] |
75
+ | Ready to merge | My approved PRs without conflicts or failing checks, that GitHub's rules let me merge [PRS-03, PRS-13] |
76
76
  | Needs upstream | My PRs with conflicts or an out-of-sync stack [UPS-01, UPS-02] |
77
77
  | Waiting too long | Waiting items older than `waitingTooLongDays` (default 3); it's mine to nudge [ATT-11] |
78
78
  | Needs a reviewer | My PRs nobody has been asked to review, even while CI runs [PRS-12] |
@@ -91,6 +91,8 @@ Top to bottom. Each item appears once, under its most urgent reason [ATT-02]. `s
91
91
  2. a stacked PR no longer builds on its parent's head,
92
92
  3. it is ready to merge (CI ran against an old base).
93
93
  Otherwise the behind count is shown on rows that appear anyway, but never puts an item on the list by itself. Its chip stays neutral; only conflicts are flagged, in red.
94
+ - **Repo rules** [PRS-13]: GitHub's `mergeStateStatus` says whether branch protection and rulesets let a PR merge now, but not which rule blocks it. Approvals already show in `reviewDecision`, conflicts in `mergeable`, and running CI blocks too, so a block only counts as a rule's when none of those explain it: an approved PR without conflicts, failing checks, requested changes or running CI. It then waits in Waiting for review with a "blocked by repo rules" chip, no Merge and no person, and never moves to Waiting too long. Needs a reviewer offers Merge only when GitHub doesn't say blocked. `UNKNOWN` (not computed yet) decides nothing.
95
+ - **Required checks** [PRS-14]: the details request asks which checks on each of my PRs the repo requires (`isRequired`). Where some are required, only they count: failing optional checks leave the PR ready with an "optional checks failing" chip, and optional ones still running don't hold up Merge. A required check that hasn't reported yet isn't listed, so GitHub blocking while CI runs counts as CI running. Where none are required, every check counts.
94
96
  - **Stale draft** [PRS-07]: a draft untouched for 30 days offers Refresh and Close instead of Rebase.
95
97
 
96
98
  ## Next up
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@andrioid/paseo-attention-span",
3
- "version": "0.3.5",
3
+ "version": "0.3.6",
4
4
  "description": "For when your attention is spread thin: the GitHub issues and pull requests waiting on you, grouped by why, with one-tap Paseo sessions.",
5
5
  "license": "MIT",
6
6
  "repository": {
package/requirements.yaml CHANGED
@@ -60,6 +60,8 @@ functional:
60
60
  PRS-10: turn on auto-merge for an approved pull request whose checks are still running; so that it ships without me waiting for CI.
61
61
  PRS-11: mark a healthy draft ready for review and pick its reviewers in one step; so that finished drafts reach reviewers.
62
62
  PRS-12: see my pull requests that nobody has been asked to review, and ask people or teams from there, or merge where nobody reviews; so that work doesn't sit as "waiting" when nobody has the next move.
63
+ PRS-13: see an approved pull request that the repo's rules still block as waiting, without Merge; so that Merge is offered only when GitHub would allow it.
64
+ PRS-14: have checks the repo doesn't require not hold up a pull request, where the repo requires others; so that a failing or slow optional check doesn't keep finished work from shipping.
63
65
  upstream:
64
66
  As a developer, I can:
65
67
  UPS-01: see my pull requests that conflict with their base; so that pull requests needing updates from upstream are easy to fix.
@@ -5,7 +5,7 @@ import type { Actor, Comment, Details, HistoryResult, IssueNode, LinkedIssue, Li
5
5
  import { excerpt, plainText } from "./markdown";
6
6
  import { prKey } from "./queries";
7
7
  import { issueFor } from "./references";
8
- import { ISSUE_RULES, type IssueState, pick, PR_RULES, type PrState, replyActions } from "./rules";
8
+ import { ISSUE_RULES, type IssueState, pick, PR_RULES, type PrState, replyActions, rulesBlock } from "./rules";
9
9
 
10
10
  // Turns one refresh worth of GitHub data into what needs me. Pure, so every rule is testable.
11
11
 
@@ -79,6 +79,14 @@ export function classify({ data, details, config, now }: ClassifyInput): Attenti
79
79
  const state = (pr: PullRequestNode) => {
80
80
  const commit = pr.commits.nodes[0]?.commit;
81
81
  const ci = commit?.statusCheckRollup?.state;
82
+ const anyFailing = ci === "FAILURE" || ci === "ERROR";
83
+ const anyPending = ci === "PENDING" || ci === "EXPECTED";
84
+ const mergeBlocked = pr.mergeStateStatus === "BLOCKED";
85
+ // Where the repo requires checks, only those count; one that hasn't reported yet shows as GitHub blocking while CI runs.
86
+ // Where it requires none, every check counts [PRS-14].
87
+ const required = details.checks[prKey(pr)];
88
+ const ciFailing = required?.required ? required.failing > 0 : anyFailing;
89
+ const ciPending = !ciFailing && (required?.required ? required.pending > 0 || (anyPending && mergeBlocked) : anyPending);
82
90
  const unresolved = pr.reviewThreads.nodes.filter((thread) => !thread.isResolved);
83
91
  const last = (thread: (typeof unresolved)[number]) => thread.comments.nodes.at(-1);
84
92
  const onMe = unresolved.filter((thread) => !isMe(last(thread)?.author));
@@ -86,9 +94,12 @@ export function classify({ data, details, config, now }: ClassifyInput): Attenti
86
94
  const changesRequestedAt = latest(...pr.latestReviews.nodes.filter((r) => r.state === "CHANGES_REQUESTED").map((r) => r.submittedAt));
87
95
  const behindBy = details.behind[prKey(pr)] ?? 0;
88
96
  return {
89
- ciFailing: ci === "FAILURE" || ci === "ERROR",
90
- ciPending: ci === "PENDING" || ci === "EXPECTED",
97
+ ciFailing,
98
+ ciPending,
99
+ optionalFailing: !ciFailing && anyFailing,
100
+ optionalPending: !ciFailing && !ciPending && anyPending,
91
101
  conflicts: pr.mergeable === "CONFLICTING",
102
+ mergeBlocked,
92
103
  approved: pr.reviewDecision === "APPROVED",
93
104
  // A request counts even when its reviewer can't be seen, like a team I can't read; so does any review [PRS-12].
94
105
  asked:
@@ -138,6 +149,7 @@ export function classify({ data, details, config, now }: ClassifyInput): Attenti
138
149
  changes: s.changes,
139
150
  approved: s.approved,
140
151
  conflicts: s.conflicts,
152
+ mergeBlocked: s.mergeBlocked,
141
153
  blocked: s.conflicts || outOfSync,
142
154
  autoMerge: s.autoMerge,
143
155
  autoMergeAllowed: !!bottom.repository.autoMergeAllowed,
@@ -152,6 +164,7 @@ export function classify({ data, details, config, now }: ClassifyInput): Attenti
152
164
  const section = pick(PR_RULES, flags) ?? "wait_review";
153
165
  const rule = PR_RULES[section];
154
166
  const actions = rule?.actions?.(flags) ?? [];
167
+ const rulesBlocked = rulesBlock(flags);
155
168
  // Who it waits on: the reviewer who asked for changes, else who's requested, else who reviewed.
156
169
  const reviewer = replied
157
170
  ? bottom.latestReviews.nodes.find((review) => review.state === "CHANGES_REQUESTED")?.author
@@ -162,12 +175,14 @@ export function classify({ data, details, config, now }: ClassifyInput): Attenti
162
175
  if (section === "too_long") chips.push(chip(`${rule?.label?.(flags)} · ${ago(waitingSince, now)}`, "warn"));
163
176
  if (bottom.isDraft && s.stale) chips.push(chip(`untouched ${ago(bottom.updatedAt, now)}`, "warn"));
164
177
  if (s.approved && !bottom.isDraft) chips.push(chip("approved", "good"));
178
+ if (rulesBlocked) chips.push(chip("blocked by repo rules", "warn"));
165
179
  if (s.autoMerge) chips.push(chip("auto-merge on", "good"));
166
180
  if (bottom.reviewDecision === "CHANGES_REQUESTED") chips.push(chip("changes requested", "warn"));
167
181
  if (s.threadsOnMe > 0) chips.push(chip(`${s.threadsOnMe} unresolved`, "warn"));
168
182
  if (s.ciFailing) chips.push(chip("CI failing", "bad"));
169
183
  else if (s.ciPending) chips.push(chip("CI running", "warn"));
170
- else if (section === "ready" && s.behindBy === 0) chips.push(chip("CI passed", "good"));
184
+ else if (s.optionalFailing) chips.push(chip("optional checks failing", "warn"));
185
+ else if (section === "ready" && s.behindBy === 0) chips.push(chip(s.optionalPending ? "required checks passed" : "CI passed", "good"));
171
186
  if (s.conflicts) chips.push(chip("conflicts", "bad"));
172
187
  if (s.behindBy > 0) chips.push(behindChip(s.behindBy, base));
173
188
  if (stack.length > 1) chips.push(chip(`stack of ${stack.length}`));
@@ -183,7 +198,8 @@ export function classify({ data, details, config, now }: ClassifyInput): Attenti
183
198
  waiting ??
184
199
  (section === "answered" ? answer : undefined) ??
185
200
  (section === "changes" && s.botThreadsOnly ? { login: "review bot", bot: true, since: s.lastCommitAt } : undefined) ??
186
- (section === "too_long" || SECTIONS[section].tab === "waiting" ? person(reviewer, waitingSince) : undefined),
201
+ // A rule, not a person, holds it up [PRS-13].
202
+ (!rulesBlocked && (section === "too_long" || SECTIONS[section].tab === "waiting") ? person(reviewer, waitingSince) : undefined),
187
203
  othersActivityAt: latest(...stack.map((pr) => state(pr).othersActivityAt), waiting?.since, answer?.since),
188
204
  };
189
205
  });
package/server/fixture.ts CHANGED
@@ -164,6 +164,11 @@ export function fixture(now: Date): { data: SearchResult; details: Details } {
164
164
  pr(125, { title: "Log slow database queries" }, "PENDING"),
165
165
  // A review that only commented keeps it waiting on that reviewer.
166
166
  pr(126, { title: "Tidy the admin menu", latestReviews: { nodes: [{ author: alice, state: "COMMENTED", submittedAt: daysAgo(0.8) }] } }),
167
+ // Approved and green, yet a repo rule blocks it, so it waits [PRS-13].
168
+ pr(127, { title: "Sign the release artifacts", reviewDecision: "APPROVED", mergeStateStatus: "BLOCKED" }),
169
+ // Only checks the repo doesn't require fail, or still run: ready all the same [PRS-14].
170
+ pr(128, { title: "Lazy-load product images", reviewDecision: "APPROVED", mergeStateStatus: "UNSTABLE" }, "FAILURE"),
171
+ pr(129, { title: "Compress API responses", reviewDecision: "APPROVED", mergeStateStatus: "UNSTABLE" }, "PENDING"),
167
172
  ],
168
173
  reviews: [pr(120, { title: "Add a status page", author: bob }), pr(121, { title: "Rework the cart totals", author: alice })],
169
174
  mentions: [
@@ -231,6 +236,7 @@ export function fixture(now: Date): { data: SearchResult; details: Details } {
231
236
  behind: { [key(103)]: 1, [key(106)]: 12, [key(108)]: 139, [key(110)]: 2307, [key(114)]: 3, [key(115)]: 40 },
232
237
  fieldOptions: { Priority: ["🌋 P0 Urgent", "🏔 P1 High", "🏕P2 Medium", "🏝 P3 Low"] },
233
238
  issues: { [key(132)]: { number: 132, title: "The calendar can't be used with a keyboard", url: `https://github.com/${REPO}/issues/132`, repository } },
239
+ checks: { [key(128)]: { required: 2, failing: 0, pending: 0 }, [key(129)]: { required: 1, failing: 0, pending: 0 } },
234
240
  },
235
241
  };
236
242
  }
@@ -47,6 +47,8 @@ export interface PullRequestNode {
47
47
  headRefOid: string;
48
48
  isCrossRepository?: boolean;
49
49
  mergeable: "MERGEABLE" | "CONFLICTING" | "UNKNOWN";
50
+ // GitHub's own answer to whether the repo's rules let it merge now; BLOCKED doesn't say which rule [PRS-13].
51
+ mergeStateStatus?: "BEHIND" | "BLOCKED" | "CLEAN" | "DIRTY" | "DRAFT" | "HAS_HOOKS" | "UNKNOWN" | "UNSTABLE";
50
52
  reviewDecision: "APPROVED" | "CHANGES_REQUESTED" | "REVIEW_REQUIRED" | null;
51
53
  autoMergeRequest?: { enabledAt: string } | null;
52
54
  assignees: Nodes<{ login: string }>;
@@ -131,6 +133,10 @@ export interface Details {
131
133
  fieldOptions: Record<string, string[]>;
132
134
  // "owner/name#number" -> the open issue my PRs' descriptions refer to; PRs and closed issues are left out [ATT-03].
133
135
  issues: Record<string, LinkedIssue>;
136
+ // "owner/name#number" -> the checks the repo requires on my PR's last commit, as far as they've reported [PRS-14].
137
+ checks: Record<string, RequiredChecks>;
134
138
  }
135
139
 
140
+ export type RequiredChecks = { required: number; failing: number; pending: number };
141
+
136
142
  export type LinkedIssue = { number: number; title: string; url: string; repository: Repo };
package/server/queries.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import type { UnclaimedSource } from "../shared/attention";
2
2
  import type { AttentionConfig } from "../shared/config";
3
- import type { PickableNode, PullRequestNode } from "./github-types";
3
+ import type { PickableNode, PullRequestNode, RequiredChecks } from "./github-types";
4
4
  import type { IssueRef } from "./references";
5
5
 
6
6
  // An issue or PR with its last conversation comments [ATT-16].
@@ -60,7 +60,7 @@ const FRAGMENTS: Record<string, string> = {
60
60
  id number title url body isDraft createdAt updatedAt
61
61
  author { ...author }
62
62
  repository { nameWithOwner squashMergeAllowed mergeCommitAllowed autoMergeAllowed defaultBranchRef { name } }
63
- baseRefName headRefName headRefOid isCrossRepository mergeable reviewDecision
63
+ baseRefName headRefName headRefOid isCrossRepository mergeable mergeStateStatus reviewDecision
64
64
  autoMergeRequest { enabledAt }
65
65
  assignees(first: 10) { nodes { login } }
66
66
  closingIssuesReferences(first: 5) { nodes { number title url repository { nameWithOwner } } }
@@ -181,15 +181,26 @@ const repository = (repo: string) => {
181
181
  return `repository(owner: ${JSON.stringify(owner)}, name: ${JSON.stringify(name)})`;
182
182
  };
183
183
 
184
- // After my PRs and Next up's issues: how far my PRs are behind their bases, the option order of org issue fields, and
185
- // what the issues my PRs' descriptions refer to are [GH-01, ATT-03].
184
+ // After my PRs and Next up's issues: how far my PRs are behind their bases, which of their checks the repo requires, the
185
+ // option order of org issue fields, and what the issues my PRs' descriptions refer to are [GH-01, ATT-03, PRS-14].
186
186
  export function detailsQuery(prs: PullRequestNode[], orgs: string[], refs: IssueRef[] = []): { query: string; compares: Record<string, string> } {
187
187
  const compares: Record<string, string> = {};
188
- const fields = prs.map((pr, index) => {
188
+ const fields = prs.flatMap((pr, index) => {
189
189
  compares[`c${index}`] = prKey(pr);
190
- return `c${index}: ${repository(pr.repository.nameWithOwner)} {
190
+ compares[`r${index}`] = prKey(pr);
191
+ const required = `isRequired(pullRequestNumber: ${pr.number})`;
192
+ // Apart from the compare, so a repo that won't say which checks are required costs only this field.
193
+ return [
194
+ `c${index}: ${repository(pr.repository.nameWithOwner)} {
191
195
  ref(qualifiedName: ${JSON.stringify(`refs/heads/${pr.baseRefName}`)}) { compare(headRef: ${JSON.stringify(pr.headRefName)}) { behindBy } }
192
- }`;
196
+ }`,
197
+ `r${index}: ${repository(pr.repository.nameWithOwner)} {
198
+ pullRequest(number: ${pr.number}) { commits(last: 1) { nodes { commit { statusCheckRollup { contexts(first: 100) { nodes {
199
+ ... on CheckRun { status conclusion ${required} }
200
+ ... on StatusContext { state ${required} }
201
+ } } } } } } }
202
+ }`,
203
+ ];
193
204
  });
194
205
  refs.forEach((ref, index) =>
195
206
  fields.push(`i${index}: ${repository(ref.repo)} {
@@ -203,3 +214,13 @@ export function detailsQuery(prs: PullRequestNode[], orgs: string[], refs: Issue
203
214
  );
204
215
  return { query: `query Details {\n${fields.join("\n")}\n}`, compares };
205
216
  }
217
+
218
+ export type CheckContext = { status?: string; conclusion?: string | null; state?: string; isRequired?: boolean };
219
+
220
+ // How the checks the repo requires stand. A check run passes as success, neutral or skipped, like GitHub counts it [PRS-14].
221
+ export function requiredChecks(contexts: CheckContext[]): RequiredChecks {
222
+ const required = contexts.filter((context) => context.isRequired);
223
+ const pending = (c: CheckContext) => (c.state ? c.state === "PENDING" || c.state === "EXPECTED" : c.status !== "COMPLETED");
224
+ const failing = (c: CheckContext) => (c.state ? c.state === "FAILURE" || c.state === "ERROR" : !pending(c) && !["SUCCESS", "NEUTRAL", "SKIPPED"].includes(c.conclusion ?? ""));
225
+ return { required: required.length, failing: required.filter(failing).length, pending: required.filter(pending).length };
226
+ }
package/server/rules.ts CHANGED
@@ -35,6 +35,8 @@ export interface PrState {
35
35
  changes: boolean;
36
36
  approved: boolean;
37
37
  conflicts: boolean;
38
+ // GitHub says the repo's rules block merging it now, for whatever reason [PRS-13].
39
+ mergeBlocked: boolean;
38
40
  // Conflicts, or a PR above it no longer builds on its parent [UPS-01, UPS-02].
39
41
  blocked: boolean;
40
42
  autoMerge: boolean;
@@ -50,6 +52,10 @@ export interface PrState {
50
52
  tooLong: boolean;
51
53
  }
52
54
 
55
+ // Approved and nothing I know of in the way, yet GitHub's rules still block it: signed commits, a required check that never
56
+ // reported, a resolved-conversations rule, and the like. Nothing for me to do here, so it waits [PRS-13].
57
+ export const rulesBlock = (s: PrState) => !s.draft && s.mergeBlocked && s.approved && !s.ciPending && !s.ciFailing && !s.changes && !s.conflicts;
58
+
53
59
  const waitingFor = (s: PrState) => (s.ciPending ? "CI running" : s.replied ? "waiting for the reviewer" : "waiting for review");
54
60
 
55
61
  // Merge only once CI passed against the current base [PRS-04, UPS-07]. Until then, auto-merge if the repo allows it [PRS-10].
@@ -74,19 +80,21 @@ export const PR_RULES: Rules<PrState> = {
74
80
  ci: { when: (s) => !s.draft && s.ciFailing, actions: () => ["fix", "rerun"] },
75
81
  changes: { when: (s) => !s.draft && s.changes, actions: () => ["address"] },
76
82
  // Auto-merge waiting on CI leaves nothing for me to do.
77
- ready: { when: (s) => !s.draft && s.approved && !s.conflicts && !s.ciFailing && !s.changes && !(s.autoMerge && s.ciPending), actions: readyActions },
83
+ // Blocked while CI runs counts as waiting on CI, which auto-merge covers [PRS-10, PRS-13].
84
+ ready: { when: (s) => !s.draft && s.approved && !s.conflicts && !s.ciFailing && !s.changes && !(s.autoMerge && s.ciPending) && !rulesBlock(s), actions: readyActions },
78
85
  upstream: { when: (s) => !s.draft && s.blocked, actions: () => ["rebase"] },
79
- // After too long it's mine to nudge [ATT-11].
80
- too_long: { when: (s) => !s.draft && s.asked && s.tooLong, label: waitingFor },
81
- // Mine until I ask someone, even while CI runs. Merge, for repos where nobody reviews, once CI passed on the current base [PRS-12, PRS-04].
86
+ // After too long it's mine to nudge [ATT-11]; a rule has no one to nudge [PRS-13].
87
+ too_long: { when: (s) => !s.draft && s.asked && s.tooLong && !rulesBlock(s), label: waitingFor },
88
+ // Mine until I ask someone, even while CI runs. Merge, for repos where nobody reviews, once CI passed on the current base
89
+ // and GitHub's rules allow it [PRS-12, PRS-04, PRS-13].
82
90
  needs_reviewer: {
83
91
  when: (s) => !s.draft && !s.asked,
84
- actions: (s) => (!s.ciFailing && !s.ciPending && s.behindBy === 0 ? ["request_review", "merge"] : ["request_review"]),
92
+ actions: (s) => (!s.ciFailing && !s.ciPending && s.behindBy === 0 && !s.mergeBlocked ? ["request_review", "merge"] : ["request_review"]),
85
93
  },
86
94
  drafts: { when: (s) => s.draft, actions: draftActions },
87
- // Otherwise it waits on others: CI, the reviewer after my reply, or a review [WAI-01].
88
- wait_review: { when: (s) => !s.draft && s.asked && !s.ciPending && !s.replied, label: waitingFor },
89
- wait_reviewer: { when: (s) => !s.draft && s.asked && !s.ciPending && s.replied, label: waitingFor },
95
+ // Otherwise it waits on others: CI, the reviewer after my reply, or a review [WAI-01]. Blocked by rules waits with reviews [PRS-13].
96
+ wait_review: { when: (s) => !s.draft && s.asked && !s.ciPending && (!s.replied || rulesBlock(s)), label: waitingFor },
97
+ wait_reviewer: { when: (s) => !s.draft && s.asked && !s.ciPending && s.replied && !rulesBlock(s), label: waitingFor },
90
98
  wait_ci: { when: (s) => !s.draft && s.asked && s.ciPending, label: waitingFor },
91
99
  };
92
100
 
package/server/service.ts CHANGED
@@ -5,7 +5,7 @@ import { classify, classifyHistory } from "./classify";
5
5
  import { FIXTURE, graphql } from "./gh";
6
6
  import { fixture, FIXTURE_AGENTS } from "./fixture";
7
7
  import type { Details, HistoryResult, LinkedIssue, LiveResult } from "./github-types";
8
- import { detailsQuery, HISTORY_SEARCHES, mergeUnclaimed, prKey, type SearchName, searchQuery, searchVariables, type UnclaimedSearch, unclaimedSearches } from "./queries";
8
+ import { type CheckContext, detailsQuery, HISTORY_SEARCHES, mergeUnclaimed, prKey, requiredChecks, type SearchName, searchQuery, searchVariables, type UnclaimedSearch, unclaimedSearches } from "./queries";
9
9
  import { toLookUp } from "./references";
10
10
  import { loadConfig, loadState, moveOldFiles, saveCodeRepo, saveCoverage, saveFollowThreads, saveNextUpSources, saveState, State } from "./store";
11
11
  import { applyPending, buildView, doneItem, type Effect, isPending, SETTLE_MS } from "./view";
@@ -252,7 +252,7 @@ export class AttentionService {
252
252
  return Object.fromEntries(names.map((name) => [name, all[name]]));
253
253
  }
254
254
 
255
- // Behind counts [UPS-07] and issue field option order [NXT-02].
255
+ // Behind counts [UPS-07], required checks [PRS-14] and issue field option order [NXT-02].
256
256
  private async details(data: Pick<LiveResult, "mine" | "assigned" | "unclaimed">): Promise<Details> {
257
257
  const prs = data.mine.nodes.filter((pr) => pr?.headRefName && !pr.isCrossRepository);
258
258
  const { priority, effort } = this.config.nextUp;
@@ -260,19 +260,22 @@ export class AttentionService {
260
260
  const issues = [...data.unclaimed.nodes, ...data.assigned.nodes];
261
261
  const orgs = needsOptions ? [...new Set(issues.map((issue) => issue?.repository?.nameWithOwner.split("/")[0]).filter(Boolean))] : [];
262
262
  const refs = toLookUp(data.mine.nodes.filter((pr) => pr?.repository));
263
- const details: Details = { behind: {}, fieldOptions: {}, issues: {} };
263
+ const details: Details = { behind: {}, fieldOptions: {}, issues: {}, checks: {} };
264
264
  if (prs.length === 0 && orgs.length === 0 && refs.length === 0) return details;
265
265
  const { query, compares } = detailsQuery(prs, orgs as string[], refs);
266
266
  type Result = {
267
267
  ref?: { compare: { behindBy: number } | null } | null;
268
268
  issueFields?: { nodes: { name?: string; options?: { name: string }[] }[] };
269
269
  issueOrPullRequest?: (LinkedIssue & { state?: string }) | null;
270
+ pullRequest?: { commits: { nodes: { commit: { statusCheckRollup: { contexts: { nodes: CheckContext[] } } | null } }[] } } | null;
270
271
  } | null;
271
272
  // A reference to a repo I can't see fails only its own field.
272
273
  const result = await graphql<Record<string, Result>>(query);
273
274
  for (const [alias, value] of Object.entries(result)) {
274
275
  const behindBy = value?.ref?.compare?.behindBy;
275
276
  if (typeof behindBy === "number") details.behind[compares[alias]] = behindBy;
277
+ const contexts = value?.pullRequest?.commits.nodes[0]?.commit.statusCheckRollup?.contexts.nodes;
278
+ if (contexts) details.checks[compares[alias]] = requiredChecks(contexts);
276
279
  for (const field of value?.issueFields?.nodes ?? []) if (field.name && field.options) details.fieldOptions[field.name] ??= field.options.map((o) => o.name);
277
280
  const issue = value?.issueOrPullRequest; // empty for a PR
278
281
  if (issue?.state === "OPEN") details.issues[prKey(issue)] = { number: issue.number, title: issue.title, url: issue.url, repository: issue.repository };