@andrioid/paseo-attention-span 0.4.9 → 0.4.10

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.
Files changed (41) hide show
  1. package/OVERVIEW.md +3 -1
  2. package/client/attention-screen.tsx +33 -17
  3. package/client/card.tsx +31 -8
  4. package/client/coverage-settings.tsx +36 -1
  5. package/client/entity.tsx +118 -0
  6. package/client/feedback.tsx +2 -2
  7. package/client/icons.ts +5 -0
  8. package/client/next-up.tsx +145 -74
  9. package/client/sheet.tsx +91 -10
  10. package/client/ui.tsx +97 -6
  11. package/docs/architecture.md +12 -6
  12. package/docs/screenshots/desktop-dark-doing-acknowledge.png +0 -0
  13. package/docs/screenshots/desktop-dark-doing-clear.png +0 -0
  14. package/docs/screenshots/desktop-dark-doing-issue-sheet.png +0 -0
  15. package/docs/screenshots/desktop-dark-doing-reviewers.png +0 -0
  16. package/docs/screenshots/desktop-dark-doing-sheet.png +0 -0
  17. package/docs/screenshots/desktop-dark-doing.png +0 -0
  18. package/docs/screenshots/desktop-dark-history-reviewed.png +0 -0
  19. package/docs/screenshots/desktop-dark-history.png +0 -0
  20. package/docs/screenshots/desktop-dark-next-up.png +0 -0
  21. package/docs/screenshots/desktop-dark-settings.png +0 -0
  22. package/docs/screenshots/desktop-dark-waiting-too-long.png +0 -0
  23. package/docs/screenshots/desktop-dark-waiting.png +0 -0
  24. package/docs/screenshots/phone-dark-doing.png +0 -0
  25. package/docs/screenshots/phone-light-next-up-filtered.png +0 -0
  26. package/index.server.ts +2 -0
  27. package/package.json +1 -1
  28. package/requirements.yaml +4 -2
  29. package/server/classify.ts +56 -12
  30. package/server/details.ts +3 -2
  31. package/server/fixture.ts +33 -9
  32. package/server/gh.ts +29 -12
  33. package/server/github-types.ts +19 -2
  34. package/server/projects.ts +47 -0
  35. package/server/queries.ts +41 -6
  36. package/server/service.ts +138 -22
  37. package/server/store.ts +2 -0
  38. package/server/view.ts +2 -0
  39. package/shared/attention.ts +57 -0
  40. package/shared/opening.ts +31 -0
  41. package/shared/rpc.ts +5 -1
package/OVERVIEW.md CHANGED
@@ -55,7 +55,9 @@ When someone needs a nudge, **Copy list** next to their name copies their items
55
55
 
56
56
  ## Next up: for when your plate is clear
57
57
 
58
- It does happen. Next up lists issues assigned to you first, because finishing what you've taken seems polite, and then open issues nobody's claimed. If your org uses issue fields for priority and effort, it ranks by those, so the important quick wins float to the top. Fields called Priority, Effort and Scope are picked up on their own; if yours are called something else, pick them in Settings. Each issue shows its repo, priority, effort and scope, and whether someone already has a PR open for it. That last one has saved me from duplicating a colleague's work more than once.
58
+ It does happen. Next up lists issues assigned to you first, because finishing what you've taken seems polite, and then open issues nobody's claimed. If your org uses issue fields for priority and effort, it ranks by those, so the important quick wins float to the top. Fields called Priority, Effort and Scope are picked up on their own; if yours are called something else, pick them in Settings. Each issue shows its repo, priority, effort and scope, and whether someone already has a PR open for it. That last one has saved me from duplicating a colleague's work more than once. Each fact sits in a small pill with an icon, so "Medium" never leaves you guessing whether it's priority or effort, and priority wears the color your org gave it.
59
+
60
+ If your issues live on GitHub project boards, Next up shows which board and column each one is in, and the filter lets you pick boards and their columns: only TODO's Todo, say, and leave Ideas out. That needs one more permission than `gh` asks for by default; Settings tells you the command (`gh auth refresh -s read:project`) and until then everything else works as before.
59
61
 
60
62
  ![Next up](docs/screenshots/desktop-dark-next-up.png)
61
63
 
@@ -1,12 +1,12 @@
1
1
  import type { RpcInput, RpcOutput } from "@getpaseo/plugin";
