@andrioid/paseo-attention-span 0.4.0 → 0.4.1

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; 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, and my comments since someone else last spoke ask something: a question mark outside quotes, code and links, read from GitHub's rendered comments (`bodyHTML`) so code and links count however they were written; a statement, tagged or not, waits on nobody and isn't listed): on my own issues however old, on others' only while my comment is within `mentionDays` [ATT-11]. Each shows who it waits on, never a guess [WAI-02]: on a PR, the reviewers currently requested and, after I replied, whoever requested changes, but nobody when a repo rule blocks it; on a question, the people and teams my comments since the last answer tag, read from GitHub's rendered comments (`bodyHTML`), where only real accounts and teams I can see are linked, never in code; tags in quotes don't count, and only the last 10 comments are read. Waiting groups it all by who it waits on, not by those reasons [WAI-01]: one group per person or team (a person tagged with other capitals is one), whoever blocks the most items first, ties by whose oldest item has waited longest, then requested bots, who can't be nudged, and last *Not on a person* for work nobody is on record for. In each group, work with a session that needs me leads, then one that's working, then the rest, oldest first; a finished session I've seen doesn't lift it. Work waiting on several is under each, saying "also waiting on" the rest, and counts once in the tab. *Waiting too long* items show here too, flagged "waited too long". Each card says why it waits (review, re-review, question, or nobody asked again after a review that only commented; nothing where its chips say, like approved, blocked by repo rules, or CI running with nobody asked) and since when. A group's **Copy list** copies its items oldest first as a Markdown list, each line led by why and how long ("- Review 2h: [title](url)"), for a nudge; a requested bot gets none [WAI-03]. Outside Waiting, as in *Waiting too long*, one person shows by name, several by picture, named on hover and in the sheet. |
53
+ | Waiting | My work where someone else has the next move [WAI-01]: *Waiting for review* (while GitHub records a review as owed: a pending request, or an approval or requested changes; 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, and my comments since someone else last spoke ask something: a question mark outside quotes, code and links, read from GitHub's rendered comments (`bodyHTML`) so code and links count however they were written; a statement, tagged or not, waits on nobody and isn't listed): on my own issues however old, on others' only while my comment is within `mentionDays` [ATT-11]. Each shows who it waits on, never a guess [WAI-02]: on a PR, the reviewers currently requested and, after I replied, whoever requested changes, but nobody when a repo rule blocks it; on a question, the people and teams my comments since the last answer tag, read from GitHub's rendered comments (`bodyHTML`), where only real accounts and teams I can see are linked, never in code; tags in quotes don't count, and only the last 10 comments are read. Waiting groups it all by who it waits on, not by those reasons [WAI-01]: one group per person or team (a person tagged with other capitals is one), whoever blocks the most items first, ties by whose oldest item has waited longest, then requested bots, who can't be nudged, and last *Not on a person* for work nobody is on record for. In each group, work with a session that needs me leads, then one that's working, then the rest, oldest first; a finished session I've seen doesn't lift it. Work waiting on several is under each, saying "also waiting on" the rest, and counts once in the tab. *Waiting too long* items show here too, flagged "waited too long". Each card says why it waits (review, re-review or question; nothing where its chips say, like approved, blocked by repo rules, or CI running) and since when. A group's **Copy list** copies its items oldest first as a Markdown list, each line led by why and how long ("- Review 2h: [title](url)"), for a nudge; a requested bot gets none [WAI-03]. Outside Waiting, as in *Waiting too long*, one person shows by name, several by picture, named on hover and in the sheet. |
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.
@@ -75,7 +75,7 @@ Top to bottom. Each item appears once, under its most urgent reason [ATT-02]. `s
75
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
- | Needs a reviewer | My PRs nobody has been asked to review, even while CI runs [PRS-12] |
78
+ | Needs a reviewer | My PRs nobody has been asked to review, even while CI runs [PRS-12]. Only what GitHub records counts as asked: a pending request, an approval or requested changes. GitHub drops a reviewer's request once they review, so a review that only commented, by a person or a bot, leaves it here to re-request; the repo, not us, decides whose approval counts |
79
79
  | My drafts | My drafts, with their own state tags [PRS-05, PRS-06] |
80
80
 
81
81
  ## Rules
@@ -91,7 +91,7 @@ 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.
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. GitHub works out the merge state for at most five PRs per request; asked about more, through search, a repo's PR list or aliases alike, it says `BLOCKED` for all of them (seen 2026-11-04). So the state is asked five PRs per request, in parallel, and search's answer is only the fallback when a request fails.
95
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.
96
96
  - **Stale draft** [PRS-07]: a draft untouched for 30 days offers Refresh and Close instead of Rebase.
97
97
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@andrioid/paseo-attention-span",
3
- "version": "0.4.0",
3
+ "version": "0.4.1",
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": {
@@ -94,7 +94,8 @@ export function classify({ data, details, config, now }: ClassifyInput): Attenti
94
94
  const ci = commit?.statusCheckRollup?.state;
95
95
  const anyFailing = ci === "FAILURE" || ci === "ERROR";
96
96
  const anyPending = ci === "PENDING" || ci === "EXPECTED";
97
- const mergeBlocked = pr.mergeStateStatus === "BLOCKED";
97
+ // Asked a few PRs at a time where we could; search's answer is BLOCKED for all once there are more than a few [PRS-13].
98
+ const mergeBlocked = (details.mergeState[prKey(pr)] ?? pr.mergeStateStatus) === "BLOCKED";
98
99
  // Where the repo requires checks, only those count; one that hasn't reported yet shows as GitHub blocking while CI runs.
99
100
  // Where it requires none, every check counts [PRS-14].
100
101
  const required = details.checks[prKey(pr)];
@@ -114,12 +115,10 @@ export function classify({ data, details, config, now }: ClassifyInput): Attenti
114
115
  conflicts: pr.mergeable === "CONFLICTING",
115
116
  mergeBlocked,
116
117
  approved: pr.reviewDecision === "APPROVED",
117
- // A request counts even when its reviewer can't be seen, like a team I can't read; so does any review [PRS-12].
118
- asked:
119
- pr.reviewRequests.nodes.length > 0 ||
120
- pr.latestReviews.nodes.some((review) => isOther(review.author)) ||
121
- pr.reviewDecision === "APPROVED" ||
122
- pr.reviewDecision === "CHANGES_REQUESTED",
118
+ // Only what GitHub records as owed: a pending request, even one whose reviewer I can't see, or a decision. Who has
119
+ // reviewed doesn't count; GitHub drops a reviewer's request once they review, so a comment leaves the next move to
120
+ // me. The repo decides what counts as a review, not us [PRS-12].
121
+ asked: pr.reviewRequests.nodes.length > 0 || pr.reviewDecision === "APPROVED" || pr.reviewDecision === "CHANGES_REQUESTED",
123
122
  autoMerge: !!pr.autoMergeRequest,
124
123
  threadsOnMe: onMe.length,
125
124
  botThreadsOnly: onMe.length > 0 && onMe.every((thread) => (thread.opener?.nodes[0] ?? last(thread))?.author?.__typename === "Bot"),
@@ -194,9 +193,7 @@ export function classify({ data, details, config, now }: ClassifyInput): Attenti
194
193
  : "review"
195
194
  : rulesBlocked || s.approved || s.ciPending
196
195
  ? undefined
197
- : bottom.reviewRequests.nodes.length > 0
198
- ? "review"
199
- : "nobody asked again";
196
+ : "review";
200
197
 
201
198
  const chips: Chip[] = [];
202
199
  if (bottom.isDraft && s.stale) chips.push(chip(`untouched ${ago(bottom.updatedAt, now)}`, "warn"));
package/server/fixture.ts CHANGED
@@ -166,7 +166,7 @@ export function fixture(now: Date): { data: SearchResult; details: Details } {
166
166
  // Nobody asked yet: green, so Merge too; and one still in CI [PRS-12].
167
167
  pr(124, { title: "Export invoices as CSV", commits: commit("SUCCESS", 0.5) }),
168
168
  pr(125, { title: "Log slow database queries" }, "PENDING"),
169
- // A review that only commented, and nobody asked again: it waits, on nobody in particular [WAI-02].
169
+ // A review that only commented, and nobody asked again: GitHub says nobody owes a look, so it's mine to re-request [PRS-12].
170
170
  pr(126, { title: "Tidy the admin menu", latestReviews: { nodes: [{ author: alice, state: "COMMENTED", submittedAt: daysAgo(0.8) }] } }),
171
171
  // Approved and green, yet a repo rule blocks it, so it waits [PRS-13].
172
172
  pr(127, { title: "Sign the release artifacts", reviewDecision: "APPROVED", mergeStateStatus: "BLOCKED" }),
@@ -252,6 +252,7 @@ export function fixture(now: Date): { data: SearchResult; details: Details } {
252
252
  fieldOptions: { Priority: ["🌋 P0 Urgent", "🏔 P1 High", "🏕P2 Medium", "🏝 P3 Low"] },
253
253
  issues: { [key(132)]: { number: 132, title: "The calendar can't be used with a keyboard", url: `https://github.com/${REPO}/issues/132`, repository } },
