@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
|
@@ -4,9 +4,9 @@ import { Markdown, Modal, TextInput, useToast } from "@getpaseo/plugin/client/ui
|
|
|
4
4
|
import { useQuery, useQueryClient } from "@tanstack/react-query";
|
|
5
5
|
import { type ReactNode, useState } from "react";
|
|
6
6
|
import { Pressable, ScrollView, Text, View } from "react-native";
|
|
7
|
-
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";
|
|
7
|
+
import { type ActionId, type AgentSummary, type AttentionView, type Chip, type FailingChecks, type Item, itemSessions, type NextUpIssue, type Section, type SectionId, type SubRow, TAB_FEED, type TabId, type Target } from "../shared/attention";
|
|
8
8
|
import { type AttentionConfig, nextUpSources, type SessionKind } from "../shared/config";
|
|
9
|
-
import { ago, linkList } from "../shared/format";
|
|
9
|
+
import { ago, linkList, repoLabel } 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";
|
|
@@ -14,10 +14,11 @@ import { useAttention } from "./data";
|
|
|
14
14
|
import { CardList, CardRow, type CardProps } from "./card";
|
|
15
15
|
import type { IconName } from "./icons";
|
|
16
16
|
import { NextUpList } from "./next-up";
|
|
17
|
-
import {
|
|
17
|
+
import { agentSignal, openSessionEntry, sessionsGroup } from "./session-menu";
|
|
18
|
+
import { ActionSheet, DetailLines, type MenuGroup, MenuSheet, type SheetEntry } from "./sheet";
|
|
18
19
|
import { branchWorkspaces, findCheckout, githubProjects, itemAgents, listProfiles, noProjectMessage, resolveAgentConfig, startSession } from "./sessions";
|
|
19
20
|
import { SetupChecklist } from "./setup";
|
|
20
|
-
import { Avatar, Button, KeepStyles, Meta, SectionHeader, StylesProvider, TablerIcon, Toggle, useCopy, useHover, useStyles } from "./ui";
|
|
21
|
+
import { type Anchor, Avatar, Button, KeepStyles, Loading, Meta, SectionHeader, SpinningIcon, StylesProvider, TablerIcon, Toggle, useCopy, useHover, useStyles } from "./ui";
|
|
21
22
|
|
|
22
23
|
// The agent icon marks every action that starts an agent session; the rest act on GitHub right away [ATT-13].
|
|
23
24
|
const ACTION_ICONS: Record<ActionId, IconName> = {
|
|
@@ -67,7 +68,7 @@ function actionDetail(action: Exclude<ActionId, "rerun">, item: Item): string {
|
|
|
67
68
|
return {
|
|
68
69
|
reply: item.person ? `Opens ${item.person.login}'s comment on GitHub` : "Opens it on GitHub",
|
|
69
70
|
acknowledge:
|
|
70
|
-
comments.length === 1 ? `Reacts
|
|
71
|
+
comments.length === 1 ? `Reacts to ${comments[0].author}'s comment, which clears it` : `Pick which of the ${comments.length} waiting comments to react to`,
|
|
71
72
|
review: "An agent reviews the PR in a checkout and reports back. Nothing is posted",
|
|
72
73
|
fix: "An agent reads the failing logs and commits a fix, without pushing",
|
|
73
74
|
address: "An agent works through the unresolved comments and applies the trivial ones, without pushing",
|
|
@@ -95,16 +96,6 @@ function rerunEntry(failing: FailingChecks[] | undefined, loading: boolean): { d
|
|
|
95
96
|
return { detail: `${names} Β· ${reruns ? `rerun ${reruns === 1 ? "once" : `${reruns} times`} already` : "not rerun yet"}`, runIds: runs.map((run) => run.id) };
|
|
96
97
|
}
|
|
97
98
|
|
|
98
|
-
// "Continue review" keeps what the session is for [SES-03].
|
|
99
|
-
const CONTINUE_LABELS: Record<SessionKind, string> = {
|
|
100
|
-
review: "Continue review",
|
|
101
|
-
fix: "Continue fix",
|
|
102
|
-
address: "Continue comments",
|
|
103
|
-
rebase: "Continue rebase",
|
|
104
|
-
refresh: "Continue refresh",
|
|
105
|
-
start: "Continue",
|
|
106
|
-
};
|
|
107
|
-
|
|
108
99
|
const SECTION_ICONS: Record<SectionId, IconName> = {
|
|
109
100
|
reply: "reply",
|
|
110
101
|
review: "review",
|
|
@@ -143,6 +134,16 @@ interface Placing {
|
|
|
143
134
|
before?: () => Promise<unknown>;
|
|
144
135
|
}
|
|
145
136
|
|
|
137
|
+
// Session options, before it starts [SES-02].
|
|
138
|
+
export interface OptionsSpec {
|
|
139
|
+
itemKey: string;
|
|
140
|
+
title: string;
|
|
141
|
+
kind: SessionKind;
|
|
142
|
+
target: Target;
|
|
143
|
+
// Claims an issue first [NXT-05].
|
|
144
|
+
before?: () => Promise<unknown>;
|
|
145
|
+
}
|
|
146
|
+
|
|
146
147
|
// Something I just did, offered for undo until the tab changes [ATT-08, ATT-14].
|
|
147
148
|
interface Undoable {
|
|
148
149
|
id: number;
|
|
@@ -151,14 +152,6 @@ interface Undoable {
|
|
|
151
152
|
undo: () => Promise<unknown>;
|
|
152
153
|
}
|
|
153
154
|
|
|
154
|
-
// A session started from the item, as a signal [ATT-07].
|
|
155
|
-
function agentSignal(agent: AgentSummary): Chip {
|
|
156
|
-
if (agent.requiresAttention) return { text: "agent needs you", tone: "warn" };
|
|
157
|
-
if (agent.status === "running" || agent.status === "initializing") return { text: "agent working", tone: "good" };
|
|
158
|
-
if (agent.status === "error") return { text: "agent failed", tone: "bad" };
|
|
159
|
-
return { text: "agent idle", tone: "neutral" };
|
|
160
|
-
}
|
|
161
|
-
|
|
162
155
|
// `openSettings` opens the orgs and repos settings [SRC-02].
|
|
163
156
|
export function AttentionScreen({ theme, layout, navigation, openSettings }: PluginScreenProps & { openSettings?: () => void }) {
|
|
164
157
|
return (
|
|
@@ -197,9 +190,11 @@ function AttentionList({ navigation, openSettings }: Pick<PluginScreenProps, "na
|
|
|
197
190
|
const fetchDefaultBranch = useRpc(rpc.defaultBranch);
|
|
198
191
|
const defaultBranch: DefaultBranch = async (repo) => (await fetchDefaultBranch({ repo })).name;
|
|
199
192
|
const [tab, setTab] = useState<TabId>("doing");
|
|
200
|
-
|
|
193
|
+
// Every card with a change still running: each runs on its own.
|
|
194
|
+
const [busy, setBusy] = useState<ReadonlySet<string>>(new Set());
|
|
201
195
|
const [undoable, setUndoable] = useState<Undoable[]>([]);
|
|
202
196
|
const [placing, setPlacing] = useState<Placing | null>(null);
|
|
197
|
+
const [options, setOptions] = useState<OptionsSpec | null>(null);
|
|
203
198
|
const view = attention.data;
|
|
204
199
|
// Only when something fails: is it setup, and what's missing [SET-01]?
|
|
205
200
|
const fetchSetup = useRpc(rpc.setupStatus);
|
|
@@ -208,27 +203,24 @@ function AttentionList({ navigation, openSettings }: Pick<PluginScreenProps, "na
|
|
|
208
203
|
const [checking, setChecking] = useState(false);
|
|
209
204
|
|
|
210
205
|
async function run(key: string, label: string, work: () => Promise<unknown>) {
|
|
211
|
-
setBusy(key);
|
|
206
|
+
setBusy((keys) => new Set(keys).add(key));
|
|
212
207
|
try {
|
|
213
208
|
await work();
|
|
214
209
|
} catch (error) {
|
|
215
210
|
toast.error(`${label} failed: ${(error as Error).message}`);
|
|
216
211
|
} finally {
|
|
217
|
-
setBusy(
|
|
212
|
+
setBusy((keys) => new Set([...keys].filter((other) => other !== key)));
|
|
218
213
|
}
|
|
219
214
|
}
|
|
220
215
|
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
// A change on GitHub from one tap, without confirming: Undo instead, where GitHub can take it back [SAFE-01, ATT-14].
|
|
226
|
-
function onGitHub(key: string, label: string, work: () => Promise<unknown>, done: string, undo?: () => Promise<unknown>) {
|
|
216
|
+
// A change from one tap, without confirming: Undo instead, where it can be taken back [SAFE-01, ATT-08, ATT-14].
|
|
217
|
+
// The server answers each with the list after it, so nothing needs a refresh.
|
|
218
|
+
function change(key: string, label: string, work: () => Promise<AttentionView>, done: string, undo?: () => Promise<AttentionView>, dismissal?: boolean) {
|
|
227
219
|
void run(key, label, async () => {
|
|
228
|
-
await work();
|
|
229
|
-
if (undo)
|
|
230
|
-
|
|
231
|
-
|
|
220
|
+
attention.setView(await work());
|
|
221
|
+
if (!undo) return toast.show(done, { variant: "success" });
|
|
222
|
+
const id = Date.now() + Math.random();
|
|
223
|
+
setUndoable((rows) => [...rows, { id, text: done, undo: async () => attention.setView(await undo()), dismissal }]);
|
|
232
224
|
});
|
|
233
225
|
}
|
|
234
226
|
|
|
@@ -242,10 +234,8 @@ function AttentionList({ navigation, openSettings }: Pick<PluginScreenProps, "na
|
|
|
242
234
|
openAgent(agentId);
|
|
243
235
|
}
|
|
244
236
|
|
|
245
|
-
// One tap:
|
|
237
|
+
// One tap: start a session with defaults [SES-01]. An open one is offered first, by the card [SES-03].
|
|
246
238
|
async function startWithDefaults(itemKey: string, kind: SessionKind, target: Target, before?: () => Promise<unknown>) {
|
|
247
|
-
const existing = (view?.fixtureAgents ?? agents.data)?.[itemKey];
|
|
248
|
-
if (existing) return openAgent(existing.id);
|
|
249
239
|
if (!view) return;
|
|
250
240
|
await run(itemKey, "Starting the session", () => startNow(itemKey, kind, target, view.config, before));
|
|
251
241
|
}
|
|
@@ -288,13 +278,14 @@ function AttentionList({ navigation, openSettings }: Pick<PluginScreenProps, "na
|
|
|
288
278
|
if (!view) {
|
|
289
279
|
return (
|
|
290
280
|
<View style={[styles.screen, styles.content]}>
|
|
291
|
-
|
|
281
|
+
{attention.error ? <Text style={styles.danger}>Couldn't load Attention Span: {(attention.error as Error).message}</Text> : <Loading text="Loadingβ¦" />}
|
|
292
282
|
</View>
|
|
293
283
|
);
|
|
294
284
|
}
|
|
295
285
|
|
|
296
286
|
// Each tab shows how fresh its own feed is.
|
|
297
287
|
const feed = view.feeds[TAB_FEED[tab]];
|
|
288
|
+
const refreshing = feed.refreshing || attention.isFetching;
|
|
298
289
|
const tooLong = view.doing.find((section) => section.id === "too_long")?.items.length ?? 0;
|
|
299
290
|
const counts: Record<TabId, number> = {
|
|
300
291
|
history: view.history.filter((item) => item.section === "done").length,
|
|
@@ -304,9 +295,11 @@ function AttentionList({ navigation, openSettings }: Pick<PluginScreenProps, "na
|
|
|
304
295
|
};
|
|
305
296
|
|
|
306
297
|
const actions: Actions = {
|
|
307
|
-
agents: view.fixtureAgents ?? agents.data ??
|
|
298
|
+
agents: view.fixtureAgents ?? agents.data ?? [],
|
|
299
|
+
startWithOptions: setOptions,
|
|
308
300
|
busy,
|
|
309
301
|
config: view.config,
|
|
302
|
+
login: view.login,
|
|
310
303
|
fetchContext,
|
|
311
304
|
fetchDetails,
|
|
312
305
|
defaultBranch,
|
|
@@ -317,38 +310,26 @@ function AttentionList({ navigation, openSettings }: Pick<PluginScreenProps, "na
|
|
|
317
310
|
const { target } = item;
|
|
318
311
|
if (action === "reply") return void openExternalUrl(item.person?.url ?? item.url);
|
|
319
312
|
if (session) return void startWithDefaults(item.key, session, target);
|
|
320
|
-
if (action === "update")
|
|
321
|
-
void run(item.key, "Update", async () => {
|
|
322
|
-
await update({ target });
|
|
323
|
-
toast.show(`Updating PR ${target.number} with ${target.baseRefName}`, { variant: "success" });
|
|
324
|
-
});
|
|
313
|
+
if (action === "update") change(item.key, "Update", () => update({ key: item.key, target }), `Updating PR ${target.number} with ${target.baseRefName}`);
|
|
325
314
|
// [PRS-11]
|
|
326
315
|
if (action === "ready")
|
|
327
|
-
|
|
316
|
+
change(item.key, "Ready for review", () => setReady({ key: item.key, target, ready: true }), `PR ${target.number} is ready for review`, () => setReady({ key: item.key, target, ready: false }));
|
|
328
317
|
// [PRS-10]
|
|
329
318
|
if (action === "automerge")
|
|
330
|
-
|
|
319
|
+
change(item.key, "Auto-merge", () => setAutoMerge({ key: item.key, target, on: true }), `PR ${target.number} merges once checks pass`, () => setAutoMerge({ key: item.key, target, on: false }));
|
|
331
320
|
},
|
|
332
321
|
// [PRS-09]
|
|
333
|
-
rerun: (item, runIds) =>
|
|
334
|
-
onGitHub(item.key, "Rerun", () => rerunFailed({ repo: item.target.repo, runIds }), `Rerunning the failed jobs of PR ${item.target.number}`),
|
|
322
|
+
rerun: (item, runIds) => change(item.key, "Rerun", () => rerunFailed({ key: item.key, repo: item.target.repo, runIds }), `Rerunning the failed jobs of PR ${item.target.number}`),
|
|
335
323
|
// [MEN-07]
|
|
336
324
|
acknowledge: (item, ids) =>
|
|
337
|
-
|
|
338
|
-
react({ subjectIds: ids, on: false }),
|
|
325
|
+
change(item.key, "Acknowledge", () => react({ key: item.key, subjectIds: ids, on: true }), `Acknowledged ${ids.length === 1 ? "a comment" : `${ids.length} comments`} on #${item.number}`, () =>
|
|
326
|
+
react({ key: item.key, subjectIds: ids, on: false }),
|
|
339
327
|
),
|
|
340
328
|
confirm: (item, action, comment) =>
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
await attention.refreshNow("live");
|
|
346
|
-
}),
|
|
347
|
-
dismiss: (item) =>
|
|
348
|
-
void run(item.key, "Dismiss", async () => {
|
|
349
|
-
attention.setView(await dismiss({ key: item.key }));
|
|
350
|
-
offerUndo(`Dismissed β${item.title}β`, async () => attention.setView(await undismiss({ key: item.key })), true);
|
|
351
|
-
}),
|
|
329
|
+
action === "merge"
|
|
330
|
+
? change(item.key, "Merge", () => merge({ key: item.key, target: item.target }), `PR ${item.target.number} merged`)
|
|
331
|
+
: change(item.key, "Close", () => close({ key: item.key, target: item.target, comment }), `PR ${item.target.number} closed`),
|
|
332
|
+
dismiss: (item) => change(item.key, "Dismiss", () => dismiss({ key: item.key }), `Dismissed β${item.title}β`, () => undismiss({ key: item.key }), true),
|
|
352
333
|
};
|
|
353
334
|
|
|
354
335
|
const switchTab = (id: TabId) => {
|
|
@@ -365,9 +346,15 @@ function AttentionList({ navigation, openSettings }: Pick<PluginScreenProps, "na
|
|
|
365
346
|
))}
|
|
366
347
|
</View>
|
|
367
348
|
<View style={[styles.row, { gap: 16 }]}>
|
|
368
|
-
<Pressable
|
|
369
|
-
|
|
370
|
-
|
|
349
|
+
<Pressable
|
|
350
|
+
accessibilityRole="button"
|
|
351
|
+
accessibilityLabel="Refresh now"
|
|
352
|
+
accessibilityState={{ busy: refreshing }}
|
|
353
|
+
style={styles.row}
|
|
354
|
+
onPress={() => void attention.refreshNow(TAB_FEED[tab]).catch(() => {})}
|
|
355
|
+
>
|
|
356
|
+
<SpinningIcon name="update" size={14} spinning={refreshing} />
|
|
357
|
+
<Text style={styles.muted}>{feed.fetchedAt ? `${ago(feed.fetchedAt)} ago` : "never"}</Text>
|
|
371
358
|
</Pressable>
|
|
372
359
|
{openSettings ? (
|
|
373
360
|
<Pressable accessibilityRole="button" accessibilityLabel="Attention Span settings" onPress={openSettings} hitSlop={8}>
|
|
@@ -390,7 +377,6 @@ function AttentionList({ navigation, openSettings }: Pick<PluginScreenProps, "na
|
|
|
390
377
|
void run(String(row.id), "Undo", async () => {
|
|
391
378
|
await row.undo();
|
|
392
379
|
setUndoable((rows) => rows.filter((other) => other.id !== row.id));
|
|
393
|
-
if (!row.dismissal) void attention.refreshNow("live").catch(() => {});
|
|
394
380
|
})
|
|
395
381
|
}
|
|
396
382
|
/>
|
|
@@ -434,27 +420,33 @@ function AttentionList({ navigation, openSettings }: Pick<PluginScreenProps, "na
|
|
|
434
420
|
saveSources({ sources }).catch((error) => toast.error(`Saving the filter failed: ${(error as Error).message}`));
|
|
435
421
|
}}
|
|
436
422
|
agents={actions.agents}
|
|
423
|
+
login={view.login}
|
|
437
424
|
busy={busy}
|
|
438
425
|
fetchDetails={fetchDetails}
|
|
439
426
|
onOpenAgent={openAgent}
|
|
440
427
|
onStart={(issue, claimFirst) => {
|
|
441
428
|
const target = issueTarget(issue);
|
|
442
|
-
void startWithDefaults(issue.key, "start", target, claimFirst ? () => claim({ target }) : undefined);
|
|
429
|
+
void startWithDefaults(issue.key, "start", target, claimFirst ? async () => attention.setView(await claim({ key: issue.key, target })) : undefined);
|
|
430
|
+
}}
|
|
431
|
+
onOptions={(issue, claimFirst, label) => {
|
|
432
|
+
const target = issueTarget(issue);
|
|
433
|
+
setOptions({ itemKey: issue.key, title: `${label}: ${issue.title}`, kind: "start", target, before: claimFirst ? async () => attention.setView(await claim({ key: issue.key, target })) : undefined });
|
|
443
434
|
}}
|
|
444
435
|
// Claim without starting, or give it back; each undoes the other [NXT-07].
|
|
445
436
|
onClaim={(issue, on) => {
|
|
446
437
|
const target = issueTarget(issue);
|
|
447
|
-
const [take, giveBack] = [() => claim({ target }), () => unclaim({ target })];
|
|
448
|
-
|
|
438
|
+
const [take, giveBack] = [() => claim({ key: issue.key, target }), () => unclaim({ key: issue.key, target })];
|
|
439
|
+
change(issue.key, on ? "Claim" : "Unclaim", on ? take : giveBack, `${on ? "Claimed" : "Unclaimed"} #${issue.number}`, on ? giveBack : take);
|
|
449
440
|
}}
|
|
450
441
|
// Undo reopens; a comment already posted stays [NXT-11].
|
|
451
442
|
onCloseIssue={(issue, reason, comment) => {
|
|
452
443
|
const target = issueTarget(issue);
|
|
453
444
|
const done = `Closed #${issue.number} as ${reason === "completed" ? "completed" : "not planned"}`;
|
|
454
|
-
|
|
445
|
+
change(issue.key, "Close", () => closeIssue({ key: issue.key, target, reason, comment: comment || undefined }), done, () => reopenIssue({ key: issue.key, target }));
|
|
455
446
|
}}
|
|
456
447
|
/>
|
|
457
448
|
) : null}
|
|
449
|
+
{options ? <SessionOptions spec={options} actions={actions} onClose={() => setOptions(null)} /> : null}
|
|
458
450
|
{placing ? <CodeRepoPicker issueRepo={placing.target.repo} missing={placing.missing} onPick={place} onClose={() => setPlacing(null)} /> : null}
|
|
459
451
|
</ScrollView>
|
|
460
452
|
);
|
|
@@ -480,9 +472,11 @@ function Tab({ icon, label, count, active, onPress }: { icon: IconName; label: s
|
|
|
480
472
|
}
|
|
481
473
|
|
|
482
474
|
interface Actions {
|
|
483
|
-
agents:
|
|
484
|
-
|
|
475
|
+
agents: AgentSummary[];
|
|
476
|
+
startWithOptions: (spec: OptionsSpec) => void;
|
|
477
|
+
busy: ReadonlySet<string>;
|
|
485
478
|
config: AttentionConfig;
|
|
479
|
+
login: string | null;
|
|
486
480
|
fetchContext: FetchContext;
|
|
487
481
|
fetchDetails: FetchDetails;
|
|
488
482
|
defaultBranch: DefaultBranch;
|
|
@@ -505,16 +499,20 @@ function stateMark(item: Item): CardProps["mark"] {
|
|
|
505
499
|
// A card that works collapsed: its main action and β―. Tapping it opens the sheet with everything else [ATT-05, ATT-06].
|
|
506
500
|
const isRed = (chips: Chip[]) => chips.some((chip) => chip.tone === "bad");
|
|
507
501
|
|
|
508
|
-
|
|
502
|
+
// The sheet, Acknowledge, or a split button's menu: for the open sessions, or for starting one of `kind`.
|
|
503
|
+
type Sheet = "item" | "acknowledge" | { anchor?: Anchor; kind?: SessionKind } | null;
|
|
504
|
+
|
|
505
|
+
// A session on an item that has no session action of its own starts with this prompt; it's editable first.
|
|
506
|
+
const fallbackKind = (item: Item): SessionKind => (item.target.kind === "issue" ? "start" : "review");
|
|
509
507
|
|
|
510
508
|
function ItemRow({ item, first, actions }: { item: Item; first: boolean; actions: Actions }) {
|
|
511
|
-
|
|
512
|
-
const
|
|
509
|
+
// An open session leads; without one, the item's own action does [SES-03].
|
|
510
|
+
const sessions = itemSessions(actions.agents, item);
|
|
511
|
+
const chips = sessions[0] ? [...item.chips, agentSignal(sessions[0])] : item.chips;
|
|
513
512
|
const [sheet, setSheet] = useState<Sheet>(null);
|
|
514
513
|
const [confirm, setConfirm] = useState<"merge" | "close" | null>(null);
|
|
515
|
-
const sessionAction = item.actions.find((action) => ACTION_SESSION[action]);
|
|
516
|
-
const sessionKind = sessionAction ? ACTION_SESSION[sessionAction] : undefined;
|
|
517
514
|
const main = item.actions[0];
|
|
515
|
+
const mainKind = main ? ACTION_SESSION[main] : undefined;
|
|
518
516
|
// The full stack is in the sheet; the card shows the PRs that need attention [ATT-04].
|
|
519
517
|
const children = item.children.filter((child) => child.attention || isRed(child.chips));
|
|
520
518
|
const open = () => setSheet("item");
|
|
@@ -527,11 +525,13 @@ function ItemRow({ item, first, actions }: { item: Item; first: boolean; actions
|
|
|
527
525
|
else if (action === "acknowledge") setSheet("acknowledge");
|
|
528
526
|
else actions.act(item, action);
|
|
529
527
|
}
|
|
530
|
-
const
|
|
528
|
+
const onMenu = (kind?: SessionKind) => (anchor: Anchor | undefined) => setSheet({ anchor, kind });
|
|
529
|
+
const handlers: SheetHandlers = { onPerform: perform, onMenu, onClose: () => setSheet(null) };
|
|
531
530
|
// A menu with one action is a wasted tap: show that action instead of β―. The card still opens the sheet [ATT-06].
|
|
532
|
-
const entries = sheetEntries(item,
|
|
531
|
+
const entries = sheetEntries(item, sessions, actions, handlers);
|
|
533
532
|
const only = entries.length === 1 ? entries[0] : undefined;
|
|
534
533
|
const confirmed = (action: "merge" | "close") => (comment: string) => (setConfirm(null), actions.confirm(item, action, comment));
|
|
534
|
+
const sessionMenu = { label: "Session choices", onPress: onMenu() };
|
|
535
535
|
|
|
536
536
|
return (
|
|
537
537
|
<CardRow
|
|
@@ -539,7 +539,7 @@ function ItemRow({ item, first, actions }: { item: Item; first: boolean; actions
|
|
|
539
539
|
mark={stateMark(item)}
|
|
540
540
|
title={item.title}
|
|
541
541
|
meta={{
|
|
542
|
-
place: `${item.repo.
|
|
542
|
+
place: `${repoLabel(item.repo, actions.login)} #${item.number}`,
|
|
543
543
|
when: item.closedAt ? `${item.kind === "pr" ? "merged" : "closed"} ${ago(item.closedAt)} ago` : undefined,
|
|
544
544
|
signals: chips,
|
|
545
545
|
}}
|
|
@@ -552,12 +552,17 @@ function ItemRow({ item, first, actions }: { item: Item; first: boolean; actions
|
|
|
552
552
|
) : null
|
|
553
553
|
}
|
|
554
554
|
onOpen={open}
|
|
555
|
-
busy={actions.busy
|
|
555
|
+
busy={actions.busy.has(item.key)}
|
|
556
556
|
primary={
|
|
557
|
-
|
|
558
|
-
? { label:
|
|
557
|
+
sessions[0]
|
|
558
|
+
? { label: "Open session", icon: "agent", onPress: () => actions.openAgent(sessions[0].id), menu: sessionMenu }
|
|
559
559
|
: main
|
|
560
|
-
? {
|
|
560
|
+
? {
|
|
561
|
+
label: actionLabel(main, item),
|
|
562
|
+
icon: ACTION_ICONS[main],
|
|
563
|
+
onPress: () => perform(main),
|
|
564
|
+
menu: mainKind ? { label: `${actionLabel(main, item)} choices`, onPress: onMenu(mainKind) } : undefined,
|
|
565
|
+
}
|
|
561
566
|
: undefined
|
|
562
567
|
}
|
|
563
568
|
secondary={[
|
|
@@ -583,23 +588,59 @@ function ItemRow({ item, first, actions }: { item: Item; first: boolean; actions
|
|
|
583
588
|
}
|
|
584
589
|
overlay={
|
|
585
590
|
<>
|
|
586
|
-
{sheet === "item" ? <ItemSheet item={item}
|
|
591
|
+
{sheet === "item" ? <ItemSheet item={item} sessions={sessions} actions={actions} {...handlers} /> : null}
|
|
587
592
|
{sheet === "acknowledge" ? <AcknowledgeSheet item={item} onReact={(ids) => (setSheet(null), actions.acknowledge(item, ids))} onClose={() => setSheet(null)} /> : null}
|
|
588
|
-
{sheet && typeof sheet === "object" ?
|
|
593
|
+
{sheet && typeof sheet === "object" ? (
|
|
594
|
+
<MenuSheet title={item.title} anchor={sheet.anchor} groups={menuGroups(item, sessions, sheet.kind, actions, perform, () => setSheet(null))} onClose={() => setSheet(null)} />
|
|
595
|
+
) : null}
|
|
589
596
|
</>
|
|
590
597
|
}
|
|
591
598
|
/>
|
|
592
599
|
);
|
|
593
600
|
}
|
|
594
601
|
|
|
602
|
+
// A split button's menu. With sessions open: each of them, then starting a new one. Without: the action with options [SES-02, SES-03].
|
|
603
|
+
function menuGroups(
|
|
604
|
+
item: Item,
|
|
605
|
+
sessions: AgentSummary[],
|
|
606
|
+
kind: SessionKind | undefined,
|
|
607
|
+
actions: Actions,
|
|
608
|
+
perform: (action: ActionId) => void,
|
|
609
|
+
close: () => void,
|
|
610
|
+
): MenuGroup[] {
|
|
611
|
+
const withOptions = (action: ActionId | undefined, sessionKind: SessionKind): SheetEntry => {
|
|
612
|
+
const label = action ? actionLabel(action, item) : "Start session";
|
|
613
|
+
return {
|
|
614
|
+
key: `${action ?? "start"}-options`,
|
|
615
|
+
icon: "agent",
|
|
616
|
+
label: `${label} with optionsβ¦`,
|
|
617
|
+
detail: "Choose the workspace, agent profile and prompt first",
|
|
618
|
+
onPress: () => (close(), actions.startWithOptions({ itemKey: item.key, title: `${label}: ${item.title}`, kind: sessionKind, target: item.target })),
|
|
619
|
+
};
|
|
620
|
+
};
|
|
621
|
+
const sessionActions = item.actions.filter((action) => ACTION_SESSION[action]);
|
|
622
|
+
if (sessions.length === 0) {
|
|
623
|
+
const action = sessionActions.find((candidate) => ACTION_SESSION[candidate] === kind);
|
|
624
|
+
return [{ entries: [withOptions(action, kind ?? fallbackKind(item))] }];
|
|
625
|
+
}
|
|
626
|
+
const start = sessionActions.flatMap((action): SheetEntry[] => [
|
|
627
|
+
{ key: action, icon: "agent", label: actionLabel(action, item), detail: actionDetail(action as Exclude<ActionId, "rerun">, item), onPress: () => perform(action) },
|
|
628
|
+
withOptions(action, ACTION_SESSION[action]!),
|
|
629
|
+
]);
|
|
630
|
+
return [
|
|
631
|
+
sessionsGroup(sessions, (agentId) => (close(), actions.openAgent(agentId))),
|
|
632
|
+
{ title: "Start a new one", entries: start.length ? start : [withOptions(undefined, fallbackKind(item))] },
|
|
633
|
+
];
|
|
634
|
+
}
|
|
635
|
+
|
|
595
636
|
interface SheetHandlers {
|
|
596
637
|
onPerform: (action: ActionId) => void;
|
|
597
|
-
|
|
638
|
+
onMenu: (kind?: SessionKind) => (anchor: Anchor | undefined) => void;
|
|
598
639
|
onClose: () => void;
|
|
599
640
|
}
|
|
600
641
|
|
|
601
642
|
// What the card already knows on top, then every action, then what's fetched when it opens, so nothing jumps as it loads [ATT-06, GH-01].
|
|
602
|
-
function ItemSheet({ item,
|
|
643
|
+
function ItemSheet({ item, sessions, actions, ...handlers }: { item: Item; sessions: AgentSummary[]; actions: Actions } & SheetHandlers) {
|
|
603
644
|
const checks = item.actions.includes("rerun");
|
|
604
645
|
const details = useQuery({
|
|
605
646
|
queryKey: ["attention-span", "details", item.key, checks],
|
|
@@ -621,7 +662,7 @@ function ItemSheet({ item, agent, actions, ...handlers }: { item: Item; agent?:
|
|
|
621
662
|
{item.children.length > 0 ? <StackLine rows={item.children} merged={!!item.closedAt} links /> : null}
|
|
622
663
|
</>
|
|
623
664
|
}
|
|
624
|
-
entries={sheetEntries(item,
|
|
665
|
+
entries={sheetEntries(item, sessions, actions, handlers, details)}
|
|
625
666
|
bottom={<DetailLines details={extra} loading={details.isLoading} error={details.error} linkedLabel={item.kind === "issue" ? "PR" : "Closes"} />}
|
|
626
667
|
/>
|
|
627
668
|
);
|
|
@@ -630,26 +671,31 @@ function ItemSheet({ item, agent, actions, ...handlers }: { item: Item; agent?:
|
|
|
630
671
|
// Everything an item's sheet offers, each saying what it will do [ATT-06]. Rerun's line needs the fetched checks.
|
|
631
672
|
function sheetEntries(
|
|
632
673
|
item: Item,
|
|
633
|
-
|
|
674
|
+
sessions: AgentSummary[],
|
|
634
675
|
actions: Actions,
|
|
635
|
-
{ onPerform,
|
|
676
|
+
{ onPerform, onMenu, onClose }: SheetHandlers,
|
|
636
677
|
details?: { data?: { failing: FailingChecks[] }; isLoading: boolean },
|
|
637
678
|
): SheetEntry[] {
|
|
638
679
|
const inDoing = !item.section.startsWith("wait_") && item.section !== "done" && item.section !== "reviewed";
|
|
639
680
|
const close = (then: () => void) => () => (onClose(), then());
|
|
640
681
|
|
|
641
|
-
|
|
642
|
-
|
|
682
|
+
// An open session first; starting another is in its menu [SES-03].
|
|
683
|
+
const entries: SheetEntry[] = sessions.length
|
|
684
|
+
? [openSessionEntry(sessions, (agentId) => close(() => actions.openAgent(agentId))(), { label: "Session choices", onPress: onMenu() })]
|
|
685
|
+
: [];
|
|
643
686
|
for (const action of item.actions) {
|
|
644
687
|
const kind = ACTION_SESSION[action];
|
|
645
688
|
const label = actionLabel(action, item);
|
|
646
|
-
if (kind &&
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
689
|
+
if (kind && sessions.length) continue;
|
|
690
|
+
else if (kind) {
|
|
691
|
+
entries.push({
|
|
692
|
+
key: action,
|
|
693
|
+
icon: "agent",
|
|
694
|
+
label,
|
|
695
|
+
detail: actionDetail(action as Exclude<ActionId, "rerun">, item),
|
|
696
|
+
onPress: () => onPerform(action),
|
|
697
|
+
menu: { label: `${label} choices`, onPress: onMenu(kind) },
|
|
698
|
+
});
|
|
653
699
|
} else if (action === "rerun") {
|
|
654
700
|
const { detail, runIds } = rerunEntry(details?.data?.failing, details?.isLoading ?? true);
|
|
655
701
|
entries.push({ key: action, icon: ACTION_ICONS.rerun, label, detail, disabled: runIds.length === 0, onPress: close(() => actions.rerun(item, runIds)) });
|
|
@@ -680,7 +726,10 @@ function AcknowledgeSheet({ item, onReact, onClose }: { item: Item; onReact: (id
|
|
|
680
726
|
<Modal title={`Acknowledge: ${item.title}`} open onOpenChange={(open) => (open ? null : onClose())}>
|
|
681
727
|
<Modal.Content>
|
|
682
728
|
<KeepStyles styles={styles}>
|
|
683
|
-
<
|
|
729
|
+
<View style={styles.row}>
|
|
730
|
+
<TablerIcon name="thumbUp" size={14} />
|
|
731
|
+
<Text style={[styles.muted, { flexShrink: 1 }]}>Tells them you've seen it, and clears it from your list.</Text>
|
|
732
|
+
</View>
|
|
684
733
|
{comments.map((c) => (
|
|
685
734
|
<Pressable
|
|
686
735
|
key={c.id}
|
|
@@ -701,7 +750,9 @@ function AcknowledgeSheet({ item, onReact, onClose }: { item: Item; onReact: (id
|
|
|
701
750
|
))}
|
|
702
751
|
<View style={styles.wrap}>
|
|
703
752
|
<Button
|
|
704
|
-
label={
|
|
753
|
+
label={`${picked.size} comment${picked.size === 1 ? "" : "s"}`}
|
|
754
|
+
icon="thumbUp"
|
|
755
|
+
accessibilityLabel={`Acknowledge ${picked.size} comment${picked.size === 1 ? "" : "s"}`}
|
|
705
756
|
variant="solid"
|
|
706
757
|
disabled={picked.size === 0}
|
|
707
758
|
onPress={() => onReact(comments.filter((c) => picked.has(c.id)).map((c) => c.id))}
|
|
@@ -870,13 +921,13 @@ function StackRow({ url, number, link, children }: { url: string; number: number
|
|
|
870
921
|
}
|
|
871
922
|
|
|
872
923
|
// Session options in a modal: a bottom sheet on phones [SES-02].
|
|
873
|
-
function SessionOptions({
|
|
924
|
+
function SessionOptions({ spec, actions, onClose }: { spec: OptionsSpec; actions: Actions; onClose: () => void }) {
|
|
874
925
|
const styles = useStyles();
|
|
875
926
|
const paseo = usePaseo();
|
|
876
927
|
const toast = useToast();
|
|
877
|
-
const { target } =
|
|
928
|
+
const { itemKey, kind, target } = spec;
|
|
878
929
|
const options = useQuery({
|
|
879
|
-
queryKey: ["attention-span", "options",
|
|
930
|
+
queryKey: ["attention-span", "options", itemKey, kind],
|
|
880
931
|
queryFn: async () => {
|
|
881
932
|
const [{ context }, profiles, checkout, defaults] = await Promise.all([
|
|
882
933
|
actions.fetchContext({ kind, target }),
|
|
@@ -900,7 +951,8 @@ function SessionOptions({ item, kind, actions, onClose }: { item: Item; kind: Se
|
|
|
900
951
|
if (!data) return;
|
|
901
952
|
setStarting(true);
|
|
902
953
|
try {
|
|
903
|
-
await
|
|
954
|
+
await spec.before?.();
|
|
955
|
+
await actions.started(await startSession(paseo, { itemKey, kind, target, prompt: prompt ?? data.prompt, config: actions.config, checkout: data.checkout, profileId, workspaceId }));
|
|
904
956
|
onClose();
|
|
905
957
|
} catch (error) {
|
|
906
958
|
toast.error(`Starting the session failed: ${(error as Error).message}`);
|
|
@@ -910,10 +962,10 @@ function SessionOptions({ item, kind, actions, onClose }: { item: Item; kind: Se
|
|
|
910
962
|
}
|
|
911
963
|
|
|
912
964
|
return (
|
|
913
|
-
<Modal title={
|
|
965
|
+
<Modal title={spec.title} open onOpenChange={(open) => (open ? null : onClose())}>
|
|
914
966
|
<Modal.Content>
|
|
915
967
|
<KeepStyles styles={styles}>
|
|
916
|
-
{options.isLoading ? <
|
|
968
|
+
{options.isLoading ? <Loading text="Loading contextβ¦" /> : null}
|
|
917
969
|
{!options.isLoading && !data ? <Text style={styles.danger}>{(options.error as Error)?.message ?? "No options"}</Text> : null}
|
|
918
970
|
{data && !data.checkout.project ? <Text style={styles.danger}>{noProjectMessage(data.checkout, target)}</Text> : null}
|
|
919
971
|
{data?.checkout.project ? (
|
|
@@ -957,7 +1009,7 @@ function CodeRepoPicker({ issueRepo, missing, onPick, onClose }: { issueRepo: st
|
|
|
957
1009
|
<KeepStyles styles={styles}>
|
|
958
1010
|
<View style={{ gap: 10 }}>
|
|
959
1011
|
<Text style={styles.text}>No Paseo project has {missing} as its GitHub remote. Pick the project that holds the code for issues in {issueRepo}.</Text>
|
|
960
|
-
{projects.isLoading ? <
|
|
1012
|
+
{projects.isLoading ? <Loading text="Loading projectsβ¦" /> : null}
|
|
961
1013
|
{projects.data?.length === 0 ? <Text style={styles.danger}>No Paseo project has a GitHub remote. Add the code repository as a project first.</Text> : null}
|
|
962
1014
|
<View style={styles.wrap}>
|
|
963
1015
|
{projects.data?.map((project) => (
|
package/client/card.tsx
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { TextInput } from "@getpaseo/plugin/client/ui";
|
|
2
2
|
import { type ReactNode, useState } from "react";
|
|
3
|
-
import { Pressable, Text, View } from "react-native";
|
|
3
|
+
import { ActivityIndicator, Pressable, Text, View } from "react-native";
|
|
4
4
|
import type { Chip } from "../shared/attention";
|
|
5
5
|
import type { IconName } from "./icons";
|
|
6
|
-
import { Button, Meta, TablerIcon, toneColor, useStyles } from "./ui";
|
|
6
|
+
import { type Anchor, Button, Meta, SplitButton, TablerIcon, toneColor, useStyles } from "./ui";
|
|
7
7
|
|
|
8
8
|
// Every card in every list has this anatomy; tabs fill it in with data and slots, not layout [ATT-05].
|
|
9
9
|
//
|
|
@@ -23,6 +23,8 @@ export interface CardAction {
|
|
|
23
23
|
onPress: () => void;
|
|
24
24
|
// Defaults to the label.
|
|
25
25
|
accessibilityLabel?: string;
|
|
26
|
+
// βΎ beside it, for the choices around it: a split button [SES-03].
|
|
27
|
+
menu?: { label: string; onPress: (anchor: Anchor | undefined) => void };
|
|
26
28
|
}
|
|
27
29
|
|
|
28
30
|
export interface ConfirmSpec {
|
|
@@ -63,10 +65,20 @@ export function CardRow({ first, mark, title, meta, accessibilityLabel, onOpen,
|
|
|
63
65
|
const styles = useStyles();
|
|
64
66
|
const actions = (
|
|
65
67
|
<View style={styles.wrap}>
|
|
66
|
-
{
|
|
67
|
-
<
|
|
68
|
+
{primary?.menu ? (
|
|
69
|
+
<SplitButton
|
|
70
|
+
label={primary.label}
|
|
71
|
+
accessibilityLabel={primary.accessibilityLabel}
|
|
72
|
+
icon={primary.icon}
|
|
73
|
+
busy={busy}
|
|
74
|
+
onPress={primary.onPress}
|
|
75
|
+
menuLabel={primary.menu.label}
|
|
76
|
+
onMenu={primary.menu.onPress}
|
|
77
|
+
/>
|
|
68
78
|
) : primary ? (
|
|
69
|
-
<Button label={primary.label} accessibilityLabel={primary.accessibilityLabel} icon={primary.icon} variant="calm" onPress={primary.onPress} />
|
|
79
|
+
<Button label={primary.label} accessibilityLabel={primary.accessibilityLabel} icon={primary.icon} variant="calm" busy={busy} onPress={primary.onPress} />
|
|
80
|
+
) : busy ? (
|
|
81
|
+
<ActivityIndicator size="small" color={styles.c.foregroundMuted} />
|
|
70
82
|
) : null}
|
|
71
83
|
{secondary.map((action) => (
|
|
72
84
|
<Button key={action.accessibilityLabel ?? action.label} icon={action.icon} variant="ghost" accessibilityLabel={action.accessibilityLabel ?? action.label} onPress={action.onPress} />
|
package/client/data.ts
CHANGED
|
@@ -13,7 +13,8 @@ export function useAttention() {
|
|
|
13
13
|
const query = useQuery({
|
|
14
14
|
queryKey: VIEW_QUERY_KEY,
|
|
15
15
|
queryFn: () => fetchAttention({}),
|
|
16
|
-
|
|
16
|
+
// Sooner while a change waits on GitHub, so the list shows GitHub's own word on it soon after [FRESH-02].
|
|
17
|
+
refetchInterval: (query) => (query.state.data?.pending ? 10_000 : 60_000),
|
|
17
18
|
});
|
|
18
19
|
const setView = useCallback((view: AttentionView) => queryClient.setQueryData(VIEW_QUERY_KEY, view), [queryClient]);
|
|
19
20
|
// β³ fetches only the feed behind the tab I'm on.
|
package/client/icons.ts
CHANGED
|
@@ -40,6 +40,8 @@ export const ICONS = {
|
|
|
40
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>" },
|
|
41
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>" },
|
|
42
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>" },
|
|
43
|
+
chevronDown: { 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=\"m6 9l6 6l6-6\"/></svg>" },
|
|
44
|
+
check: { 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=\"m5 12l5 5L20 7\"/></svg>" },
|
|
43
45
|
// Tabler message-ai: marks actions that start or continue an agent session.
|
|
44
46
|
agent: { 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=\"M8 9h8m-8 4h3.5m-1.506 6.804L8 21v-3H6a3 3 0 0 1-3-3V7a3 3 0 0 1 3-3h12a3 3 0 0 1 3 3v4\"/><path d=\"M14 21v-4a2 2 0 1 1 4 0v4m-4-2h4m3-4v6\"/></g></svg>" },
|
|
45
47
|
} as const;
|