@andrioid/paseo-attention-span 0.4.7 → 0.4.8

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.
@@ -4,7 +4,7 @@ import { Markdown, Modal, TextInput, useToast } from "@getpaseo/plugin/client/ui
4
4
  import { useQuery, useQueryClient } from "@tanstack/react-query";
5
5
  import { type ReactNode, useState } from "react";
6
6
  import { Pressable, ScrollView, Text, View } from "react-native";
7
- import { type ActionId, type AgentSummary, type AttentionView, type Chip, checkoutPr, type FailingChecks, type Item, itemSessions, liftActive, looseSessions, type NextUpIssue, ownStack, type Reviewer, type Section, type SectionId, SECTIONS, type SubRow, TAB_FEED, type TabId, type Target, type WaitingGroup, type WaitingOn } from "../shared/attention";
7
+ import { type ActionId, type AgentSummary, type AttentionView, type Chip, checkoutPr, type FailingChecks, type Item, itemSessions, liftActive, looseSessions, type NextUpIssue, ownStack, type PersonRole, type Reviewer, type Section, type SectionId, SECTIONS, type SubRow, TAB_FEED, type TabId, type Target, type WaitingGroup, type WaitingOn } from "../shared/attention";
8
8
  import { type AttentionConfig, nextUpSources, type SessionKind } from "../shared/config";
9
9
  import { ago, linkList, repoLabel } from "../shared/format";
10
10
  import { isClear } from "../shared/still";
