@andrioid/paseo-attention-span 0.1.2 → 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 +232 -175
- package/client/card.tsx +141 -0
- package/client/coverage-settings.tsx +73 -20
- package/client/data.ts +2 -1
- package/client/icons.ts +3 -0
- package/client/next-up.tsx +266 -62
- 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 +21 -19
- package/package.json +1 -1
- package/paseo-plugin.json +4 -2
- package/server/actions.ts +15 -1
- package/server/classify.ts +21 -13
- package/server/fixture.ts +34 -14
- package/server/github-types.ts +5 -1
- package/server/queries.ts +44 -13
- package/server/service.ts +90 -16
- package/server/setup.ts +12 -5
- package/server/store.ts +18 -2
- package/server/view.ts +72 -1
- package/shared/attention.ts +34 -2
- package/shared/config.ts +20 -3
- package/shared/format.ts +16 -0
- package/shared/rpc.ts +19 -11
- package/shared/setup.ts +2 -0
package/client/next-up.tsx
CHANGED
|
@@ -2,12 +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 } 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
|
+
import type { NextUpSource } from "../shared/config";
|
|
7
8
|
import type { IconName } from "./icons";
|
|
8
9
|
import type { FetchDetails } from "./attention-screen";
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
10
|
+
import { CardList, CardRow, type Tone } from "./card";
|
|
11
|
+
import { openSessionEntry, sessionsGroup } from "./session-menu";
|
|
12
|
+
import { ActionSheet, DetailLines, type MenuGroup, MenuSheet, type SheetEntry } from "./sheet";
|
|
13
|
+
import { Modal } from "@getpaseo/plugin/client/ui";
|
|
14
|
+
import { type Anchor, Button, KeepStyles, Meta, SectionHeader, TablerIcon, useHover, useStyles } from "./ui";
|
|
11
15
|
|
|
12
16
|
const TYPE_ICONS: Record<string, IconName> = { bug: "bug", feature: "feature", debt: "debt", task: "task", epic: "epic" };
|
|
13
17
|
|
|
@@ -15,28 +19,50 @@ interface Props {
|
|
|
15
19
|
assigned: NextUpIssue[];
|
|
16
20
|
unclaimed: NextUpIssue[];
|
|
17
21
|
unclaimedFrom: UnclaimedSource;
|
|
18
|
-
//
|
|
22
|
+
// Scopes I ticked in the filter; none means all [NXT-03].
|
|
19
23
|
selected: string[];
|
|
20
24
|
onSelect: (scopes: string[]) => void;
|
|
21
|
-
|
|
22
|
-
|
|
25
|
+
// Where Next up looks, and the sources I ticked; none means all [NXT-09].
|
|
26
|
+
sources: NextUpSource[];
|
|
27
|
+
selectedSources: string[];
|
|
28
|
+
onSelectSources: (sources: string[]) => void;
|
|
29
|
+
agents: AgentSummary[];
|
|
30
|
+
// Mine, so my repos show without the owner.
|
|
31
|
+
login: string | null;
|
|
32
|
+
busy: ReadonlySet<string>;
|
|
23
33
|
fetchDetails: FetchDetails;
|
|
24
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;
|
|
25
37
|
// Claim without starting, or give an assigned issue back [NXT-07].
|
|
26
38
|
onClaim: (issue: NextUpIssue, on: boolean) => void;
|
|
39
|
+
// Close it, once I've confirmed the reason [NXT-11].
|
|
40
|
+
onCloseIssue: (issue: NextUpIssue, reason: IssueCloseReason, comment: string) => void;
|
|
27
41
|
onOpenAgent: (agentId: string) => void;
|
|
28
42
|
}
|
|
29
43
|
|
|
30
|
-
type RowProps = Omit<Props, "assigned" | "unclaimed" | "unclaimedFrom" | "selected" | "onSelect">;
|
|
44
|
+
type RowProps = Omit<Props, "assigned" | "unclaimed" | "unclaimedFrom" | "selected" | "onSelect" | "sources" | "selectedSources" | "onSelectSources">;
|
|
31
45
|
|
|
32
46
|
// 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) {
|
|
47
|
+
export function NextUpList({ assigned, unclaimed, unclaimedFrom, selected, onSelect, sources, selectedSources, onSelectSources, ...rowProps }: Props) {
|
|
34
48
|
const styles = useStyles();
|
|
35
49
|
const scopes = useMemo(() => [...new Set(unclaimed.map((issue) => issue.scope).filter((scope): scope is string => !!scope))].sort(), [unclaimed]);
|
|
36
50
|
// Filter by the scopes I picked last time [NXT-03]; a picked scope with no issues left is ignored.
|
|
37
51
|
const active = selected.filter((scope) => scopes.includes(scope));
|
|
38
|
-
|
|
52
|
+
// And by source, when there's more than one [NXT-09]; a picked source no longer in settings is ignored.
|
|
53
|
+
const activeSources = sources.length > 1 ? selectedSources.filter((id) => sources.some((source) => source.id === id)) : [];
|
|
54
|
+
const shown = unclaimed.filter(
|
|
55
|
+
(issue) => (active.length === 0 || (issue.scope && active.includes(issue.scope))) && (activeSources.length === 0 || issue.sources.some((id) => activeSources.includes(id))),
|
|
56
|
+
);
|
|
39
57
|
const toggle = (scope: string) => onSelect(active.includes(scope) ? active.filter((s) => s !== scope) : [...active, scope]);
|
|
58
|
+
const toggleSource = (id: string) => onSelectSources(activeSources.includes(id) ? activeSources.filter((s) => s !== id) : [...activeSources, id]);
|
|
59
|
+
const narrowedBy = [activeSources.length ? "sources" : null, active.length ? "scopes" : null].filter(Boolean).join(" and ");
|
|
60
|
+
const [filtering, setFiltering] = useState(false);
|
|
61
|
+
const picked = active.length + activeSources.length;
|
|
62
|
+
const groups: FilterGroup[] = [
|
|
63
|
+
...(sources.length > 1 ? [{ title: "Source", options: sources, active: activeSources, onToggle: toggleSource }] : []),
|
|
64
|
+
...(scopes.length > 0 ? [{ title: "Scope", options: scopes.map((scope) => ({ id: scope, label: scope })), active, onToggle: toggle }] : []),
|
|
65
|
+
];
|
|
40
66
|
|
|
41
67
|
return (
|
|
42
68
|
<View style={{ gap: 24 }}>
|
|
@@ -47,19 +73,36 @@ export function NextUpList({ assigned, unclaimed, unclaimedFrom, selected, onSel
|
|
|
47
73
|
</View>
|
|
48
74
|
) : null}
|
|
49
75
|
<View>
|
|
50
|
-
<SectionHeader
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
76
|
+
<SectionHeader
|
|
77
|
+
icon="nextUp"
|
|
78
|
+
title="Unclaimed"
|
|
79
|
+
count={shown.length}
|
|
80
|
+
action={
|
|
81
|
+
groups.length > 0 ? (
|
|
82
|
+
<Button
|
|
83
|
+
label={picked ? `Filter · ${picked}` : "Filter"}
|
|
84
|
+
accessibilityLabel={picked ? `Filter, ${picked} on` : "Filter"}
|
|
85
|
+
icon="filter"
|
|
86
|
+
variant={picked ? "calm" : "ghost"}
|
|
87
|
+
onPress={() => setFiltering(true)}
|
|
88
|
+
/>
|
|
89
|
+
) : null
|
|
90
|
+
}
|
|
91
|
+
/>
|
|
92
|
+
{filtering ? (
|
|
93
|
+
<FilterSheet
|
|
94
|
+
groups={groups}
|
|
95
|
+
onClear={() => {
|
|
96
|
+
onSelect([]);
|
|
97
|
+
onSelectSources([]);
|
|
98
|
+
}}
|
|
99
|
+
onClose={() => setFiltering(false)}
|
|
100
|
+
/>
|
|
58
101
|
) : null}
|
|
59
102
|
{unclaimedFrom === "none" ? (
|
|
60
|
-
<Text style={styles.text}>No repos to look in. Register a project in Paseo, or
|
|
103
|
+
<Text style={styles.text}>No repos to look in. Register a project in Paseo, or choose where Next up looks in Settings.</Text>
|
|
61
104
|
) : shown.length === 0 ? (
|
|
62
|
-
<Text style={styles.text}>No unclaimed issues{
|
|
105
|
+
<Text style={styles.text}>No unclaimed issues{narrowedBy ? ` in these ${narrowedBy}` : ""}.</Text>
|
|
63
106
|
) : (
|
|
64
107
|
<IssueList issues={shown} claim {...rowProps} />
|
|
65
108
|
)}
|
|
@@ -68,62 +111,228 @@ export function NextUpList({ assigned, unclaimed, unclaimedFrom, selected, onSel
|
|
|
68
111
|
);
|
|
69
112
|
}
|
|
70
113
|
|
|
71
|
-
|
|
114
|
+
// Source and scope filters behind one button, so they take no room above the list [NXT-03, NXT-09].
|
|
115
|
+
// Ticks apply right away; a bottom sheet on phones, a dialog on desktop.
|
|
116
|
+
function FilterSheet({ groups, onClear, onClose }: { groups: FilterGroup[]; onClear: () => void; onClose: () => void }) {
|
|
117
|
+
const styles = useStyles();
|
|
118
|
+
const any = groups.some((group) => group.active.length > 0);
|
|
119
|
+
return (
|
|
120
|
+
<Modal title="Filter" open onOpenChange={(open) => (open ? null : onClose())}>
|
|
121
|
+
<Modal.Content>
|
|
122
|
+
<KeepStyles styles={styles}>
|
|
123
|
+
{groups.map((group) => (
|
|
124
|
+
<View key={group.title} style={{ gap: 6 }}>
|
|
125
|
+
<Text style={styles.muted}>{group.title}</Text>
|
|
126
|
+
<View style={[styles.card, { backgroundColor: styles.c.surface2 }]}>
|
|
127
|
+
{group.options.map((option, index) => (
|
|
128
|
+
<FilterOption key={option.id} label={option.label} checked={group.active.includes(option.id)} first={index === 0} onPress={() => group.onToggle(option.id)} />
|
|
129
|
+
))}
|
|
130
|
+
</View>
|
|
131
|
+
</View>
|
|
132
|
+
))}
|
|
133
|
+
<View style={[styles.row, { justifyContent: "flex-end" }]}>
|
|
134
|
+
<Button label="Clear" variant="ghost" disabled={!any} onPress={onClear} />
|
|
135
|
+
<Button label="Done" variant="solid" onPress={onClose} />
|
|
136
|
+
</View>
|
|
137
|
+
</KeepStyles>
|
|
138
|
+
</Modal.Content>
|
|
139
|
+
</Modal>
|
|
140
|
+
);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
interface FilterGroup {
|
|
144
|
+
title: string;
|
|
145
|
+
options: { id: string; label: string }[];
|
|
146
|
+
active: string[];
|
|
147
|
+
onToggle: (id: string) => void;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
function FilterOption({ label, checked, first, onPress }: { label: string; checked: boolean; first: boolean; onPress: () => void }) {
|
|
72
151
|
const styles = useStyles();
|
|
152
|
+
const { hovered, hover } = useHover();
|
|
153
|
+
return (
|
|
154
|
+
<Pressable
|
|
155
|
+
accessibilityRole="checkbox"
|
|
156
|
+
accessibilityState={{ checked }}
|
|
157
|
+
accessibilityLabel={label}
|
|
158
|
+
onPress={onPress}
|
|
159
|
+
{...hover}
|
|
160
|
+
style={({ pressed }) => [
|
|
161
|
+
styles.row,
|
|
162
|
+
{ paddingVertical: 10, paddingHorizontal: 12, backgroundColor: pressed || hovered ? styles.c.border : "transparent" },
|
|
163
|
+
first ? null : { borderTopWidth: 1, borderTopColor: styles.c.surface1 },
|
|
164
|
+
]}
|
|
165
|
+
>
|
|
166
|
+
<TablerIcon name={checked ? "squareCheck" : "square"} size={18} color={checked ? styles.action : styles.c.foregroundMuted} />
|
|
167
|
+
<Text style={styles.text}>{label}</Text>
|
|
168
|
+
</Pressable>
|
|
169
|
+
);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
function IssueList({ issues, claim, ...rowProps }: RowProps & { issues: NextUpIssue[]; claim: boolean }) {
|
|
73
173
|
return (
|
|
74
|
-
<
|
|
174
|
+
<CardList>
|
|
75
175
|
{issues.map((issue, index) => (
|
|
76
176
|
<IssueRow key={issue.key} issue={issue} claim={claim} first={index === 0} {...rowProps} />
|
|
77
177
|
))}
|
|
78
|
-
</
|
|
178
|
+
</CardList>
|
|
79
179
|
);
|
|
80
180
|
}
|
|
81
181
|
|
|
82
|
-
|
|
182
|
+
// 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].
|
|
183
|
+
// The type is the mark. The sheet has the full values.
|
|
184
|
+
const fullFacts = (issue: NextUpIssue) => [
|
|
185
|
+
`${issue.repo}#${issue.number}`,
|
|
186
|
+
`${ago(issue.createdAt)} old`,
|
|
187
|
+
...[issue.type, issue.priority, issue.effort, issue.scope].filter((v): v is string => !!v),
|
|
188
|
+
];
|
|
83
189
|
|
|
84
|
-
//
|
|
85
|
-
function
|
|
190
|
+
// An open PR that closes it means someone may already be on it [NXT-10].
|
|
191
|
+
function prSignal(issue: NextUpIssue): Chip[] {
|
|
192
|
+
const [first, ...more] = issue.openPrs;
|
|
193
|
+
if (!first) return [];
|
|
194
|
+
return [{ text: `PR by ${first.author ?? "someone"}${more.length ? ` +${more.length}` : ""}`, tone: "warn" }];
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
// The top priority is warm, the next accent, the rest quiet; unknown order stays quiet.
|
|
198
|
+
function Tags({ issue }: { issue: NextUpIssue }) {
|
|
86
199
|
const styles = useStyles();
|
|
87
|
-
const
|
|
88
|
-
const
|
|
89
|
-
|
|
200
|
+
const priorityColor = issue.priorityRank === 0 ? styles.c.statusWarning : issue.priorityRank === 1 ? styles.action : undefined;
|
|
201
|
+
const tags = [
|
|
202
|
+
issue.priority ? { key: "priority", text: shortValue(issue.priority), color: priorityColor } : null,
|
|
203
|
+
issue.effort ? { key: "effort", text: shortValue(issue.effort) } : null,
|
|
204
|
+
issue.scope ? { key: "scope", text: shortValue(issue.scope) } : null,
|
|
205
|
+
].filter((tag): tag is { key: string; text: string; color?: string } => !!tag);
|
|
206
|
+
if (tags.length === 0) return null;
|
|
90
207
|
return (
|
|
91
|
-
<View style={[styles.
|
|
92
|
-
|
|
93
|
-
<
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
208
|
+
<View style={[styles.wrap, { gap: 4, marginTop: 2 }]}>
|
|
209
|
+
{tags.map((tag) => (
|
|
210
|
+
<Text
|
|
211
|
+
key={tag.key}
|
|
212
|
+
style={{
|
|
213
|
+
fontSize: 11,
|
|
214
|
+
color: tag.color ?? styles.c.foregroundMuted,
|
|
215
|
+
borderWidth: 1,
|
|
216
|
+
borderColor: tag.color ?? styles.c.border,
|
|
217
|
+
borderRadius: 4,
|
|
218
|
+
paddingHorizontal: 5,
|
|
219
|
+
paddingVertical: 1,
|
|
220
|
+
}}
|
|
221
|
+
>
|
|
222
|
+
{tag.text}
|
|
98
223
|
</Text>
|
|
99
|
-
|
|
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}
|
|
224
|
+
))}
|
|
113
225
|
</View>
|
|
114
226
|
);
|
|
115
227
|
}
|
|
116
228
|
|
|
229
|
+
// The type as the card's mark: red bugs, green features and epics, amber debt, the rest quiet.
|
|
230
|
+
const TYPE_TONES: Record<string, Tone> = { bug: "bad", feature: "good", epic: "good", debt: "warn" };
|
|
231
|
+
|
|
232
|
+
// Its main action and ⋯; tapping it opens the sheet with the description, Claim or Unclaim [ATT-06, NXT-07].
|
|
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);
|
|
236
|
+
// Closing asks first, with the reason and an optional comment [NXT-11, SAFE-01].
|
|
237
|
+
const [closing, setClosing] = useState(false);
|
|
238
|
+
// An open session leads; without one, Start does [SES-03].
|
|
239
|
+
const sessions = matchSessions(agents, [issue.key]);
|
|
240
|
+
const startLabel = claim ? "Claim & start" : "Start";
|
|
241
|
+
const type = issue.type?.toLowerCase() ?? "";
|
|
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] }];
|
|
258
|
+
return (
|
|
259
|
+
<CardRow
|
|
260
|
+
first={first}
|
|
261
|
+
mark={{ icon: TYPE_ICONS[type] ?? "issue", tone: TYPE_TONES[type] ?? "neutral" }}
|
|
262
|
+
title={issue.title}
|
|
263
|
+
accessibilityLabel={`${issue.type ? `${issue.type}: ` : ""}${issue.title}, more`}
|
|
264
|
+
meta={{ place: `${repoLabel(issue.repo, login)} #${issue.number}`, when: `${ago(issue.createdAt)} old`, signals: prSignal(issue) }}
|
|
265
|
+
extra={<Tags issue={issue} />}
|
|
266
|
+
onOpen={() => setSheet("item")}
|
|
267
|
+
busy={busy.has(issue.key)}
|
|
268
|
+
primary={
|
|
269
|
+
sessions[0]
|
|
270
|
+
? { label: "Open session", icon: "agent", onPress: () => onOpenAgent(sessions[0].id), menu: { label: "Session choices", onPress: onMenu } }
|
|
271
|
+
: // Claim first so teammates see it's taken [NXT-05].
|
|
272
|
+
{ label: startLabel, accessibilityLabel: `${startLabel} ${issue.title}`, icon: "agent", onPress: () => onStart(issue, claim), menu: { label: `${startLabel} choices`, onPress: onMenu } }
|
|
273
|
+
}
|
|
274
|
+
secondary={[{ label: "More actions", icon: "dots", onPress: () => setSheet("item") }]}
|
|
275
|
+
confirm={
|
|
276
|
+
closing
|
|
277
|
+
? {
|
|
278
|
+
text: `Close #${issue.number}? A comment is only posted if you write one.`,
|
|
279
|
+
comment: true,
|
|
280
|
+
choices: [
|
|
281
|
+
{ label: "Completed", icon: "issueClosed", solid: true, onConfirm: close("completed") },
|
|
282
|
+
{ label: "Not planned", icon: "close", onConfirm: close("not_planned") },
|
|
283
|
+
],
|
|
284
|
+
onCancel: () => setClosing(false),
|
|
285
|
+
}
|
|
286
|
+
: null
|
|
287
|
+
}
|
|
288
|
+
overlay={
|
|
289
|
+
sheet === "item" ? (
|
|
290
|
+
<IssueSheet
|
|
291
|
+
issue={issue}
|
|
292
|
+
claim={claim}
|
|
293
|
+
sessions={sessions}
|
|
294
|
+
fetchDetails={fetchDetails}
|
|
295
|
+
onStart={onStart}
|
|
296
|
+
onClaim={onClaim}
|
|
297
|
+
onOpenAgent={onOpenAgent}
|
|
298
|
+
onMenu={onMenu}
|
|
299
|
+
onCloseIssue={() => setClosing(true)}
|
|
300
|
+
onClose={() => setSheet(null)}
|
|
301
|
+
/>
|
|
302
|
+
) : sheet ? (
|
|
303
|
+
<MenuSheet title={issue.title} anchor={sheet.anchor} groups={groups} onClose={() => setSheet(null)} />
|
|
304
|
+
) : null
|
|
305
|
+
}
|
|
306
|
+
/>
|
|
307
|
+
);
|
|
308
|
+
}
|
|
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
|
+
|
|
117
317
|
function IssueSheet({
|
|
118
318
|
issue,
|
|
119
319
|
claim,
|
|
120
|
-
|
|
320
|
+
sessions,
|
|
121
321
|
fetchDetails,
|
|
122
322
|
onStart,
|
|
123
323
|
onClaim,
|
|
124
324
|
onOpenAgent,
|
|
325
|
+
onMenu,
|
|
326
|
+
onCloseIssue,
|
|
125
327
|
onClose,
|
|
126
|
-
}: 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
|
+
}) {
|
|
127
336
|
const details = useQuery({
|
|
128
337
|
queryKey: ["attention-span", "details", issue.key, false],
|
|
129
338
|
queryFn: () => fetchDetails({ subject: { kind: "issue", repo: issue.repo, number: issue.number }, checks: false }),
|
|
@@ -131,19 +340,14 @@ function IssueSheet({
|
|
|
131
340
|
});
|
|
132
341
|
const close = (then: () => void) => () => (onClose(), then());
|
|
133
342
|
const entries: SheetEntry[] = [
|
|
134
|
-
|
|
135
|
-
?
|
|
136
|
-
: {
|
|
137
|
-
key: "start",
|
|
138
|
-
icon: "agent",
|
|
139
|
-
label: claim ? "Claim & start" : "Start",
|
|
140
|
-
detail: `${claim ? "Assigns you, then an agent" : "An agent"} reads the issue and proposes a plan`,
|
|
141
|
-
onPress: close(() => onStart(issue, claim)),
|
|
142
|
-
},
|
|
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 } },
|
|
143
346
|
claim
|
|
144
347
|
? { key: "claim", icon: "claim", label: "Claim", detail: "Assigns you, without starting a session", onPress: close(() => onClaim(issue, true)) }
|
|
145
348
|
: { key: "unclaim", icon: "unclaim", label: "Unclaim", detail: "Removes you as assignee, so it goes back to Unclaimed", onPress: close(() => onClaim(issue, false)) },
|
|
146
349
|
{ key: "github", icon: "github", label: "Open issue on GitHub", detail: `${issue.repo}#${issue.number}`, onPress: close(() => void openExternalUrl(issue.url)) },
|
|
350
|
+
{ key: "close", icon: "issueClosed", label: "Close issue", detail: "Asks first: as completed or not planned, with an optional comment", onPress: close(onCloseIssue) },
|
|
147
351
|
];
|
|
148
352
|
return (
|
|
149
353
|
<ActionSheet
|
|
@@ -151,7 +355,7 @@ function IssueSheet({
|
|
|
151
355
|
onClose={onClose}
|
|
152
356
|
top={
|
|
153
357
|
<>
|
|
154
|
-
<Meta facts={
|
|
358
|
+
<Meta facts={fullFacts(issue)} chips={prSignal(issue)} />
|
|
155
359
|
</>
|
|
156
360
|
}
|
|
157
361
|
entries={entries}
|
|
@@ -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
|
<>
|