254
254
  checks: { [key(128)]: { required: 2, failing: 0, pending: 0 }, [key(129)]: { required: 1, failing: 0, pending: 0 } },
255
+ mergeState: {},
255
256
  },
256
257
  };
257
258
  }
@@ -50,7 +50,8 @@ export interface PullRequestNode {
50
50
  isCrossRepository?: boolean;
51
51
  mergeable: "MERGEABLE" | "CONFLICTING" | "UNKNOWN";
52
52
  // GitHub's own answer to whether the repo's rules let it merge now; BLOCKED doesn't say which rule [PRS-13].
53
- mergeStateStatus?: "BEHIND" | "BLOCKED" | "CLEAN" | "DIRTY" | "DRAFT" | "HAS_HOOKS" | "UNKNOWN" | "UNSTABLE";
53
+ // Wrong when a request asks about more than a few PRs, as search does, so Details' answer comes first.
54
+ mergeStateStatus?: MergeStateStatus;
54
55
  reviewDecision: "APPROVED" | "CHANGES_REQUESTED" | "REVIEW_REQUIRED" | null;
55
56
  autoMergeRequest?: { enabledAt: string } | null;
56
57
  assignees: Nodes<{ login: string }>;
@@ -137,8 +138,12 @@ export interface Details {
137
138
  issues: Record<string, LinkedIssue>;
138
139
  // "owner/name#number" -> the checks the repo requires on my PR's last commit, as far as they've reported [PRS-14].
139
140
  checks: Record<string, RequiredChecks>;
141
+ // "owner/name#number" -> my PR's merge state, asked a few PRs at a time: asked about more, GitHub says BLOCKED [PRS-13].
142
+ mergeState: Record<string, MergeStateStatus>;
140
143
  }
141
144
 
145
+ export type MergeStateStatus = "BEHIND" | "BLOCKED" | "CLEAN" | "DIRTY" | "DRAFT" | "HAS_HOOKS" | "UNKNOWN" | "UNSTABLE";
146
+
142
147
  export type RequiredChecks = { required: number; failing: number; pending: number };
143
148
 
144
149
  export type LinkedIssue = { number: number; title: string; url: string; repository: Repo };
package/server/queries.ts CHANGED
@@ -215,6 +215,20 @@ export function detailsQuery(prs: PullRequestNode[], orgs: string[], refs: Issue
215
215
  return { query: `query Details {\n${fields.join("\n")}\n}`, compares };
216
216
  }
217
217
 
218
+ // GitHub works out at most this many PRs' merge state per request; asked about more, it says BLOCKED for all of them, even
219
+ // in search and in a repo's PR list. Seen on 2026-11-04 [PRS-13].
220
+ export const MERGE_STATE_BATCH = 5;
221
+
222
+ // The merge state of up to MERGE_STATE_BATCH PRs, in one request; m0, m1, … map back to their keys.
223
+ export function mergeStateQuery(prs: PullRequestNode[]): { query: string; keys: Record<string, string> } {
224
+ const keys: Record<string, string> = {};
225
+ const fields = prs.map((pr, index) => {
226
+ keys[`m${index}`] = prKey(pr);
227
+ return `m${index}: ${repository(pr.repository.nameWithOwner)} { pullRequest(number: ${pr.number}) { mergeStateStatus } }`;
228
+ });
229
+ return { query: `query MergeState {\n${fields.join("\n")}\n}`, keys };
230
+ }
231
+
218
232
  export type CheckContext = { status?: string; conclusion?: string | null; state?: string; isRequired?: boolean };
219
233
 
220
234
  // How the checks the repo requires stand. A check run passes as success, neutral or skipped, like GitHub counts it [PRS-14].
package/server/service.ts CHANGED
@@ -4,8 +4,8 @@ import { AttentionConfig, githubRepoOf } from "../shared/config";
4
4
  import { classify, classifyHistory } from "./classify";
5
5
  import { FIXTURE, graphql } from "./gh";
6
6
  import { fixture, FIXTURE_AGENTS } from "./fixture";
7
- import type { Details, HistoryResult, LinkedIssue, LiveResult } from "./github-types";
8
- import { type CheckContext, detailsQuery, HISTORY_SEARCHES, mergeUnclaimed, prKey, requiredChecks, type SearchName, searchQuery, searchVariables, type UnclaimedSearch, unclaimedSearches } from "./queries";
7
+ import type { Details, HistoryResult, LinkedIssue, LiveResult, MergeStateStatus, PullRequestNode } from "./github-types";
8
+ import { type CheckContext, detailsQuery, HISTORY_SEARCHES, MERGE_STATE_BATCH, mergeStateQuery, 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";
@@ -260,8 +260,9 @@ 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: {}, checks: {} };
264
- if (prs.length === 0 && orgs.length === 0 && refs.length === 0) return details;
263
+ const mergeStates = this.mergeStates(data.mine.nodes.filter((pr) => pr?.repository));
264
+ const details: Details = { behind: {}, fieldOptions: {}, issues: {}, checks: {}, mergeState: {} };
265
+ if (prs.length === 0 && orgs.length === 0 && refs.length === 0) return { ...details, mergeState: await mergeStates };
265
266
  const { query, compares } = detailsQuery(prs, orgs as string[], refs);
266
267
  type Result = {
267
268
  ref?: { compare: { behindBy: number } | null } | null;
@@ -280,7 +281,21 @@ export class AttentionService {
280
281
  const issue = value?.issueOrPullRequest; // empty for a PR
281
282
  if (issue?.state === "OPEN") details.issues[prKey(issue)] = { number: issue.number, title: issue.title, url: issue.url, repository: issue.repository };
282
283
  }
283
- return details;
284
+ return { ...details, mergeState: await mergeStates };
285
+ }
286
+
287
+ // My PRs' merge state, a few per request in parallel, as GitHub only works it out for a few at a time; search's answer
288
+ // for more is BLOCKED for all [PRS-13]. A request that fails leaves its PRs to search's answer.
289
+ private async mergeStates(prs: PullRequestNode[]): Promise<Details["mergeState"]> {
290
+ const batches = Array.from({ length: Math.ceil(prs.length / MERGE_STATE_BATCH) }, (_, i) => prs.slice(i * MERGE_STATE_BATCH, (i + 1) * MERGE_STATE_BATCH));
291
+ const results = await Promise.all(
292
+ batches.map(async (batch) => {
293
+ const { query, keys } = mergeStateQuery(batch);
294
+ const result = await graphql<Record<string, { pullRequest: { mergeStateStatus?: MergeStateStatus } | null } | null>>(query).catch(() => ({}) as Record<string, never>);
295
+ return Object.entries(result).flatMap(([alias, value]) => (value?.pullRequest?.mergeStateStatus ? [[keys[alias], value.pullRequest.mergeStateStatus] as const] : []));
296
+ }),
297
+ );
298
+ return Object.fromEntries(results.flat());
284
299
  }
285
300
 
286
301
  private async reloadConfig(): Promise<void> {