@andrioid/paseo-attention-span 0.1.1 → 0.1.3

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.
package/OVERVIEW.md CHANGED
@@ -6,7 +6,7 @@ The screen has four tabs. A sidebar entry, Attention, shows how many items need
6
6
 
7
7
  - **Doing:** what needs you, in sections: waiting for your reply, review requested, CI failing, changes requested, ready to merge, needs upstream, waiting too long, and your drafts. Each item appears once, under its most urgent reason. An issue and the pull requests that close it are one item, and so is a stack of pull requests.
8
8
  - **Waiting:** your work where someone else has the next move.
9
- - **Next up:** issues assigned to you, then open issues nobody has claimed, ranked by priority and effort when your org uses issue fields for them. Unclaimed issues come from the repositories you choose, or else from your Paseo projects' repositories.
9
+ - **Next up:** issues assigned to you, then open issues nobody has claimed, ranked by priority and effort when your org uses issue fields for them. Unclaimed issues come from the sources you choose (your own repositories, your organizations or single repositories), and can be filtered by source, or else from your Paseo projects' repositories.
10
10
  - **History:** what you finished and reviewed in recent weeks.
11
11
 
12
12
  A mention only counts while the person is still waiting for you; replying or reacting clears it. Mentions of your teams are left out. You can dismiss an item until something new happens on it.
@@ -21,14 +21,14 @@ When `gh` is missing or signed out, or `config.json` can't be read, the screen s
21
21
 
22
22
  It works without configuration: the lists about you cover everything on GitHub that involves you, and Next up looks for unclaimed issues in your Paseo projects' repositories.
23
23
 
24
- To narrow it down, choose organizations and repositories under Settings, Plugins, Attention Span, or with the gear on the screen. Each one is checked on GitHub as you add it. Next up's unclaimed issues use them too, instead of your projects.
24
+ To narrow it down, choose organizations and repositories under Settings, Plugins, Attention Span, or with the gear on the screen. Each one is checked on GitHub as you add it. Next up's unclaimed issues use them too, instead of your projects, unless you choose Next up's own sources there.
25
25
 
26
26
  Everything else is set in `~/.config/paseo-attention-span/config.json` on the daemon host, which the settings screen also writes to:
27
27
  - `profiles`: the Paseo agent profile per session type. Reviews use `review`, everything else `default`, and a missing profile falls back to Paseo's defaults.
28
28
  - `prompts`: your own prompt template per session type, replacing the built-in one.
29
29
  - `mergeMethods`: squash, merge or rebase per repository.
30
30
  - `codeRepos`: where an issue repository's code lives, for issues kept apart from the code. The screen asks and fills this in when needed.
31
- - `nextUp`: which repositories to pick from, and the org issue fields for priority, effort and scope.
31
+ - `nextUp`: where to pick from (also in Settings), and the org issue fields for priority, effort and scope.
32
32
  - `refreshMinutes` (15), `waitingTooLongDays` (3), `staleDraftDays` (30), `mentionDays` (30) and `historyWeeks` (4).
33
33
 
34
34
  ## Actions
@@ -5,18 +5,19 @@ 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 Chip, type FailingChecks, type Item, type NextUpIssue, type Section, type SectionId, type SubRow, TAB_FEED, type TabId, type Target } from "../shared/attention";
8
- import type { AttentionConfig, SessionKind } from "../shared/config";
9
- import { ago } from "../shared/format";
8
+ import { type AttentionConfig, nextUpSources, type SessionKind } from "../shared/config";
9
+ import { ago, linkList } from "../shared/format";
10
10
  import { ACTION_SESSION, renderPrompt } from "../shared/prompts";
11
11
  import * as rpc from "../shared/rpc";
12
12
  import { blocks } from "../shared/setup";
13
13
  import { useAttention } from "./data";
14
+ import { CardList, CardRow, type CardProps } from "./card";
14
15
  import type { IconName } from "./icons";
15
16
  import { NextUpList } from "./next-up";
16
17
  import { ActionSheet, DetailLines, type SheetEntry } from "./sheet";
17
18
  import { branchWorkspaces, findCheckout, githubProjects, itemAgents, listProfiles, noProjectMessage, resolveAgentConfig, startSession } from "./sessions";
18
19
  import { SetupChecklist } from "./setup";
19
- import { Avatar, Button, KeepStyles, Meta, SectionHeader, StylesProvider, TablerIcon, Toggle, useHover, useStyles } from "./ui";
20
+ import { Avatar, Button, KeepStyles, Meta, SectionHeader, StylesProvider, TablerIcon, Toggle, useCopy, useHover, useStyles } from "./ui";
20
21
 
21
22
  // The agent icon marks every action that starts an agent session; the rest act on GitHub right away [ATT-13].