2
2
  import { openExternalUrl, type PluginScreenProps, usePaseo, useRpc } from "@getpaseo/plugin/client";
3
- import { Markdown, Modal, TextInput, useToast } from "@getpaseo/plugin/client/ui";
3
+ import { Markdown, 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
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
- import { ago, linkList, repoLabel } from "../shared/format";
9
+ import { ago, linkList } from "../shared/format";
10
10
  import { isClear } from "../shared/still";
11
11
  import { workEmoji } from "../shared/work";
12
12
  import { ACTION_SESSION, renderPrompt } from "../shared/prompts";
@@ -16,10 +16,11 @@ import { blocks } from "../shared/setup";
16
16
  import { useAttention } from "./data";
17
17
  import { CardList, CardRow, type CardProps } from "./card";
18
18
  import type { IconName } from "./icons";
19
+ import { NumberText, PlaceText } from "./entity";
19
20
  import { NextUpList } from "./next-up";
20
21
  import { Still } from "./still";
21
22
  import { agentSignal, sessionEntry, startAnotherEntry } from "./session-menu";
22
- import { ActionSheet, DetailLines, type SheetEntry } from "./sheet";
23
+ import { ActionSheet, cancelPendingOpen, DETAILS_STALE_MS, DetailLines, type DetailsQuery, detailsKey, Modal, type SheetEntry, useSheetOpener } from "./sheet";
23
24
  import { FeedbackAsk, FeedbackLine, type FeedbackScreen, FeedbackSheet } from "./feedback";
24
25
  import { branchWorkspaces, type FetchProviders, findCheckout, githubProjects, itemAgents, listProfiles, noProjectMessage, resolveAgentConfig, startSession } from "./sessions";
25
26
  import { SetupChecklist } from "./setup";
@@ -194,6 +195,7 @@ function AttentionList({
194
195
  const restore = useRpc(rpc.restoreDismissed);
195
196
  const saveScopes = useRpc(rpc.setScopes);
196
197
  const saveSources = useRpc(rpc.setSources);
198
+ const saveProjects = useRpc(rpc.setProjectFilter);
197
199
  const closeIssue = useRpc(rpc.closeIssue);
198
200
  const reopenIssue = useRpc(rpc.reopenIssue);
199
201
  const update = useRpc(rpc.updateBranch);
@@ -399,7 +401,7 @@ function AttentionList({
399
401
  <Text style={styles.muted}>{feed.fetchedAt ? `${ago(feed.fetchedAt)} ago` : "never"}</Text>
400
402
  </Pressable>
401
403
  {openSettings ? (
402
- <Pressable accessibilityRole="button" accessibilityLabel="Attention Span settings" onPress={openSettings} hitSlop={8}>
404
+ <Pressable accessibilityRole="button" accessibilityLabel="Attention Span settings" onPress={() => (cancelPendingOpen(), openSettings())} hitSlop={8}>
403
405
  <TablerIcon name="settings" size={16} />
404
406
  </Pressable>
405
407
  ) : null}
@@ -449,12 +451,15 @@ function AttentionList({
449
451
  selected={view.scopes}
450
452
  sources={nextUpSources(view.config)}
451
453
  selectedSources={view.sources}
452
- // One setView for both, so clearing scopes and sources together can't put either back.
454
+ projects={view.projects}
455
+ selectedProjects={view.projectFilter}
456
+ // One setView for all, so clearing them together can't put any back.
453
457
  onFilter={(change) => {
454
458
  attention.setView({ ...view, ...change });
455
459
  const failed = (error: Error) => toast.error(`Saving the filter failed: ${error.message}`);
456
460
  if (change.scopes) saveScopes({ scopes: change.scopes }).catch(failed);
457
461
  if (change.sources) saveSources({ sources: change.sources }).catch(failed);
462
+ if (change.projectFilter) saveProjects({ projects: change.projectFilter }).catch(failed);
458
463
  }}
459
464
  agents={actions.agents}
460
465
  login={view.login}
@@ -606,11 +611,15 @@ function ItemRow({ item, first, actions, group }: { item: Item; first: boolean;
606
611
  const main = item.actions[0];
607
612
  // The full stack is in the sheet; the card shows the PRs that need attention [ATT-04].
608
613
  const children = item.children.filter((child) => child.attention || isRed(child.chips));
609
- const open = () => setSheet("item");
614
+ // The sheet opens once its details are in; meanwhile › spins [ATT-06].
615
+ const opener = useSheetOpener(itemDetailsQuery(item, actions.fetchDetails), () => setSheet("item"));
616
+ const open = opener.open;
610
617
  const copy = useCopy();
611
618
  const history = SECTIONS[item.section].tab === "history";
612
619
 
613
620
  function perform(action: ActionId) {
621
+ // An action opening its own sheet wins over a details sheet still waiting to open [ATT-06].
622
+ cancelPendingOpen();
614
623
  setSheet(null);
615
624
  if (action === "merge" || action === "close") setConfirm(action);
616
625
  else if (action === "acknowledge") setSheet("acknowledge");
@@ -631,7 +640,7 @@ function ItemRow({ item, first, actions, group }: { item: Item; first: boolean;
631
640
  mark={stateMark(item)}
632
641
  title={item.title}
633
642
  meta={{
634
- place: `${repoLabel(item.repo, actions.login)} #${item.number}`,
643
+ place: { repo: item.repo, number: item.number, login: actions.login },
635
644
  when: item.closedAt ? `${item.kind === "pr" ? "merged" : "closed"} ${ago(item.closedAt)} ago` : undefined,
636
645
  signals: chips,
637
646
  }}
@@ -646,6 +655,8 @@ function ItemRow({ item, first, actions, group }: { item: Item; first: boolean;
646
655
  ) : null
647
656
  }
648
657
  onOpen={open}
658
+ opening={opener.opening}
659
+ hover={opener.hover}
649
660
  busy={actions.busy.has(item.key)}
650
661
  primary={
651
662
  sessions[0]
@@ -700,14 +711,17 @@ interface SheetHandlers {
700
711
  }
701
712
 
702
713
  // What the card already knows on top, then every action, then what's fetched when it opens, so nothing jumps as it loads [ATT-06, GH-01].
703
- function ItemSheet({ item, chips, sessions, actions, ...handlers }: { item: Item; chips: Chip[]; sessions: AgentSummary[]; actions: Actions } & SheetHandlers) {
714
+ // What an item's sheet fetches when it opens; its card fetches the same ahead, so the sheet opens complete [ATT-06].
715
+ // `checks` asks for failing checks too, for Rerun.
716
+ function itemDetailsQuery(item: Item, fetchDetails: FetchDetails): DetailsQuery {
704
717
  const checks = item.actions.includes("rerun");
705
- const details = useQuery({
706
- queryKey: ["attention-span", "details", item.key, checks],
707
- queryFn: () => actions.fetchDetails({ subject: { kind: item.kind, repo: item.repo, number: item.number }, target: item.target, checks }),
708
- staleTime: 60_000,
709
- });
710
- const meta = [`${item.repo}#${item.number}`, ...(item.target.number !== item.number ? [`actions apply to PR #${item.target.number}`] : [])];
718
+ const subject = { kind: item.kind, repo: item.repo, number: item.number };
719
+ return { queryKey: detailsKey(subject, item.target, checks), queryFn: () => fetchDetails({ subject, target: item.target, checks }) };
720
+ }
721
+
722
+ function ItemSheet({ item, chips, sessions, actions, ...handlers }: { item: Item; chips: Chip[]; sessions: AgentSummary[]; actions: Actions } & SheetHandlers) {
723
+ const details = useQuery({ ...itemDetailsQuery(item, actions.fetchDetails), staleTime: DETAILS_STALE_MS });
724
+ const meta = item.target.number !== item.number ? [`actions apply to PR #${item.target.number}`] : [];
711
725
  // PRs already in the stack line link from there; list only the rest, like someone else's PR closing the same issue.
712
726
  const shown = new Set(item.children.map((child) => child.url));
713
727
  const extra = details.data && { ...details.data, linked: details.data.linked.filter((link) => !shown.has(link.url)) };
@@ -717,14 +731,16 @@ function ItemSheet({ item, chips, sessions, actions, ...handlers }: { item: Item
717
731
  onClose={handlers.onClose}
718
732
  top={
719
733
  <>
720
- <Meta facts={meta} chips={chips} />
734
+ {/* Number first, as on the card; the sheet always names the owner, even of my own repos [ATT-20]. */}
735
+ <Meta lead={<PlaceText place={{ repo: item.repo, number: item.number, login: null }} />} facts={meta} chips={chips} />
721
736
  {item.person ? <PersonQuote person={item.person} expanded /> : null}
722
737
  {item.waitingOn ? <WaitingOnLine people={item.waitingOn} asked={item.wait?.reason === "question"} expanded /> : null}
723
738
  {item.children.length > 0 ? <StackLine rows={item.children} merged={!!item.closedAt} links /> : null}
724
739
  </>
725
740
  }
726
741
  entries={sheetEntries(item, sessions, actions, handlers, details)}
727
- bottom={<DetailLines details={extra} loading={details.isLoading} error={details.error} linkedLabel={item.kind === "issue" ? "PR" : "Closes"} />}
742
+ // The PR its actions apply to has a size line; an issue's PRs are in its stack line already, so few more come [ATT-06].
743
+ bottom={<DetailLines details={extra} loading={details.isLoading} error={details.error} linkedLabel={item.kind === "issue" ? "PR" : "Closes"} expected={item.target.kind === "pr" ? 1 : 0} />}
728
744
  />
729
745
  );
730
746
  }
@@ -1167,7 +1183,7 @@ function StackLine({ rows, merged, links = false }: { rows: SubRow[]; merged: bo
1167
1183
  <Text style={{ color: styles.c.foreground, fontSize: 13 }} numberOfLines={1}>
1168
1184
  {row.title}
1169
1185
  </Text>
1170
- <Meta facts={[`#${row.number}`]} chips={row.chips} />
1186
+ <Meta lead={<NumberText number={row.number} />} facts={[]} chips={row.chips} />
1171
1187
  </View>
1172
1188
  {links ? (
1173
1189
  <View style={{ justifyContent: "center", paddingHorizontal: 4 }}>
package/client/card.tsx CHANGED
@@ -3,12 +3,14 @@ import { type ReactNode, useState } from "react";
3
3
  import { ActivityIndicator, Pressable, Text, View } from "react-native";
4
4
  import type { Chip } from "../shared/attention";
5
5
  import type { IconName } from "./icons";
6
+ import { type Place, PlaceText } from "./entity";
7
+ import { cancelPendingOpen } from "./sheet";
6
8
  import { Button, HintArea, Meta, TablerIcon, toneColor, useStyles } from "./ui";
7
9
 
8
10
  // Every card in every list has this anatomy; tabs fill it in with data and slots, not layout [ATT-05].
9
11
  //
10
12
  // [mark] title (2 lines at most) [actions] ← desktop
11
- // place · when · signals
13
+ // #number · repo · when · signals
12
14
  // extra (slot)
13
15
  // [actions] ← phone, labelled
14
16
  // confirm bar
@@ -36,12 +38,16 @@ export interface ConfirmSpec {
36
38
  export interface CardProps {
37
39
  mark: { icon: IconName; tone: Tone };
38
40
  title: string;
39
- // "repo #number", then when it happened, then signals [ATT-05].
40
- meta: { place: string; when?: string; signals: Chip[] };
41
+ // "#number · repo", then when it happened, then signals [ATT-05, ATT-20].
42
+ meta: { place: Place; when?: string; signals: Chip[] };
41
43
  // Defaults to "<title>, more".
42
44
  accessibilityLabel?: string;
43
45
  // Tapping the card opens its sheet [ATT-06].
44
46
  onOpen: () => void;
47
+ // While its sheet waits for its details, a spinner takes the place of › [ATT-06].
48
+ opening?: boolean;
49
+ // Resting the pointer on the card, to fetch its sheet's details ahead.
50
+ hover?: { onHoverIn: () => void; onHoverOut: () => void };
45
51
  // The labelled main action; secondary ones are icon-only (›, copy).
46
52
  primary?: CardAction;
47
53
  secondary: CardAction[];
@@ -59,20 +65,37 @@ export function CardList({ children }: { children: ReactNode }) {
59
65
  return <View style={styles.card}>{children}</View>;
60
66
  }
61
67
 
62
- export function CardRow({ first, mark, title, meta, accessibilityLabel, onOpen, primary, secondary, busy, extra, confirm, overlay }: CardProps & { first: boolean }) {
68
+ export function CardRow({ first, mark, title, meta, accessibilityLabel, onOpen, opening, hover, primary, secondary, busy, extra, confirm, overlay }: CardProps & { first: boolean }) {
63
69
  const styles = useStyles();
70
+ const chevron = secondary.some((action) => action.icon === "chevronRight");
64
71
  const actions = (
65
72
  <View style={styles.wrap}>
66
73
  {primary ? (
67
- <Button label={primary.label} accessibilityLabel={primary.accessibilityLabel} icon={primary.icon} variant="calm" busy={busy} onPress={primary.onPress} />
74
+ <Button
75
+ label={primary.label}
76
+ accessibilityLabel={primary.accessibilityLabel}
77
+ icon={primary.icon}
78
+ variant="calm"
79
+ busy={busy}
80
+ // A card's action wins over its sheet still waiting to open [ATT-06].
81
+ onPress={() => (cancelPendingOpen(), primary.onPress())}
82
+ />
68
83
  ) : busy ? (
69
84
  <ActivityIndicator size="small" color={styles.c.foregroundMuted} />
70
85
  ) : null}
71
86
  {/* On phones › and copy sit at the far edge, apart from the labelled action. */}
72
87
  {styles.compact && secondary.length ? <View style={{ flex: 1 }} /> : null}
73
88
  {secondary.map((action) => (
74
- <Button key={action.accessibilityLabel ?? action.label} icon={action.icon} variant="ghost" accessibilityLabel={action.accessibilityLabel ?? action.label} onPress={action.onPress} />
89
+ <Button
90
+ key={action.accessibilityLabel ?? action.label}
91
+ icon={action.icon}
92
+ variant="ghost"
93
+ accessibilityLabel={action.accessibilityLabel ?? action.label}
94
+ busy={opening && action.icon === "chevronRight"}
95
+ onPress={action.onPress}
96
+ />
75
97
  ))}
98
+ {opening && !chevron ? <ActivityIndicator size="small" color={styles.c.foregroundMuted} accessibilityLabel="Opening" /> : null}
76
99
  </View>
77
100
  );
78
101
  return (
@@ -80,11 +103,11 @@ export function CardRow({ first, mark, title, meta, accessibilityLabel, onOpen,
80
103
  <View style={styles.item}>
81
104
  <Mark {...mark} />
82
105
  <HintArea style={styles.body}>
83
- <Pressable accessibilityRole="button" accessibilityLabel={accessibilityLabel ?? `${title}, more`} onPress={onOpen} style={{ gap: 6 }}>
106
+ <Pressable accessibilityRole="button" accessibilityLabel={accessibilityLabel ?? `${title}, more`} onPress={onOpen} {...hover} style={{ gap: 6 }}>
84
107
  <Text style={styles.title} numberOfLines={2}>
85
108
  {title}
86
109
  </Text>
87
- <Meta facts={meta.when ? [meta.place, meta.when] : [meta.place]} chips={meta.signals} />
110
+ <Meta lead={<PlaceText place={meta.place} />} facts={meta.when ? [meta.when] : []} chips={meta.signals} />
88
111
  {extra}
89
112
  </Pressable>
90
113
  {/* On phones the actions sit under the text, labelled, so mixed actions stay readable. */}
@@ -7,11 +7,12 @@ import * as rpc from "../shared/rpc";
7
7
  import { DEFAULT_FIELD, FIELD_ROLES, type FieldRole, sameField } from "../shared/config";
8
8
  import type { ConfigStatus, CoverageKind, IssueField } from "../shared/setup";
9
9
  import { VIEW_QUERY_KEY } from "./data";
10
- import { Button, StylesProvider, useStyles } from "./ui";
10
+ import { Button, StylesProvider, useCopy, useStyles } from "./ui";
11
11
 
12
12
  const COVERAGE_QUERY_KEY = ["attention-span", "coverage"] as const;
13
13
  const MY_ORGS_QUERY_KEY = ["attention-span", "my-orgs"] as const;
14
14
  const FIELDS_QUERY_KEY = ["attention-span", "issue-fields"] as const;
15
+ const PROJECTS_QUERY_KEY = ["attention-span", "projects-access"] as const;
15
16
  // A caption belongs to the card above it, so it sits closer to that card than to the next heading.
16
17
  const CAPTION = { marginTop: -24, marginBottom: 16 };
17
18
 
@@ -216,6 +217,7 @@ function NextUpFields({ value, disabled, onChange }: { value: ConfigStatus["fiel
216
217
  />
217
218
  );
218
219
  })}
220
+ <ProjectsRow />
219
221
  </SettingsCard>
220
222
  </SettingsSection>
221
223
  <Text style={[styles.muted, CAPTION]}>
@@ -227,6 +229,39 @@ function NextUpFields({ value, disabled, onChange }: { value: ConfigStatus["fiel
227
229
  );
228
230
  }
229
231
 
232
+ // Projects need the read:project scope, which gh doesn't ask for by default. Asked again each time Settings opens, so the
233
+ // row turns On once it's fixed. How to fix it depends on where gh's token comes from: its own login takes one command; a
234
+ // token in GH_TOKEN or GITHUB_TOKEN, which gh reads first, needs that permission on GitHub; anything else, like an org's
235
+ // SSO, gets GitHub's own words [NXT-12].
236
+ const SCOPE_COMMAND = "gh auth refresh -s read:project";
237
+
238
+ function ProjectsRow() {
239
+ const styles = useStyles();
240
+ const copy = useCopy();
241
+ const check = useRpc(rpc.projectsAccess);
242
+ const access = useQuery({ queryKey: PROJECTS_QUERY_KEY, queryFn: () => check({}), staleTime: 0 });
243
+ const status = access.data;
244
+ if (status?.state === "missing" && status.token === "gh")
245
+ return <SettingsAction label="Projects" hint={`Needs the read:project scope. Run ${SCOPE_COMMAND} on this host`} actionLabel="Copy command" onPress={() => copy(SCOPE_COMMAND, "Copied the command")} />;
246
+ const hint =
247
+ status?.state === "missing"
248
+ ? `Your token comes from ${status.token}. Give it read:project (classic) or Projects: read (fine-grained), then restart the daemon`
249
+ : status?.state === "failed"
250
+ ? `Couldn't read projects: ${status.error}`
251
+ : status?.state === "unknown"
252
+ ? "Couldn't tell whether projects can be read"
253
+ : // On, but some went wrong last time, like boards an org's SSO hides: in GitHub's words, so it can be fixed.
254
+ status?.warning || status?.error
255
+ ? `On, but GitHub said: ${status.warning ?? status.error}`
256
+ : "Shows each issue's project and Status on its card, and adds them to the filter";
257
+ const on = status?.state === "on";
258
+ return (
259
+ <SettingsRow label="Projects" hint={hint} error={access.error ? (access.error as Error).message : null}>
260
+ <Text style={[styles.text, { color: on ? styles.action : styles.c.foregroundMuted }]}>{on ? "On" : access.isLoading ? "Checking…" : "Off"}</Text>
261
+ </SettingsRow>
262
+ );
263
+ }
264
+
230
265
  // Each name is checked on GitHub before it's saved; GitHub's exact name is what's kept.
231
266
  function AddRow({ kind, placeholder, existing, disabled, onAdd }: { kind: CoverageKind; placeholder?: string; existing: string[]; disabled: boolean; onAdd: (name: string) => Promise<void> }) {
232
267
  const styles = useStyles();
@@ -0,0 +1,118 @@
1
+ import { Text, View } from "react-native";
2
+ import type { GithubColor, IssueProject, NextUpIssue } from "../shared/attention";
3
+ import type { FieldRole } from "../shared/config";
4
+ import { repoLabel, shortValue } from "../shared/format";
5
+ import type { IconName } from "./icons";
6
+ import { Pill, type Styles, useStrongText, useStyles } from "./ui";
7
+
8
+ // How an issue or PR is presented wherever it shows, on a card or in its sheet: which one it is, and the facts that help
9
+ // pick it up. Tabs and sheets compose these rather than format their own.
10
+
11
+ // ---- Which item [ATT-20] ----
12
+
13
+ // An item's number and repo. My own repos go without their owner where `login` is given; a sheet passes none, so it always
14
+ // names the owner.
15
+ export interface Place {
16
+ repo: string;
17
+ number: number;
18
+ login: string | null;
19
+ }
20
+
21
+ // "#160", standing out a little from the quiet text it leads, like a stack's rows in a sheet.
22
+ export function NumberText({ number }: { number: number }) {
23
+ return <Text style={useStrongText()}>#{number}</Text>;
24
+ }
25
+
26
+ // "#160 · acme/shop", to lead a Meta line: the number on its own first, then the repo with its name standing out from its
27
+ // owner, so cards from several repos scan.
28
+ export function PlaceText({ place }: { place: Place }) {
29
+ const strong = useStrongText();
30
+ const label = repoLabel(place.repo, place.login);
31
+ const cut = label.lastIndexOf("/") + 1;
32
+ return (
33
+ <>
34
+ <NumberText number={place.number} />
35
+ {" · "}
36
+ {label.slice(0, cut)}
37
+ <Text style={strong}>{label.slice(cut)}</Text>
38
+ </>
39
+ );
40
+ }
41
+
42
+ // ---- GitHub's option colors [NXT-10] ----
43
+
44
+ // The colors GitHub offers for issue field and project options, as GitHub draws them on dark and on light.
45
+ const GITHUB_COLORS: Record<GithubColor, { dark: string; light: string }> = {
46
+ GRAY: { dark: "#8b949e", light: "#6e7781" },
47
+ BLUE: { dark: "#4493f8", light: "#0969da" },
48
+ GREEN: { dark: "#3fb950", light: "#1a7f37" },
49
+ YELLOW: { dark: "#d29922", light: "#9a6700" },
50
+ ORANGE: { dark: "#db6d28", light: "#bc4c00" },
51
+ RED: { dark: "#f85149", light: "#cf222e" },
52
+ PINK: { dark: "#db61a2", light: "#bf3989" },
53
+ PURPLE: { dark: "#ab7df8", light: "#8250df" },
54
+ };
55
+
56
+ // An option's color for this theme. GRAY is what an option looks like when nobody chose a color, so it tints nothing.
57
+ export function githubColor(styles: Styles, color: GithubColor | undefined): string | undefined {
58
+ return color && color !== "GRAY" ? GITHUB_COLORS[color]?.[styles.dark ? "dark" : "light"] : undefined;
59
+ }
60
+
61
+ // ---- An issue to pick up [NXT-10, NXT-12] ----
62
+
63
+ // Each field's pill: its icon says which field the value is.
64
+ const FIELDS = [
65
+ { role: "priority", label: "Priority", icon: "flag" },
66
+ { role: "effort", label: "Effort", icon: "weight" },
67
+ { role: "scope", label: "Scope", icon: "layers" },
68
+ ] as const satisfies { role: FieldRole; label: string; icon: IconName }[];
69
+
70
+ // Priority in the color the org gave it; where it colored none, the top priority is warm, the next accent, the rest quiet.
71
+ function priorityColor(styles: Styles, issue: NextUpIssue): string | undefined {
72
+ if (issue.priorityColor) return githubColor(styles, issue.priorityColor);
73
+ return issue.priorityRank === 0 ? styles.c.statusWarning : issue.priorityRank === 1 ? styles.action : undefined;
74
+ }
75
+
76
+ // A board it's on, and its column there in the board's color.
77
+ export function ProjectPill({ project }: { project: IssueProject }) {
78
+ const styles = useStyles();
79
+ return (
80
+ <Pill
81
+ icon="kanban"
82
+ label={project.title}
83
+ value={project.status}
84
+ color={githubColor(styles, project.color)}
85
+ hint={`Project ${project.title}: ${project.status ?? "no status"}`}
86
+ />
87
+ );
88
+ }
89
+
90
+ // One of its fields. `full` (the sheet) names the field and keeps the value whole, as phones can't show a pill's hint;
91
+ // the card trims the value's emoji and notes in brackets.
92
+ export function FieldPill({ issue, role, full = false }: { issue: NextUpIssue; role: FieldRole; full?: boolean }) {
93
+ const styles = useStyles();
94
+ const field = FIELDS.find((f) => f.role === role)!;
95
+ const raw = issue[role];
96
+ if (!raw) return null;
97
+ const value = full ? raw : shortValue(raw);
98
+ const color = role === "priority" ? priorityColor(styles, issue) : undefined;
99
+ return <Pill icon={field.icon} label={full ? field.label : undefined} value={value} color={color} hint={`${field.label}: ${value}`} />;
100
+ }
101
+
102
+ // What helps decide whether to pick it up: the boards it's on, then priority, effort and scope. Nothing when it has none.
103
+ export function IssuePills({ issue, full = false }: { issue: NextUpIssue; full?: boolean }) {
104
+ const styles = useStyles();
105
+ const projects = issue.projects ?? [];
106
+ const fields = FIELDS.filter(({ role }) => issue[role]);
107
+ if (projects.length === 0 && fields.length === 0) return null;
108
+ return (
109
+ <View style={[styles.wrap, { gap: 4, marginTop: 2 }]}>
110
+ {projects.map((project) => (
111
+ <ProjectPill key={project.id} project={project} />
112
+ ))}
113
+ {fields.map(({ role }) => (
114
+ <FieldPill key={role} issue={issue} role={role} full={full} />
115
+ ))}
116
+ </View>
117
+ );
118
+ }
@@ -1,12 +1,12 @@
1
1
  import { openExternalUrl, type PluginClientContext, usePaseo, useRpc } from "@getpaseo/plugin/client";
2
- import { Modal, TextInput, useToast } from "@getpaseo/plugin/client/ui";
2
+ import { TextInput, useToast } from "@getpaseo/plugin/client/ui";
3
3
  import { useState } from "react";
4
4
  import { Pressable, Text, View } from "react-native";
5
5
  import type { AgentSummary } from "../shared/attention";
6
6
  import type { AttentionConfig } from "../shared/config";
7
7
  import { FEEDBACK_REPO, type FeedbackContext, type FeedbackKind, feedbackItemKey, feedbackPrompt } from "../shared/feedback";
8
8
  import * as rpc from "../shared/rpc";
9
- import { ActionSheet, type SheetEntry } from "./sheet";
9
+ import { ActionSheet, Modal, type SheetEntry } from "./sheet";
10
10
  import { sessionEntry } from "./session-menu";
11
11
  import { ITEM_LABEL, KIND_LABEL, LABEL, resolveAgentConfig } from "./sessions";
12
12
  import { Button, KeepStyles, TablerIcon, useStyles } from "./ui";
package/client/icons.ts CHANGED
@@ -41,6 +41,11 @@ export const ICONS = {
41
41
  filter: { svg: "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\"><path fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M4 4h16v2.172a2 2 0 0 1-.586 1.414L15 12v7l-6 2v-8.5L4.52 7.572A2 2 0 0 1 4 6.227z\"/></svg>" },
42
42
  square: { svg: "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\"><path fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M3 5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z\"/></svg>" },
43
43
  squareCheck: { svg: "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\"><path fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M3 5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2zm6 7l2 2l4-4\"/></svg>" },
44
+ squareMinus: { svg: "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\"><path fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M9 12h6M3 5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z\"/></svg>" },
45
+ flag: { svg: "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\"><path fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M5 5a5 5 0 0 1 7 0a5 5 0 0 0 7 0v9a5 5 0 0 1-7 0a5 5 0 0 0-7 0zm0 16v-7\"/></svg>" },
46
+ weight: { svg: "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\"><g fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\"><path d=\"M9 6a3 3 0 1 0 6 0a3 3 0 1 0-6 0\"/><path d=\"M6.835 9h10.33a1 1 0 0 1 .984.821l1.637 9A1 1 0 0 1 18.802 20H5.198a1 1 0 0 1-.984-1.179l1.637-9A1 1 0 0 1 6.835 9\"/></g></svg>" },
47
+ layers: { svg: "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\"><path fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M12 4L4 8l8 4l8-4zm-8 8l8 4l8-4M4 16l8 4l8-4\"/></svg>" },
48
+ kanban: { svg: "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\"><path fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M4 4h6m4 0h6M4 10a2 2 0 0 1 2-2h2a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2zm10 0a2 2 0 0 1 2-2h2a2 2 0 0 1 2 2v2a2 2 0 0 1-2 2h-2a2 2 0 0 1-2-2z\"/></svg>" },
44
49
  chevronRight: { svg: "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\"><path fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"m9 6l6 6l-6 6\"/></svg>" },
45
50
  plus: { svg: "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\"><path fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M12 5v14m-7-7h14\"/></svg>" },
46
51
  check: { svg: "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\"><path fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"m5 12l5 5L20 7\"/></svg>" },