@andrioid/paseo-attention-span 0.1.1 → 0.1.2

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.
@@ -6,7 +6,7 @@ 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
8
  import type { AttentionConfig, SessionKind } from "../shared/config";
9
- import { ago } from "../shared/format";
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";
@@ -16,7 +16,7 @@ import { NextUpList } from "./next-up";
16
16
  import { ActionSheet, DetailLines, type SheetEntry } from "./sheet";
17
17
  import { branchWorkspaces, findCheckout, githubProjects, itemAgents, listProfiles, noProjectMessage, resolveAgentConfig, startSession } from "./sessions";
18
18
  import { SetupChecklist } from "./setup";
19
- import { Avatar, Button, KeepStyles, Meta, SectionHeader, StylesProvider, TablerIcon, Toggle, useHover, useStyles } from "./ui";
19
+ import { Avatar, Button, KeepStyles, Meta, SectionHeader, StylesProvider, TablerIcon, Toggle, useCopy, useHover, useStyles } from "./ui";
20
20
 
21
21
  // The agent icon marks every action that starts an agent session; the rest act on GitHub right away [ATT-13].
22
22
  const ACTION_ICONS: Record<ActionId, IconName> = {
@@ -509,6 +509,8 @@ function ItemRow({ item, first, actions }: { item: Item; first: boolean; actions
509
509
  const children = item.children.filter((child) => child.attention || isRed(child.chips));
510
510
  const icon = stateIcon(item, styles.c);
511
511
  const open = () => setSheet("item");
512
+ const copy = useCopy();
513
+ const history = item.section === "done" || item.section === "reviewed";
512
514
 
513
515
  function perform(action: ActionId) {
514
516
  setSheet(null);
@@ -535,6 +537,8 @@ function ItemRow({ item, first, actions }: { item: Item; first: boolean; actions
535
537
  ) : (
536
538
  <Button icon="dots" variant="ghost" accessibilityLabel="More actions" onPress={open} />
537
539
  )}
540
+ {/* History is where I report from, so its cards copy their link in one tap [ATT-15]. */}
541
+ {history ? <Button icon="copy" variant="ghost" accessibilityLabel={`Copy link to #${item.number}`} onPress={() => copy(item.url, `Copied link to #${item.number}`)} /> : null}
538
542
  </View>
539
543
  );
540
544
 
@@ -647,8 +651,15 @@ function sheetEntries(
647
651
  entries.push({ key: action, icon: ACTION_ICONS[action], label, detail: actionDetail(action, item), onPress: () => onPerform(action) });
648
652
  }
649
653
  }
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)) });
654
+ // Anything Attention Span doesn't cover [ATT-12], and its link to share [ATT-15].
655
+ entries.push({
656
+ key: "github",
657
+ icon: "github",
658
+ label: `Open ${item.kind === "issue" ? "issue" : "PR"} on GitHub`,
659
+ detail: `${item.repo}#${item.number}`,
660
+ onPress: close(() => void openExternalUrl(item.url)),
661
+ copy: { text: item.url, label: `Copy link to #${item.number}`, done: `Copied link to #${item.number}` },
662
+ });
652
663
  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
664
  return entries;
654
665
  }
@@ -758,8 +769,10 @@ function weekLabel(monday: Date): string {
758
769
  }
759
770
 
760
771
  // What I finished, by week, with reviews tucked away per week [HIS-01, HIS-02].
772
+ // A week copies as a list of links to paste into a report; reviews stay out of it [HIS-03].
761
773
  function History({ items, actions }: { items: Item[]; actions: Actions }) {
762
774
  const styles = useStyles();
775
+ const copy = useCopy();
763
776
  const [open, setOpen] = useState<string | null>(null);
764
777
  if (items.length === 0) return <Text style={styles.text}>Nothing finished in this period.</Text>;
765
778
  const weeks = new Map<number, Item[]>();
@@ -774,7 +787,21 @@ function History({ items, actions }: { items: Item[]; actions: Actions }) {
774
787
  const label = weekLabel(new Date(week));
775
788
  blocks.push(
776
789
  <View key={week} style={{ gap: 8 }}>
777
- <SectionHeader icon="clock" title={label} count={done.length} />
790
+ <SectionHeader
791
+ icon="clock"
792
+ title={label}
793
+ count={done.length}
794
+ action={
795
+ done.length > 0 ? (
796
+ <Button
797
+ icon="copy"
798
+ variant="ghost"
799
+ accessibilityLabel={`Copy links from ${label}`}
800
+ onPress={() => copy(linkList(done), `Copied ${done.length} link${done.length === 1 ? "" : "s"} from ${label}`)}
801
+ />
802
+ ) : null
803
+ }
804
+ />
778
805
  {done.length > 0 ? <Card items={done} actions={actions} /> : null}
779
806
  {reviewed.length > 0 ? (
780
807
  <View style={{ gap: 8 }}>
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>" },
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/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.2",
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/shared/format.ts CHANGED
@@ -14,3 +14,8 @@ export function ago(iso: string, now: Date = new Date()): string {
14
14
  export function daysSince(iso: string, now: Date): number {
15
15
  return (now.getTime() - new Date(iso).getTime()) / 86_400_000;
16
16
  }
17
+
18
+ // A Markdown bullet list of links, for pasting a week's work into a report [HIS-03].
19
+ export function linkList(items: { title: string; url: string }[]): string {
20
+ return items.map(({ title, url }) => `- [${title.replace(/[[\]\\]/g, "\\$&")}](${url})`).join("\n");
21
+ }