22
23
  const ACTION_ICONS: Record<ActionId, IconName> = {
@@ -179,6 +180,9 @@ function AttentionList({ navigation, openSettings }: Pick<PluginScreenProps, "na
179
180
  const undismiss = useRpc(rpc.undismissItem);
180
181
  const restore = useRpc(rpc.restoreDismissed);
181
182
  const saveScopes = useRpc(rpc.setScopes);
183
+ const saveSources = useRpc(rpc.setSources);
184
+ const closeIssue = useRpc(rpc.closeIssue);
185
+ const reopenIssue = useRpc(rpc.reopenIssue);
182
186
  const update = useRpc(rpc.updateBranch);
183
187
  const merge = useRpc(rpc.mergePullRequest);
184
188
  const close = useRpc(rpc.closePullRequest);
@@ -298,14 +302,11 @@ function AttentionList({ navigation, openSettings }: Pick<PluginScreenProps, "na
298
302
  waiting: view.waiting.reduce((sum, section) => sum + section.items.length, 0),
299
303
  next: view.assigned.length + view.unclaimed.length,
300
304
  };
301
- // The repo is worth showing only when the list spans several.
302
- const repos = new Set([...view.doing, ...view.waiting].flatMap((section) => section.items.map((item) => item.repo)));
303
305
 
304
306
  const actions: Actions = {
305
307
  agents: view.fixtureAgents ?? agents.data ?? {},
306
308
  busy,
307
309
  config: view.config,
308
- showRepo: repos.size > 1,
309
310
  fetchContext,
310
311
  fetchDetails,
311
312
  defaultBranch,
@@ -426,6 +427,12 @@ function AttentionList({ navigation, openSettings }: Pick<PluginScreenProps, "na
426
427
  attention.setView({ ...view, scopes });
427
428
  saveScopes({ scopes }).catch((error) => toast.error(`Saving the filter failed: ${(error as Error).message}`));
428
429
  }}
430
+ sources={nextUpSources(view.config)}
431
+ selectedSources={view.sources}
432
+ onSelectSources={(sources) => {
433
+ attention.setView({ ...view, sources });
434
+ saveSources({ sources }).catch((error) => toast.error(`Saving the filter failed: ${(error as Error).message}`));
435
+ }}
429
436
  agents={actions.agents}
430
437
  busy={busy}
431
438
  fetchDetails={fetchDetails}
@@ -440,6 +447,12 @@ function AttentionList({ navigation, openSettings }: Pick<PluginScreenProps, "na
440
447
  const [take, giveBack] = [() => claim({ target }), () => unclaim({ target })];
441
448
  onGitHub(issue.key, on ? "Claim" : "Unclaim", on ? take : giveBack, `${on ? "Claimed" : "Unclaimed"} #${issue.number}`, on ? giveBack : take);
442
449
  }}
450
+ // Undo reopens; a comment already posted stays [NXT-11].
451
+ onCloseIssue={(issue, reason, comment) => {
452
+ const target = issueTarget(issue);
453
+ const done = `Closed #${issue.number} as ${reason === "completed" ? "completed" : "not planned"}`;
454
+ onGitHub(issue.key, "Close", () => closeIssue({ target, reason, comment: comment || undefined }), done, () => reopenIssue({ target }));
455
+ }}
443
456
  />
444
457
  ) : null}
445
458
  {placing ? <CodeRepoPicker issueRepo={placing.target.repo} missing={placing.missing} onPick={place} onClose={() => setPlacing(null)} /> : null}