@@ -314,7 +314,9 @@ function AttentionList({
314
314
  const feed = view.feeds[TAB_FEED[tab]];
315
315
  // Calm only once a refresh that worked says Doing is empty [ATT-18].
316
316
  const clear = isClear(view, !!attention.error);
317
- const refreshing = feed.refreshing || attention.isFetching;
317
+ // ⟳ turns for any refresh of this tab's feed, but only my own press locks it: the cached view can still say a background one runs after it's done.
318
+ const pressed = attention.isRefreshing(TAB_FEED[tab]);
319
+ const refreshing = feed.refreshing || attention.isFetching || pressed;
318
320
  const counts: Record<TabId, number> = {
319
321
  history: view.history.filter((item) => item.section === "done").length,
320
322
  doing: view.count,
@@ -389,7 +391,8 @@ function AttentionList({
389
391
  <Pressable
390
392
  accessibilityRole="button"
391
393
  accessibilityLabel="Refresh now"
392
- accessibilityState={{ busy: refreshing }}
394
+ accessibilityState={{ busy: refreshing, disabled: pressed }}
395
+ disabled={pressed}
393
396
  style={styles.row}
394
397
  onPress={() => void attention.refreshNow(TAB_FEED[tab]).catch(() => {})}
395
398
  >
@@ -597,7 +600,7 @@ function ItemRow({ item, first, actions, group }: { item: Item; first: boolean;
597
600
  const chips = sessions[0] ? [...own, agentSignal(sessions[0])] : own;
598
601
  // The group names one; the card names the rest [WAI-01].
599
602
  const others = group?.who ? (item.waitingOn ?? []).filter((who) => !samePerson(who, group.who!)) : [];
600
- const waitingOn = group ? null : item.waitingOn ? <WaitingOnLine people={item.waitingOn} expanded={false} /> : null;
603
+ const waitingOn = group ? null : item.waitingOn ? <WaitingOnLine people={item.waitingOn} asked={item.wait?.reason === "question"} expanded={false} /> : null;
601
604
  const alsoOn = others.length ? <Text style={styles.muted}>also waiting on {others.map((who) => who.login).join(", ")}</Text> : null;
602
605
  const [sheet, setSheet] = useState<Sheet>(null);
603
606
  const [confirm, setConfirm] = useState<"merge" | "close" | null>(null);
@@ -717,7 +720,7 @@ function ItemSheet({ item, chips, sessions, actions, ...handlers }: { item: Item
717
720
  <>
718
721
  <Meta facts={meta} chips={chips} />
719
722
  {item.person ? <PersonQuote person={item.person} expanded /> : null}
720
- {item.waitingOn ? <WaitingOnLine people={item.waitingOn} expanded /> : null}
723
+ {item.waitingOn ? <WaitingOnLine people={item.waitingOn} asked={item.wait?.reason === "question"} expanded /> : null}
721
724
  {item.children.length > 0 ? <StackLine rows={item.children} merged={!!item.closedAt} links /> : null}
722
725
  </>
723
726
  }
@@ -922,13 +925,61 @@ function ReviewerSheet({
922
925
  );
923
926
  }
924
927
 
928
+ // What a face on a card is to it, where no quote says it: the icon of the tab or section that means the same, so whom I wait on
929
+ // reads like Waiting, and whose comments are left like Changes requested [ATT-19].
930
+ const ROLE_ICON: Record<PersonRole | "waiting", IconName> = { waiting: "hourglass", author: "pencil", changes: "changes" };
931
+
932
+ // A line that says what it means in words on hover, and to screen readers; phones rely on the icon [ATT-19]. The words sit
933
+ // beside the line in its flow, not floating over it, so a card's clipping can't cut them off: they wrap where space runs out.
934
+ function Explained({ text, children }: { text: string; children: ReactNode }) {
935
+ const styles = useStyles();
936
+ const [hovered, setHovered] = useState(false);
937
+ return (
938
+ <View accessibilityLabel={text} onPointerEnter={() => setHovered(true)} onPointerLeave={() => setHovered(false)} style={{ alignSelf: "flex-start", flexDirection: "row", alignItems: "center", gap: 8 }}>
939
+ <View style={{ flexShrink: 0 }}>{children}</View>
940
+ {hovered ? (
941
+ <View style={{ flexShrink: 1, backgroundColor: styles.c.surface2, borderColor: styles.c.border, borderWidth: 1, borderRadius: 6, paddingVertical: 2, paddingHorizontal: 8 }}>
942
+ <Text style={{ color: styles.c.foreground, fontSize: 12 }}>{text}</Text>
943
+ </View>
944
+ ) : null}
945
+ </View>
946
+ );
947
+ }
948
+
949
+ // The icon sits tight against the faces it explains, apart from the name and time, so they read as one.
950
+ function Badged({ role, children }: { role: keyof typeof ROLE_ICON; children: ReactNode }) {
951
+ const styles = useStyles();
952
+ return (
953
+ <View style={{ flexDirection: "row", alignItems: "center", gap: 2 }}>
954
+ <TablerIcon name={ROLE_ICON[role]} size={16} color={styles.c.foregroundMuted} />
955
+ {children}
956
+ </View>
957
+ );
958
+ }
959
+
925
960
  // Who is waiting on me, or who I'm waiting on.
926
961
  function PersonQuote({ person, expanded }: { person: NonNullable<Item["person"]>; expanded: boolean }) {
927
962
  const styles = useStyles();
963
+ const name = <Text style={{ color: styles.c.foreground, fontSize: 12, fontWeight: "600" }}>{person.login}</Text>;
964
+ // An author line says who, not when: its time meant something different on each tab [ATT-19].
965
+ if (!person.snippet && person.role) {
966
+ const text = person.role === "author" ? `Opened by ${person.login}` : `${person.login}'s comments are left to address, since your last push ${ago(person.since)} ago`;
967
+ return (
968
+ <Explained text={text}>
969
+ <View style={styles.row}>
970
+ <Badged role={person.role}>
971
+ <Avatar url={person.avatarUrl} bot={person.bot} />
972
+ </Badged>
973
+ {name}
974
+ {person.role === "author" ? null : <Text style={styles.muted}>· {ago(person.since)}</Text>}
975
+ </View>
976
+ </Explained>
977
+ );
978
+ }
928
979
  const line = (
929
980
  <View style={styles.row}>
930
981
  <Avatar url={person.avatarUrl} bot={person.bot} />
931
- <Text style={{ color: styles.c.foreground, fontSize: 12, fontWeight: "600" }}>{person.login}</Text>
982
+ {name}
932
983
  <Text style={styles.muted}>· {ago(person.since)}</Text>
933
984
  </View>
934
985
  );
@@ -947,7 +998,8 @@ function PersonQuote({ person, expanded }: { person: NonNullable<Item["person"]>
947
998
  const MAX_FACES = 5;
948
999
 
949
1000
  // Who my work waits on: one by name, several by picture, named on hover, and each by name in the sheet [WAI-02].
950
- function WaitingOnLine({ people, expanded }: { people: WaitingOn[]; expanded: boolean }) {
1001
+ // On an issue they're who my question tagged; on a PR, reviewers since my last push or reply [WAI-02, ATT-19].
1002
+ function WaitingOnLine({ people, asked, expanded }: { people: WaitingOn[]; asked: boolean; expanded: boolean }) {
951
1003
  const styles = useStyles();
952
1004
  const [hovered, setHovered] = useState<string | null>(null);
953
1005
  const name = (login: string) => (
@@ -956,33 +1008,42 @@ function WaitingOnLine({ people, expanded }: { people: WaitingOn[]; expanded: bo
956
1008
  </Text>
957
1009
  );
958
1010
  const since = (at: string) => <Text style={styles.muted}>· {ago(at)}</Text>;
1011
+ const explain = (logins: string[], at: string) => `Waiting on ${logins.join(", ")} since ${asked ? "you asked" : "your last push or reply"}, ${ago(at)} ago`;
959
1012
  if (expanded || people.length === 1) {
960
1013
  return (
961
1014
  <View style={{ gap: 6 }}>
962
1015
  {people.map((who) => (
963
- <View key={who.login} style={styles.row}>
964
- <Avatar url={who.avatarUrl} team={who.team} />
965
- {name(who.login)}
966
- {since(who.since)}
967
- </View>
1016
+ <Explained key={who.login} text={explain([who.login], who.since)}>
1017
+ <View style={styles.row}>
1018
+ <Badged role="waiting">
1019
+ <Avatar url={who.avatarUrl} team={who.team} />
1020
+ </Badged>
1021
+ {name(who.login)}
1022
+ {since(who.since)}
1023
+ </View>
1024
+ </Explained>
968
1025
  ))}
969
1026
  </View>
970
1027
  );
971
1028
  }
972
1029
  const earliest = people.map((who) => who.since).sort()[0];
973
1030
  return (
974
- <View style={styles.row} accessibilityLabel={`Waiting on ${people.map((who) => who.login).join(", ")}`}>
975
- <View style={{ flexDirection: "row", alignItems: "center", gap: 4 }}>
976
- {people.slice(0, MAX_FACES).map((who) => (
977
- <View key={who.login} onPointerEnter={() => setHovered(who.login)} onPointerLeave={() => setHovered((current) => (current === who.login ? null : current))}>
978
- <Avatar url={who.avatarUrl} team={who.team} />
1031
+ <Explained text={explain(people.map((who) => who.login), earliest)}>
1032
+ <View style={styles.row}>
1033
+ <Badged role="waiting">
1034
+ <View style={{ flexDirection: "row", alignItems: "center", gap: 4 }}>
1035
+ {people.slice(0, MAX_FACES).map((who) => (
1036
+ <View key={who.login} onPointerEnter={() => setHovered(who.login)} onPointerLeave={() => setHovered((current) => (current === who.login ? null : current))}>
1037
+ <Avatar url={who.avatarUrl} team={who.team} />
1038
+ </View>
1039
+ ))}
1040
+ {people.length > MAX_FACES ? <Text style={styles.muted}>+{people.length - MAX_FACES}</Text> : null}
979
1041
  </View>
980
- ))}
981
- {people.length > MAX_FACES ? <Text style={styles.muted}>+{people.length - MAX_FACES}</Text> : null}
1042
+ </Badged>
1043
+ {hovered ? name(hovered) : null}
1044
+ {since(earliest)}
982
1045
  </View>
983
- {hovered ? name(hovered) : null}
984
- {since(earliest)}
985
- </View>
1046
+ </Explained>
986
1047
  );
987
1048
  }
988
1049
 
package/client/data.ts CHANGED
@@ -1,10 +1,11 @@
1
1
  import { useRpc } from "@getpaseo/plugin/client";
2
- import { useQuery, useQueryClient } from "@tanstack/react-query";
2
+ import { useMutation, useMutationState, useQuery, useQueryClient } from "@tanstack/react-query";
3
3
  import { useCallback } from "react";
4
4
  import type { AttentionView, FeedId } from "../shared/attention";
5
5
  import { getAttention } from "../shared/rpc";
6
6
 
7
7
  export const VIEW_QUERY_KEY = ["attention-span", "view"] as const;
8
+ const REFRESH_KEY = ["attention-span", "refresh"] as const;
8
9
 
9
10
  // The server owns the GitHub refresh schedule; the app only reads its cache [FRESH-01, GH-01].
10
11
  export function useAttention() {
@@ -18,6 +19,11 @@ export function useAttention() {
18
19
  });
19
20
  const setView = useCallback((view: AttentionView) => queryClient.setQueryData(VIEW_QUERY_KEY, view), [queryClient]);
20
21
  // ⟳ fetches only the feed behind the tab I'm on.
21
- const refreshNow = useCallback(async (feed: FeedId) => setView(await fetchAttention({ refresh: feed })), [fetchAttention, setView]);
22
- return { ...query, setView, refreshNow };
22
+ const refresh = useMutation({ mutationKey: REFRESH_KEY, mutationFn: (feed: FeedId) => fetchAttention({ refresh: feed }), onSuccess: setView });
23
+ const refreshNow = refresh.mutateAsync;
24
+ // The server answers ⟳ only once its refresh is done, so the view can't say it's running; the pending call does.
25
+ // Kept in the query client, so it still shows after leaving the screen and coming back mid-refresh.
26
+ const pendingFeeds = useMutationState({ filters: { mutationKey: REFRESH_KEY, status: "pending" }, select: (mutation) => mutation.state.variables as FeedId });
27
+ const isRefreshing = useCallback((feed: FeedId) => pendingFeeds.includes(feed), [pendingFeeds]);
28
+ return { ...query, setView, refreshNow, isRefreshing };
23
29
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@andrioid/paseo-attention-span",
3
- "version": "0.4.7",
3
+ "version": "0.4.8",
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
@@ -35,6 +35,7 @@ functional:
35
35
  ATT-16: see recent comments without a mention on issues and pull requests I opened, until I reply, react or dismiss them; so that answers to my questions don't get lost, while other people's threads stay out unless someone tags me.
36
36
  ATT-17: choose to follow threads I've commented on, so recent replies after mine there show without a tag, off by default; so that surfacing other people's threads is my choice, and the list stays signal, not noise.
37
37
  ATT-18: see a calm, restful scene in Doing when nothing needs me, only once a refresh has confirmed it; so that a clear list feels like rest rather than a blank page, and calm never stands in for a check that failed or hasn't run.
38
+ ATT-19: tell at a glance what each person shown on an item is to it: someone I'm waiting on, who opened it, or whose comments are left to address, with an icon by their picture and the meaning in words when I point at it; so that a face and a time never leave me guessing.
38
39
  mentions:
39
40
  As a developer, I can:
40
41
  MEN-01: see open threads where a person mentioned me and is still waiting for my response; so that I only hear about mentions when someone is waiting for me.
@@ -63,6 +64,7 @@ functional:
63
64
  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.
64
65
  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.
65
66
  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.
67
+ PRS-15: see on my pull requests in Doing whom I asked to review and who hasn't yet, approved or not; so that I know someone I wanted to read it still hasn't before I merge or move on.
66
68
  upstream:
67
69
  As a developer, I can:
68
70
  UPS-01: see my pull requests that conflict with their base; so that pull requests needing updates from upstream are easy to fix.
@@ -53,6 +53,12 @@ const behindChip = (count: number, base: string) => chip(`${count} behind ${base
53
53
  const person = (actor: Actor | null | undefined, since: string): Person | undefined =>
54
54
  actor ? { login: actor.login, avatarUrl: actor.avatarUrl, bot: actor.__typename === "Bot", since } : undefined;
55
55
 
56
+ // Who opened it, which their line says with an icon rather than a quote [ATT-19].
57
+ const author = (actor: Actor | null | undefined, since: string): Person | undefined => {
58
+ const who = person(actor, since);
59
+ return who ? { ...who, role: "author" } : undefined;
60
+ };
61
+
56
62
  // Search returns empty objects for result types a fragment doesn't cover.
57
63
  const compact = <T>(nodes: (T | null | undefined)[]) => nodes.filter((node): node is T => !!node && Object.keys(node).length > 0);
58
64
 
@@ -203,7 +209,11 @@ export function classify({ data, details, config, now }: ClassifyInput): Attenti
203
209
  const waits = !rulesBlocked && (section === "too_long" || SECTIONS[section].tab === "waiting");
204
210
  const changers = replied && !flags.ciPending ? bottom.latestReviews.nodes.filter((review) => review.state === "CHANGES_REQUESTED").map((review) => review.author) : [];
205
211
  const asked = bottom.reviewRequests.nodes.map((request) => requested(request.requestedReviewer));
206
- const waitingOn = waits ? reviewers([...changers, ...asked].filter(isOther), waitingSince) : [];
212
+ // In Doing, approved or not, whoever I asked that hasn't reviewed yet: people and teams, not bots. An approved PR stays
213
+ // mine to merge, but I see who meant to read it still hasn't. Waiting too long keeps Waiting's rule, and a PR the repo's rules
214
+ // block waits on nobody, so neither lands under a reviewer in Waiting [PRS-15, PRS-13].
215
+ const outstanding = SECTIONS[section].tab === "doing" && section !== "too_long" ? reviewers(asked.filter(isOther), waitingSince).filter((who) => !who.bot) : [];
216
+ const waitingOn = waits ? reviewers([...changers, ...asked].filter(isOther), waitingSince) : outstanding;
207
217
  // Why it waits, where the chips don't already say: approved ones say so, so do the rules that block them, and so does CI
208
218
  // running when nobody's on it [WAI-01].
209
219
  const reason =
@@ -238,7 +248,7 @@ export function classify({ data, details, config, now }: ClassifyInput): Attenti
238
248
  person:
239
249
  waiting ??
240
250
  (section === "answered" ? answer : undefined) ??
241
- (section === "changes" && s.botThreadsOnly ? { login: "review bot", bot: true, since: s.lastCommitAt } : undefined),
251
+ (section === "changes" && s.botThreadsOnly ? { login: "review bot", bot: true, since: s.lastCommitAt, role: "changes" as const } : undefined),
242
252
  waitingOn: waitingOn.length > 0 ? waitingOn : undefined,
243
253
  othersActivityAt: latest(...stack.map((pr) => state(pr).othersActivityAt), waiting?.since, answer?.since),
244
254
  };
@@ -252,7 +262,7 @@ export function classify({ data, details, config, now }: ClassifyInput): Attenti
252
262
  section: waiting ? "reply" : "review",
253
263
  actions: waiting ? [...replyActions(waiting), "review"] : ["review"],
254
264
  chips: stack.some((pr) => state(pr).ciFailing) ? [chip("CI failing", "bad")] : [],
255
- person: waiting ?? person(stack[0].author, lastCommitAt),
265
+ person: waiting ?? author(stack[0].author, lastCommitAt),
256
266
  othersActivityAt: latest(...stack.map((pr) => state(pr).othersActivityAt), lastCommitAt, waiting?.since),
257
267
  };
258
268
  };
@@ -429,7 +439,7 @@ export function classifyHistory(data: HistoryResult): Item[] {
429
439
  if (issue) issue.children.push({ key: prKey(pr), number: pr.number, title: pr.title, url: pr.url, draft: false, chips: [], attention: false });
430
440
  else items.push(kinded({ ...plain(pr, "pr", "done"), closedAt: pr.mergedAt }, pr));
431
441
  }
432
- for (const pr of compact(data.reviewed.nodes)) items.push(kinded({ ...plain(pr, "pr", "reviewed"), closedAt: pr.mergedAt, person: person(pr.author, pr.mergedAt) }, pr));
442
+ for (const pr of compact(data.reviewed.nodes)) items.push(kinded({ ...plain(pr, "pr", "reviewed"), closedAt: pr.mergedAt, person: author(pr.author, pr.mergedAt) }, pr));
433
443
  return items.sort(order);
434
444
  }
435
445
 
package/server/fixture.ts CHANGED
@@ -152,7 +152,7 @@ export function fixture(now: Date): { data: SearchResult; details: Details } {
152
152
 
153
153
  const data = search({
154
154
  mine: [
155
- pr(101, { title: "Show delivery dates on the order page" }, "FAILURE"),
155
+ pr(101, { title: "Show delivery dates on the order page", reviewRequests: { nodes: [{ requestedReviewer: alice }, { requestedReviewer: bot }] } }, "FAILURE"),
156
156
  pr(102, { title: "Retry webhook deliveries with backoff", reviewThreads: { nodes: [thread(alice, 1), thread(bot, 2)] } }),
157
157
  pr(103, { title: "Fetch supplier price files nightly", reviewDecision: "APPROVED", closingIssuesReferences: closes(90, "Supplier prices are a week out of date") }),
158
158
  pr(104, { title: "Move price-file login into a service", isDraft: true, baseRefName: "branch-103", headRefName: "branch-104" }),
@@ -167,7 +167,7 @@ export function fixture(now: Date): { data: SearchResult; details: Details } {
167
167
  pr(111, { title: "Faster product search", reviewRequests: { nodes: [{ requestedReviewer: bob }] }, commits: commit("SUCCESS", 0.3) }),
168
168
  pr(112, { title: "Translate the checkout emails", reviewDecision: "CHANGES_REQUESTED", latestReviews: { nodes: [{ author: alice, state: "CHANGES_REQUESTED", submittedAt: daysAgo(2) }] }, commits: commit("SUCCESS", 1) }),
169
169
  pr(113, { title: "Upgrade the payment SDK", reviewRequests: { nodes: [{ requestedReviewer: bob }, { requestedReviewer: alice }] } }, "PENDING"),
170
- pr(114, { title: "Cache exchange rates daily", reviewDecision: "APPROVED" }),
170
+ pr(114, { title: "Cache exchange rates daily", reviewDecision: "APPROVED", latestReviews: { nodes: [{ author: alice, state: "APPROVED", submittedAt: daysAgo(1) }] }, reviewRequests: { nodes: [{ requestedReviewer: bob }] } }),
171
171
  pr(115, { title: "Split the settings page into tabs", isDraft: true, mergeable: "CONFLICTING" }),
172
172
  pr(116, { title: "Try a faster PDF renderer", isDraft: true }, "FAILURE"),
173
173
  pr(117, { title: "Harden the upload endpoint", reviewThreads: { nodes: [thread(bot, 1)] } }),
@@ -61,9 +61,13 @@ export interface Chip {
61
61
  icon?: "thumbUp";
62
62
  }
63
63
 
64
+ export type PersonRole = "author" | "changes";
65
+
64
66
  // The person (or bot) I'm waiting on, or who is waiting on me.
65
67
  export interface Person {
66
68
  login: string;
69
+ // What they are to the item, where no quote says it: who opened it, or whose comments are left to address [ATT-19].
70
+ role?: PersonRole;
67
71
  avatarUrl?: string;
68
72
  bot: boolean;
69
73
  since: string;