@andrioid/paseo-attention-span 0.1.3 → 0.2.0
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 +116 -42
- package/README.md +12 -12
- package/client/attention-screen.tsx +162 -110
- package/client/card.tsx +17 -5
- package/client/data.ts +2 -1
- package/client/icons.ts +2 -0
- package/client/next-up.tsx +64 -30
- package/client/session-menu.ts +45 -0
- package/client/sessions.ts +10 -8
- package/client/sheet.tsx +75 -3
- package/client/ui.tsx +91 -9
- package/docs/screenshots/desktop-dark-doing.png +0 -0
- package/docs/screenshots/desktop-dark-next-up.png +0 -0
- package/docs/screenshots/phone-dark-doing.png +0 -0
- package/index.server.ts +16 -19
- package/package.json +1 -1
- package/paseo-plugin.json +4 -2
- package/server/fixture.ts +19 -7
- package/server/service.ts +55 -6
- package/server/store.ts +3 -0
- package/server/view.ts +71 -1
- package/shared/attention.ts +22 -1
- package/shared/format.ts +6 -0
- package/shared/rpc.ts +13 -12
package/client/next-up.tsx
CHANGED
|
@@ -2,15 +2,16 @@ 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, shortValue } from "../shared/format";
|
|
6
|
-
import type
|
|
5
|
+
import { ago, repoLabel, shortValue } from "../shared/format";
|
|
6
|
+
import { type AgentSummary, type Chip, type IssueCloseReason, matchSessions, type NextUpIssue, type UnclaimedSource } from "../shared/attention";
|
|
7
7
|
import type { NextUpSource } from "../shared/config";
|
|
8
8
|
import type { IconName } from "./icons";
|
|
9
9
|
import type { FetchDetails } from "./attention-screen";
|
|
10
10
|
import { CardList, CardRow, type Tone } from "./card";
|
|
11
|
-
import {
|
|
11
|
+
import { openSessionEntry, sessionsGroup } from "./session-menu";
|
|
12
|
+
import { ActionSheet, DetailLines, type MenuGroup, MenuSheet, type SheetEntry } from "./sheet";
|
|
12
13
|
import { Modal } from "@getpaseo/plugin/client/ui";
|
|
13
|
-
import { Button, KeepStyles, Meta, SectionHeader, TablerIcon, useHover, useStyles } from "./ui";
|
|
14
|
+
import { type Anchor, Button, KeepStyles, Meta, SectionHeader, TablerIcon, useHover, useStyles } from "./ui";
|
|
14
15
|
|
|
15
16
|
const TYPE_ICONS: Record<string, IconName> = { bug: "bug", feature: "feature", debt: "debt", task: "task", epic: "epic" };
|
|
16
17
|
|
|
@@ -25,10 +26,14 @@ interface Props {
|
|
|
25
26
|
sources: NextUpSource[];
|
|
26
27
|
selectedSources: string[];
|
|
27
28
|
onSelectSources: (sources: string[]) => void;
|
|
28
|
-
agents:
|
|
29
|
-
|
|
29
|
+
agents: AgentSummary[];
|
|
30
|
+
// Mine, so my repos show without the owner.
|
|
31
|
+
login: string | null;
|
|
32
|
+
busy: ReadonlySet<string>;
|
|
30
33
|
fetchDetails: FetchDetails;
|
|
31
34
|
onStart: (issue: NextUpIssue, claim: boolean) => void;
|
|
35
|
+
// The same, choosing the workspace, profile and prompt first [SES-02]; `label` names it.
|
|
36
|
+
onOptions: (issue: NextUpIssue, claim: boolean, label: string) => void;
|
|
32
37
|
// Claim without starting, or give an assigned issue back [NXT-07].
|
|
33
38
|
onClaim: (issue: NextUpIssue, on: boolean) => void;
|
|
34
39
|
// Close it, once I've confirmed the reason [NXT-11].
|
|
@@ -225,31 +230,48 @@ function Tags({ issue }: { issue: NextUpIssue }) {
|
|
|
225
230
|
const TYPE_TONES: Record<string, Tone> = { bug: "bad", feature: "good", epic: "good", debt: "warn" };
|
|
226
231
|
|
|
227
232
|
// Its main action and ⋯; tapping it opens the sheet with the description, Claim or Unclaim [ATT-06, NXT-07].
|
|
228
|
-
function IssueRow({ issue, claim, first, agents, busy, fetchDetails, onStart, onClaim, onCloseIssue, onOpenAgent }: RowProps & { issue: NextUpIssue; claim: boolean; first: boolean }) {
|
|
229
|
-
|
|
233
|
+
function IssueRow({ issue, claim, first, agents, login, busy, fetchDetails, onStart, onOptions, onClaim, onCloseIssue, onOpenAgent }: RowProps & { issue: NextUpIssue; claim: boolean; first: boolean }) {
|
|
234
|
+
// The sheet, or the split button's menu.
|
|
235
|
+
const [sheet, setSheet] = useState<"item" | { anchor?: Anchor } | null>(null);
|
|
230
236
|
// Closing asks first, with the reason and an optional comment [NXT-11, SAFE-01].
|
|
231
237
|
const [closing, setClosing] = useState(false);
|
|
232
|
-
|
|
238
|
+
// An open session leads; without one, Start does [SES-03].
|
|
239
|
+
const sessions = matchSessions(agents, [issue.key]);
|
|
233
240
|
const startLabel = claim ? "Claim & start" : "Start";
|
|
234
241
|
const type = issue.type?.toLowerCase() ?? "";
|
|
235
242
|
const close = (reason: IssueCloseReason) => (comment: string) => (setClosing(false), onCloseIssue(issue, reason, comment));
|
|
243
|
+
const onMenu = (anchor: Anchor | undefined) => setSheet({ anchor });
|
|
244
|
+
const done = (then: () => void) => () => (setSheet(null), then());
|
|
245
|
+
const withOptions: SheetEntry = {
|
|
246
|
+
key: "start-options",
|
|
247
|
+
icon: "agent",
|
|
248
|
+
label: `${startLabel} with options…`,
|
|
249
|
+
detail: "Choose the workspace, agent profile and prompt first",
|
|
250
|
+
onPress: done(() => onOptions(issue, claim, startLabel)),
|
|
251
|
+
};
|
|
252
|
+
const groups: MenuGroup[] = sessions.length
|
|
253
|
+
? [
|
|
254
|
+
sessionsGroup(sessions, (agentId) => done(() => onOpenAgent(agentId))()),
|
|
255
|
+
{ title: "Start a new one", entries: [{ ...startEntry(claim), onPress: done(() => onStart(issue, claim)) }, withOptions] },
|
|
256
|
+
]
|
|
257
|
+
: [{ entries: [withOptions] }];
|
|
236
258
|
return (
|
|
237
259
|
<CardRow
|
|
238
260
|
first={first}
|
|
239
261
|
mark={{ icon: TYPE_ICONS[type] ?? "issue", tone: TYPE_TONES[type] ?? "neutral" }}
|
|
240
262
|
title={issue.title}
|
|
241
263
|
accessibilityLabel={`${issue.type ? `${issue.type}: ` : ""}${issue.title}, more`}
|
|
242
|
-
meta={{ place: `${issue.repo
|
|
264
|
+
meta={{ place: `${repoLabel(issue.repo, login)} #${issue.number}`, when: `${ago(issue.createdAt)} old`, signals: prSignal(issue) }}
|
|
243
265
|
extra={<Tags issue={issue} />}
|
|
244
|
-
onOpen={() =>
|
|
245
|
-
busy={busy
|
|
266
|
+
onOpen={() => setSheet("item")}
|
|
267
|
+
busy={busy.has(issue.key)}
|
|
246
268
|
primary={
|
|
247
|
-
|
|
248
|
-
? { label: "
|
|
269
|
+
sessions[0]
|
|
270
|
+
? { label: "Open session", icon: "agent", onPress: () => onOpenAgent(sessions[0].id), menu: { label: "Session choices", onPress: onMenu } }
|
|
249
271
|
: // Claim first so teammates see it's taken [NXT-05].
|
|
250
|
-
{ label: startLabel, accessibilityLabel: `${startLabel} ${issue.title}`, icon: "agent", onPress: () => onStart(issue, claim) }
|
|
272
|
+
{ label: startLabel, accessibilityLabel: `${startLabel} ${issue.title}`, icon: "agent", onPress: () => onStart(issue, claim), menu: { label: `${startLabel} choices`, onPress: onMenu } }
|
|
251
273
|
}
|
|
252
|
-
secondary={[{ label: "More actions", icon: "dots", onPress: () =>
|
|
274
|
+
secondary={[{ label: "More actions", icon: "dots", onPress: () => setSheet("item") }]}
|
|
253
275
|
confirm={
|
|
254
276
|
closing
|
|
255
277
|
? {
|
|
@@ -264,35 +286,53 @@ function IssueRow({ issue, claim, first, agents, busy, fetchDetails, onStart, on
|
|
|
264
286
|
: null
|
|
265
287
|
}
|
|
266
288
|
overlay={
|
|
267
|
-
|
|
289
|
+
sheet === "item" ? (
|
|
268
290
|
<IssueSheet
|
|
269
291
|
issue={issue}
|
|
270
292
|
claim={claim}
|
|
271
|
-
|
|
293
|
+
sessions={sessions}
|
|
272
294
|
fetchDetails={fetchDetails}
|
|
273
295
|
onStart={onStart}
|
|
274
296
|
onClaim={onClaim}
|
|
275
297
|
onOpenAgent={onOpenAgent}
|
|
298
|
+
onMenu={onMenu}
|
|
276
299
|
onCloseIssue={() => setClosing(true)}
|
|
277
|
-
onClose={() =>
|
|
300
|
+
onClose={() => setSheet(null)}
|
|
278
301
|
/>
|
|
302
|
+
) : sheet ? (
|
|
303
|
+
<MenuSheet title={issue.title} anchor={sheet.anchor} groups={groups} onClose={() => setSheet(null)} />
|
|
279
304
|
) : null
|
|
280
305
|
}
|
|
281
306
|
/>
|
|
282
307
|
);
|
|
283
308
|
}
|
|
284
309
|
|
|
310
|
+
const startEntry = (claim: boolean): Omit<SheetEntry, "onPress"> => ({
|
|
311
|
+
key: "start",
|
|
312
|
+
icon: "agent",
|
|
313
|
+
label: claim ? "Claim & start" : "Start",
|
|
314
|
+
detail: `${claim ? "Assigns you, then an agent" : "An agent"} reads the issue and proposes a plan`,
|
|
315
|
+
});
|
|
316
|
+
|
|
285
317
|
function IssueSheet({
|
|
286
318
|
issue,
|
|
287
319
|
claim,
|
|
288
|
-
|
|
320
|
+
sessions,
|
|
289
321
|
fetchDetails,
|
|
290
322
|
onStart,
|
|
291
323
|
onClaim,
|
|
292
324
|
onOpenAgent,
|
|
325
|
+
onMenu,
|
|
293
326
|
onCloseIssue,
|
|
294
327
|
onClose,
|
|
295
|
-
}: Pick<Props, "fetchDetails" | "onStart" | "onClaim" | "onOpenAgent"> & {
|
|
328
|
+
}: Pick<Props, "fetchDetails" | "onStart" | "onClaim" | "onOpenAgent"> & {
|
|
329
|
+
issue: NextUpIssue;
|
|
330
|
+
claim: boolean;
|
|
331
|
+
sessions: AgentSummary[];
|
|
332
|
+
onMenu: (anchor: Anchor | undefined) => void;
|
|
333
|
+
onCloseIssue: () => void;
|
|
334
|
+
onClose: () => void;
|
|
335
|
+
}) {
|
|
296
336
|
const details = useQuery({
|
|
297
337
|
queryKey: ["attention-span", "details", issue.key, false],
|
|
298
338
|
queryFn: () => fetchDetails({ subject: { kind: "issue", repo: issue.repo, number: issue.number }, checks: false }),
|
|
@@ -300,15 +340,9 @@ function IssueSheet({
|
|
|
300
340
|
});
|
|
301
341
|
const close = (then: () => void) => () => (onClose(), then());
|
|
302
342
|
const entries: SheetEntry[] = [
|
|
303
|
-
|
|
304
|
-
?
|
|
305
|
-
: {
|
|
306
|
-
key: "start",
|
|
307
|
-
icon: "agent",
|
|
308
|
-
label: claim ? "Claim & start" : "Start",
|
|
309
|
-
detail: `${claim ? "Assigns you, then an agent" : "An agent"} reads the issue and proposes a plan`,
|
|
310
|
-
onPress: close(() => onStart(issue, claim)),
|
|
311
|
-
},
|
|
343
|
+
sessions.length
|
|
344
|
+
? openSessionEntry(sessions, (agentId) => close(() => onOpenAgent(agentId))(), { label: "Session choices", onPress: onMenu })
|
|
345
|
+
: { ...startEntry(claim), onPress: close(() => onStart(issue, claim)), menu: { label: `${claim ? "Claim & start" : "Start"} choices`, onPress: onMenu } },
|
|
312
346
|
claim
|
|
313
347
|
? { key: "claim", icon: "claim", label: "Claim", detail: "Assigns you, without starting a session", onPress: close(() => onClaim(issue, true)) }
|
|
314
348
|
: { key: "unclaim", icon: "unclaim", label: "Unclaim", detail: "Removes you as assignee, so it goes back to Unclaimed", onPress: close(() => onClaim(issue, false)) },
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { AgentSummary, Chip } from "../shared/attention";
|
|
2
|
+
import { ago } from "../shared/format";
|
|
3
|
+
import type { MenuGroup, SheetEntry } from "./sheet";
|
|
4
|
+
|
|
5
|
+
// A session started from the item, as a signal [ATT-07].
|
|
6
|
+
export function agentSignal(agent: AgentSummary): Chip {
|
|
7
|
+
if (agent.requiresAttention) return { text: "agent needs you", tone: "warn" };
|
|
8
|
+
if (agent.status === "running" || agent.status === "initializing") return { text: "agent working", tone: "good" };
|
|
9
|
+
if (agent.status === "error") return { text: "agent failed", tone: "bad" };
|
|
10
|
+
return { text: "agent idle", tone: "neutral" };
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
// "needs you · 2h ago"
|
|
14
|
+
export function sessionStatus(agent: AgentSummary): string {
|
|
15
|
+
const status = agentSignal(agent).text.replace(/^agent /, "");
|
|
16
|
+
return agent.lastActivityAt ? `${status} · ${ago(agent.lastActivityAt)} ago` : status;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// With a session open, the item's main action opens it; ▾ picks another or starts a new one [SES-03].
|
|
20
|
+
export function openSessionEntry(sessions: AgentSummary[], onOpen: (agentId: string) => void, onMenu: SheetEntry["menu"]): SheetEntry {
|
|
21
|
+
const first = sessions[0];
|
|
22
|
+
return {
|
|
23
|
+
key: "session",
|
|
24
|
+
icon: "agent",
|
|
25
|
+
label: "Open session",
|
|
26
|
+
detail: `${first.title ?? "Session"} · ${sessionStatus(first)}`,
|
|
27
|
+
onPress: () => onOpen(first.id),
|
|
28
|
+
menu: onMenu,
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// Every open session; the first is the one Open session opens.
|
|
33
|
+
export function sessionsGroup(sessions: AgentSummary[], onOpen: (agentId: string) => void): MenuGroup {
|
|
34
|
+
return {
|
|
35
|
+
title: "Sessions",
|
|
36
|
+
entries: sessions.map((agent, index) => ({
|
|
37
|
+
key: agent.id,
|
|
38
|
+
icon: "agent",
|
|
39
|
+
label: agent.title ?? "Session",
|
|
40
|
+
detail: sessionStatus(agent),
|
|
41
|
+
checked: index === 0,
|
|
42
|
+
onPress: () => onOpen(agent.id),
|
|
43
|
+
})),
|
|
44
|
+
};
|
|
45
|
+
}
|
package/client/sessions.ts
CHANGED
|
@@ -10,23 +10,25 @@ export const ITEM_LABEL = "attention-span-item";
|
|
|
10
10
|
// Sessions started under the plugin's earlier names, "GitHub attention" and "GitHub inbox".
|
|
11
11
|
const OLD_LABELS = ["github-attention", "github-inbox"];
|
|
12
12
|
|
|
13
|
-
// Agents started from Attention Span,
|
|
14
|
-
export async function itemAgents(paseo: Paseo): Promise<
|
|
13
|
+
// Agents started from Attention Span, each with the item it was started on.
|
|
14
|
+
export async function itemAgents(paseo: Paseo): Promise<AgentSummary[]> {
|
|
15
15
|
const labels = [LABEL, ...OLD_LABELS];
|
|
16
16
|
const lists = await Promise.all(labels.map((label) => paseo.agents.list({ filter: { labels: { [label]: "1" } } })));
|
|
17
|
-
const
|
|
17
|
+
const byId = new Map<string, AgentSummary>();
|
|
18
18
|
for (const { agent } of lists.flatMap((list) => list.entries)) {
|
|
19
|
-
const
|
|
20
|
-
if (!
|
|
21
|
-
|
|
19
|
+
const itemKey = labels.map((label) => agent.labels?.[`${label}-item`]).find(Boolean);
|
|
20
|
+
if (!itemKey || agent.archivedAt) continue;
|
|
21
|
+
byId.set(agent.id, {
|
|
22
22
|
id: agent.id,
|
|
23
|
+
itemKey,
|
|
23
24
|
status: agent.status,
|
|
24
25
|
requiresAttention: !!agent.requiresAttention,
|
|
25
26
|
title: agent.title ?? null,
|
|
26
27
|
workspaceId: agent.workspaceId ?? null,
|
|
27
|
-
|
|
28
|
+
lastActivityAt: agent.updatedAt ?? null,
|
|
29
|
+
});
|
|
28
30
|
}
|
|
29
|
-
return
|
|
31
|
+
return [...byId.values()];
|
|
30
32
|
}
|
|
31
33
|
|
|
32
34
|
export interface ProjectMatch {
|
package/client/sheet.tsx
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { openExternalUrl } from "@getpaseo/plugin/client";
|
|
2
2
|
import { Modal } from "@getpaseo/plugin/client/ui";
|
|
3
3
|
import type { ReactNode } from "react";
|
|
4
|
-
import { Pressable, Text, View } from "react-native";
|
|
4
|
+
import { Modal as NativeModal, Pressable, Text, useWindowDimensions, View } from "react-native";
|
|
5
5
|
import type { ItemDetails } from "../shared/attention";
|
|
6
6
|
import type { IconName } from "./icons";
|
|
7
|
-
import { Button, KeepStyles, TablerIcon, useCopy, useHover, useStyles } from "./ui";
|
|
7
|
+
import { type Anchor, Button, KeepStyles, Loading, TablerIcon, useAnchor, 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.
|
|
@@ -18,6 +18,15 @@ export interface SheetEntry {
|
|
|
18
18
|
onPress: () => void;
|
|
19
19
|
// A copy icon at the end of the line, so copying adds no line to the sheet [ATT-15].
|
|
20
20
|
copy?: { text: string; label: string; done: string };
|
|
21
|
+
// ▾ at the end of the line: the choices around this action, like a split button [SES-03].
|
|
22
|
+
menu?: { label: string; onPress: (anchor: Anchor | undefined) => void };
|
|
23
|
+
// What the line's split button opens; marked in its menu.
|
|
24
|
+
checked?: boolean;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export interface MenuGroup {
|
|
28
|
+
title?: string;
|
|
29
|
+
entries: SheetEntry[];
|
|
21
30
|
}
|
|
22
31
|
|
|
23
32
|
export function ActionSheet({ title, top, entries, bottom, onClose }: { title: string; top: ReactNode; entries: SheetEntry[]; bottom: ReactNode; onClose: () => void }) {
|
|
@@ -43,6 +52,7 @@ function Entry({ entry, first }: { entry: SheetEntry; first: boolean }) {
|
|
|
43
52
|
const styles = useStyles();
|
|
44
53
|
const { hovered, hover } = useHover();
|
|
45
54
|
const copy = useCopy();
|
|
55
|
+
const anchor = useAnchor();
|
|
46
56
|
const muted = styles.c.foregroundMuted;
|
|
47
57
|
return (
|
|
48
58
|
<View style={[styles.row, { gap: 0, alignItems: "stretch" }, first ? null : { borderTopWidth: 1, borderTopColor: styles.c.surface1 }]}>
|
|
@@ -64,7 +74,17 @@ function Entry({ entry, first }: { entry: SheetEntry; first: boolean }) {
|
|
|
64
74
|
<Text style={{ color: entry.disabled ? muted : styles.c.foreground, fontSize: 14, fontWeight: "600" }}>{entry.label}</Text>
|
|
65
75
|
{entry.detail ? <Text style={styles.muted}>{entry.detail}</Text> : null}
|
|
66
76
|
</View>
|
|
77
|
+
{entry.checked ? (
|
|
78
|
+
<View style={{ paddingTop: 1 }}>
|
|
79
|
+
<TablerIcon name="check" size={16} color={styles.action} />
|
|
80
|
+
</View>
|
|
81
|
+
) : null}
|
|
67
82
|
</Pressable>
|
|
83
|
+
{entry.menu ? (
|
|
84
|
+
<View ref={anchor.ref} collapsable={false} style={{ paddingHorizontal: 6, justifyContent: "center", borderLeftWidth: 1, borderLeftColor: styles.c.surface1 }}>
|
|
85
|
+
<Button icon="chevronDown" variant="ghost" accessibilityLabel={entry.menu.label} onPress={() => anchor.measure(entry.menu!.onPress)} />
|
|
86
|
+
</View>
|
|
87
|
+
) : null}
|
|
68
88
|
{entry.copy ? (
|
|
69
89
|
<View style={{ paddingHorizontal: 6, justifyContent: "center" }}>
|
|
70
90
|
<Button icon="copy" variant="ghost" accessibilityLabel={entry.copy.label} onPress={() => copy(entry.copy!.text, entry.copy!.done)} />
|
|
@@ -74,10 +94,62 @@ function Entry({ entry, first }: { entry: SheetEntry; first: boolean }) {
|
|
|
74
94
|
);
|
|
75
95
|
}
|
|
76
96
|
|
|
97
|
+
// A split button's choices: under the button on desktop, a bottom sheet on phones [SES-03].
|
|
98
|
+
export function MenuSheet({ title, anchor, groups, onClose }: { title: string; anchor?: Anchor; groups: MenuGroup[]; onClose: () => void }) {
|
|
99
|
+
const styles = useStyles();
|
|
100
|
+
const window = useWindowDimensions();
|
|
101
|
+
const list = (
|
|
102
|
+
<View style={{ gap: 10 }}>
|
|
103
|
+
{groups.map((group, index) => (
|
|
104
|
+
<View key={group.title ?? index} style={{ gap: 6 }}>
|
|
105
|
+
{group.title ? <Text style={[styles.muted, { fontWeight: "600" }]}>{group.title}</Text> : null}
|
|
106
|
+
<View style={[styles.card, { backgroundColor: styles.c.surface2 }]}>
|
|
107
|
+
{group.entries.map((entry, i) => (
|
|
108
|
+
<Entry key={entry.key} entry={entry} first={i === 0} />
|
|
109
|
+
))}
|
|
110
|
+
</View>
|
|
111
|
+
</View>
|
|
112
|
+
))}
|
|
113
|
+
</View>
|
|
114
|
+
);
|
|
115
|
+
if (styles.compact || !anchor) {
|
|
116
|
+
return (
|
|
117
|
+
<Modal title={title} open onOpenChange={(open) => (open ? null : onClose())}>
|
|
118
|
+
<Modal.Content>
|
|
119
|
+
<KeepStyles styles={styles}>{list}</KeepStyles>
|
|
120
|
+
</Modal.Content>
|
|
121
|
+
</Modal>
|
|
122
|
+
);
|
|
123
|
+
}
|
|
124
|
+
// Right-aligned with the button, below it, or above it in the lower half of the window.
|
|
125
|
+
const width = Math.min(340, window.width - 16);
|
|
126
|
+
const left = Math.max(8, Math.min(anchor.x + anchor.width - width, window.width - width - 8));
|
|
127
|
+
const below = anchor.y + anchor.height < window.height / 2;
|
|
128
|
+
const place = below ? { top: anchor.y + anchor.height + 4 } : { bottom: window.height - anchor.y + 4 };
|
|
129
|
+
return (
|
|
130
|
+
<NativeModal transparent visible animationType="none" onRequestClose={onClose}>
|
|
131
|
+
<KeepStyles styles={styles}>
|
|
132
|
+
<Pressable accessibilityLabel="Close menu" onPress={onClose} style={{ position: "absolute", top: 0, left: 0, right: 0, bottom: 0 }} />
|
|
133
|
+
<View
|
|
134
|
+
accessibilityRole="menu"
|
|
135
|
+
accessibilityLabel={title}
|
|
136
|
+
style={[
|
|
137
|
+
styles.card,
|
|
138
|
+
{ position: "absolute", left, width, maxHeight: window.height / 2 - 16, padding: 10, ...place },
|
|
139
|
+
{ shadowColor: "#000", shadowOpacity: 0.25, shadowRadius: 16, shadowOffset: { width: 0, height: 6 }, elevation: 8 },
|
|
140
|
+
]}
|
|
141
|
+
>
|
|
142
|
+
{list}
|
|
143
|
+
</View>
|
|
144
|
+
</KeepStyles>
|
|
145
|
+
</NativeModal>
|
|
146
|
+
);
|
|
147
|
+
}
|
|
148
|
+
|
|
77
149
|
// The PR's size and the linked issues or PRs, once fetched.
|
|
78
150
|
export function DetailLines({ details, loading, error, linkedLabel }: { details?: ItemDetails; loading: boolean; error: unknown; linkedLabel: string }) {
|
|
79
151
|
const styles = useStyles();
|
|
80
|
-
if (loading) return <
|
|
152
|
+
if (loading) return <Loading text="Loading details…" />;
|
|
81
153
|
if (!details) return error ? <Text style={styles.muted}>Couldn't load details: {(error as Error).message}</Text> : null;
|
|
82
154
|
return (
|
|
83
155
|
<>
|
package/client/ui.tsx
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { PluginScreenProps } from "@getpaseo/plugin/client";
|
|
2
2
|
import { copyText, Icon, useToast } from "@getpaseo/plugin/client/ui";
|
|
3
|
-
import { createContext, type ReactNode, useContext, useMemo, useState } from "react";
|
|
4
|
-
import { Image, Pressable, Text, View } from "react-native";
|
|
3
|
+
import { createContext, type ReactNode, useContext, useEffect, useMemo, useRef, useState } from "react";
|
|
4
|
+
import { ActivityIndicator, Animated, Easing, Image, Platform, Pressable, Text, View } from "react-native";
|
|
5
5
|
import type { Chip } from "../shared/attention";
|
|
6
6
|
import { ICONS, type IconName } from "./icons";
|
|
7
7
|
|
|
@@ -54,17 +54,45 @@ export function TablerIcon({ name, size = 16, color }: { name: IconName; size?:
|
|
|
54
54
|
return <Icon icon={ICONS[name]} size={size} color={color ?? c.foregroundMuted} />;
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
+
// An icon that turns while something runs, like ⟳ while its feed is fetched.
|
|
58
|
+
export function SpinningIcon({ name, size = 16, color, spinning }: { name: IconName; size?: number; color?: string; spinning: boolean }) {
|
|
59
|
+
const turn = useRef(new Animated.Value(0)).current;
|
|
60
|
+
useEffect(() => {
|
|
61
|
+
if (!spinning) return;
|
|
62
|
+
const loop = Animated.loop(Animated.timing(turn, { toValue: 1, duration: 1000, easing: Easing.linear, useNativeDriver: Platform.OS !== "web" }));
|
|
63
|
+
loop.start();
|
|
64
|
+
return () => (loop.stop(), turn.setValue(0));
|
|
65
|
+
}, [spinning, turn]);
|
|
66
|
+
const rotate = turn.interpolate({ inputRange: [0, 1], outputRange: ["0deg", "360deg"] });
|
|
67
|
+
return (
|
|
68
|
+
<Animated.View style={{ transform: [{ rotate }] }}>
|
|
69
|
+
<TablerIcon name={name} size={size} color={color} />
|
|
70
|
+
</Animated.View>
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// What's loading, with a spinner so it doesn't read as stuck.
|
|
75
|
+
export function Loading({ text }: { text: string }) {
|
|
76
|
+
const styles = useStyles();
|
|
77
|
+
return (
|
|
78
|
+
<View style={styles.row}>
|
|
79
|
+
<ActivityIndicator size="small" color={styles.c.foregroundMuted} />
|
|
80
|
+
<Text style={styles.muted}>{text}</Text>
|
|
81
|
+
</View>
|
|
82
|
+
);
|
|
83
|
+
}
|
|
84
|
+
|
|
57
85
|
export function toneColor(styles: Styles, tone: Chip["tone"]): string {
|
|
58
86
|
return { good: styles.c.statusSuccess, bad: styles.c.statusDanger, warn: styles.c.statusWarning, neutral: styles.c.foregroundMuted }[tone];
|
|
59
87
|
}
|
|
60
88
|
|
|
61
|
-
// A state that matters, as a colored dot and text.
|
|
62
|
-
export function Signal({ text, tone }: Chip) {
|
|
89
|
+
// A state that matters, as a colored dot (or its icon) and text.
|
|
90
|
+
export function Signal({ text, tone, icon }: Chip) {
|
|
63
91
|
const styles = useStyles();
|
|
64
92
|
const color = toneColor(styles, tone);
|
|
65
93
|
return (
|
|
66
94
|
<View style={[styles.row, { gap: 5 }]}>
|
|
67
|
-
<View style={{ width: 7, height: 7, borderRadius: 4, backgroundColor: color }} />
|
|
95
|
+
{icon ? <TablerIcon name={icon} size={13} color={color} /> : <View style={{ width: 7, height: 7, borderRadius: 4, backgroundColor: color }} />}
|
|
68
96
|
<Text style={{ color, fontSize: 12, fontWeight: "500" }}>{text}</Text>
|
|
69
97
|
</View>
|
|
70
98
|
);
|
|
@@ -73,8 +101,9 @@ export function Signal({ text, tone }: Chip) {
|
|
|
73
101
|
// The line under a title: facts as quiet text joined by "·", then signals [ATT-05].
|
|
74
102
|
export function Meta({ facts, chips }: { facts: string[]; chips: Chip[] }) {
|
|
75
103
|
const styles = useStyles();
|
|
76
|
-
const
|
|
77
|
-
const
|
|
104
|
+
const quiet = (chip: Chip) => chip.tone === "neutral" && !chip.icon;
|
|
105
|
+
const text = [...facts, ...chips.filter(quiet).map((chip) => chip.text)];
|
|
106
|
+
const signals = chips.filter((chip) => !quiet(chip));
|
|
78
107
|
return (
|
|
79
108
|
<View style={[styles.wrap, { columnGap: 10, rowGap: 4 }]}>
|
|
80
109
|
{text.length ? <Text style={styles.muted}>{text.join(" · ")}</Text> : null}
|
|
@@ -100,20 +129,26 @@ export function useHover() {
|
|
|
100
129
|
}
|
|
101
130
|
|
|
102
131
|
// Calm by default: accent text on a subtle surface. Solid accent is for confirmations.
|
|
132
|
+
// Busy: a spinner in place of the icon, and no second press while it runs.
|
|
103
133
|
export function Button({
|
|
104
134
|
label,
|
|
105
135
|
icon,
|
|
106
136
|
onPress,
|
|
107
137
|
variant = "plain",
|
|
108
138
|
disabled,
|
|
139
|
+
busy,
|
|
109
140
|
accessibilityLabel,
|
|
141
|
+
joined,
|
|
110
142
|
}: {
|
|
111
143
|
label?: string;
|
|
112
144
|
icon?: IconName;
|
|
113
145
|
onPress: () => void;
|
|
114
146
|
variant?: Variant;
|
|
115
147
|
disabled?: boolean;
|
|
148
|
+
busy?: boolean;
|
|
116
149
|
accessibilityLabel?: string;
|
|
150
|
+
// One half of a split button: square on the side it joins.
|
|
151
|
+
joined?: "start" | "end";
|
|
117
152
|
}) {
|
|
118
153
|
const styles = useStyles();
|
|
119
154
|
const { hovered, hover } = useHover();
|
|
@@ -123,7 +158,8 @@ export function Button({
|
|
|
123
158
|
<Pressable
|
|
124
159
|
accessibilityRole="button"
|
|
125
160
|
accessibilityLabel={accessibilityLabel ?? label ?? icon}
|
|
126
|
-
|
|
161
|
+
accessibilityState={{ disabled: disabled || busy, busy }}
|
|
162
|
+
disabled={disabled || busy}
|
|
127
163
|
onPress={onPress}
|
|
128
164
|
{...hover}
|
|
129
165
|
style={({ pressed }) => ({
|
|
@@ -133,16 +169,62 @@ export function Button({
|
|
|
133
169
|
height: 30,
|
|
134
170
|
paddingHorizontal: label ? 11 : 8,
|
|
135
171
|
borderRadius: 8,
|
|
172
|
+
...(joined === "start" ? { borderTopRightRadius: 0, borderBottomRightRadius: 0 } : joined === "end" ? { borderTopLeftRadius: 0, borderBottomLeftRadius: 0, paddingHorizontal: 6 } : null),
|
|
136
173
|
backgroundColor: variant === "solid" ? c.accent : hovered || (pressed && variant === "ghost") ? c.border : variant === "ghost" ? "transparent" : c.surface2,
|
|
137
174
|
opacity: disabled ? 0.5 : pressed ? 0.8 : 1,
|
|
138
175
|
})}
|
|
139
176
|
>
|
|
140
|
-
{icon ? <TablerIcon name={icon} size={15} color={color} /> : null}
|
|
177
|
+
{busy ? <ActivityIndicator size="small" color={color} style={{ width: 15, height: 15 }} /> : icon ? <TablerIcon name={icon} size={15} color={color} /> : null}
|
|
141
178
|
{label ? <Text style={{ color, fontSize: 13, fontWeight: "600" }}>{label}</Text> : null}
|
|
142
179
|
</Pressable>
|
|
143
180
|
);
|
|
144
181
|
}
|
|
145
182
|
|
|
183
|
+
// Where a menu opens from, in window coordinates.
|
|
184
|
+
export interface Anchor {
|
|
185
|
+
x: number;
|
|
186
|
+
y: number;
|
|
187
|
+
width: number;
|
|
188
|
+
height: number;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
// Measures a view, for a menu that opens under it.
|
|
192
|
+
export function useAnchor() {
|
|
193
|
+
const ref = useRef<View>(null);
|
|
194
|
+
const measure = (then: (anchor: Anchor | undefined) => void) => {
|
|
195
|
+
if (!ref.current) return then(undefined);
|
|
196
|
+
ref.current.measureInWindow((x, y, width, height) => then(width || height ? { x, y, width, height } : undefined));
|
|
197
|
+
};
|
|
198
|
+
return { ref, measure };
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
// The action, and ▾ for the choices around it [SES-03].
|
|
202
|
+
export function SplitButton({
|
|
203
|
+
label,
|
|
204
|
+
icon,
|
|
205
|
+
onPress,
|
|
206
|
+
onMenu,
|
|
207
|
+
menuLabel,
|
|
208
|
+
busy,
|
|
209
|
+
accessibilityLabel,
|
|
210
|
+
}: {
|
|
211
|
+
label: string;
|
|
212
|
+
icon?: IconName;
|
|
213
|
+
onPress: () => void;
|
|
214
|
+
onMenu: (anchor: Anchor | undefined) => void;
|
|
215
|
+
menuLabel: string;
|
|
216
|
+
busy?: boolean;
|
|
217
|
+
accessibilityLabel?: string;
|
|
218
|
+
}) {
|
|
219
|
+
const { ref, measure } = useAnchor();
|
|
220
|
+
return (
|
|
221
|
+
<View ref={ref} collapsable={false} style={{ flexDirection: "row", gap: 1 }}>
|
|
222
|
+
<Button label={label} icon={icon} variant="calm" busy={busy} accessibilityLabel={accessibilityLabel} onPress={onPress} joined="start" />
|
|
223
|
+
<Button icon="chevronDown" variant="calm" disabled={busy} accessibilityLabel={menuLabel} onPress={() => measure(onMenu)} joined="end" />
|
|
224
|
+
</View>
|
|
225
|
+
);
|
|
226
|
+
}
|
|
227
|
+
|
|
146
228
|
// Sentence case, with the count as quiet text.
|
|
147
229
|
export function SectionHeader({ icon, title, count, action }: { icon: IconName; title: string; count: number; action?: ReactNode }) {
|
|
148
230
|
const styles = useStyles();
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/index.server.ts
CHANGED
|
@@ -5,8 +5,8 @@ import { itemDetails } from "./server/details";
|
|
|
5
5
|
import { FIXTURE_CONTEXT, fixtureDetails } from "./server/fixture";
|
|
6
6
|
import { FIXTURE } from "./server/gh";
|
|
7
7
|
import { checkCoverage, configStatus, myOrgs, setupStatus } from "./server/setup";
|
|
8
|
-
import { AttentionService } from "./server/service";
|
|
9
|
-
import type {
|
|
8
|
+
import { AttentionService, type Change } from "./server/service";
|
|
9
|
+
import type { Chip } from "./shared/attention";
|
|
10
10
|
import * as rpc from "./shared/rpc";
|
|
11
11
|
|
|
12
12
|
export default function contribute(server: PluginServerContext) {
|
|
@@ -14,12 +14,9 @@ export default function contribute(server: PluginServerContext) {
|
|
|
14
14
|
const started = attention.start().catch((error) => console.error("Attention Span failed to start:", error));
|
|
15
15
|
const ready = <T>(work: () => Promise<T>) => started.then(work);
|
|
16
16
|
|
|
17
|
-
//
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
for (const feed of feeds) void attention.refresh(feed).catch(() => {});
|
|
21
|
-
return { ok: true as const };
|
|
22
|
-
};
|
|
17
|
+
// A change on GitHub, answered with the list after it; what it does to the card shows right away [FRESH-02].
|
|
18
|
+
const act = (key: string, work: () => Promise<void>, change: Change) => ready(() => attention.act(key, work, change));
|
|
19
|
+
const chip = (text: string, tone: Chip["tone"] = "neutral", icon?: Chip["icon"]): Change => ({ kind: "chip", chip: { text, tone, ...(icon ? { icon } : {}) } });
|
|
23
20
|
|
|
24
21
|
// The app asks for the list on load and every few minutes; its Paseo connection lets refreshes see my projects [NXT-08].
|
|
25
22
|
server.handle(rpc.getAttention, ({ refresh }, { paseo }) => ready(() => (attention.connect(paseo), attention.get(refresh))));
|
|
@@ -35,17 +32,17 @@ export default function contribute(server: PluginServerContext) {
|
|
|
35
32
|
server.handle(rpc.myOrgs, async () => ({ orgs: await myOrgs() }));
|
|
36
33
|
server.handle(rpc.setScopes, ({ scopes }) => ready(() => attention.setScopes(scopes)).then(() => ({ ok: true as const })));
|
|
37
34
|
server.handle(rpc.setSources, ({ sources }) => ready(() => attention.setSources(sources)).then(() => ({ ok: true as const })));
|
|
38
|
-
server.handle(rpc.updateBranch, ({ target }) =>
|
|
39
|
-
server.handle(rpc.mergePullRequest, ({ target }) =>
|
|
40
|
-
server.handle(rpc.closePullRequest, ({ target, comment }) =>
|
|
41
|
-
server.handle(rpc.claimIssue, ({ target }) =>
|
|
42
|
-
server.handle(rpc.unclaimIssue, ({ target }) =>
|
|
43
|
-
server.handle(rpc.closeIssue, ({ target, reason, comment }) =>
|
|
44
|
-
server.handle(rpc.reopenIssue, ({ target }) =>
|
|
45
|
-
server.handle(rpc.setReady, ({ target, ready }) =>
|
|
46
|
-
server.handle(rpc.setAutoMerge, ({ target, on }) =>
|
|
47
|
-
server.handle(rpc.react, ({ subjectIds, on }) =>
|
|
48
|
-
server.handle(rpc.rerunFailed, ({ repo, runIds }) =>
|
|
35
|
+
server.handle(rpc.updateBranch, ({ key, target }) => act(key, () => updateBranch(target), chip("updating")));
|
|
36
|
+
server.handle(rpc.mergePullRequest, ({ key, target }) => act(key, () => mergePullRequest(target), { kind: "finished" }));
|
|
37
|
+
server.handle(rpc.closePullRequest, ({ key, target, comment }) => act(key, () => closePullRequest(target, comment), { kind: "gone" }));
|
|
38
|
+
server.handle(rpc.claimIssue, ({ key, target }) => act(key, () => claimIssue(target), { kind: "claimed" }));
|
|
39
|
+
server.handle(rpc.unclaimIssue, ({ key, target }) => act(key, () => unclaimIssue(target), { kind: "unclaimed" }));
|
|
40
|
+
server.handle(rpc.closeIssue, ({ key, target, reason, comment }) => act(key, () => closeIssue(target, reason, comment), { kind: "finished", notPlanned: reason === "not_planned" }));
|
|
41
|
+
server.handle(rpc.reopenIssue, ({ key, target }) => act(key, () => reopenIssue(target), null));
|
|
42
|
+
server.handle(rpc.setReady, ({ key, target, ready }) => act(key, () => setReady(target, ready), ready ? chip("ready for review", "good") : null));
|
|
43
|
+
server.handle(rpc.setAutoMerge, ({ key, target, on }) => act(key, () => setAutoMerge(target, on), on ? chip("auto-merge on", "good") : null));
|
|
44
|
+
server.handle(rpc.react, ({ key, subjectIds, on }) => act(key, () => react(subjectIds, on), on ? chip("acknowledged", "neutral", "thumbUp") : null));
|
|
45
|
+
server.handle(rpc.rerunFailed, ({ key, repo, runIds }) => act(key, () => rerunFailed(repo, runIds), chip("rerunning")));
|
|
49
46
|
server.handle(rpc.itemDetails, ({ subject, target, checks }) => (FIXTURE ? Promise.resolve(fixtureDetails(subject, target, checks)) : itemDetails(subject, target, checks)));
|
|
50
47
|
server.handle(rpc.defaultBranch, async ({ repo }) => ({ name: FIXTURE ? "main" : await defaultBranch(repo) }));
|
|
51
48
|
server.handle(rpc.sessionContext, async ({ kind, target }) => ({ context: FIXTURE ? FIXTURE_CONTEXT : await sessionContext(kind, target) }));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@andrioid/paseo-attention-span",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
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/paseo-plugin.json
CHANGED
|
@@ -5,8 +5,10 @@
|
|
|
5
5
|
"icon": "assets/icon.png",
|
|
6
6
|
"media": [
|
|
7
7
|
"docs/screenshots/desktop-dark-doing.png",
|
|
8
|
-
"docs/screenshots/
|
|
9
|
-
"docs/screenshots/desktop-dark-next-up.png"
|
|
8
|
+
"docs/screenshots/desktop-dark-waiting.png",
|
|
9
|
+
"docs/screenshots/desktop-dark-next-up.png",
|
|
10
|
+
"docs/screenshots/desktop-dark-history.png",
|
|
11
|
+
"docs/screenshots/phone-dark-doing.png"
|
|
10
12
|
],
|
|
11
13
|
"requirements": {
|
|
12
14
|
"paseo": ">=0.13.0"
|