@@ -470,7 +483,6 @@ interface Actions {
470
483
  agents: Record<string, AgentSummary>;
471
484
  busy: string | null;
472
485
  config: AttentionConfig;
473
- showRepo: boolean;
474
486
  fetchContext: FetchContext;
475
487
  fetchDetails: FetchDetails;
476
488
  defaultBranch: DefaultBranch;
@@ -483,10 +495,11 @@ interface Actions {
483
495
  started: (agentId: string) => Promise<void>;
484
496
  }
485
497
 
486
- function stateIcon(item: Item, c: ReturnType<typeof useStyles>["c"]): { name: IconName; color: string } {
487
- if (item.closedAt) return item.kind === "pr" ? { name: "merge", color: c.accent } : { name: "issueClosed", color: item.chips.length ? c.foregroundMuted : c.accent };
488
- if (item.kind === "issue") return { name: "issue", color: c.statusSuccess };
489
- return item.draft ? { name: "draft", color: c.foregroundMuted } : { name: "pr", color: c.statusSuccess };
498
+ // What the card is: open, draft, merged or closed. Urgency stays in the chips and section headers.
499
+ function stateMark(item: Item): CardProps["mark"] {
500
+ if (item.closedAt) return item.kind === "pr" ? { icon: "merge", tone: "good" } : { icon: "issueClosed", tone: item.chips.length ? "neutral" : "good" };
501
+ if (item.kind === "issue") return { icon: "issue", tone: "good" };
502
+ return item.draft ? { icon: "draft", tone: "neutral" } : { icon: "pr", tone: "good" };
490
503
  }
491
504
 
492
505
  // A card that works collapsed: its main action and ⋯. Tapping it opens the sheet with everything else [ATT-05, ATT-06].
@@ -495,20 +508,18 @@ const isRed = (chips: Chip[]) => chips.some((chip) => chip.tone === "bad");
495
508
  type Sheet = "item" | "acknowledge" | { options: SessionKind } | null;
496
509
 
497
510
  function ItemRow({ item, first, actions }: { item: Item; first: boolean; actions: Actions }) {
498
- const styles = useStyles();
499
511
  const agent = actions.agents[item.key];
500
512
  const chips = agent ? [...item.chips, agentSignal(agent)] : item.chips;
501
513
  const [sheet, setSheet] = useState<Sheet>(null);
502
514
  const [confirm, setConfirm] = useState<"merge" | "close" | null>(null);
503
- const [comment, setComment] = useState("");
504
515
  const sessionAction = item.actions.find((action) => ACTION_SESSION[action]);
505
516
  const sessionKind = sessionAction ? ACTION_SESSION[sessionAction] : undefined;
506
517
  const main = item.actions[0];
507
- const facts = [`#${item.number}`, ...(actions.showRepo ? [item.repo.split("/")[1]] : [])];
508
518
  // The full stack is in the sheet; the card shows the PRs that need attention [ATT-04].
509
519
  const children = item.children.filter((child) => child.attention || isRed(child.chips));
510
- const icon = stateIcon(item, styles.c);
511
520
  const open = () => setSheet("item");
521
+ const copy = useCopy();
522
+ const history = item.section === "done" || item.section === "reviewed";
512
523
 
513
524
  function perform(action: ActionId) {
514
525
  setSheet(null);
@@ -520,65 +531,64 @@ function ItemRow({ item, first, actions }: { item: Item; first: boolean; actions
520
531
  // A menu with one action is a wasted tap: show that action instead of ⋯. The card still opens the sheet [ATT-06].
521
532
  const entries = sheetEntries(item, agent, actions, handlers);
522
533
  const only = entries.length === 1 ? entries[0] : undefined;
523
-
524
- const buttons = (
525
- <View style={styles.wrap}>
526
- {actions.busy === item.key ? (
527
- <Text style={styles.muted}>working…</Text>
528
- ) : agent && sessionKind ? (
529
- <Button label={CONTINUE_LABELS[sessionKind]} icon="agent" variant="calm" onPress={() => actions.openAgent(agent.id)} />
530
- ) : main ? (
531
- <Button label={actionLabel(main, item)} icon={ACTION_ICONS[main]} variant="calm" onPress={() => perform(main)} />
532
- ) : null}
533
- {only ? (
534
- <Button icon={only.icon} variant="ghost" accessibilityLabel={only.label} onPress={only.onPress} />
535
- ) : (
536
- <Button icon="dots" variant="ghost" accessibilityLabel="More actions" onPress={open} />
537
- )}
538
- </View>
539
- );
534
+ const confirmed = (action: "merge" | "close") => (comment: string) => (setConfirm(null), actions.confirm(item, action, comment));
540
535
 
541
536
  return (
542
- <View style={first ? null : styles.divider}>
543
- <View style={styles.item}>
544
- <View style={{ paddingTop: 3 }}>
545
- <TablerIcon name={icon.name} color={icon.color} size={18} />
546
- </View>
547
- <View style={styles.body}>
548
- <Pressable accessibilityRole="button" accessibilityLabel={`${item.title}, more`} onPress={open} style={{ gap: 6 }}>
549
- <Text style={styles.title} numberOfLines={styles.compact ? 2 : 1}>
550
- {item.title}
551
- </Text>
552
- <Meta facts={facts} chips={chips} />
537
+ <CardRow
538
+ first={first}
539
+ mark={stateMark(item)}
540
+ title={item.title}
541
+ meta={{
542
+ place: `${item.repo.split("/")[1]} #${item.number}`,
543
+ when: item.closedAt ? `${item.kind === "pr" ? "merged" : "closed"} ${ago(item.closedAt)} ago` : undefined,
544
+ signals: chips,
545
+ }}
546
+ extra={
547
+ item.person || children.length > 0 ? (
548
+ <>
553
549
  {item.person ? <PersonQuote person={item.person} expanded={false} /> : null}
554
550
  {children.length > 0 ? <StackLine rows={children} merged={!!item.closedAt} /> : null}
555
- </Pressable>
556
- {styles.compact ? buttons : null}
557
- {confirm ? (
558
- <View style={styles.panel}>
559
- <Text style={styles.text}>
560
- {confirm === "merge"
561
- ? `Merge PR ${item.target.number} into ${item.target.baseRefName} (${item.target.mergeMethod})?`
562
- : `Close PR ${item.target.number}? A comment is only posted if you write one.`}
563
- </Text>
564
- {confirm === "close" ? (
565
- <TextInput style={styles.input} placeholder="Closing comment (optional)" placeholderTextColor={styles.c.foregroundMuted} value={comment} onChangeText={setComment} multiline />
566
- ) : null}
567
- <View style={styles.wrap}>
568
- <Button label={confirm === "merge" ? "Merge" : "Close PR"} icon={confirm} variant="solid" onPress={() => (setConfirm(null), actions.confirm(item, confirm, comment))} />
569
- <Button label="Cancel" onPress={() => setConfirm(null)} />
570
- </View>
571
- </View>
572
- ) : null}
573
- </View>
574
- {styles.compact ? null : buttons}
575
- </View>
576
- {sheet === "item" ? (
577
- <ItemSheet item={item} agent={agent} actions={actions} {...handlers} />
578
- ) : null}
579
- {sheet === "acknowledge" ? <AcknowledgeSheet item={item} onReact={(ids) => (setSheet(null), actions.acknowledge(item, ids))} onClose={() => setSheet(null)} /> : null}
580
- {sheet && typeof sheet === "object" ? <SessionOptions item={item} kind={sheet.options} actions={actions} onClose={() => setSheet(null)} /> : null}
581
- </View>
551
+ </>
552
+ ) : null
553
+ }
554
+ onOpen={open}
555
+ busy={actions.busy === item.key}
556
+ primary={
557
+ agent && sessionKind
558
+ ? { label: CONTINUE_LABELS[sessionKind], icon: "agent", onPress: () => actions.openAgent(agent.id) }
559
+ : main
560
+ ? { label: actionLabel(main, item), icon: ACTION_ICONS[main], onPress: () => perform(main) }
561
+ : undefined
562
+ }
563
+ secondary={[
564
+ only ? { label: only.label, icon: only.icon, onPress: only.onPress } : { label: "More actions", icon: "dots", onPress: open },
565
+ // History is where I report from, so its cards copy their link in one tap [ATT-15].
566
+ ...(history ? [{ label: `Copy link to #${item.number}`, icon: "copy" as const, onPress: () => copy(item.url, `Copied link to #${item.number}`) }] : []),
567
+ ]}
568
+ confirm={
569
+ confirm === "merge"
570
+ ? {
571
+ text: `Merge PR ${item.target.number} into ${item.target.baseRefName} (${item.target.mergeMethod})?`,
572
+ choices: [{ label: "Merge", icon: "merge", solid: true, onConfirm: confirmed("merge") }],
573
+ onCancel: () => setConfirm(null),
574
+ }
575
+ : confirm === "close"
576
+ ? {
577
+ text: `Close PR ${item.target.number}? A comment is only posted if you write one.`,
578
+ comment: true,
579
+ choices: [{ label: "Close PR", icon: "close", solid: true, onConfirm: confirmed("close") }],
580
+ onCancel: () => setConfirm(null),
581
+ }
582
+ : null
583
+ }
584
+ overlay={
585
+ <>
586
+ {sheet === "item" ? <ItemSheet item={item} agent={agent} actions={actions} {...handlers} /> : null}
587
+ {sheet === "acknowledge" ? <AcknowledgeSheet item={item} onReact={(ids) => (setSheet(null), actions.acknowledge(item, ids))} onClose={() => setSheet(null)} /> : null}
588
+ {sheet && typeof sheet === "object" ? <SessionOptions item={item} kind={sheet.options} actions={actions} onClose={() => setSheet(null)} /> : null}
589
+ </>
590
+ }
591
+ />
582
592
  );
583
593
  }
584
594
 
@@ -647,8 +657,15 @@ function sheetEntries(
647
657
  entries.push({ key: action, icon: ACTION_ICONS[action], label, detail: actionDetail(action, item), onPress: () => onPerform(action) });
648
658
  }
649
659
  }
650
- // Anything Attention Span doesn't cover [ATT-12].
651
- entries.push({ key: "github", icon: "github", label: `Open ${item.kind === "issue" ? "issue" : "PR"} on GitHub`, detail: `${item.repo}#${item.number}`, onPress: close(() => void openExternalUrl(item.url)) });
660
+ // Anything Attention Span doesn't cover [ATT-12], and its link to share [ATT-15].
661
+ entries.push({
662
+ key: "github",
663
+ icon: "github",
664
+ label: `Open ${item.kind === "issue" ? "issue" : "PR"} on GitHub`,
665
+ detail: `${item.repo}#${item.number}`,
666
+ onPress: close(() => void openExternalUrl(item.url)),
667
+ copy: { text: item.url, label: `Copy link to #${item.number}`, done: `Copied link to #${item.number}` },
668
+ });
652
669
  if (inDoing) entries.push({ key: "dismiss", icon: "dismiss", label: "Dismiss", detail: "Hides it until something new happens on it", onPress: close(() => actions.dismiss(item)) });
653
670
  return entries;
654
671
  }
@@ -730,13 +747,12 @@ function Sections({ sections, actions, empty }: { sections: Section[]; actions:
730
747
  }
731
748
 
732
749
  function Card({ items, actions }: { items: Item[]; actions: Actions }) {
733
- const styles = useStyles();
734
750
  return (
735
- <View style={styles.card}>
751
+ <CardList>
736
752
  {items.map((item, index) => (
737
753
  <ItemRow key={item.key} item={item} first={index === 0} actions={actions} />
738
754
  ))}
739
- </View>
755
+ </CardList>
740
756
  );
741
757
  }
742
758
 
@@ -758,8 +774,10 @@ function weekLabel(monday: Date): string {
758
774
  }
759
775
 
760
776
  // What I finished, by week, with reviews tucked away per week [HIS-01, HIS-02].
777
+ // A week copies as a list of links to paste into a report; reviews stay out of it [HIS-03].
761
778
  function History({ items, actions }: { items: Item[]; actions: Actions }) {
762
779
  const styles = useStyles();
780
+ const copy = useCopy();
763
781
  const [open, setOpen] = useState<string | null>(null);
764
782
  if (items.length === 0) return <Text style={styles.text}>Nothing finished in this period.</Text>;
765
783
  const weeks = new Map<number, Item[]>();
@@ -774,7 +792,21 @@ function History({ items, actions }: { items: Item[]; actions: Actions }) {
774
792
  const label = weekLabel(new Date(week));
775
793
  blocks.push(
776
794
  <View key={week} style={{ gap: 8 }}>
777
- <SectionHeader icon="clock" title={label} count={done.length} />
795
+ <SectionHeader
796
+ icon="clock"
797
+ title={label}
798
+ count={done.length}
799
+ action={
800
+ done.length > 0 ? (
801
+ <Button
802
+ icon="copy"
803
+ variant="ghost"
804
+ accessibilityLabel={`Copy links from ${label}`}
805
+ onPress={() => copy(linkList(done), `Copied ${done.length} link${done.length === 1 ? "" : "s"} from ${label}`)}
806
+ />
807
+ ) : null
808
+ }
809
+ />
778
810
  {done.length > 0 ? <Card items={done} actions={actions} /> : null}
779
811
  {reviewed.length > 0 ? (
780
812
  <View style={{ gap: 8 }}>
@@ -800,7 +832,7 @@ function StackLine({ rows, merged, links = false }: { rows: SubRow[]; merged: bo
800
832
  <StackRow key={row.key} url={row.url} number={row.number} link={links}>
801
833
  <View style={{ width: 16, alignItems: "center" }}>
802
834
  <View style={{ width: 2, flex: 1, backgroundColor: index === 0 ? "transparent" : styles.c.border }} />
803
- <TablerIcon name={merged ? "merge" : row.draft ? "draft" : "pr"} size={14} color={merged ? styles.c.accent : row.draft ? styles.c.foregroundMuted : styles.c.statusSuccess} />
835
+ <TablerIcon name={merged ? "merge" : row.draft ? "draft" : "pr"} size={14} color={merged ? styles.c.statusSuccess : row.draft ? styles.c.foregroundMuted : styles.c.statusSuccess} />
804
836
  <View style={{ width: 2, flex: 1, backgroundColor: index === rows.length - 1 ? "transparent" : styles.c.border }} />
805
837
  </View>
806
838
  <View style={{ flex: 1, paddingVertical: 3, gap: 2 }}>
@@ -0,0 +1,129 @@
1
+ import { TextInput } from "@getpaseo/plugin/client/ui";
2
+ import { type ReactNode, useState } from "react";
3
+ import { Pressable, Text, View } from "react-native";
4
+ import type { Chip } from "../shared/attention";
5
+ import type { IconName } from "./icons";
6
+ import { Button, Meta, TablerIcon, toneColor, useStyles } from "./ui";
7
+
8
+ // Every card in every list has this anatomy; tabs fill it in with data and slots, not layout [ATT-05].
9
+ //
10
+ // [mark] title (2 lines at most) [actions] ← desktop
11
+ // place · when · signals
12
+ // extra (slot)
13
+ // [actions] ← phone, labelled
14
+ // confirm bar
15
+ //
16
+ // Colors come only from tones, so a card can't pick a theme color that some themes render plain.
17
+
18
+ export type Tone = Chip["tone"];
19
+
20
+ export interface CardAction {
21
+ label: string;
22
+ icon: IconName;
23
+ onPress: () => void;
24
+ // Defaults to the label.
25
+ accessibilityLabel?: string;
26
+ }
27
+
28
+ export interface ConfirmSpec {
29
+ text: string;
30
+ // A comment field whose text each choice receives.
31
+ comment?: boolean;
32
+ choices: { label: string; icon: IconName; solid?: boolean; onConfirm: (comment: string) => void }[];
33
+ onCancel: () => void;
34
+ }
35
+
36
+ export interface CardProps {
37
+ mark: { icon: IconName; tone: Tone };
38
+ title: string;
39
+ // "repo #number", then when it happened, then signals [ATT-05].
40
+ meta: { place: string; when?: string; signals: Chip[] };
41
+ // Defaults to "<title>, more".
42
+ accessibilityLabel?: string;
43
+ // Tapping the card opens its sheet [ATT-06].
44
+ onOpen: () => void;
45
+ // The labelled main action; secondary ones are icon-only (⋯, copy).
46
+ primary?: CardAction;
47
+ secondary: CardAction[];
48
+ // "working…" in place of the actions while a GitHub change runs.
49
+ busy?: boolean;
50
+ // Content only some lists have: tags, a quote, a stack line.
51
+ extra?: ReactNode;
52
+ confirm?: ConfirmSpec | null;
53
+ // Sheets and pickers opened from the card.
54
+ overlay?: ReactNode;
55
+ }
56
+
57
+ export function CardList({ children }: { children: ReactNode }) {
58
+ const styles = useStyles();
59
+ return <View style={styles.card}>{children}</View>;
60
+ }
61
+
62
+ export function CardRow({ first, mark, title, meta, accessibilityLabel, onOpen, primary, secondary, busy, extra, confirm, overlay }: CardProps & { first: boolean }) {
63
+ const styles = useStyles();
64
+ const actions = (
65
+ <View style={styles.wrap}>
66
+ {busy ? (
67
+ <Text style={styles.muted}>working…</Text>
68
+ ) : primary ? (
69
+ <Button label={primary.label} accessibilityLabel={primary.accessibilityLabel} icon={primary.icon} variant="calm" onPress={primary.onPress} />
70
+ ) : null}
71
+ {secondary.map((action) => (
72
+ <Button key={action.accessibilityLabel ?? action.label} icon={action.icon} variant="ghost" accessibilityLabel={action.accessibilityLabel ?? action.label} onPress={action.onPress} />
73
+ ))}
74
+ </View>
75
+ );
76
+ return (
77
+ <View style={first ? null : styles.divider}>
78
+ <View style={styles.item}>
79
+ <Mark {...mark} />
80
+ <View style={styles.body}>
81
+ <Pressable accessibilityRole="button" accessibilityLabel={accessibilityLabel ?? `${title}, more`} onPress={onOpen} style={{ gap: 6 }}>
82
+ <Text style={styles.title} numberOfLines={2}>
83
+ {title}
84
+ </Text>
85
+ <Meta facts={meta.when ? [meta.place, meta.when] : [meta.place]} chips={meta.signals} />
86
+ {extra}
87
+ </Pressable>
88
+ {/* On phones the actions sit under the text, labelled, so mixed actions stay readable. */}
89
+ {styles.compact ? actions : null}
90
+ {confirm ? <ConfirmBar {...confirm} /> : null}
91
+ </View>
92
+ {styles.compact ? null : actions}
93
+ </View>
94
+ {overlay}
95
+ </View>
96
+ );
97
+ }
98
+
99
+ // What the card is, as an icon on a softly tinted square.
100
+ export function Mark({ icon, tone }: { icon: IconName; tone: Tone }) {
101
+ const styles = useStyles();
102
+ const color = toneColor(styles, tone);
103
+ return (
104
+ <View style={{ width: 30, height: 30, borderRadius: 8, alignItems: "center", justifyContent: "center" }}>
105
+ <View style={{ position: "absolute", top: 0, left: 0, right: 0, bottom: 0, borderRadius: 8, backgroundColor: color, opacity: 0.16 }} />
106
+ <TablerIcon name={icon} size={17} color={color} />
107
+ </View>
108
+ );
109
+ }
110
+
111
+ // A change on GitHub asks first, on the card [SAFE-01].
112
+ export function ConfirmBar({ text, comment, choices, onCancel }: ConfirmSpec) {
113
+ const styles = useStyles();
114
+ const [value, setValue] = useState("");
115
+ return (
116
+ <View style={styles.panel}>
117
+ <Text style={styles.text}>{text}</Text>
118
+ {comment ? (
119
+ <TextInput style={styles.input} placeholder="Closing comment (optional)" placeholderTextColor={styles.c.foregroundMuted} value={value} onChangeText={setValue} multiline />
120
+ ) : null}
121
+ <View style={styles.wrap}>
122
+ {choices.map((choice) => (
123
+ <Button key={choice.label} label={choice.label} icon={choice.icon} variant={choice.solid ? "solid" : "plain"} onPress={() => choice.onConfirm(value)} />
124
+ ))}
125
+ <Button label="Cancel" variant="ghost" onPress={onCancel} />
126
+ </View>
127
+ </View>
128
+ );
129
+ }
@@ -1,5 +1,5 @@
1
1
  import { type PluginSurfaceProps, useRpc } from "@getpaseo/plugin/client";
2
- import { SettingsAction, SettingsCard, SettingsRow, SettingsSection, TextInput } from "@getpaseo/plugin/client/ui";
2
+ import { SettingsAction, SettingsCard, SettingsRow, SettingsSection, SettingsSelect, SettingsSwitch, TextInput } from "@getpaseo/plugin/client/ui";
3
3
  import { useQuery, useQueryClient } from "@tanstack/react-query";
4
4
  import { useState } from "react";
5
5
  import { Text, View } from "react-native";
@@ -9,8 +9,12 @@ import { VIEW_QUERY_KEY } from "./data";
9
9
  import { Button, StylesProvider, useStyles } from "./ui";
10
10
 
11
11
  const COVERAGE_QUERY_KEY = ["attention-span", "coverage"] as const;
12
+ const MY_ORGS_QUERY_KEY = ["attention-span", "my-orgs"] as const;
13
+ // A caption belongs to the card above it, so it sits closer to that card than to the next heading.
14
+ const CAPTION = { marginTop: -24, marginBottom: 16 };
12
15
 
13
- // Settings → Plugins → Attention Span: which orgs and repos the lists cover, saved to config.json [SRC-02].
16
+ // Settings → Plugins → Attention Span: which orgs and repos the lists cover, and where Next up looks,
17
+ // saved to config.json [SRC-02, NXT-04].
14
18
  export function CoverageSettings({ theme, layout }: PluginSurfaceProps) {
15
19
  return (
16
20
  <StylesProvider theme={theme} compact={layout.compact}>
@@ -24,6 +28,7 @@ function Coverage() {
24
28
  const queryClient = useQueryClient();
25
29
  const fetchCoverage = useRpc(rpc.getCoverage);
26
30
  const save = useRpc(rpc.setCoverage);
31
+ const saveNextUp = useRpc(rpc.setNextUpSources);
27
32
  const coverage = useQuery({ queryKey: COVERAGE_QUERY_KEY, queryFn: () => fetchCoverage({}) });
28
33
  const [saving, setSaving] = useState(false);
29
34
  const [error, setError] = useState<string | null>(null);
@@ -36,7 +41,7 @@ function Coverage() {
36
41
  </SettingsCard>
37
42
  </SettingsSection>
38
43
  );
39
- const { orgs, repos } = coverage.data;
44
+ const { orgs, repos, nextUp } = coverage.data;
40
45
  // A file that doesn't parse is left for the person who edited it.
41
46
  if (coverage.data.error)
42
47
  return (
@@ -48,11 +53,11 @@ function Coverage() {
48
53
  );
49
54
 
50
55
  // Saving refreshes the lists on the daemon; the screen picks them up on its next read.
51
- async function persist(next: Pick<ConfigStatus, "orgs" | "repos">) {
56
+ async function write(next: Partial<ConfigStatus>, send: () => Promise<unknown>) {
52
57
  setSaving(true);
53
58
  setError(null);
54
59
  try {
55
- await save(next);
60
+ await send();
56
61
  queryClient.setQueryData(COVERAGE_QUERY_KEY, { ...coverage.data!, ...next });
57
62
  await queryClient.invalidateQueries({ queryKey: VIEW_QUERY_KEY });
58
63
  } catch (failure) {
@@ -61,6 +66,9 @@ function Coverage() {
61
66
  setSaving(false);
62
67
  }
63
68
  }
69
+ const persist = (next: Pick<ConfigStatus, "orgs" | "repos">) => write(next, () => save(next));
70
+ const persistNextUp = (next: ConfigStatus["nextUp"]) => write({ nextUp: next }, () => saveNextUp(next));
71
+ const chosen = nextUp.mine || nextUp.orgs.length > 0 || nextUp.repos.length > 0;
64
72
 
65
73
  return (
66
74
  <View style={{ gap: 24 }}>
@@ -72,21 +80,33 @@ function Coverage() {
72
80
  <AddRow kind="org" existing={orgs} disabled={saving} onAdd={(name) => persist({ orgs: [...orgs, name], repos })} />
73
81
  </SettingsCard>
74
82
  </SettingsSection>
75
- <SettingsSection title="Repositories">
76
- <SettingsCard>
77
- {repos.map((repo) => (
78
- <SettingsAction key={repo} label={repo} actionLabel="Remove" disabled={saving} onPress={() => void persist({ orgs, repos: repos.filter((other) => other !== repo) })} />
79
- ))}
80
- <AddRow kind="repo" existing={repos} disabled={saving} onAdd={(name) => persist({ orgs, repos: [...repos, name] })} />
81
- </SettingsCard>
82
- </SettingsSection>
83
- <View style={{ gap: 4 }}>
84
- {error ? <Text style={styles.danger}>{error}</Text> : null}
85
- <Text style={styles.muted}>
83
+ <View style={{ gap: 8 }}>
84
+ <SettingsSection title="Repositories">
85
+ <SettingsCard>
86
+ {repos.map((repo) => (
87
+ <SettingsAction key={repo} label={repo} actionLabel="Remove" disabled={saving} onPress={() => void persist({ orgs, repos: repos.filter((other) => other !== repo) })} />
88
+ ))}
89
+ <AddRow kind="repo" existing={repos} disabled={saving} onAdd={(name) => persist({ orgs, repos: [...repos, name] })} />
90
+ </SettingsCard>
91
+ </SettingsSection>
92
+ <Text style={[styles.muted, CAPTION]}>
86
93
  {orgs.length || repos.length
87
- ? "Attention Span only shows pull requests and issues from the organizations and repositories above. Next up suggests unclaimed issues from them too."
88
- : "With none chosen, Attention Span shows everything on GitHub that involves you, and Next up suggests issues from your Paseo projects' repositories."}
94
+ ? "Attention Span only shows pull requests and issues from the organizations and repositories above."
95
+ : "With none chosen, Attention Span shows everything on GitHub that involves you."}
96
+ </Text>
97
+ </View>
98
+ <View style={{ gap: 8 }}>
99
+ <NextUpSources value={nextUp} disabled={saving} onChange={persistNextUp} />
100
+ <Text style={[styles.muted, CAPTION]}>
101
+ {chosen
102
+ ? "Next up suggests unclaimed issues from these."
103
+ : orgs.length || repos.length
104
+ ? "None chosen: using the orgs and repos above."
105
+ : "None chosen: using your Paseo projects."}
89
106
  </Text>
107
+ </View>
108
+ <View style={{ gap: 4 }}>
109
+ {error ? <Text style={styles.danger}>{error}</Text> : null}
90
110
  {/* Until more moves here, point to the file for the rest. */}
91
111
  <Text style={styles.muted}>Settings are not complete yet. Until then, check out your ~/.config/paseo-attention-span/config.json for more options.</Text>
92
112
  </View>
@@ -94,8 +114,41 @@ function Coverage() {
94
114
  );
95
115
  }
96
116
 
117
+ // Where Next up looks [NXT-04]: my own repos, orgs I belong to, and single repos. Each is its own chip on Next up [NXT-09].
118
+ function NextUpSources({ value, disabled, onChange }: { value: ConfigStatus["nextUp"]; disabled: boolean; onChange: (next: ConfigStatus["nextUp"]) => Promise<void> }) {
119
+ const fetchOrgs = useRpc(rpc.myOrgs);
120
+ const myOrgs = useQuery({ queryKey: MY_ORGS_QUERY_KEY, queryFn: () => fetchOrgs({}) });
121
+ const choosable = (myOrgs.data?.orgs ?? []).filter((org) => !value.orgs.some((added) => added.toLowerCase() === org.toLowerCase()));
122
+ return (
123
+ <SettingsSection title="Next up">
124
+ <SettingsCard>
125
+ <SettingsSwitch label="My repos" value={value.mine} disabled={disabled} onValueChange={(mine) => void onChange({ ...value, mine })} />
126
+ {value.orgs.map((org) => (
127
+ <SettingsAction key={`org:${org}`} label={org} actionLabel="Remove" disabled={disabled} onPress={() => void onChange({ ...value, orgs: value.orgs.filter((other) => other !== org) })} />
128
+ ))}
129
+ {value.repos.map((repo) => (
130
+ <SettingsAction key={`repo:${repo}`} label={repo} actionLabel="Remove" disabled={disabled} onPress={() => void onChange({ ...value, repos: value.repos.filter((other) => other !== repo) })} />
131
+ ))}
132
+ {myOrgs.data && myOrgs.data.orgs.length === 0 ? (
133
+ <SettingsRow label="Add an organization" hint="You're not a member of any organizations" />
134
+ ) : (
135
+ <SettingsSelect
136
+ label="Add an organization"
137
+ error={myOrgs.error ? (myOrgs.error as Error).message : null}
138
+ value=""
139
+ options={[{ label: myOrgs.isLoading ? "Loading…" : "Choose…", value: "" }, ...choosable.map((org) => ({ label: org, value: org }))]}
140
+ disabled={disabled || choosable.length === 0}
141
+ onValueChange={(org) => void (org && onChange({ ...value, orgs: [...value.orgs, org] }))}
142
+ />
143
+ )}
144
+ <AddRow kind="repo" placeholder="owner/name" existing={value.repos} disabled={disabled} onAdd={(name) => onChange({ ...value, repos: [...value.repos, name] })} />
145
+ </SettingsCard>
146
+ </SettingsSection>
147
+ );
148
+ }
149
+
97
150
  // Each name is checked on GitHub before it's saved; GitHub's exact name is what's kept.
98
- function AddRow({ kind, existing, disabled, onAdd }: { kind: CoverageKind; existing: string[]; disabled: boolean; onAdd: (name: string) => Promise<void> }) {
151
+ function AddRow({ kind, placeholder, existing, disabled, onAdd }: { kind: CoverageKind; placeholder?: string; existing: string[]; disabled: boolean; onAdd: (name: string) => Promise<void> }) {
99
152
  const styles = useStyles();
100
153
  const check = useRpc(rpc.checkCoverage);
101
154
  const [text, setText] = useState("");
@@ -130,7 +183,7 @@ function AddRow({ kind, existing, disabled, onAdd }: { kind: CoverageKind; exist
130
183
  setText(value);
131
184
  setError(null);
132
185
  }}
133
- placeholder={kind === "org" ? "acme" : "acme/shop"}
186
+ placeholder={placeholder ?? (kind === "org" ? "acme" : "acme/shop")}
134
187
  placeholderTextColor={styles.c.foregroundMuted}
135
188
  autoCapitalize="none"
136
189
  autoCorrect={false}