@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/client/icons.ts CHANGED
@@ -17,6 +17,7 @@ export const ICONS = {
17
17
  close: { 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=\"M18 6L6 18M6 6l12 12\"/></svg>" },
18
18
  play: { 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=\"M7 4v16l13-8z\"/></svg>" },
19
19
  github: { 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 19c-4.3 1.4-4.3-2.5-6-3m12 5v-3.5c0-1 .1-1.4-.5-2c2.8-.3 5.5-1.4 5.5-6a4.6 4.6 0 0 0-1.3-3.2a4.2 4.2 0 0 0-.1-3.2s-1.1-.3-3.5 1.3a12.3 12.3 0 0 0-6.2 0C6.5 2.8 5.4 3.1 5.4 3.1a4.2 4.2 0 0 0-.1 3.2A4.6 4.6 0 0 0 4 9.5c0 4.6 2.7 5.7 5.5 6c-.6.6-.6 1.2-.5 2V21\"/></svg>" },
20
+ copy: { 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=\"M7 9.667A2.667 2.667 0 0 1 9.667 7h8.666A2.667 2.667 0 0 1 21 9.667v8.666A2.667 2.667 0 0 1 18.333 21H9.667A2.667 2.667 0 0 1 7 18.333z\"/><path d=\"M4.012 16.737A2 2 0 0 1 3 15V5c0-1.1.9-2 2-2h10c.75 0 1.158.385 1.5 1\"/></g></svg>" },
20
21
  dismiss: { 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=\"M10.585 10.587a2 2 0 0 0 2.829 2.828\"/><path d=\"M16.681 16.673A8.7 8.7 0 0 1 12 18q-5.4 0-9-6q1.908-3.18 4.32-4.674m2.86-1.146A9 9 0 0 1 12 6q5.4 0 9 6q-1 1.665-2.138 2.87M3 3l18 18\"/></g></svg>" },
21
22
  // The plugin's logo in one colour, for the sidebar (assets/logo.svg).
22
23
  logo: { svg: "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"207 195 585 585\" fill=\"currentColor\"><path d=\"M 562.9 297.9 C 577.2 309.5 586.1 323.3 595.5 338.9 C 599.6 345.7 603.7 352.3 607.9 358.9 C 624.5 384.8 640.6 410.9 656.4 437.3 C 659.6 442.7 662.8 448.1 666.1 453.4 C 667.3 455.5 668.6 457.6 669.8 459.7 C 670.4 460.6 670.9 461.5 671.5 462.5 C 673 465 674.5 467.5 676 470 C 675.7 470.7 675.3 471.3 675 472 C 673.8 470.7 672.5 469.4 671.2 468.1 C 640.6 436.7 605.7 416.8 561.3 415 C 497.3 414.6 443.8 453.2 399 495 C 397.6 496.3 396.2 497.6 394.8 498.9 C 384.5 508.6 374.3 518.3 365 529 C 362.7 531.3 360.3 533.7 358 536 C 355.7 538.7 353.3 541.3 351 544 C 349.4 545.8 347.8 547.5 346.1 549.3 C 342 553.8 338.1 558.5 334.3 563.2 C 331.9 566.1 329.5 568.8 327 571.5 C 322.9 575.9 319.1 580.5 315.3 585.1 C 312.8 588.2 310.2 591.3 307.6 594.3 C 302.9 599.9 298.4 605.5 293.9 611.3 C 290.7 615.4 287.4 619.4 284 623.5 C 279.8 628.6 275.6 633.8 271.5 639 C 248.5 668.5 248.5 668.5 241 671 C 234.5 671.8 229.5 671.7 223.5 668.9 C 219.1 665.2 215.8 661.5 214 656 C 213.3 646.3 216.7 639.9 222.3 632.2 C 223.4 630.8 224.5 629.3 225.6 627.8 C 226.7 626.2 227.8 624.6 229 623 C 231.3 619.7 233.6 616.5 235.9 613.2 C 237.1 611.5 238.2 609.8 239.4 608.1 C 240 607.3 240.6 606.4 241.2 605.6 C 243 603 244.8 600.4 246.6 597.8 C 252 590.2 257.3 582.5 262.6 574.8 C 267.3 568 272 561.3 276.7 554.7 C 282.5 546.5 288.2 538.2 293.9 530 C 297.3 525.1 300.6 520.3 304 515.5 C 305.3 513.6 306.7 511.7 308 509.7 C 364 429.2 364 429.2 366 426.4 C 367.3 424.5 368.7 422.5 370 420.6 C 373.3 415.8 376.7 411 380 406.2 C 388.5 394.1 396.9 381.8 405.2 369.6 C 408 365.5 410.8 361.5 413.6 357.4 C 418.2 350.7 422.7 343.9 427.2 337.1 C 428.4 335.4 429.6 333.6 430.8 331.8 C 432.7 328.9 434.6 326.1 436.5 323.2 C 450.8 302 470.3 287 495.6 281.4 C 520.2 278.3 542.9 282.9 562.9 297.9 Z\"/><path d=\"M 576.8 472.7 C 577.6 472.7 577.6 472.7 581.9 472.7 C 593.2 472.8 603.9 473.3 615 476 C 616.6 476.4 618.2 476.8 619.8 477.2 C 653.1 486.3 682.9 506.7 704 534 C 705.2 535.5 706.4 537 707.7 538.5 C 718.6 552.2 728.7 566.7 739 581 C 740.1 582.5 741.2 584 742.3 585.5 C 748.6 594.2 754.8 602.9 761 611.7 C 765.2 617.8 769.6 623.8 774 629.8 C 781.8 640.7 785.2 647.6 784 661 C 780.2 671 774.4 678.5 765 683.4 C 752.7 689 740.9 689.6 728 685 C 708.8 676.4 695.5 661.4 683 645 C 682.2 644 681.4 642.9 680.5 641.8 C 673.5 632.7 666.7 623.4 660 614 C 657.8 611 655.7 608 653.5 605 C 652.4 603.5 651.4 602 650.3 600.5 C 648.1 597.5 645.9 594.4 643.6 591.4 C 638.8 584.6 633.9 577.9 629.1 571.1 C 610.5 545.1 610.5 545.1 601 535 C 600 533.7 598.9 532.4 597.8 531.1 C 584 516.2 567 505.1 548 498 C 547 497.6 546 497.2 545 496.8 C 532.1 492.2 519.1 491.7 505.6 491.9 C 504.2 491.9 502.8 491.9 501.3 491.9 C 497.9 491.9 494.4 492 491 492 C 499.6 483.4 519 480.2 530.6 477.6 C 531.6 477.3 532.6 477.1 533.6 476.9 C 548 473.7 562 472.6 576.8 472.7 Z\"/><path fill-rule=\"evenodd\" d=\"M 510 543 C 510.5 543.2 510.5 543.2 512.8 544.3 C 530.3 552.9 543.5 569.8 550.4 587.8 C 553.3 597 554.3 605.2 554.3 614.8 C 554.3 615.9 554.3 617 554.4 618.1 C 554.4 639.1 544.4 657.2 530.3 672.2 C 524.8 677.5 518.7 681.3 512 685 C 511.2 685.5 511.2 685.5 506.9 687.8 C 488.9 695.8 468.4 696.2 449.7 689.9 C 427.8 681.2 412.1 665.9 402.5 644.6 C 395.2 626.6 394.4 606.4 401 588 C 404.9 578.8 409.5 570.6 416 563 C 416.9 561.9 417.8 560.7 418.7 559.5 C 442.5 534.3 479.1 528.1 510 543 Z M 465.2 570.6 C 471.2 574.4 474.4 578.4 477 585 C 477.5 591.4 476.9 596.2 474 602 C 468.5 607.4 464.9 609.9 457.2 610.3 C 452.1 610.2 448.4 609.8 444 607 C 436.8 599.4 435.5 596.1 435.6 585.8 C 436.2 580.3 438 577.8 442 574 C 450.1 569 456.1 567.2 465.2 570.6 Z\"/></svg>" },
@@ -36,6 +37,7 @@ export const ICONS = {
36
37
  settings: { 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=\"M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 0 0 2.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 0 0 1.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 0 0-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 0 0-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 0 0-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 0 0-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 0 0 1.066-2.573c-.94-1.543.826-3.31 2.37-2.37c1 .608 2.296.07 2.572-1.065\"/><path d=\"M9 12a3 3 0 1 0 6 0a3 3 0 0 0-6 0\"/></g></svg>" },
37
38
  reload: { 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=\"M19.933 13.041a8 8 0 1 1-9.925-8.788c3.899-1 7.935 1.007 9.425 4.747M20 4v5h-5\"/></svg>" },
38
39
  unclaim: { 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=\"M8 7a4 4 0 1 0 8 0a4 4 0 0 0-8 0M6 21v-2a4 4 0 0 1 4-4h4c.348 0 .686.045 1.009.128M16 19h6\"/></svg>" },
40
+ 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>" },
39
41
  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>" },
40
42
  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>" },
41
43
  // Tabler message-ai: marks actions that start or continue an agent session.
@@ -2,12 +2,15 @@ import { openExternalUrl } from "@getpaseo/plugin/client";
2
2
  import { useQuery } from "@tanstack/react-query";
3
3
  import { useMemo, useState } from "react";
4
4
  import { Pressable, Text, View } from "react-native";
5
- import { ago } from "../shared/format";
6
- import type { AgentSummary, NextUpIssue, UnclaimedSource } from "../shared/attention";
5
+ import { ago, shortValue } from "../shared/format";
6
+ import type { AgentSummary, Chip, IssueCloseReason, NextUpIssue, UnclaimedSource } from "../shared/attention";
7
+ import type { NextUpSource } from "../shared/config";
7
8
  import type { IconName } from "./icons";
8
9
  import type { FetchDetails } from "./attention-screen";
10
+ import { CardList, CardRow, type Tone } from "./card";
9
11
  import { ActionSheet, DetailLines, type SheetEntry } from "./sheet";
10
- import { Button, Meta, SectionHeader, TablerIcon, Toggle, useStyles } from "./ui";
12
+ import { Modal } from "@getpaseo/plugin/client/ui";
13
+ import { Button, KeepStyles, Meta, SectionHeader, TablerIcon, useHover, useStyles } from "./ui";
11
14
 
12
15
  const TYPE_ICONS: Record<string, IconName> = { bug: "bug", feature: "feature", debt: "debt", task: "task", epic: "epic" };
13
16
 
@@ -15,28 +18,46 @@ interface Props {
15
18
  assigned: NextUpIssue[];
16
19
  unclaimed: NextUpIssue[];
17
20
  unclaimedFrom: UnclaimedSource;
18
- // Scope chips I picked; none means all [NXT-03].
21
+ // Scopes I ticked in the filter; none means all [NXT-03].
19
22
  selected: string[];
20
23
  onSelect: (scopes: string[]) => void;
24
+ // Where Next up looks, and the sources I ticked; none means all [NXT-09].
25
+ sources: NextUpSource[];
26
+ selectedSources: string[];
27
+ onSelectSources: (sources: string[]) => void;
21
28
  agents: Record<string, AgentSummary>;
22
29
  busy: string | null;
23
30
  fetchDetails: FetchDetails;
24
31
  onStart: (issue: NextUpIssue, claim: boolean) => void;
25
32
  // Claim without starting, or give an assigned issue back [NXT-07].
26
33
  onClaim: (issue: NextUpIssue, on: boolean) => void;
34
+ // Close it, once I've confirmed the reason [NXT-11].
35
+ onCloseIssue: (issue: NextUpIssue, reason: IssueCloseReason, comment: string) => void;
27
36
  onOpenAgent: (agentId: string) => void;
28
37
  }
29
38
 
30
- type RowProps = Omit<Props, "assigned" | "unclaimed" | "unclaimedFrom" | "selected" | "onSelect">;
39
+ type RowProps = Omit<Props, "assigned" | "unclaimed" | "unclaimedFrom" | "selected" | "onSelect" | "sources" | "selectedSources" | "onSelectSources">;
31
40
 
32
41
  // Assigned issues first [NXT-06], then unclaimed ones [NXT-01]; both already ranked by the server [NXT-02].
33
- export function NextUpList({ assigned, unclaimed, unclaimedFrom, selected, onSelect, ...rowProps }: Props) {
42
+ export function NextUpList({ assigned, unclaimed, unclaimedFrom, selected, onSelect, sources, selectedSources, onSelectSources, ...rowProps }: Props) {
34
43
  const styles = useStyles();
35
44
  const scopes = useMemo(() => [...new Set(unclaimed.map((issue) => issue.scope).filter((scope): scope is string => !!scope))].sort(), [unclaimed]);
36
45
  // Filter by the scopes I picked last time [NXT-03]; a picked scope with no issues left is ignored.
37
46
  const active = selected.filter((scope) => scopes.includes(scope));
38
- const shown = active.length === 0 ? unclaimed : unclaimed.filter((issue) => issue.scope && active.includes(issue.scope));
47
+ // And by source, when there's more than one [NXT-09]; a picked source no longer in settings is ignored.
48
+ const activeSources = sources.length > 1 ? selectedSources.filter((id) => sources.some((source) => source.id === id)) : [];
49
+ const shown = unclaimed.filter(
50
+ (issue) => (active.length === 0 || (issue.scope && active.includes(issue.scope))) && (activeSources.length === 0 || issue.sources.some((id) => activeSources.includes(id))),
51
+ );
39
52
  const toggle = (scope: string) => onSelect(active.includes(scope) ? active.filter((s) => s !== scope) : [...active, scope]);
53
+ const toggleSource = (id: string) => onSelectSources(activeSources.includes(id) ? activeSources.filter((s) => s !== id) : [...activeSources, id]);
54
+ const narrowedBy = [activeSources.length ? "sources" : null, active.length ? "scopes" : null].filter(Boolean).join(" and ");
55
+ const [filtering, setFiltering] = useState(false);
56
+ const picked = active.length + activeSources.length;
57
+ const groups: FilterGroup[] = [
58
+ ...(sources.length > 1 ? [{ title: "Source", options: sources, active: activeSources, onToggle: toggleSource }] : []),
59
+ ...(scopes.length > 0 ? [{ title: "Scope", options: scopes.map((scope) => ({ id: scope, label: scope })), active, onToggle: toggle }] : []),
60
+ ];
40
61
 
41
62
  return (
42
63
  <View style={{ gap: 24 }}>
@@ -47,19 +68,36 @@ export function NextUpList({ assigned, unclaimed, unclaimedFrom, selected, onSel
47
68
  </View>
48
69
  ) : null}
49
70
  <View>
50
- <SectionHeader icon="nextUp" title="Unclaimed" count={shown.length} />
51
- {scopes.length > 0 ? (
52
- <View style={[styles.wrap, { marginBottom: 10 }]}>
53
- <Toggle label="All" active={active.length === 0} onPress={() => onSelect([])} />
54
- {scopes.map((scope) => (
55
- <Toggle key={scope} label={scope} active={active.includes(scope)} onPress={() => toggle(scope)} />
56
- ))}
57
- </View>
71
+ <SectionHeader
72
+ icon="nextUp"
73
+ title="Unclaimed"
74
+ count={shown.length}
75
+ action={
76
+ groups.length > 0 ? (
77
+ <Button
78
+ label={picked ? `Filter · ${picked}` : "Filter"}
79
+ accessibilityLabel={picked ? `Filter, ${picked} on` : "Filter"}
80
+ icon="filter"
81
+ variant={picked ? "calm" : "ghost"}
82
+ onPress={() => setFiltering(true)}
83
+ />
84
+ ) : null
85
+ }
86
+ />
87
+ {filtering ? (
88
+ <FilterSheet
89
+ groups={groups}
90
+ onClear={() => {
91
+ onSelect([]);
92
+ onSelectSources([]);
93
+ }}
94
+ onClose={() => setFiltering(false)}
95
+ />
58
96
  ) : null}
59
97
  {unclaimedFrom === "none" ? (
60
- <Text style={styles.text}>No repos to look in. Register a project in Paseo, or set nextUp.repos in config.json.</Text>
98
+ <Text style={styles.text}>No repos to look in. Register a project in Paseo, or choose where Next up looks in Settings.</Text>
61
99
  ) : shown.length === 0 ? (
62
- <Text style={styles.text}>No unclaimed issues{active.length ? " in these scopes" : ""}.</Text>
100
+ <Text style={styles.text}>No unclaimed issues{narrowedBy ? ` in these ${narrowedBy}` : ""}.</Text>
63
101
  ) : (
64
102
  <IssueList issues={shown} claim {...rowProps} />
65
103
  )}
@@ -68,49 +106,179 @@ export function NextUpList({ assigned, unclaimed, unclaimedFrom, selected, onSel
68
106
  );
69
107
  }
70
108
 
71
- function IssueList({ issues, claim, ...rowProps }: RowProps & { issues: NextUpIssue[]; claim: boolean }) {
109
+ // Source and scope filters behind one button, so they take no room above the list [NXT-03, NXT-09].
110
+ // Ticks apply right away; a bottom sheet on phones, a dialog on desktop.
111
+ function FilterSheet({ groups, onClear, onClose }: { groups: FilterGroup[]; onClear: () => void; onClose: () => void }) {
112
+ const styles = useStyles();
113
+ const any = groups.some((group) => group.active.length > 0);
114
+ return (
115
+ <Modal title="Filter" open onOpenChange={(open) => (open ? null : onClose())}>
116
+ <Modal.Content>
117
+ <KeepStyles styles={styles}>
118
+ {groups.map((group) => (
119
+ <View key={group.title} style={{ gap: 6 }}>
120
+ <Text style={styles.muted}>{group.title}</Text>
121
+ <View style={[styles.card, { backgroundColor: styles.c.surface2 }]}>
122
+ {group.options.map((option, index) => (
123
+ <FilterOption key={option.id} label={option.label} checked={group.active.includes(option.id)} first={index === 0} onPress={() => group.onToggle(option.id)} />
124
+ ))}
125
+ </View>
126
+ </View>
127
+ ))}
128
+ <View style={[styles.row, { justifyContent: "flex-end" }]}>
129
+ <Button label="Clear" variant="ghost" disabled={!any} onPress={onClear} />
130
+ <Button label="Done" variant="solid" onPress={onClose} />
131
+ </View>
132
+ </KeepStyles>
133
+ </Modal.Content>
134
+ </Modal>
135
+ );
136
+ }
137
+
138
+ interface FilterGroup {
139
+ title: string;
140
+ options: { id: string; label: string }[];
141
+ active: string[];
142
+ onToggle: (id: string) => void;
143
+ }
144
+
145
+ function FilterOption({ label, checked, first, onPress }: { label: string; checked: boolean; first: boolean; onPress: () => void }) {
72
146
  const styles = useStyles();
147
+ const { hovered, hover } = useHover();
148
+ return (
149
+ <Pressable
150
+ accessibilityRole="checkbox"
151
+ accessibilityState={{ checked }}
152
+ accessibilityLabel={label}
153
+ onPress={onPress}
154
+ {...hover}
155
+ style={({ pressed }) => [
156
+ styles.row,
157
+ { paddingVertical: 10, paddingHorizontal: 12, backgroundColor: pressed || hovered ? styles.c.border : "transparent" },
158
+ first ? null : { borderTopWidth: 1, borderTopColor: styles.c.surface1 },
159
+ ]}
160
+ >
161
+ <TablerIcon name={checked ? "squareCheck" : "square"} size={18} color={checked ? styles.action : styles.c.foregroundMuted} />
162
+ <Text style={styles.text}>{label}</Text>
163
+ </Pressable>
164
+ );
165
+ }
166
+
167
+ function IssueList({ issues, claim, ...rowProps }: RowProps & { issues: NextUpIssue[]; claim: boolean }) {
73
168
  return (
74
- <View style={styles.card}>
169
+ <CardList>
75
170
  {issues.map((issue, index) => (
76
171
  <IssueRow key={issue.key} issue={issue} claim={claim} first={index === 0} {...rowProps} />
77
172
  ))}
173
+ </CardList>
174
+ );
175
+ }
176
+
177
+ // What tells me whether to pick it up: where it lives and how old it is, then priority, effort and scope as tags [NXT-10].
178
+ // The type is the mark. The sheet has the full values.
179
+ const fullFacts = (issue: NextUpIssue) => [
180
+ `${issue.repo}#${issue.number}`,
181
+ `${ago(issue.createdAt)} old`,
182
+ ...[issue.type, issue.priority, issue.effort, issue.scope].filter((v): v is string => !!v),
183
+ ];
184
+
185
+ // An open PR that closes it means someone may already be on it [NXT-10].
186
+ function prSignal(issue: NextUpIssue): Chip[] {
187
+ const [first, ...more] = issue.openPrs;
188
+ if (!first) return [];
189
+ return [{ text: `PR by ${first.author ?? "someone"}${more.length ? ` +${more.length}` : ""}`, tone: "warn" }];
190
+ }
191
+
192
+ // The top priority is warm, the next accent, the rest quiet; unknown order stays quiet.
193
+ function Tags({ issue }: { issue: NextUpIssue }) {
194
+ const styles = useStyles();
195
+ const priorityColor = issue.priorityRank === 0 ? styles.c.statusWarning : issue.priorityRank === 1 ? styles.action : undefined;
196
+ const tags = [
197
+ issue.priority ? { key: "priority", text: shortValue(issue.priority), color: priorityColor } : null,
198
+ issue.effort ? { key: "effort", text: shortValue(issue.effort) } : null,
199
+ issue.scope ? { key: "scope", text: shortValue(issue.scope) } : null,
200
+ ].filter((tag): tag is { key: string; text: string; color?: string } => !!tag);
201
+ if (tags.length === 0) return null;
202
+ return (
203
+ <View style={[styles.wrap, { gap: 4, marginTop: 2 }]}>
204
+ {tags.map((tag) => (
205
+ <Text
206
+ key={tag.key}
207
+ style={{
208
+ fontSize: 11,
209
+ color: tag.color ?? styles.c.foregroundMuted,
210
+ borderWidth: 1,
211
+ borderColor: tag.color ?? styles.c.border,
212
+ borderRadius: 4,
213
+ paddingHorizontal: 5,
214
+ paddingVertical: 1,
215
+ }}
216
+ >
217
+ {tag.text}
218
+ </Text>
219
+ ))}
78
220
  </View>
79
221
  );
80
222
  }
81
223
 
82
- const facts = (issue: NextUpIssue) => [`#${issue.number}`, `${ago(issue.createdAt)} old`, ...[issue.type, issue.priority, issue.effort, issue.scope].filter((v): v is string => !!v)];
224
+ // The type as the card's mark: red bugs, green features and epics, amber debt, the rest quiet.
225
+ const TYPE_TONES: Record<string, Tone> = { bug: "bad", feature: "good", epic: "good", debt: "warn" };
83
226
 
84
227
  // Its main action and ⋯; tapping it opens the sheet with the description, Claim or Unclaim [ATT-06, NXT-07].
85
- function IssueRow({ issue, claim, first, agents, busy, fetchDetails, onStart, onClaim, onOpenAgent }: RowProps & { issue: NextUpIssue; claim: boolean; first: boolean }) {
86
- const styles = useStyles();
228
+ function IssueRow({ issue, claim, first, agents, busy, fetchDetails, onStart, onClaim, onCloseIssue, onOpenAgent }: RowProps & { issue: NextUpIssue; claim: boolean; first: boolean }) {
87
229
  const [open, setOpen] = useState(false);
230
+ // Closing asks first, with the reason and an optional comment [NXT-11, SAFE-01].
231
+ const [closing, setClosing] = useState(false);
88
232
  const agent = agents[issue.key];
89
233
  const startLabel = claim ? "Claim & start" : "Start";
234
+ const type = issue.type?.toLowerCase() ?? "";
235
+ const close = (reason: IssueCloseReason) => (comment: string) => (setClosing(false), onCloseIssue(issue, reason, comment));
90
236
  return (
91
- <View style={[styles.item, first ? null : styles.divider]}>
92
- <View style={{ paddingTop: 2 }}>
93
- <TablerIcon name={TYPE_ICONS[issue.type?.toLowerCase() ?? ""] ?? "issue"} size={18} color={issue.type === "Bug" ? styles.c.statusDanger : styles.c.foregroundMuted} />
94
- </View>
95
- <Pressable accessibilityRole="button" accessibilityLabel={`${issue.title}, more`} onPress={() => setOpen(true)} style={styles.body}>
96
- <Text style={styles.title} numberOfLines={2}>
97
- {issue.title}
98
- </Text>
99
- <Meta facts={facts(issue)} chips={[]} />
100
- </Pressable>
101
- <View style={styles.wrap}>
102
- {busy === issue.key ? (
103
- <Text style={styles.muted}>working…</Text>
104
- ) : agent ? (
105
- <Button label={styles.compact ? undefined : "Continue"} icon="agent" variant="calm" onPress={() => onOpenAgent(agent.id)} />
106
- ) : (
107
- // Claim first so teammates see it's taken [NXT-05].
108
- <Button label={styles.compact ? undefined : startLabel} accessibilityLabel={`${startLabel} ${issue.title}`} icon="agent" variant="calm" onPress={() => onStart(issue, claim)} />
109
- )}
110
- <Button icon="dots" variant="ghost" accessibilityLabel="More actions" onPress={() => setOpen(true)} />
111
- </View>
112
- {open ? <IssueSheet issue={issue} claim={claim} agent={agent} fetchDetails={fetchDetails} onStart={onStart} onClaim={onClaim} onOpenAgent={onOpenAgent} onClose={() => setOpen(false)} /> : null}
113
- </View>
237
+ <CardRow
238
+ first={first}
239
+ mark={{ icon: TYPE_ICONS[type] ?? "issue", tone: TYPE_TONES[type] ?? "neutral" }}
240
+ title={issue.title}
241
+ accessibilityLabel={`${issue.type ? `${issue.type}: ` : ""}${issue.title}, more`}
242
+ meta={{ place: `${issue.repo.split("/")[1]} #${issue.number}`, when: `${ago(issue.createdAt)} old`, signals: prSignal(issue) }}
243
+ extra={<Tags issue={issue} />}
244
+ onOpen={() => setOpen(true)}
245
+ busy={busy === issue.key}
246
+ primary={
247
+ agent
248
+ ? { label: "Continue", icon: "agent", onPress: () => onOpenAgent(agent.id) }
249
+ : // Claim first so teammates see it's taken [NXT-05].
250
+ { label: startLabel, accessibilityLabel: `${startLabel} ${issue.title}`, icon: "agent", onPress: () => onStart(issue, claim) }
251
+ }
252
+ secondary={[{ label: "More actions", icon: "dots", onPress: () => setOpen(true) }]}
253
+ confirm={
254
+ closing
255
+ ? {
256
+ text: `Close #${issue.number}? A comment is only posted if you write one.`,
257
+ comment: true,
258
+ choices: [
259
+ { label: "Completed", icon: "issueClosed", solid: true, onConfirm: close("completed") },
260
+ { label: "Not planned", icon: "close", onConfirm: close("not_planned") },
261
+ ],
262
+ onCancel: () => setClosing(false),
263
+ }
264
+ : null
265
+ }
266
+ overlay={
267
+ open ? (
268
+ <IssueSheet
269
+ issue={issue}
270
+ claim={claim}
271
+ agent={agent}
272
+ fetchDetails={fetchDetails}
273
+ onStart={onStart}
274
+ onClaim={onClaim}
275
+ onOpenAgent={onOpenAgent}
276
+ onCloseIssue={() => setClosing(true)}
277
+ onClose={() => setOpen(false)}
278
+ />
279
+ ) : null
280
+ }
281
+ />
114
282
  );
115
283
  }
116
284
 
@@ -122,8 +290,9 @@ function IssueSheet({
122
290
  onStart,
123
291
  onClaim,
124
292
  onOpenAgent,
293
+ onCloseIssue,
125
294
  onClose,
126
- }: Pick<Props, "fetchDetails" | "onStart" | "onClaim" | "onOpenAgent"> & { issue: NextUpIssue; claim: boolean; agent?: AgentSummary; onClose: () => void }) {
295
+ }: Pick<Props, "fetchDetails" | "onStart" | "onClaim" | "onOpenAgent"> & { issue: NextUpIssue; claim: boolean; agent?: AgentSummary; onCloseIssue: () => void; onClose: () => void }) {
127
296
  const details = useQuery({
128
297
  queryKey: ["attention-span", "details", issue.key, false],
129
298
  queryFn: () => fetchDetails({ subject: { kind: "issue", repo: issue.repo, number: issue.number }, checks: false }),
@@ -144,6 +313,7 @@ function IssueSheet({
144
313
  ? { key: "claim", icon: "claim", label: "Claim", detail: "Assigns you, without starting a session", onPress: close(() => onClaim(issue, true)) }
145
314
  : { key: "unclaim", icon: "unclaim", label: "Unclaim", detail: "Removes you as assignee, so it goes back to Unclaimed", onPress: close(() => onClaim(issue, false)) },
146
315
  { key: "github", icon: "github", label: "Open issue on GitHub", detail: `${issue.repo}#${issue.number}`, onPress: close(() => void openExternalUrl(issue.url)) },
316
+ { key: "close", icon: "issueClosed", label: "Close issue", detail: "Asks first: as completed or not planned, with an optional comment", onPress: close(onCloseIssue) },
147
317
  ];
148
318
  return (
149
319
  <ActionSheet
@@ -151,7 +321,7 @@ function IssueSheet({
151
321
  onClose={onClose}
152
322
  top={
153
323
  <>
154
- <Meta facts={[`${issue.repo}#${issue.number}`, ...facts(issue).slice(1)]} chips={[]} />
324
+ <Meta facts={fullFacts(issue)} chips={prSignal(issue)} />
155
325
  </>
156
326
  }
157
327
  entries={entries}
package/client/setup.tsx CHANGED
@@ -1,11 +1,10 @@
1
1
  import { openExternalUrl, usePaseo } from "@getpaseo/plugin/client";
2
- import { copyText, useToast } from "@getpaseo/plugin/client/ui";
3
2
  import { useQuery } from "@tanstack/react-query";
4
3
  import { Text, View } from "react-native";
5
4
  import { AttentionConfig } from "../shared/config";
6
5
  import type { SetupStatus } from "../shared/setup";
7
6
  import { githubProjects, listProfiles } from "./sessions";
8
- import { Button, useStyles } from "./ui";
7
+ import { Button, useCopy, useStyles } from "./ui";
9
8
 
10
9
  type State = "done" | "missing" | "optional";
11
10
 
@@ -35,17 +34,11 @@ export function SetupChecklist({
35
34
  }) {
36
35
  const styles = useStyles();
37
36
  const paseo = usePaseo();
38
- const toast = useToast();
37
+ const copy = useCopy();
39
38
  const projects = useQuery({ queryKey: ["attention-span", "github-projects"], queryFn: () => githubProjects(paseo) });
40
39
  const profiles = useQuery({ queryKey: ["attention-span", "profiles"], queryFn: () => listProfiles(paseo) });
41
40
  const { gh, config } = status;
42
41
 
43
- const copy = (command: string) =>
44
- void copyText(command).then(
45
- () => toast.show(`Copied ${command}`, { variant: "success" }),
46
- () => toast.error("Couldn't copy"),
47
- );
48
-
49
42
  const lines: Line[] = [];
50
43
  lines.push(
51
44
  gh.found
@@ -67,7 +60,7 @@ export function SetupChecklist({
67
60
  state: "missing",
68
61
  title: "Sign in to GitHub",
69
62
  detail: `Run gh auth login on the machine that runs Paseo. gh says: ${gh.error}`,
70
- action: { label: "Copy command", onPress: () => copy("gh auth login") },
63
+ action: { label: "Copy command", onPress: () => copy("gh auth login", "Copied gh auth login") },
71
64
  },
72
65
  );
73
66
  lines.push(
package/client/sheet.tsx CHANGED
@@ -4,7 +4,7 @@ import type { ReactNode } from "react";
4
4
  import { Pressable, Text, View } from "react-native";
5
5
  import type { ItemDetails } from "../shared/attention";
6
6
  import type { IconName } from "./icons";
7
- import { KeepStyles, TablerIcon, useHover, useStyles } from "./ui";
7
+ import { Button, KeepStyles, TablerIcon, useCopy, useHover, useStyles } from "./ui";
8
8
 
9
9
  // Tapping a card opens its sheet: what the card knows, every action saying what it will do, then what's fetched [ATT-06].
10
10
  // Fetched details go last, so the actions don't move when they arrive. A bottom sheet on phones, a dialog on desktop.
@@ -16,6 +16,8 @@ export interface SheetEntry {
16
16
  detail?: string;
17
17
  disabled?: boolean;
18
18
  onPress: () => void;
19
+ // A copy icon at the end of the line, so copying adds no line to the sheet [ATT-15].
20
+ copy?: { text: string; label: string; done: string };
19
21
  }
20
22
 
21
23
  export function ActionSheet({ title, top, entries, bottom, onClose }: { title: string; top: ReactNode; entries: SheetEntry[]; bottom: ReactNode; onClose: () => void }) {
@@ -40,28 +42,35 @@ export function ActionSheet({ title, top, entries, bottom, onClose }: { title: s
40
42
  function Entry({ entry, first }: { entry: SheetEntry; first: boolean }) {
41
43
  const styles = useStyles();
42
44
  const { hovered, hover } = useHover();
45
+ const copy = useCopy();
43
46
  const muted = styles.c.foregroundMuted;
44
47
  return (
45
- <Pressable
46
- accessibilityRole="button"
47
- accessibilityLabel={entry.label}
48
- disabled={entry.disabled}
49
- onPress={entry.onPress}
50
- {...hover}
51
- style={({ pressed }) => [
52
- styles.row,
53
- { alignItems: "flex-start", paddingVertical: 10, paddingHorizontal: 12, backgroundColor: pressed || hovered ? styles.c.border : "transparent" },
54
- first ? null : { borderTopWidth: 1, borderTopColor: styles.c.surface1 },
55
- ]}
56
- >
57
- <View style={{ paddingTop: 1 }}>
58
- <TablerIcon name={entry.icon} size={16} color={entry.disabled ? muted : styles.action} />
59
- </View>
60
- <View style={{ flex: 1, gap: 2 }}>
61
- <Text style={{ color: entry.disabled ? muted : styles.c.foreground, fontSize: 14, fontWeight: "600" }}>{entry.label}</Text>
62
- {entry.detail ? <Text style={styles.muted}>{entry.detail}</Text> : null}
63
- </View>
64
- </Pressable>
48
+ <View style={[styles.row, { gap: 0, alignItems: "stretch" }, first ? null : { borderTopWidth: 1, borderTopColor: styles.c.surface1 }]}>
49
+ <Pressable
50
+ accessibilityRole="button"
51
+ accessibilityLabel={entry.label}
52
+ disabled={entry.disabled}
53
+ onPress={entry.onPress}
54
+ {...hover}
55
+ style={({ pressed }) => [
56
+ styles.row,
57
+ { flex: 1, alignItems: "flex-start", paddingVertical: 10, paddingHorizontal: 12, backgroundColor: pressed || hovered ? styles.c.border : "transparent" },
58
+ ]}
59
+ >
60
+ <View style={{ paddingTop: 1 }}>
61
+ <TablerIcon name={entry.icon} size={16} color={entry.disabled ? muted : styles.action} />
62
+ </View>
63
+ <View style={{ flex: 1, gap: 2 }}>
64
+ <Text style={{ color: entry.disabled ? muted : styles.c.foreground, fontSize: 14, fontWeight: "600" }}>{entry.label}</Text>
65
+ {entry.detail ? <Text style={styles.muted}>{entry.detail}</Text> : null}
66
+ </View>
67
+ </Pressable>
68
+ {entry.copy ? (
69
+ <View style={{ paddingHorizontal: 6, justifyContent: "center" }}>
70
+ <Button icon="copy" variant="ghost" accessibilityLabel={entry.copy.label} onPress={() => copy(entry.copy!.text, entry.copy!.done)} />
71
+ </View>
72
+ ) : null}
73
+ </View>
65
74
  );
66
75
  }
67
76
 
package/client/ui.tsx CHANGED
@@ -1,5 +1,5 @@
1
1
  import type { PluginScreenProps } from "@getpaseo/plugin/client";
2
- import { Icon } from "@getpaseo/plugin/client/ui";
2
+ import { copyText, Icon, useToast } from "@getpaseo/plugin/client/ui";
3
3
  import { createContext, type ReactNode, useContext, useMemo, useState } from "react";
4
4
  import { Image, Pressable, Text, View } from "react-native";
5
5
  import type { Chip } from "../shared/attention";
@@ -144,19 +144,30 @@ export function Button({
144
144
  }
145
145
 
146
146
  // Sentence case, with the count as quiet text.
147
- export function SectionHeader({ icon, title, count }: { icon: IconName; title: string; count: number }) {
147
+ export function SectionHeader({ icon, title, count, action }: { icon: IconName; title: string; count: number; action?: ReactNode }) {
148
148
  const styles = useStyles();
149
149
  return (
150
150
  <View style={[styles.row, { marginBottom: 10 }]}>
151
151
  <TablerIcon name={icon} size={15} />
152
- <Text style={{ color: styles.c.foreground, fontSize: 13, fontWeight: "600" }}>
152
+ <Text style={{ color: styles.c.foreground, fontSize: 13, fontWeight: "600", flex: 1 }}>
153
153
  {title}
154
154
  <Text style={{ color: styles.c.foregroundMuted, fontWeight: "400" }}> · {count}</Text>
155
155
  </Text>
156
+ {action}
156
157
  </View>
157
158
  );
158
159
  }
159
160
 
161
+ // Copy text and say so, since an icon-only button gives no other sign it worked.
162
+ export function useCopy() {
163
+ const toast = useToast();
164
+ return (text: string, done: string) =>
165
+ void copyText(text).then(
166
+ () => toast.show(done, { variant: "success" }),
167
+ () => toast.error("Couldn't copy"),
168
+ );
169
+ }
170
+
160
171
  // Choice chips for options and filters: the only pills, because they're tappable.
161
172
  export function Toggle({ label, active, onPress }: { label: string; active: boolean; onPress: () => void }) {
162
173
  const { c } = useStyles();
package/index.server.ts CHANGED
@@ -1,10 +1,10 @@
1
1
  import type { PluginServerContext } from "@getpaseo/plugin/server";
2
- import { claimIssue, closePullRequest, mergePullRequest, react, rerunFailed, setAutoMerge, setReady, unclaimIssue, updateBranch } from "./server/actions";
2
+ import { claimIssue, closeIssue, closePullRequest, mergePullRequest, react, reopenIssue, rerunFailed, setAutoMerge, setReady, unclaimIssue, updateBranch } from "./server/actions";
3
3
  import { defaultBranch, sessionContext } from "./server/context";
4
4
  import { itemDetails } from "./server/details";
5
5
  import { FIXTURE_CONTEXT, fixtureDetails } from "./server/fixture";
6
6
  import { FIXTURE } from "./server/gh";
7
- import { checkCoverage, configStatus, setupStatus } from "./server/setup";
7
+ import { checkCoverage, configStatus, myOrgs, setupStatus } from "./server/setup";
8
8
  import { AttentionService } from "./server/service";
9
9
  import type { FeedId } from "./shared/attention";
10
10
  import * as rpc from "./shared/rpc";
@@ -31,12 +31,17 @@ export default function contribute(server: PluginServerContext) {
31
31
  server.handle(rpc.getCoverage, () => configStatus());
32
32
  server.handle(rpc.checkCoverage, ({ kind, name }) => checkCoverage(kind, name));
33
33
  server.handle(rpc.setCoverage, ({ orgs, repos }) => ready(() => attention.setCoverage(orgs, repos)).then(() => ({ ok: true as const })));
34
+ server.handle(rpc.setNextUpSources, (sources) => ready(() => attention.setNextUpSources(sources)).then(() => ({ ok: true as const })));
35
+ server.handle(rpc.myOrgs, async () => ({ orgs: await myOrgs() }));
34
36
  server.handle(rpc.setScopes, ({ scopes }) => ready(() => attention.setScopes(scopes)).then(() => ({ ok: true as const })));
37
+ server.handle(rpc.setSources, ({ sources }) => ready(() => attention.setSources(sources)).then(() => ({ ok: true as const })));
35
38
  server.handle(rpc.updateBranch, ({ target }) => thenRefresh(updateBranch(target)));
36
39
  server.handle(rpc.mergePullRequest, ({ target }) => thenRefresh(mergePullRequest(target), ["live", "history"]));
37
40
  server.handle(rpc.closePullRequest, ({ target, comment }) => thenRefresh(closePullRequest(target, comment)));
38
41
  server.handle(rpc.claimIssue, ({ target }) => thenRefresh(claimIssue(target)));
39
42
  server.handle(rpc.unclaimIssue, ({ target }) => thenRefresh(unclaimIssue(target)));
43
+ server.handle(rpc.closeIssue, ({ target, reason, comment }) => thenRefresh(closeIssue(target, reason, comment)));
44
+ server.handle(rpc.reopenIssue, ({ target }) => thenRefresh(reopenIssue(target)));
40
45
  server.handle(rpc.setReady, ({ target, ready }) => thenRefresh(setReady(target, ready)));
41
46
  server.handle(rpc.setAutoMerge, ({ target, on }) => thenRefresh(setAutoMerge(target, on)));
42
47
  server.handle(rpc.react, ({ subjectIds, on }) => thenRefresh(react(subjectIds, on)));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@andrioid/paseo-attention-span",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
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/server/actions.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { Target } from "../shared/attention";
1
+ import type { IssueCloseReason, Target } from "../shared/attention";
2
2
  import { graphql, runGh } from "./gh";
3
3
 
4
4
  // Each action runs only from an explicit tap in Attention Span [SAFE-01].
@@ -46,6 +46,20 @@ export async function claimIssue(target: Target): Promise<void> {
46
46
  if (code !== 0) throw new Error(stderr.trim() || "Claiming the issue failed");
47
47
  }
48
48
 
49
+ // Close an issue I won't pick up, as completed or not planned; comment only when I wrote one [NXT-11].
50
+ export async function closeIssue(target: Target, reason: IssueCloseReason, comment?: string): Promise<void> {
51
+ const args = ["issue", "close", String(target.number), "--repo", target.repo, "--reason", reason === "not_planned" ? "not planned" : "completed"];
52
+ if (comment?.trim()) args.push("--comment", comment.trim());
53
+ const { code, stderr } = await runGh(args);
54
+ if (code !== 0) throw new Error(stderr.trim() || "Closing the issue failed");
55
+ }
56
+
57
+ // Undo of Close [NXT-11]. A comment already posted stays.
58
+ export async function reopenIssue(target: Target): Promise<void> {
59
+ const { code, stderr } = await runGh(["issue", "reopen", String(target.number), "--repo", target.repo]);
60
+ if (code !== 0) throw new Error(stderr.trim() || "Reopening the issue failed");
61
+ }
62
+
49
63
  // Hand an assigned issue back; also undoes a claim [NXT-07].
50
64
  export async function unclaimIssue(target: Target): Promise<void> {
51
65
  const { code, stderr } = await runGh(["issue", "edit", String(target.number), "--repo", target.repo, "--remove-assignee", "@me"]);