@andrioid/paseo-attention-span 0.5.0 → 0.6.1
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 +7 -1
- package/client/attention-screen.tsx +74 -1176
- package/client/coverage-settings.tsx +5 -4
- package/client/data.ts +4 -2
- package/client/feedback.tsx +21 -25
- package/client/history.tsx +17 -50
- package/client/item-actions.ts +363 -0
- package/client/item-row.tsx +450 -0
- package/client/new-issue.tsx +244 -0
- package/client/next-up.tsx +36 -183
- package/client/pickers.tsx +237 -0
- package/client/session-menu.ts +3 -11
- package/client/sessions.ts +58 -57
- package/client/setup.tsx +2 -1
- package/client/sheet.tsx +92 -15
- package/client/still.tsx +70 -27
- package/client/ui.tsx +23 -14
- package/client/wrap-up.tsx +151 -85
- package/docs/architecture.md +22 -11
- package/docs/screenshots/desktop-dark-doing-acknowledge.png +0 -0
- package/docs/screenshots/desktop-dark-doing-clear.png +0 -0
- package/docs/screenshots/desktop-dark-doing-issue-sheet.png +0 -0
- package/docs/screenshots/desktop-dark-doing-reviewers.png +0 -0
- package/docs/screenshots/desktop-dark-doing-sheet.png +0 -0
- package/docs/screenshots/desktop-dark-doing-wrap-dirty.png +0 -0
- package/docs/screenshots/desktop-dark-doing-wrap-multi.png +0 -0
- package/docs/screenshots/desktop-dark-doing-wrap.png +0 -0
- package/docs/screenshots/desktop-dark-doing.png +0 -0
- package/docs/screenshots/desktop-dark-next-up-setup.png +0 -0
- package/docs/screenshots/desktop-dark-next-up.png +0 -0
- package/docs/screenshots/desktop-dark-settings.png +0 -0
- package/docs/screenshots/phone-dark-doing.png +0 -0
- package/docs/screenshots/phone-light-next-up-filtered.png +0 -0
- package/index.client.tsx +19 -0
- package/index.server.ts +43 -26
- package/package.json +3 -1
- package/requirements.yaml +11 -3
- package/server/actions.ts +2 -1
- package/server/archive.ts +146 -67
- package/server/archived.ts +12 -16
- package/server/changes.ts +34 -54
- package/server/classify.ts +142 -136
- package/server/feedback.ts +2 -6
- package/server/fetch.ts +262 -0
- package/server/fixture.ts +91 -7
- package/server/github-types.ts +3 -1
- package/server/markdown.ts +3 -1
- package/server/port.ts +46 -0
- package/server/queries.ts +33 -23
- package/server/service.ts +155 -272
- package/server/setup.ts +15 -14
- package/server/store.ts +94 -80
- package/server/update.ts +34 -13
- package/server/view.ts +16 -15
- package/shared/archive.ts +116 -13
- package/shared/attention.ts +50 -18
- package/shared/changes.ts +2 -1
- package/shared/config.ts +2 -6
- package/shared/drafting.ts +17 -0
- package/shared/feedback.ts +6 -5
- package/shared/format.ts +2 -1
- package/shared/history-report.ts +2 -1
- package/shared/item-sessions.ts +76 -0
- package/shared/item-view.ts +223 -0
- package/shared/linked-sessions.ts +59 -8
- package/shared/names.ts +17 -0
- package/shared/new-issue.ts +129 -0
- package/shared/next-up-filter.ts +137 -0
- package/shared/paging.ts +16 -0
- package/shared/rpc.ts +23 -10
- package/shared/setup.ts +3 -1
- package/shared/still.ts +28 -7
- package/shared/wrap-up.ts +20 -23
|
@@ -1,178 +1,32 @@
|
|
|
1
|
-
import type
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { type ReactNode, useState } from "react";
|
|
1
|
+
import { type PluginScreenProps, useRpc } from "@getpaseo/plugin/client";
|
|
2
|
+
import { useToast } from "@getpaseo/plugin/client/ui";
|
|
3
|
+
import { useQuery } from "@tanstack/react-query";
|
|
4
|
+
import { useEffect, useState } from "react";
|
|
6
5
|
import { Pressable, ScrollView, Text, View } from "react-native";
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import { failingList, groupLabel, rerunHistory, summarizeRerun } from "../shared/checks";
|
|
10
|
-
import { changeText } from "../shared/changes";
|
|
6
|
+
import { liftActive, type Section, type SectionId, TAB_FEED, type TabId, type WaitingGroup } from "../shared/attention";
|
|
7
|
+
import { nextUpSources } from "../shared/config";
|
|
11
8
|
import { ago, linkList } from "../shared/format";
|
|
12
|
-
import { isClear } from "../shared/still";
|
|
13
|
-
import { ACTION_SESSION, renderPrompt } from "../shared/prompts";
|
|
9
|
+
import { historyClear, isClear, nextUpClear, waitingClear } from "../shared/still";
|
|
14
10
|
import * as rpc from "../shared/rpc";
|
|
15
11
|
import { type FeedbackKind, themeName } from "../shared/feedback";
|
|
16
12
|
import { blocks } from "../shared/setup";
|
|
13
|
+
import { cleanSingle, unreadChanges, wrapItems } from "../shared/wrap-up";
|
|
14
|
+
import { nudgeLead, tabCounts } from "../shared/item-view";
|
|
17
15
|
import { useAttention } from "./data";
|
|
18
|
-
import { CardList, CardRow } from "./card";
|
|
19
16
|
import type { IconName } from "./icons";
|
|
20
|
-
import {
|
|
17
|
+
import { type Actions, useItemActions } from "./item-actions";
|
|
18
|
+
import { Card } from "./item-row";
|
|
21
19
|
import { NextUpList } from "./next-up";
|
|
20
|
+
import { CodeRepoPicker, SessionOptions } from "./pickers";
|
|
22
21
|
import { Still } from "./still";
|
|
23
|
-
import { agentSignal, sessionEntry, startAnotherEntry } from "./session-menu";
|
|
24
|
-
import { ActionSheet, DETAILS_STALE_MS, DetailLines, type DetailsQuery, detailsKey, FadeIn, githubEntry, Modal, type SheetEntry, useArrived, usePrefetchOnRest } from "./sheet";
|
|
25
22
|
import { FeedbackAsk, FeedbackLine, type FeedbackScreen, FeedbackSheet } from "./feedback";
|
|
26
|
-
import {
|
|
27
|
-
import {
|
|
28
|
-
import { cleanSingle, doingCount, unreadChanges, wrapItems } from "../shared/wrap-up";
|
|
29
|
-
import { type ArchiveOutcome, archiveTarget } from "../shared/archive";
|
|
23
|
+
import { NewIssueSheet, type NewIssueRequest, takeNewIssueRequest } from "./new-issue";
|
|
24
|
+
import { useItemAgents } from "./sessions";
|
|
30
25
|
import { History } from "./history";
|
|
31
|
-
import { stateMark } from "./mark";
|
|
32
26
|
import { WrapUp } from "./wrap-up";
|
|
33
27
|
import { SetupChecklist } from "./setup";
|
|
34
28
|
import { UpdateNotice } from "./update";
|
|
35
|
-
import { Avatar, Button,
|
|
36
|
-
|
|
37
|
-
// The agent icon marks every action that starts an agent session; the rest act on GitHub right away [ATT-13].
|
|
38
|
-
const ACTION_ICONS: Record<ActionId, IconName> = {
|
|
39
|
-
reply: "replyArrow",
|
|
40
|
-
acknowledge: "thumbUp",
|
|
41
|
-
review: "agent",
|
|
42
|
-
fix: "agent",
|
|
43
|
-
rerun: "reload",
|
|
44
|
-
address: "agent",
|
|
45
|
-
update: "update",
|
|
46
|
-
rebase: "agent",
|
|
47
|
-
refresh: "agent",
|
|
48
|
-
ready: "pr",
|
|
49
|
-
request_review: "claim",
|
|
50
|
-
automerge: "clock",
|
|
51
|
-
merge: "merge",
|
|
52
|
-
close: "close",
|
|
53
|
-
start: "agent",
|
|
54
|
-
got_it: "check",
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
function actionLabel(action: ActionId, item: Item): string {
|
|
58
|
-
// Review takes the whole stack; Rebase, my PRs in it [ATT-04].
|
|
59
|
-
const stacked = ownStack(item.target).length > 1;
|
|
60
|
-
return {
|
|
61
|
-
reply: "Reply ↗",
|
|
62
|
-
acknowledge: "Acknowledge",
|
|
63
|
-
review: (item.target.stack?.length ?? 0) > 1 ? "Review stack" : "Review",
|
|
64
|
-
fix: "Fix CI",
|
|
65
|
-
rerun: "Rerun failed jobs",
|
|
66
|
-
address: "Address comments",
|
|
67
|
-
update: "Update branch",
|
|
68
|
-
rebase: stacked ? "Rebase stack" : "Rebase",
|
|
69
|
-
refresh: "Refresh draft",
|
|
70
|
-
ready: "Ready for review",
|
|
71
|
-
request_review: "Request review",
|
|
72
|
-
automerge: "Auto-merge",
|
|
73
|
-
merge: "Merge",
|
|
74
|
-
close: "Close draft",
|
|
75
|
-
start: "Start",
|
|
76
|
-
got_it: "Got it",
|
|
77
|
-
}[action];
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
// What an action will do, in the sheet, so pressing it makes sense [ATT-06]. Rerun's comes from the fetched checks.
|
|
81
|
-
function actionDetail(action: Exclude<ActionId, "rerun">, item: Item): string {
|
|
82
|
-
const { target } = item;
|
|
83
|
-
const pr = `#${target.number}`;
|
|
84
|
-
const base = target.baseRefName ?? target.defaultBranch ?? "its base";
|
|
85
|
-
const stacked = ownStack(target).length > 1;
|
|
86
|
-
const asking = (target.stack ?? []).filter((p) => p.review);
|
|
87
|
-
const comments = item.person?.comments ?? [];
|
|
88
|
-
return {
|
|
89
|
-
reply: item.person ? `Opens ${item.person.login}'s comment on GitHub` : "Opens it on GitHub",
|
|
90
|
-
acknowledge:
|
|
91
|
-
comments.length === 1 ? `Reacts to ${comments[0].author}'s comment, which clears it` : `Pick which of the ${comments.length} waiting comments to react to`,
|
|
92
|
-
review:
|
|
93
|
-
(target.stack?.length ?? 0) > 1
|
|
94
|
-
? `An agent reviews ${asking.map((p) => `#${p.number}`).join(", ") || "the stack"} in a checkout of the stack's top and reports back. Nothing is posted`
|
|
95
|
-
: "An agent reviews the PR in a checkout and reports back. Nothing is posted",
|
|
96
|
-
fix: "An agent reads the failing logs and commits a fix, without pushing",
|
|
97
|
-
address: "An agent works through the unresolved comments and applies the trivial ones, without pushing",
|
|
98
|
-
update: `GitHub rebases ${pr} onto ${base}`,
|
|
99
|
-
rebase: `An agent rebases ${stacked ? "the stack" : pr} onto ${base}. It pushes only if there were no conflicts`,
|
|
100
|
-
refresh: `An agent rebases the draft onto ${base} and says what it still needs`,
|
|
101
|
-
ready: `Takes ${pr} out of draft, then asks who should review it`,
|
|
102
|
-
request_review: `Pick people or teams to review ${pr}`,
|
|
103
|
-
automerge: `GitHub merges ${pr} into ${base} (${target.mergeMethod}) once checks pass`,
|
|
104
|
-
merge: `Merges ${pr} into ${base} (${target.mergeMethod}) now`,
|
|
105
|
-
close: `Closes ${pr}. A comment is posted only if you write one`,
|
|
106
|
-
start: "An agent reads the issue and proposes a plan",
|
|
107
|
-
got_it: "Clears this note. Nothing changes on GitHub",
|
|
108
|
-
}[action];
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
// Rerun failed jobs as a sheet line: which checks failed and whether they were rerun before, flaky or real? [PRS-09]
|
|
112
|
-
// It can be pressed before the checks are in: the sheet closes, and the rerun goes ahead once they are.
|
|
113
|
-
function rerunEntry(label: string, details: SheetDetails | undefined, rerun: (runIds?: number[]) => void): SheetEntry {
|
|
114
|
-
const base = { key: "rerun", icon: ACTION_ICONS.rerun, label, live: true };
|
|
115
|
-
if (!details || details.isLoading) return { ...base, detail: "Checking which checks failed…", onPress: () => rerun() };
|
|
116
|
-
const failing = details.data?.failing;
|
|
117
|
-
if (!failing) return { ...base, detail: "Couldn't find the failing checks", disabled: true, onPress: () => {} };
|
|
118
|
-
const summary = summarizeRerun(failing);
|
|
119
|
-
if (summary.failed === 0) return { ...base, detail: "No failed checks on the latest commit", disabled: true, onPress: () => {} };
|
|
120
|
-
if (summary.runIds.length === 0)
|
|
121
|
-
return { ...base, detail: `${summary.failed} failed, none in GitHub Actions, so none can be rerun here`, hint: failingList(failing), disabled: true, onPress: () => {} };
|
|
122
|
-
return { ...base, detailNode: <RerunDetail failing={failing} arrived={!!details.arrived} />, hint: failingList(failing), onPress: () => rerun(summary.runIds) };
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
// What an item's sheet has fetched, as its lines need it; `arrived` once it came in while the sheet was open.
|
|
126
|
-
interface SheetDetails {
|
|
127
|
-
data?: { failing: FailingChecks[] };
|
|
128
|
-
isLoading: boolean;
|
|
129
|
-
arrived?: boolean;
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
// "7 failed · lint, e2e ×3, unit ×2 · ↻ rerun once": the count and names quiet, as the card's red already says CI failed; checks
|
|
133
|
-
// that can't rerun dimmer; the history amber once rerun, a hint it may not be flaky. One line on desktop, where the names give way
|
|
134
|
-
// and the hint has them all; two on phones, which can't point at a hint [PRS-09].
|
|
135
|
-
function RerunDetail({ failing, arrived }: { failing: FailingChecks[]; arrived: boolean }) {
|
|
136
|
-
const styles = useStyles();
|
|
137
|
-
const summary = summarizeRerun(failing);
|
|
138
|
-
const strong = useStrongText();
|
|
139
|
-
// Dimmer than the quiet text, on the line's own background, so it reads in any theme.
|
|
140
|
-
const dimmer = { color: mix(styles.c.foregroundMuted, styles.c.surface2, 0.55) };
|
|
141
|
-
const stack = summary.prs.length > 1;
|
|
142
|
-
const names = summary.prs.map(({ pr, groups }, index) => (
|
|
143
|
-
<Text key={pr}>
|
|
144
|
-
{index > 0 ? " · " : null}
|
|
145
|
-
{stack ? <Text style={strong}>#{pr} </Text> : null}
|
|
146
|
-
{groups.map((group, at) => (
|
|
147
|
-
<Text key={`${group.name}-${group.rerunnable}`} style={group.rerunnable ? null : dimmer}>
|
|
148
|
-
{at > 0 ? ", " : null}
|
|
149
|
-
{groupLabel(group)}
|
|
150
|
-
</Text>
|
|
151
|
-
))}
|
|
152
|
-
</Text>
|
|
153
|
-
));
|
|
154
|
-
const history = (
|
|
155
|
-
<Text style={summary.reruns ? { color: styles.c.statusWarning, fontWeight: "500" } : null}>{summary.reruns ? `↻ ${rerunHistory(summary.reruns)}` : rerunHistory(0)}</Text>
|
|
156
|
-
);
|
|
157
|
-
const line = [styles.muted, { lineHeight: LINE_HEIGHT }];
|
|
158
|
-
return (
|
|
159
|
-
<FadeIn active={arrived}>
|
|
160
|
-
{styles.compact ? (
|
|
161
|
-
<Text style={line} numberOfLines={2}>
|
|
162
|
-
{summary.failed} failed · {names} · {history}
|
|
163
|
-
</Text>
|
|
164
|
-
) : (
|
|
165
|
-
<View style={{ flexDirection: "row", minWidth: 0 }}>
|
|
166
|
-
<Text style={line}>{summary.failed} failed · </Text>
|
|
167
|
-
<Text style={[line, { flexShrink: 1 }]} numberOfLines={1}>
|
|
168
|
-
{names}
|
|
169
|
-
</Text>
|
|
170
|
-
<Text style={line}> · {history}</Text>
|
|
171
|
-
</View>
|
|
172
|
-
)}
|
|
173
|
-
</FadeIn>
|
|
174
|
-
);
|
|
175
|
-
}
|
|
29
|
+
import { Avatar, Button, Loading, SectionHeader, SpinningIcon, StylesProvider, TablerIcon, tint, useCopy, useStyles } from "./ui";
|
|
176
30
|
|
|
177
31
|
const SECTION_ICONS: Record<SectionId, IconName> = {
|
|
178
32
|
reply: "reply",
|
|
@@ -202,164 +56,44 @@ const TABS: { id: TabId; label: string; icon: IconName }[] = [
|
|
|
202
56
|
{ id: "next", label: "Next up", icon: "nextUp" },
|
|
203
57
|
];
|
|
204
58
|
|
|
205
|
-
type FetchContext = (input: RpcInput<typeof rpc.sessionContext>) => Promise<RpcOutput<typeof rpc.sessionContext>>;
|
|
206
|
-
export type FetchDetails = (input: RpcInput<typeof rpc.itemDetails>) => Promise<RpcOutput<typeof rpc.itemDetails>>;
|
|
207
|
-
type DefaultBranch = (repo: string) => Promise<string | null>;
|
|
208
|
-
type FetchReviewers = (input: RpcInput<typeof rpc.reviewerChoices>) => Promise<RpcOutput<typeof rpc.reviewerChoices>>;
|
|
209
|
-
|
|
210
|
-
// A start held back until I say where the issue's code lives [SES-07].
|
|
211
|
-
interface Placing {
|
|
212
|
-
itemKey: string;
|
|
213
|
-
kind: SessionKind;
|
|
214
|
-
target: Target;
|
|
215
|
-
missing: string;
|
|
216
|
-
before?: () => Promise<unknown>;
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
// Session options, before it starts [SES-02].
|
|
220
|
-
export interface OptionsSpec {
|
|
221
|
-
itemKey: string;
|
|
222
|
-
title: string;
|
|
223
|
-
kind: SessionKind;
|
|
224
|
-
target: Target;
|
|
225
|
-
// Claims an issue first [NXT-05].
|
|
226
|
-
before?: () => Promise<unknown>;
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
// Something I just did, offered for undo until the tab changes [ATT-08, ATT-14].
|
|
230
|
-
interface Undoable {
|
|
231
|
-
id: number;
|
|
232
|
-
text: string;
|
|
233
|
-
dismissal?: boolean;
|
|
234
|
-
undo: () => Promise<unknown>;
|
|
235
|
-
}
|
|
236
|
-
|
|
237
59
|
// `openSettings` opens the orgs and repos settings [SRC-02].
|
|
238
|
-
export function AttentionScreen({ theme, layout, navigation, openSettings }: PluginScreenProps & { openSettings?: () => void }) {
|
|
60
|
+
export function AttentionScreen({ theme, layout, navigation, params, openSettings }: PluginScreenProps & { openSettings?: () => void }) {
|
|
239
61
|
return (
|
|
240
62
|
<StylesProvider theme={theme} compact={layout.compact}>
|
|
241
|
-
<AttentionList navigation={navigation} openSettings={openSettings} device={{ device: layout.compact ? "phone" : "desktop", platform: layout.platform, theme: themeName(theme.colors.surface0) }} />
|
|
63
|
+
<AttentionList navigation={navigation} params={params} openSettings={openSettings} device={{ device: layout.compact ? "phone" : "desktop", platform: layout.platform, theme: themeName(theme.colors.surface0) }} />
|
|
242
64
|
</StylesProvider>
|
|
243
65
|
);
|
|
244
66
|
}
|
|
245
67
|
|
|
246
68
|
function AttentionList({
|
|
247
69
|
navigation,
|
|
70
|
+
params,
|
|
248
71
|
openSettings,
|
|
249
72
|
device,
|
|
250
|
-
}: Pick<PluginScreenProps, "navigation"> & { openSettings?: () => void; device: Omit<FeedbackScreen, "tab" | "refreshError"> }) {
|
|
73
|
+
}: Pick<PluginScreenProps, "navigation" | "params"> & { openSettings?: () => void; device: Omit<FeedbackScreen, "tab" | "refreshError"> }) {
|
|
251
74
|
const styles = useStyles();
|
|
252
|
-
const paseo = usePaseo();
|
|
253
75
|
const toast = useToast();
|
|
254
|
-
const queryClient = useQueryClient();
|
|
255
76
|
const attention = useAttention();
|
|
256
77
|
const agents = useItemAgents();
|
|
257
|
-
const
|
|
258
|
-
const dismiss = useRpc(rpc.dismissItem);
|
|
259
|
-
const undismiss = useRpc(rpc.undismissItem);
|
|
260
|
-
const restore = useRpc(rpc.restoreDismissed);
|
|
261
|
-
const gotIt = useRpc(rpc.gotIt);
|
|
262
|
-
const saveHistoryFilter = useRpc(rpc.setHistoryFilter);
|
|
263
|
-
const archiveSessions = useRpc(rpc.archiveSessions);
|
|
264
|
-
const saveScopes = useRpc(rpc.setScopes);
|
|
265
|
-
const saveSources = useRpc(rpc.setSources);
|
|
266
|
-
const saveProjects = useRpc(rpc.setProjectFilter);
|
|
267
|
-
const closeIssue = useRpc(rpc.closeIssue);
|
|
268
|
-
const reopenIssue = useRpc(rpc.reopenIssue);
|
|
269
|
-
const update = useRpc(rpc.updateBranch);
|
|
270
|
-
const merge = useRpc(rpc.mergePullRequest);
|
|
271
|
-
const close = useRpc(rpc.closePullRequest);
|
|
272
|
-
const claim = useRpc(rpc.claimIssue);
|
|
273
|
-
const unclaim = useRpc(rpc.unclaimIssue);
|
|
274
|
-
const setReady = useRpc(rpc.setReady);
|
|
275
|
-
const setAutoMerge = useRpc(rpc.setAutoMerge);
|
|
276
|
-
const react = useRpc(rpc.react);
|
|
277
|
-
const requestReviewers = useRpc(rpc.requestReviewers);
|
|
278
|
-
const fetchReviewers = useRpc(rpc.reviewerChoices);
|
|
279
|
-
const rerunFailed = useRpc(rpc.rerunFailed);
|
|
280
|
-
const fetchDetails = useRpc(rpc.itemDetails);
|
|
281
|
-
const setCodeRepo = useRpc(rpc.setCodeRepo);
|
|
282
|
-
const fetchDefaultBranch = useRpc(rpc.defaultBranch);
|
|
283
|
-
const fetchReadyProviders = useRpc(rpc.readyProviders);
|
|
284
|
-
const fetchProviders: FetchProviders = () => fetchReadyProviders({}).then((result) => result.providers);
|
|
285
|
-
const defaultBranch: DefaultBranch = async (repo) => (await fetchDefaultBranch({ repo })).name;
|
|
78
|
+
const act = useItemActions(attention, navigation);
|
|
286
79
|
const [tab, setTab] = useState<TabId>("doing");
|
|
287
|
-
// Every card with a change still running: each runs on its own.
|
|
288
|
-
const [busy, setBusy] = useState<ReadonlySet<string>>(new Set());
|
|
289
|
-
// Sessions archived here, hidden before Paseo's list catches up; in previews, where nothing really archives, this is what
|
|
290
|
-
// makes a Wrap up row go away after its screenshot [ATT-22].
|
|
291
|
-
const [archivedSessions, setArchivedSessions] = useState<ReadonlySet<string>>(new Set());
|
|
292
|
-
const [undoable, setUndoable] = useState<Undoable[]>([]);
|
|
293
|
-
const [placing, setPlacing] = useState<Placing | null>(null);
|
|
294
|
-
const [options, setOptions] = useState<OptionsSpec | null>(null);
|
|
295
80
|
// History's Filter sheet: Reviewed and Changed by others per week [HIS-07].
|
|
296
81
|
const [filtering, setFiltering] = useState(false);
|
|
297
82
|
// The feedback sheet, then the first words for the kind picked in it [FB-01].
|
|
298
83
|
const [feedback, setFeedback] = useState<"sheet" | FeedbackKind | null>(null);
|
|
84
|
+
// The New issue sheet, from ⌘K by the screen's params or from Next up [ISS-01].
|
|
85
|
+
const [newIssue, setNewIssue] = useState<Omit<NewIssueRequest, "at"> | null>(null);
|
|
86
|
+
const newIssueAt = params?.newIssue;
|
|
87
|
+
useEffect(() => {
|
|
88
|
+
const request = takeNewIssueRequest(params);
|
|
89
|
+
if (request) setNewIssue(request);
|
|
90
|
+
}, [newIssueAt]);
|
|
299
91
|
const view = attention.data;
|
|
300
92
|
// Only when something fails: is it setup, and what's missing [SET-01]?
|
|
301
93
|
const fetchSetup = useRpc(rpc.setupStatus);
|
|
302
94
|
const failing = !!attention.error || !!view?.feeds.live.error;
|
|
303
95
|
const setup = useQuery({ queryKey: ["attention-span", "setup"], queryFn: () => fetchSetup({}), enabled: failing });
|
|
304
96
|
const [checking, setChecking] = useState(false);
|
|
305
|
-
async function run(key: string, label: string, work: () => Promise<unknown>) {
|
|
306
|
-
setBusy((keys) => new Set(keys).add(key));
|
|
307
|
-
try {
|
|
308
|
-
await work();
|
|
309
|
-
} catch (error) {
|
|
310
|
-
toast.error(`${label} failed: ${(error as Error).message}`);
|
|
311
|
-
} finally {
|
|
312
|
-
setBusy((keys) => new Set([...keys].filter((other) => other !== key)));
|
|
313
|
-
}
|
|
314
|
-
}
|
|
315
|
-
|
|
316
|
-
// A change from one tap, without confirming: Undo instead, where it can be taken back [SAFE-01, ATT-08, ATT-14].
|
|
317
|
-
// The server answers each with the list after it, so nothing needs a refresh.
|
|
318
|
-
function change(key: string, label: string, work: () => Promise<AttentionView>, done: string, undo?: () => Promise<AttentionView>, dismissal?: boolean) {
|
|
319
|
-
void run(key, label, async () => {
|
|
320
|
-
attention.setView(await work());
|
|
321
|
-
if (!undo) return toast.show(done, { variant: "success" });
|
|
322
|
-
const id = Date.now() + Math.random();
|
|
323
|
-
setUndoable((rows) => [...rows, { id, text: done, undo: async () => attention.setView(await undo()), dismissal }]);
|
|
324
|
-
});
|
|
325
|
-
}
|
|
326
|
-
|
|
327
|
-
function openAgent(agentId: string) {
|
|
328
|
-
if (navigation?.openAgent) navigation.openAgent({ agentId });
|
|
329
|
-
else toast.show("Session started. Open it from the sidebar.", { variant: "success" });
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
async function started(agentId: string) {
|
|
333
|
-
await queryClient.invalidateQueries({ queryKey: AGENTS_QUERY_KEY });
|
|
334
|
-
openAgent(agentId);
|
|
335
|
-
}
|
|
336
|
-
|
|
337
|
-
// One tap: start a session with defaults [SES-01]. An open one is offered first, by the card [SES-03].
|
|
338
|
-
async function startWithDefaults(itemKey: string, kind: SessionKind, target: Target, before?: () => Promise<unknown>) {
|
|
339
|
-
if (!view) return;
|
|
340
|
-
await run(itemKey, "Starting the session", () => startNow(itemKey, kind, target, view.config, before));
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
async function startNow(itemKey: string, kind: SessionKind, target: Target, config: AttentionConfig, before?: () => Promise<unknown>) {
|
|
344
|
-
const checkout = await findCheckout(paseo, config, target, defaultBranch);
|
|
345
|
-
// Ask where an issue's code lives before claiming it, so a failed start doesn't leave it taken [SES-07].
|
|
346
|
-
if (!checkout.project && target.kind === "issue") return setPlacing({ itemKey, kind, target, missing: checkout.repo, before });
|
|
347
|
-
await before?.();
|
|
348
|
-
const { context } = await fetchContext({ kind, target });
|
|
349
|
-
const prompt = renderPrompt(kind, target, context, config);
|
|
350
|
-
await started(await startSession(paseo, { itemKey, kind, target, prompt, config, fetchProviders, checkout }));
|
|
351
|
-
}
|
|
352
|
-
|
|
353
|
-
function place(codeRepo: string) {
|
|
354
|
-
if (!placing) return;
|
|
355
|
-
const { itemKey, kind, target, before } = placing;
|
|
356
|
-
setPlacing(null);
|
|
357
|
-
void run(itemKey, "Starting the session", async () => {
|
|
358
|
-
const next = await setCodeRepo({ issueRepo: target.repo, codeRepo });
|
|
359
|
-
attention.setView(next);
|
|
360
|
-
await startNow(itemKey, kind, target, next.config, before);
|
|
361
|
-
});
|
|
362
|
-
}
|
|
363
97
|
|
|
364
98
|
if (failing && setup.data && blocks(setup.data)) {
|
|
365
99
|
const check = async () => {
|
|
@@ -386,126 +120,32 @@ function AttentionList({
|
|
|
386
120
|
// Each tab shows how fresh its own feed is.
|
|
387
121
|
const feed = view.feeds[TAB_FEED[tab]];
|
|
388
122
|
// Wrap up is made here from the sessions the screen and sidebar already poll; the server archives and acknowledges [ATT-22].
|
|
389
|
-
const agentsNow = (view.fixtureAgents ?? agents.data ?? []).filter((agent) => !archivedSessions.has(agent.id));
|
|
123
|
+
const agentsNow = (view.fixtureAgents ?? agents.data ?? []).filter((agent) => !act.archivedSessions.has(agent.id));
|
|
390
124
|
const wrap = wrapItems(view, agentsNow);
|
|
391
125
|
// Notes about work Already in Wrap up wait there; archiving acknowledges them [HIS-07, ATT-22].
|
|
392
126
|
const notes = unreadChanges(view.history.filter((item) => item.section === "changed"), wrap);
|
|
393
127
|
// Calm only once a refresh that worked says Doing is empty, Wrap up included [ATT-18, ATT-22].
|
|
394
128
|
// Sessions not known yet, or failing to load, leave Wrap up unknown: no calm on that [ATT-18, ATT-22].
|
|
395
129
|
const sessionsKnown = !!view.fixtureAgents || (agents.isSuccess && !agents.isError);
|
|
396
|
-
|
|
130
|
+
// A worktree that stayed after its sessions were archived lingers in Wrap up, uncounted, but keeps the calm away [ATT-22].
|
|
131
|
+
const kept = view.kept ?? [];
|
|
132
|
+
const clear = sessionsKnown && isClear(view, !!attention.error, wrap.length + kept.length);
|
|
133
|
+
// The other tabs' scenes, on the same terms [HIS-08, WAI-04, NXT-13].
|
|
134
|
+
const calm = {
|
|
135
|
+
history: historyClear(view, notes.length, !!attention.error),
|
|
136
|
+
waiting: waitingClear(view, !!attention.error),
|
|
137
|
+
next: nextUpClear(view, !!attention.error),
|
|
138
|
+
};
|
|
397
139
|
// ⟳ turns for any refresh of this tab's feed, but only my own press locks it: the cached view can still say a background one runs after it's done.
|
|
398
140
|
const pressed = attention.isRefreshing(TAB_FEED[tab]);
|
|
399
141
|
const refreshing = feed.refreshing || attention.isFetching || pressed;
|
|
400
|
-
const counts
|
|
401
|
-
history: view.history.filter((item) => item.section === "done").length,
|
|
402
|
-
doing: doingCount(view, wrap),
|
|
403
|
-
// Work waiting on several people counts once.
|
|
404
|
-
waiting: new Set(view.waiting.flatMap((group) => group.items.map((item) => item.key))).size,
|
|
405
|
-
next: view.assigned.length + view.unclaimed.length,
|
|
406
|
-
};
|
|
407
|
-
|
|
408
|
-
const actions: Actions = {
|
|
409
|
-
agents: agentsNow,
|
|
410
|
-
fixture: !!view.fixtureAgents,
|
|
411
|
-
startWithOptions: setOptions,
|
|
412
|
-
busy,
|
|
413
|
-
config: view.config,
|
|
414
|
-
login: view.login,
|
|
415
|
-
fetchContext,
|
|
416
|
-
fetchDetails,
|
|
417
|
-
fetchReviewers,
|
|
418
|
-
defaultBranch,
|
|
419
|
-
fetchProviders,
|
|
420
|
-
openAgent,
|
|
421
|
-
started,
|
|
422
|
-
act: (item, action) => {
|
|
423
|
-
const session = ACTION_SESSION[action];
|
|
424
|
-
const { target } = item;
|
|
425
|
-
if (action === "reply") return void openExternalUrl(item.person?.url ?? item.url);
|
|
426
|
-
// [HIS-07]
|
|
427
|
-
if (action === "got_it" && item.change) {
|
|
428
|
-
const { id } = item.change;
|
|
429
|
-
return change(item.key, "Got it", () => gotIt({ ids: [id], on: true }), `Cleared the note on “${item.title}”`, () => gotIt({ ids: [id], on: false }));
|
|
430
|
-
}
|
|
431
|
-
if (session) return void startWithDefaults(item.key, session, target);
|
|
432
|
-
if (action === "update") change(item.key, "Update", () => update({ key: item.key, target }), `Updating PR ${target.number} with ${target.baseRefName}`);
|
|
433
|
-
// [PRS-11]
|
|
434
|
-
if (action === "ready")
|
|
435
|
-
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 }));
|
|
436
|
-
// [PRS-10]
|
|
437
|
-
if (action === "automerge")
|
|
438
|
-
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 }));
|
|
439
|
-
},
|
|
440
|
-
// [PRS-09]
|
|
441
|
-
rerun: (item, known) => {
|
|
442
|
-
if (!known) toast.show("Finding the failed jobs to rerun…");
|
|
443
|
-
change(
|
|
444
|
-
item.key,
|
|
445
|
-
"Rerun",
|
|
446
|
-
async () => {
|
|
447
|
-
const runIds = known ?? summarizeRerun((await queryClient.fetchQuery({ ...itemDetailsQuery(item, fetchDetails), staleTime: DETAILS_STALE_MS })).failing).runIds;
|
|
448
|
-
if (runIds.length === 0) throw new Error("no failed GitHub Actions jobs to rerun");
|
|
449
|
-
return rerunFailed({ key: item.key, repo: item.target.repo, runIds });
|
|
450
|
-
},
|
|
451
|
-
`Rerunning the failed jobs of PR ${item.target.number}`,
|
|
452
|
-
);
|
|
453
|
-
},
|
|
454
|
-
// [PRS-12]
|
|
455
|
-
requestReviewers: (item, reviewers) => {
|
|
456
|
-
const { target } = item;
|
|
457
|
-
const names = reviewers.length === 1 ? reviewers[0] : `${reviewers.length} reviewers`;
|
|
458
|
-
change(item.key, "Request review", () => requestReviewers({ key: item.key, target, reviewers, on: true }), `Asked ${names} to review PR ${target.number}`, () =>
|
|
459
|
-
requestReviewers({ key: item.key, target, reviewers, on: false }),
|
|
460
|
-
);
|
|
461
|
-
},
|
|
462
|
-
// [MEN-07]
|
|
463
|
-
acknowledge: (item, ids) =>
|
|
464
|
-
change(item.key, "Acknowledge", () => react({ key: item.key, subjectIds: ids, on: true }), `Acknowledged ${ids.length === 1 ? "a comment" : `${ids.length} comments`} on #${item.number}`, () =>
|
|
465
|
-
react({ key: item.key, subjectIds: ids, on: false }),
|
|
466
|
-
),
|
|
467
|
-
confirm: (item, action, comment) =>
|
|
468
|
-
action === "merge"
|
|
469
|
-
? change(item.key, "Merge", () => merge({ key: item.key, target: item.target }), `PR ${item.target.number} merged`)
|
|
470
|
-
: change(item.key, "Close", () => close({ key: item.key, target: item.target, comment }), `PR ${item.target.number} closed`),
|
|
471
|
-
// Got it on every Changed by others note at once; one Undo brings them all back [HIS-07].
|
|
472
|
-
gotItAll: (items) => {
|
|
473
|
-
const ids = items.flatMap((item) => (item.change ? [item.change.id] : []));
|
|
474
|
-
const notes = `${ids.length} note${ids.length === 1 ? "" : "s"}`;
|
|
475
|
-
change(ALL_NOTES, "Mark all as read", () => gotIt({ ids, on: true }), `Cleared ${notes} on changes by others`, () => gotIt({ ids, on: false }));
|
|
476
|
-
},
|
|
477
|
-
dismiss: (item) => change(item.key, "Dismiss", () => dismiss({ key: item.key }), `Dismissed “${item.title}”`, () => undismiss({ key: item.key }), true),
|
|
478
|
-
};
|
|
142
|
+
const counts = tabCounts(view, wrap);
|
|
479
143
|
|
|
480
|
-
|
|
481
|
-
// No Undo: Paseo's SDK can't restore a workspace and its agents, so the sheet is the safeguard instead.
|
|
482
|
-
async function archiveRows(items: WrapItem[], confirm: boolean, key = ALL_WRAP): Promise<ArchiveOutcome | null> {
|
|
483
|
-
if (items.length === 0) return null;
|
|
484
|
-
setBusy((keys) => new Set(keys).add(key));
|
|
485
|
-
try {
|
|
486
|
-
const outcome = await archiveSessions({ targets: items.map(archiveTarget), confirm });
|
|
487
|
-
attention.setView(outcome.view);
|
|
488
|
-
if (outcome.ok) {
|
|
489
|
-
const archived = new Set(items.flatMap((item) => item.wrap.sessions.map((session) => session.id)));
|
|
490
|
-
setArchivedSessions((known) => new Set([...known, ...archived]));
|
|
491
|
-
const sessions = archived.size;
|
|
492
|
-
if (outcome.warning) toast.error(outcome.warning);
|
|
493
|
-
else toast.show(sessions === 1 ? `Archived the session on #${items[0].number}` : `Archived ${sessions} sessions`, { variant: "success" });
|
|
494
|
-
} else if (outcome.reason === "working") {
|
|
495
|
-
toast.error(`Couldn't archive: ${outcome.message}`);
|
|
496
|
-
}
|
|
497
|
-
return outcome;
|
|
498
|
-
} catch (error) {
|
|
499
|
-
toast.error(`Archive failed: ${(error as Error).message}`);
|
|
500
|
-
return null;
|
|
501
|
-
} finally {
|
|
502
|
-
setBusy((keys) => new Set([...keys].filter((other) => other !== key)));
|
|
503
|
-
}
|
|
504
|
-
}
|
|
144
|
+
const actions = act.itemActions(view, agentsNow);
|
|
505
145
|
|
|
506
146
|
const switchTab = (id: TabId) => {
|
|
507
147
|
setTab(id);
|
|
508
|
-
|
|
148
|
+
act.clearUndo();
|
|
509
149
|
};
|
|
510
150
|
|
|
511
151
|
return (
|
|
@@ -539,59 +179,48 @@ function AttentionList({
|
|
|
539
179
|
{feed.error ? <Text style={styles.danger}>{feed.error}</Text> : null}
|
|
540
180
|
<UpdateNotice />
|
|
541
181
|
|
|
542
|
-
{undoable.map((row) => (
|
|
182
|
+
{act.undoable.map((row) => (
|
|
543
183
|
<View key={row.id} style={[styles.panel, styles.row, { justifyContent: "space-between" }]}>
|
|
544
184
|
<Text style={[styles.muted, { flexShrink: 1 }]} numberOfLines={1}>
|
|
545
185
|
{row.text}
|
|
546
186
|
</Text>
|
|
547
|
-
<Button
|
|
548
|
-
label="Undo"
|
|
549
|
-
variant="calm"
|
|
550
|
-
onPress={() =>
|
|
551
|
-
void run(String(row.id), "Undo", async () => {
|
|
552
|
-
await row.undo();
|
|
553
|
-
setUndoable((rows) => rows.filter((other) => other.id !== row.id));
|
|
554
|
-
})
|
|
555
|
-
}
|
|
556
|
-
/>
|
|
187
|
+
<Button label="Undo" variant="calm" onPress={() => act.undo(row)} />
|
|
557
188
|
</View>
|
|
558
189
|
))}
|
|
559
190
|
{tab === "history" ? (
|
|
560
191
|
<History
|
|
192
|
+
calm={calm.history}
|
|
561
193
|
notes={notes}
|
|
562
194
|
items={view.history}
|
|
563
195
|
filter={view.historyFilter ?? []}
|
|
564
196
|
filtering={filtering}
|
|
565
197
|
onFiltering={setFiltering}
|
|
566
|
-
onFilter={(next) =>
|
|
567
|
-
|
|
568
|
-
attention.setView({ ...view, historyFilter: next });
|
|
569
|
-
saveHistoryFilter({ filter: next })
|
|
570
|
-
.then((saved) => attention.setView(saved))
|
|
571
|
-
.catch((error: Error) => toast.error(`Saving the filter failed: ${error.message}`));
|
|
572
|
-
}}
|
|
573
|
-
busy={busy}
|
|
198
|
+
onFilter={(next) => act.filterHistory(view, next)}
|
|
199
|
+
busy={act.busy}
|
|
574
200
|
onMarkAllRead={actions.gotItAll}
|
|
575
201
|
card={(items) => <Card items={items} actions={actions} />}
|
|
576
202
|
/>
|
|
577
203
|
) : null}
|
|
578
204
|
{tab === "doing" ? (
|
|
579
205
|
<>
|
|
580
|
-
{clear ? <Still /> : wrap.length || view.doing.length ? (
|
|
206
|
+
{clear ? <Still /> : wrap.length || kept.length || view.doing.length ? (
|
|
581
207
|
<>
|
|
582
|
-
{wrap.length > 0 ? (
|
|
208
|
+
{wrap.length + kept.length > 0 ? (
|
|
583
209
|
<WrapUp
|
|
584
210
|
items={wrap}
|
|
585
|
-
|
|
211
|
+
kept={kept}
|
|
212
|
+
onArchiveWorktree={act.archiveWorktree}
|
|
213
|
+
onDismissKept={act.dismissKept}
|
|
214
|
+
busy={act.busy}
|
|
586
215
|
login={view.login}
|
|
587
216
|
fixture={!!view.fixtureAgents}
|
|
588
|
-
openAgent={openAgent}
|
|
589
|
-
onArchive={(item, confirm) => archiveRows([item], confirm, item.key)}
|
|
217
|
+
openAgent={act.openAgent}
|
|
218
|
+
onArchive={(item, confirm, terminals) => act.archiveRows([item], confirm, item.key, terminals)}
|
|
590
219
|
onArchiveAll={async () => {
|
|
591
220
|
const clean = wrap.filter(cleanSingle);
|
|
592
221
|
if (clean.length === 0) return;
|
|
593
|
-
const outcome = await archiveRows(clean, false);
|
|
594
|
-
if (outcome && !outcome.ok && outcome.reason === "unsaved") toast.error("Some sessions have unsaved changes. Archive them one by one.");
|
|
222
|
+
const outcome = await act.archiveRows(clean, false);
|
|
223
|
+
if (outcome && !outcome.ok && outcome.reason === "unsaved") toast.error("Some sessions have unsaved changes or open terminals. Archive them one by one.");
|
|
595
224
|
}}
|
|
596
225
|
/>
|
|
597
226
|
) : null}
|
|
@@ -604,20 +233,24 @@ function AttentionList({
|
|
|
604
233
|
) : !sessionsKnown ? (
|
|
605
234
|
<Loading text="Checking your sessions…" />
|
|
606
235
|
) : null}
|
|
607
|
-
{view.dismissedCount > undoable.filter((row) => row.dismissal).length ? (
|
|
236
|
+
{view.dismissedCount > act.undoable.filter((row) => row.dismissal).length ? (
|
|
608
237
|
<Pressable
|
|
609
238
|
accessibilityRole="button"
|
|
610
239
|
style={clear ? { alignSelf: "center", opacity: 0.7 } : undefined}
|
|
611
|
-
onPress={
|
|
240
|
+
onPress={act.restoreDismissed}
|
|
612
241
|
>
|
|
613
242
|
<Text style={styles.muted}>{view.dismissedCount} dismissed · show them again</Text>
|
|
614
243
|
</Pressable>
|
|
615
244
|
) : null}
|
|
616
245
|
</>
|
|
617
246
|
) : null}
|
|
618
|
-
{tab === "waiting" ?
|
|
247
|
+
{tab === "waiting" ? (
|
|
248
|
+
calm.waiting ? <Still shore="jetty" title="Nobody's holding you up." line="Nothing to chase." /> : <Waiting groups={view.waiting} actions={actions} />
|
|
249
|
+
) : null}
|
|
619
250
|
{tab === "next" ? (
|
|
620
251
|
<NextUpList
|
|
252
|
+
calm={calm.next}
|
|
253
|
+
openSettings={openSettings}
|
|
621
254
|
assigned={view.assigned}
|
|
622
255
|
unclaimed={view.unclaimed}
|
|
623
256
|
unclaimedFrom={view.unclaimedFrom}
|
|
@@ -626,55 +259,32 @@ function AttentionList({
|
|
|
626
259
|
selectedSources={view.sources}
|
|
627
260
|
projects={view.projects}
|
|
628
261
|
selectedProjects={view.projectFilter}
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
const failed = (error: Error) => toast.error(`Saving the filter failed: ${error.message}`);
|
|
633
|
-
if (change.scopes) saveScopes({ scopes: change.scopes }).catch(failed);
|
|
634
|
-
if (change.sources) saveSources({ sources: change.sources }).catch(failed);
|
|
635
|
-
if (change.projectFilter) saveProjects({ projects: change.projectFilter }).catch(failed);
|
|
636
|
-
}}
|
|
262
|
+
onFilter={(change) => act.filterNextUp(view, change)}
|
|
263
|
+
// Narrowed to one repository, a new issue starts there [ISS-01].
|
|
264
|
+
onNewIssue={() => setNewIssue({ nextUp: view.sources.length === 1 && view.sources[0].startsWith("repo:") ? view.sources[0].slice(5) : undefined })}
|
|
637
265
|
agents={actions.agents}
|
|
638
266
|
login={view.login}
|
|
639
|
-
busy={busy}
|
|
640
|
-
fetchDetails={fetchDetails}
|
|
641
|
-
onOpenAgent={openAgent}
|
|
642
|
-
|
|
643
|
-
const target = issueTarget(issue);
|
|
644
|
-
void startWithDefaults(issue.key, "start", target, claimFirst ? async () => attention.setView(await claim({ key: issue.key, target })) : undefined);
|
|
645
|
-
}}
|
|
646
|
-
onOptions={(issue, claimFirst, label) => {
|
|
647
|
-
const target = issueTarget(issue);
|
|
648
|
-
setOptions({ itemKey: issue.key, title: `${label}: ${issue.title}`, kind: "start", target, before: claimFirst ? async () => attention.setView(await claim({ key: issue.key, target })) : undefined });
|
|
649
|
-
}}
|
|
650
|
-
// Claim without starting, or give it back; each undoes the other [NXT-07].
|
|
651
|
-
onClaim={(issue, on) => {
|
|
652
|
-
const target = issueTarget(issue);
|
|
653
|
-
const [take, giveBack] = [() => claim({ key: issue.key, target }), () => unclaim({ key: issue.key, target })];
|
|
654
|
-
change(issue.key, on ? "Claim" : "Unclaim", on ? take : giveBack, `${on ? "Claimed" : "Unclaimed"} #${issue.number}`, on ? giveBack : take);
|
|
655
|
-
}}
|
|
656
|
-
// Undo reopens; a comment already posted stays [NXT-11].
|
|
657
|
-
onCloseIssue={(issue, reason, comment) => {
|
|
658
|
-
const target = issueTarget(issue);
|
|
659
|
-
const done = `Closed #${issue.number} as ${reason === "completed" ? "completed" : "not planned"}`;
|
|
660
|
-
change(issue.key, "Close", () => closeIssue({ key: issue.key, target, reason, comment: comment || undefined }), done, () => reopenIssue({ key: issue.key, target }));
|
|
661
|
-
}}
|
|
267
|
+
busy={act.busy}
|
|
268
|
+
fetchDetails={act.fetchDetails}
|
|
269
|
+
onOpenAgent={act.openAgent}
|
|
270
|
+
{...act.issueActions}
|
|
662
271
|
/>
|
|
663
272
|
) : null}
|
|
664
273
|
<FeedbackLine onPress={() => setFeedback("sheet")} />
|
|
665
|
-
{feedback === "sheet" ? <FeedbackSheet agents={actions.agents} onOpenAgent={openAgent} onAsk={setFeedback} onClose={() => setFeedback(null)} /> : null}
|
|
274
|
+
{feedback === "sheet" ? <FeedbackSheet agents={actions.agents} onOpenAgent={act.openAgent} onAsk={setFeedback} onClose={() => setFeedback(null)} /> : null}
|
|
666
275
|
{feedback && feedback !== "sheet" ? (
|
|
667
276
|
<FeedbackAsk
|
|
668
277
|
kind={feedback}
|
|
669
278
|
config={view.config}
|
|
670
279
|
screen={{ ...device, tab, refreshError: feed.error ?? null }}
|
|
671
|
-
onStarted={started}
|
|
280
|
+
onStarted={act.started}
|
|
672
281
|
onBack={() => setFeedback("sheet")}
|
|
673
282
|
onClose={() => setFeedback(null)}
|
|
674
283
|
/>
|
|
675
284
|
) : null}
|
|
676
|
-
{
|
|
677
|
-
{
|
|
285
|
+
{newIssue ? <NewIssueSheet request={newIssue} view={view} onView={attention.setView} onStarted={act.started} onClose={() => setNewIssue(null)} /> : null}
|
|
286
|
+
{act.options ? <SessionOptions spec={act.options} config={view.config} started={act.started} onClose={act.closeOptions} /> : null}
|
|
287
|
+
{act.placing ? <CodeRepoPicker issueRepo={act.placing.target.repo} missing={act.placing.missing} onPick={act.place} onClose={act.cancelPlacing} /> : null}
|
|
678
288
|
</ScrollView>
|
|
679
289
|
);
|
|
680
290
|
}
|
|
@@ -703,547 +313,6 @@ function Tab({ icon, label, count, active, dot, onPress }: { icon: IconName; lab
|
|
|
703
313
|
);
|
|
704
314
|
}
|
|
705
315
|
|
|
706
|
-
// A theme colour, see-through, so a badge reads on any surface; colours that aren't #rrggbb fall back to none.
|
|
707
|
-
function tint(color: string, alpha: number): string {
|
|
708
|
-
const hex = /^#([0-9a-f]{6})/i.exec(color)?.[1];
|
|
709
|
-
if (!hex) return "transparent";
|
|
710
|
-
const [r, g, b] = [0, 2, 4].map((at) => parseInt(hex.slice(at, at + 2), 16));
|
|
711
|
-
return `rgba(${r}, ${g}, ${b}, ${alpha})`;
|
|
712
|
-
}
|
|
713
|
-
|
|
714
|
-
interface Actions {
|
|
715
|
-
agents: AgentSummary[];
|
|
716
|
-
// Previews have made-up sessions: show their sheets locally instead of asking a daemon that has none.
|
|
717
|
-
fixture: boolean;
|
|
718
|
-
startWithOptions: (spec: OptionsSpec) => void;
|
|
719
|
-
busy: ReadonlySet<string>;
|
|
720
|
-
config: AttentionConfig;
|
|
721
|
-
login: string | null;
|
|
722
|
-
fetchContext: FetchContext;
|
|
723
|
-
fetchDetails: FetchDetails;
|
|
724
|
-
fetchReviewers: FetchReviewers;
|
|
725
|
-
defaultBranch: DefaultBranch;
|
|
726
|
-
fetchProviders: FetchProviders;
|
|
727
|
-
act: (item: Item, action: ActionId) => void;
|
|
728
|
-
requestReviewers: (item: Item, reviewers: string[]) => void;
|
|
729
|
-
// Without run ids, it finds them first: Rerun pressed before the sheet had the failing checks.
|
|
730
|
-
rerun: (item: Item, runIds?: number[]) => void;
|
|
731
|
-
acknowledge: (item: Item, commentIds: string[]) => void;
|
|
732
|
-
confirm: (item: Item, action: "merge" | "close", comment?: string) => void;
|
|
733
|
-
dismiss: (item: Item) => void;
|
|
734
|
-
gotItAll: (items: Item[]) => void;
|
|
735
|
-
openAgent: (agentId: string) => void;
|
|
736
|
-
started: (agentId: string) => Promise<void>;
|
|
737
|
-
}
|
|
738
|
-
|
|
739
|
-
// A card that works collapsed: its main action and ›. Tapping it opens the sheet with everything else [ATT-05, ATT-06].
|
|
740
|
-
const isRed = (chips: Chip[]) => chips.some((chip) => chip.tone === "bad");
|
|
741
|
-
|
|
742
|
-
// The sheet, Acknowledge, or the reviewer picker (after Ready for review, or on its own).
|
|
743
|
-
type Sheet = "item" | "acknowledge" | "reviewers" | "reviewers-after-ready" | null;
|
|
744
|
-
|
|
745
|
-
// A session on an item that has no session action of its own starts with this prompt; it's editable first.
|
|
746
|
-
const fallbackKind = (item: Item): SessionKind => (item.target.kind === "issue" ? "start" : "review");
|
|
747
|
-
|
|
748
|
-
// Why it waits and how long, in Waiting only; Doing says what's mine to do. Once it has waited too long, where nudging is
|
|
749
|
-
// fair, the age itself turns amber with ⌛ and says so in words [WAI-01, ATT-11].
|
|
750
|
-
function waitChips(item: Item, inWaiting: boolean, tooLongDays: number): Chip[] {
|
|
751
|
-
const { wait } = item;
|
|
752
|
-
if (!wait || !inWaiting) return [];
|
|
753
|
-
const age = ago(wait.since);
|
|
754
|
-
const reason: Chip[] = wait.reason ? [{ text: wait.reason, tone: "neutral" }] : [];
|
|
755
|
-
if (!wait.tooLong) return [...reason, { text: age, tone: "neutral" }];
|
|
756
|
-
const since = wait.reason === "question" ? "you asked" : "your last push or reply";
|
|
757
|
-
const limit = `${tooLongDays} day${tooLongDays === 1 ? "" : "s"}`;
|
|
758
|
-
return [...reason, { text: age, tone: "warn", icon: "hourglass", hint: `Waited too long: ${age} since ${since}, more than ${limit}` }];
|
|
759
|
-
}
|
|
760
|
-
|
|
761
|
-
// "Review 2h", "Question 3d": why and how long, to lead a line in a nudge [WAI-03].
|
|
762
|
-
function nudgeLead(item: Item): string | undefined {
|
|
763
|
-
if (!item.wait) return undefined;
|
|
764
|
-
const { reason, since } = item.wait;
|
|
765
|
-
return reason ? `${reason[0].toUpperCase()}${reason.slice(1)} ${ago(since)}` : ago(since);
|
|
766
|
-
}
|
|
767
|
-
|
|
768
|
-
const samePerson = (a: WaitingOn, b: WaitingOn) => a.team === b.team && a.login.toLowerCase() === b.login.toLowerCase();
|
|
769
|
-
|
|
770
|
-
// In Waiting, a card sits under one of whom it waits on: its group.
|
|
771
|
-
function ItemRow({ item, first, actions, group }: { item: Item; first: boolean; actions: Actions; group?: WaitingGroup }) {
|
|
772
|
-
const styles = useStyles();
|
|
773
|
-
// An open session leads; without one, the item's own action does [SES-03].
|
|
774
|
-
const sessions = itemSessions(actions.agents, item);
|
|
775
|
-
const waits = waitChips(item, !!group, actions.config.waitingTooLongDays);
|
|
776
|
-
// The group names one; the card names the rest [WAI-01].
|
|
777
|
-
const others = group?.who ? (item.waitingOn ?? []).filter((who) => !samePerson(who, group.who!)) : [];
|
|
778
|
-
const waitingOn = group ? null : item.waitingOn ? <WaitingOnLine people={item.waitingOn} asked={item.wait?.reason === "question"} expanded={false} /> : null;
|
|
779
|
-
const alsoOn = others.length ? <Text style={styles.muted}>also waiting on {others.map((who) => who.login).join(", ")}</Text> : null;
|
|
780
|
-
const [sheet, setSheet] = useState<Sheet>(null);
|
|
781
|
-
const [confirm, setConfirm] = useState<"merge" | "close" | null>(null);
|
|
782
|
-
const main = item.actions[0];
|
|
783
|
-
// The full stack is in the sheet; the card shows the PRs that need attention [ATT-04]. Once it shows any, it shows the PR an
|
|
784
|
-
// issue's actions apply to as well, tinted, and says that PR's facts there rather than in its meta, as the sheet does [ATT-06].
|
|
785
|
-
const target = targetUrl(item);
|
|
786
|
-
const needing = item.children.some((child) => child.attention || isRed(child.chips));
|
|
787
|
-
const children = needing ? item.children.filter((child) => child.attention || isRed(child.chips) || child.url === target) : [];
|
|
788
|
-
const targetRow = children.find((child) => child.url === target);
|
|
789
|
-
const shown = [...waits, ...stackMetaChips(item, targetRow)];
|
|
790
|
-
const chips = sessions[0] ? [...shown, agentSignal(sessions[0])] : shown;
|
|
791
|
-
// The sheet opens at once; what it fetches fills in [ATT-06].
|
|
792
|
-
const open = () => setSheet("item");
|
|
793
|
-
const prefetch = usePrefetchOnRest(itemDetailsQuery(item, actions.fetchDetails));
|
|
794
|
-
const copy = useCopy();
|
|
795
|
-
const history = SECTIONS[item.section].tab === "history";
|
|
796
|
-
|
|
797
|
-
function perform(action: ActionId) {
|
|
798
|
-
setSheet(null);
|
|
799
|
-
if (action === "merge" || action === "close") setConfirm(action);
|
|
800
|
-
else if (action === "acknowledge") setSheet("acknowledge");
|
|
801
|
-
else if (action === "request_review") setSheet("reviewers");
|
|
802
|
-
// A draft made ready goes straight on to who should review it [PRS-11].
|
|
803
|
-
else if (action === "ready") (actions.act(item, action), setSheet("reviewers-after-ready"));
|
|
804
|
-
else actions.act(item, action);
|
|
805
|
-
}
|
|
806
|
-
const handlers: SheetHandlers = { onPerform: perform, onClose: () => setSheet(null) };
|
|
807
|
-
// A sheet with one action is a wasted tap: show that action instead of ›. The card still opens the sheet, quiet lines and all [ATT-06].
|
|
808
|
-
const loud = sheetEntries(item, sessions, actions, handlers).filter((entry) => !entry.quiet);
|
|
809
|
-
const only = loud.length === 1 ? loud[0] : undefined;
|
|
810
|
-
const confirmed = (action: "merge" | "close") => (comment: string) => (setConfirm(null), actions.confirm(item, action, comment));
|
|
811
|
-
|
|
812
|
-
return (
|
|
813
|
-
<CardRow
|
|
814
|
-
first={first}
|
|
815
|
-
mark={stateMark(item)}
|
|
816
|
-
title={item.title}
|
|
817
|
-
meta={{
|
|
818
|
-
place: { repo: item.repo, number: item.number, login: actions.login },
|
|
819
|
-
when: item.change
|
|
820
|
-
? changeText(item.change)
|
|
821
|
-
: item.closedAt
|
|
822
|
-
? `${item.kind === "pr" ? "merged" : "closed"} ${ago(item.closedAt)} ago${(item.kind === "pr" ? item.mergedBy : item.closedBy) ? ` by ${item.kind === "pr" ? item.mergedBy : item.closedBy}` : ""}${item.notPlanned ? " as not planned" : ""}`
|
|
823
|
-
: undefined,
|
|
824
|
-
signals: chips,
|
|
825
|
-
}}
|
|
826
|
-
extra={
|
|
827
|
-
item.person || waitingOn || alsoOn || children.length > 0 ? (
|
|
828
|
-
<>
|
|
829
|
-
{item.person ? <PersonQuote person={item.person} expanded={false} /> : null}
|
|
830
|
-
{waitingOn}
|
|
831
|
-
{alsoOn}
|
|
832
|
-
{children.length > 0 ? <StackLine rows={children} merged={!!item.closedAt} target={targetRow?.key} /> : null}
|
|
833
|
-
</>
|
|
834
|
-
) : null
|
|
835
|
-
}
|
|
836
|
-
onOpen={open}
|
|
837
|
-
hover={prefetch}
|
|
838
|
-
busy={item.change ? noteBusy(actions.busy, item.key) : actions.busy.has(item.key)}
|
|
839
|
-
primary={
|
|
840
|
-
sessions[0]
|
|
841
|
-
? { label: "Open session", icon: "agent", onPress: () => actions.openAgent(sessions[0].id) }
|
|
842
|
-
: main
|
|
843
|
-
? { label: actionLabel(main, item), icon: ACTION_ICONS[main], iconOnly: main === "got_it", onPress: () => perform(main) }
|
|
844
|
-
: undefined
|
|
845
|
-
}
|
|
846
|
-
secondary={[
|
|
847
|
-
only ? { label: only.label, accessibilityLabel: only.accessibilityLabel, icon: only.icon, onPress: only.onPress } : { label: `Details for #${item.number}`, icon: "chevronRight", onPress: open },
|
|
848
|
-
// History is where I report from, so its cards copy their link in one tap [ATT-15]. Unread notes are not report rows.
|
|
849
|
-
...(history && item.section !== "changed" ? [{ label: `Copy link to #${item.number}`, icon: "copy" as const, onPress: () => copy(item.url, `Copied link to #${item.number}`) }] : []),
|
|
850
|
-
]}
|
|
851
|
-
confirm={
|
|
852
|
-
confirm === "merge"
|
|
853
|
-
? {
|
|
854
|
-
text: `Merge PR ${item.target.number} into ${item.target.baseRefName} (${item.target.mergeMethod})?`,
|
|
855
|
-
choices: [{ label: "Merge", icon: "merge", solid: true, onConfirm: confirmed("merge") }],
|
|
856
|
-
onCancel: () => setConfirm(null),
|
|
857
|
-
}
|
|
858
|
-
: confirm === "close"
|
|
859
|
-
? {
|
|
860
|
-
text: `Close PR ${item.target.number}? A comment is only posted if you write one.`,
|
|
861
|
-
comment: true,
|
|
862
|
-
choices: [{ label: "Close PR", icon: "close", solid: true, onConfirm: confirmed("close") }],
|
|
863
|
-
onCancel: () => setConfirm(null),
|
|
864
|
-
}
|
|
865
|
-
: null
|
|
866
|
-
}
|
|
867
|
-
overlay={
|
|
868
|
-
<>
|
|
869
|
-
{sheet === "item" ? <ItemSheet item={item} waitChips={waits} sessions={sessions} actions={actions} {...handlers} /> : null}
|
|
870
|
-
{sheet === "acknowledge" ? <AcknowledgeSheet item={item} onReact={(ids) => (setSheet(null), actions.acknowledge(item, ids))} onClose={() => setSheet(null)} /> : null}
|
|
871
|
-
{sheet === "reviewers" || sheet === "reviewers-after-ready" ? (
|
|
872
|
-
<ReviewerSheet
|
|
873
|
-
item={item}
|
|
874
|
-
afterReady={sheet === "reviewers-after-ready"}
|
|
875
|
-
fetchReviewers={actions.fetchReviewers}
|
|
876
|
-
onRequest={(reviewers) => (setSheet(null), actions.requestReviewers(item, reviewers))}
|
|
877
|
-
onClose={() => setSheet(null)}
|
|
878
|
-
/>
|
|
879
|
-
) : null}
|
|
880
|
-
</>
|
|
881
|
-
}
|
|
882
|
-
/>
|
|
883
|
-
);
|
|
884
|
-
}
|
|
885
|
-
|
|
886
|
-
interface SheetHandlers {
|
|
887
|
-
onPerform: (action: ActionId) => void;
|
|
888
|
-
onClose: () => void;
|
|
889
|
-
}
|
|
890
|
-
|
|
891
|
-
// 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].
|
|
892
|
-
// What an item's sheet fetches when it opens; resting the pointer on its card fetches the same ahead. `checks` asks for
|
|
893
|
-
// failing checks too, for Rerun.
|
|
894
|
-
function itemDetailsQuery(item: Item, fetchDetails: FetchDetails): DetailsQuery {
|
|
895
|
-
const checks = item.actions.includes("rerun");
|
|
896
|
-
const subject = { kind: item.kind, repo: item.repo, number: item.number };
|
|
897
|
-
return { queryKey: detailsKey(subject, item.target, checks), queryFn: () => fetchDetails({ subject, target: item.target, checks }) };
|
|
898
|
-
}
|
|
899
|
-
|
|
900
|
-
// The PR an item's actions apply to, where that isn't the item itself, like an issue's PR.
|
|
901
|
-
const targetUrl = (item: Item) => (item.target.number !== item.number || item.target.kind !== item.kind ? item.target.url : undefined);
|
|
902
|
-
|
|
903
|
-
// An issue's chips are about the PR its actions apply to. Where its stack line shows that PR, each is said once, on that PR's
|
|
904
|
-
// row, and the meta keeps only what the row doesn't say; "PR #103" and "stack of 2" are the stack line itself. The sheet always
|
|
905
|
-
// shows the row; a card only when a PR in the stack needs attention [ATT-04, ATT-06].
|
|
906
|
-
function stackMetaChips(item: Item, targetRow: SubRow | undefined): Chip[] {
|
|
907
|
-
if (!targetRow) return item.chips;
|
|
908
|
-
const onRow = new Set(targetRow.chips.map((chip) => chip.text));
|
|
909
|
-
return item.chips.filter((chip) => !/^PR #\d+$/.test(chip.text) && !/^stack of \d+$/.test(chip.text) && !onRow.has(chip.text));
|
|
910
|
-
}
|
|
911
|
-
|
|
912
|
-
function ItemSheet({ item, waitChips, sessions, actions, ...handlers }: { item: Item; waitChips: Chip[]; sessions: AgentSummary[]; actions: Actions } & SheetHandlers) {
|
|
913
|
-
const details = useQuery({ ...itemDetailsQuery(item, actions.fetchDetails), staleTime: DETAILS_STALE_MS });
|
|
914
|
-
const arrived = useArrived(details.isLoading);
|
|
915
|
-
const elsewhere = !!targetUrl(item);
|
|
916
|
-
// The row of the PR its actions apply to, where it's in the stack line: marked there instead of named on top.
|
|
917
|
-
const targetRow = elsewhere ? item.children.find((child) => child.url === item.target.url) : undefined;
|
|
918
|
-
const meta = elsewhere && !targetRow ? [`actions apply to PR #${item.target.number}`] : [];
|
|
919
|
-
// PRs already in the stack line link from there; list only the rest, like someone else's PR closing the same issue.
|
|
920
|
-
const shown = new Set(item.children.map((child) => child.url));
|
|
921
|
-
const extra = details.data && { ...details.data, linked: details.data.linked.filter((link) => !shown.has(link.url)) };
|
|
922
|
-
return (
|
|
923
|
-
<ActionSheet
|
|
924
|
-
title={item.title}
|
|
925
|
-
onClose={handlers.onClose}
|
|
926
|
-
top={
|
|
927
|
-
<>
|
|
928
|
-
{/* Number first, as on the card; the sheet always names the owner, even of my own repos [ATT-20]. */}
|
|
929
|
-
<Meta lead={<PlaceText place={{ repo: item.repo, number: item.number, login: null }} />} facts={meta} chips={[...waitChips, ...stackMetaChips(item, targetRow)]} />
|
|
930
|
-
{item.person ? <PersonQuote person={item.person} expanded /> : null}
|
|
931
|
-
{item.waitingOn ? <WaitingOnLine people={item.waitingOn} asked={item.wait?.reason === "question"} expanded /> : null}
|
|
932
|
-
{item.children.length > 0 ? <StackLine rows={item.children} merged={!!item.closedAt} links target={targetRow?.key} /> : null}
|
|
933
|
-
</>
|
|
934
|
-
}
|
|
935
|
-
entries={sheetEntries(item, sessions, actions, handlers, { data: details.data, isLoading: details.isLoading, arrived })}
|
|
936
|
-
// The PR its actions apply to has a size line, named where it isn't the item; an issue's PRs are in its stack line
|
|
937
|
-
// already, so few more come [ATT-06].
|
|
938
|
-
bottom={
|
|
939
|
-
<DetailLines
|
|
940
|
-
details={extra}
|
|
941
|
-
loading={details.isLoading}
|
|
942
|
-
error={details.error}
|
|
943
|
-
linkedLabel={item.kind === "issue" ? "PR" : "Closes"}
|
|
944
|
-
expected={item.target.kind === "pr" ? 1 : 0}
|
|
945
|
-
sizeOf={elsewhere ? item.target.number : undefined}
|
|
946
|
-
/>
|
|
947
|
-
}
|
|
948
|
-
/>
|
|
949
|
-
);
|
|
950
|
-
}
|
|
951
|
-
|
|
952
|
-
// Everything an item's sheet offers, each saying what it will do [ATT-06]. Rerun's line says more once the checks are in.
|
|
953
|
-
function sheetEntries(
|
|
954
|
-
item: Item,
|
|
955
|
-
sessions: AgentSummary[],
|
|
956
|
-
actions: Actions,
|
|
957
|
-
{ onPerform, onClose }: SheetHandlers,
|
|
958
|
-
details?: SheetDetails,
|
|
959
|
-
): SheetEntry[] {
|
|
960
|
-
const inDoing = SECTIONS[item.section].tab === "doing";
|
|
961
|
-
const close = (then: () => void) => () => (onClose(), then());
|
|
962
|
-
|
|
963
|
-
const open = (agentId: string) => close(() => actions.openAgent(agentId))();
|
|
964
|
-
const withOptions = (label: string, kind: SessionKind) => close(() => actions.startWithOptions({ itemKey: item.key, title: `${label}: ${item.title}`, kind, target: item.target }));
|
|
965
|
-
// Sessions none of its actions would start lead, needs me first [SES-03].
|
|
966
|
-
const kinds = item.actions.flatMap((action) => ACTION_SESSION[action] ?? []);
|
|
967
|
-
const entries: SheetEntry[] = looseSessions(sessions, kinds).map((agent) => sessionEntry(agent, sessionLabel(agent.kind, item), open));
|
|
968
|
-
for (const action of item.actions) {
|
|
969
|
-
const kind = ACTION_SESSION[action];
|
|
970
|
-
const label = actionLabel(action, item);
|
|
971
|
-
if (kind) {
|
|
972
|
-
// An action's session takes its line once it runs, so work on it stays in one place [SES-03].
|
|
973
|
-
// Until then it asks first: the card's button is the one-tap start [SES-01, SES-02].
|
|
974
|
-
const running = sessions.filter((agent) => agent.kind === kind);
|
|
975
|
-
if (running.length) entries.push(...running.map((agent) => sessionEntry(agent, sessionLabel(kind, item), open)));
|
|
976
|
-
else entries.push({ key: action, icon: "agent", label: `${label}…`, detail: actionDetail(action as Exclude<ActionId, "rerun">, item), onPress: withOptions(label, kind) });
|
|
977
|
-
} else if (action === "rerun") {
|
|
978
|
-
entries.push(rerunEntry(label, details, (runIds) => close(() => actions.rerun(item, runIds))()));
|
|
979
|
-
} else {
|
|
980
|
-
// Closing it sits apart, below the work, with Dismiss [ATT-06].
|
|
981
|
-
entries.push({ key: action, icon: ACTION_ICONS[action], label, detail: actionDetail(action, item), housekeeping: action === "close", onPress: () => onPerform(action) });
|
|
982
|
-
}
|
|
983
|
-
}
|
|
984
|
-
// Anything Attention Span doesn't cover [ATT-12], with an issue's PR beside it: the one its actions apply to, or in
|
|
985
|
-
// History, where an issue is its own target, the first of the PRs that closed it.
|
|
986
|
-
const pr = targetUrl(item) && item.target.kind === "pr" ? item.target : item.kind === "issue" && item.children[0] ? item.children[0] : undefined;
|
|
987
|
-
entries.push(githubEntry(item, (url) => close(() => void openExternalUrl(url))(), pr));
|
|
988
|
-
// Nothing's left to start on once it's merged or closed, or out of my hands; a note is cleared with Got it, not dismissed [HIS-07].
|
|
989
|
-
if (!item.closedAt && !item.change) entries.push(startAnotherEntry(sessions.length > 0, withOptions("Start session", fallbackKind(item))));
|
|
990
|
-
if (inDoing && !item.change) entries.push({ key: "dismiss", icon: "dismiss", label: "Dismiss", detail: "Hides it until something new happens on it", housekeeping: true, onPress: close(() => actions.dismiss(item)) });
|
|
991
|
-
return entries;
|
|
992
|
-
}
|
|
993
|
-
|
|
994
|
-
// A session is named for what started it; one of no kind, or a Start's, just continues.
|
|
995
|
-
const sessionLabel = (kind: SessionKind | undefined, item: Item) => (kind && kind !== "start" ? actionLabel(kind, item) : "Continue session");
|
|
996
|
-
|
|
997
|
-
// Pick which waiting comments get a 👍, after reading them in full; all are picked to start [MEN-07].
|
|
998
|
-
function AcknowledgeSheet({ item, onReact, onClose }: { item: Item; onReact: (ids: string[]) => void; onClose: () => void }) {
|
|
999
|
-
const styles = useStyles();
|
|
1000
|
-
const comments = item.person?.comments ?? [];
|
|
1001
|
-
const [picked, setPicked] = useState(() => new Set(comments.map((c) => c.id)));
|
|
1002
|
-
const toggle = (id: string) => setPicked((now) => (now.has(id) ? new Set([...now].filter((other) => other !== id)) : new Set([...now, id])));
|
|
1003
|
-
return (
|
|
1004
|
-
<Modal title={`Acknowledge: ${item.title}`} open onOpenChange={(open) => (open ? null : onClose())}>
|
|
1005
|
-
<Modal.Content>
|
|
1006
|
-
<KeepStyles styles={styles}>
|
|
1007
|
-
<View style={styles.row}>
|
|
1008
|
-
<TablerIcon name="thumbUp" size={14} />
|
|
1009
|
-
<Text style={[styles.muted, { flexShrink: 1 }]}>Tells them you've seen it, and clears it from your list.</Text>
|
|
1010
|
-
</View>
|
|
1011
|
-
{comments.map((c) => (
|
|
1012
|
-
<Pressable
|
|
1013
|
-
key={c.id}
|
|
1014
|
-
accessibilityRole="checkbox"
|
|
1015
|
-
accessibilityState={{ checked: picked.has(c.id) }}
|
|
1016
|
-
accessibilityLabel={`Comment from ${c.author}`}
|
|
1017
|
-
onPress={() => toggle(c.id)}
|
|
1018
|
-
style={[styles.quote, styles.row, { alignItems: "flex-start", gap: 10 }]}
|
|
1019
|
-
>
|
|
1020
|
-
<TablerIcon name={picked.has(c.id) ? "squareCheck" : "square"} size={18} color={picked.has(c.id) ? styles.action : styles.c.foregroundMuted} />
|
|
1021
|
-
<View style={{ flex: 1, gap: 4 }}>
|
|
1022
|
-
<Text style={{ color: styles.c.foreground, fontSize: 12, fontWeight: "600" }}>
|
|
1023
|
-
{c.author} <Text style={[styles.muted, { fontWeight: "400" }]}>· {ago(c.createdAt)}</Text>
|
|
1024
|
-
</Text>
|
|
1025
|
-
<Markdown>{c.body}</Markdown>
|
|
1026
|
-
</View>
|
|
1027
|
-
</Pressable>
|
|
1028
|
-
))}
|
|
1029
|
-
<View style={styles.wrap}>
|
|
1030
|
-
<Button
|
|
1031
|
-
label={`${picked.size} comment${picked.size === 1 ? "" : "s"}`}
|
|
1032
|
-
icon="thumbUp"
|
|
1033
|
-
accessibilityLabel={`Acknowledge ${picked.size} comment${picked.size === 1 ? "" : "s"}`}
|
|
1034
|
-
variant="solid"
|
|
1035
|
-
disabled={picked.size === 0}
|
|
1036
|
-
onPress={() => onReact(comments.filter((c) => picked.has(c.id)).map((c) => c.id))}
|
|
1037
|
-
/>
|
|
1038
|
-
<Button label="Cancel" onPress={onClose} />
|
|
1039
|
-
</View>
|
|
1040
|
-
</KeepStyles>
|
|
1041
|
-
</Modal.Content>
|
|
1042
|
-
</Modal>
|
|
1043
|
-
);
|
|
1044
|
-
}
|
|
1045
|
-
|
|
1046
|
-
// Who should review a PR: GitHub's suggestions, who reviewed my other PRs in the repo, its teams, or anyone typed in.
|
|
1047
|
-
// All start unticked; requesting keeps whoever is already asked [PRS-12].
|
|
1048
|
-
function ReviewerSheet({
|
|
1049
|
-
item,
|
|
1050
|
-
afterReady,
|
|
1051
|
-
fetchReviewers,
|
|
1052
|
-
onRequest,
|
|
1053
|
-
onClose,
|
|
1054
|
-
}: {
|
|
1055
|
-
item: Item;
|
|
1056
|
-
afterReady: boolean;
|
|
1057
|
-
fetchReviewers: FetchReviewers;
|
|
1058
|
-
onRequest: (reviewers: string[]) => void;
|
|
1059
|
-
onClose: () => void;
|
|
1060
|
-
}) {
|
|
1061
|
-
const styles = useStyles();
|
|
1062
|
-
const choices = useQuery({ queryKey: ["attention-span", "reviewers", item.target.repo, item.target.number], queryFn: () => fetchReviewers({ target: item.target }), staleTime: 60_000 });
|
|
1063
|
-
const [picked, setPicked] = useState<ReadonlySet<string>>(new Set());
|
|
1064
|
-
const [typed, setTyped] = useState<Reviewer[]>([]);
|
|
1065
|
-
const [text, setText] = useState("");
|
|
1066
|
-
const toggle = (login: string) => setPicked((now) => (now.has(login) ? new Set([...now].filter((other) => other !== login)) : new Set([...now, login])));
|
|
1067
|
-
// Each person or team once, in the first group that has them.
|
|
1068
|
-
const seen = new Set<string>();
|
|
1069
|
-
const once = (list: Reviewer[]) => list.filter((reviewer) => !seen.has(reviewer.login.toLowerCase()) && seen.add(reviewer.login.toLowerCase()));
|
|
1070
|
-
const groups = [
|
|
1071
|
-
{ title: "Added", list: once(typed) },
|
|
1072
|
-
{ title: "Suggested by GitHub", list: once(choices.data?.suggested ?? []) },
|
|
1073
|
-
{ title: "Recent on your PRs here", list: once(choices.data?.recent ?? []) },
|
|
1074
|
-
{ title: "Teams", list: once(choices.data?.teams ?? []) },
|
|
1075
|
-
];
|
|
1076
|
-
const add = () => {
|
|
1077
|
-
const login = text.trim().replace(/^@/, "");
|
|
1078
|
-
if (!login) return;
|
|
1079
|
-
setTyped((now) => [...now, { login, team: login.includes("/") }]);
|
|
1080
|
-
setPicked((now) => new Set([...now, login]));
|
|
1081
|
-
setText("");
|
|
1082
|
-
};
|
|
1083
|
-
const count = `${picked.size} reviewer${picked.size === 1 ? "" : "s"}`;
|
|
1084
|
-
return (
|
|
1085
|
-
<Modal title={`${afterReady ? "Ready for review" : "Request review"}: ${item.title}`} open onOpenChange={(open) => (open ? null : onClose())}>
|
|
1086
|
-
<Modal.Content>
|
|
1087
|
-
<KeepStyles styles={styles}>
|
|
1088
|
-
<Text style={styles.muted}>{afterReady ? `PR ${item.target.number} is out of draft. Who should review it?` : `Who should review PR ${item.target.number}?`}</Text>
|
|
1089
|
-
{choices.isLoading ? <Loading text="Loading suggestions…" /> : null}
|
|
1090
|
-
{choices.error ? <Text style={styles.danger}>Couldn't load suggestions: {(choices.error as Error).message}</Text> : null}
|
|
1091
|
-
{groups.map(({ title, list }) =>
|
|
1092
|
-
list.length > 0 ? (
|
|
1093
|
-
<View key={title} style={{ gap: 4 }}>
|
|
1094
|
-
<Text style={[styles.muted, { fontSize: 12 }]}>{title}</Text>
|
|
1095
|
-
{list.map((reviewer) => (
|
|
1096
|
-
<Pressable
|
|
1097
|
-
key={reviewer.login}
|
|
1098
|
-
accessibilityRole="checkbox"
|
|
1099
|
-
accessibilityState={{ checked: picked.has(reviewer.login) }}
|
|
1100
|
-
accessibilityLabel={reviewer.login}
|
|
1101
|
-
onPress={() => toggle(reviewer.login)}
|
|
1102
|
-
style={[styles.row, { paddingVertical: 4 }]}
|
|
1103
|
-
>
|
|
1104
|
-
<TablerIcon name={picked.has(reviewer.login) ? "squareCheck" : "square"} size={18} color={picked.has(reviewer.login) ? styles.action : styles.c.foregroundMuted} />
|
|
1105
|
-
{reviewer.team ? <TablerIcon name="claim" size={18} color={styles.c.foregroundMuted} /> : <Avatar url={reviewer.avatarUrl} />}
|
|
1106
|
-
<Text style={{ color: styles.c.foreground, fontSize: 13 }}>{reviewer.login}</Text>
|
|
1107
|
-
</Pressable>
|
|
1108
|
-
))}
|
|
1109
|
-
</View>
|
|
1110
|
-
) : null,
|
|
1111
|
-
)}
|
|
1112
|
-
{choices.data?.teamsNote ? <Text style={styles.muted}>{choices.data.teamsNote}</Text> : null}
|
|
1113
|
-
<View style={styles.row}>
|
|
1114
|
-
<TextInput
|
|
1115
|
-
style={[styles.input, { flex: 1 }]}
|
|
1116
|
-
placeholder="Login, or org/team"
|
|
1117
|
-
placeholderTextColor={styles.c.foregroundMuted}
|
|
1118
|
-
value={text}
|
|
1119
|
-
onChangeText={setText}
|
|
1120
|
-
onSubmitEditing={add}
|
|
1121
|
-
autoCapitalize="none"
|
|
1122
|
-
autoCorrect={false}
|
|
1123
|
-
/>
|
|
1124
|
-
<Button label="Add" variant="calm" disabled={!text.trim()} onPress={add} />
|
|
1125
|
-
</View>
|
|
1126
|
-
<View style={styles.wrap}>
|
|
1127
|
-
<Button
|
|
1128
|
-
label={`Request ${count}`}
|
|
1129
|
-
icon="claim"
|
|
1130
|
-
variant="solid"
|
|
1131
|
-
disabled={picked.size === 0}
|
|
1132
|
-
onPress={() => onRequest([...picked])}
|
|
1133
|
-
/>
|
|
1134
|
-
<Button label={afterReady ? "Skip" : "Cancel"} onPress={onClose} />
|
|
1135
|
-
</View>
|
|
1136
|
-
</KeepStyles>
|
|
1137
|
-
</Modal.Content>
|
|
1138
|
-
</Modal>
|
|
1139
|
-
);
|
|
1140
|
-
}
|
|
1141
|
-
|
|
1142
|
-
// What a face on a card is to it, where no quote says it: the icon of the tab or section that means the same, so whom I wait on
|
|
1143
|
-
// reads like Waiting, and whose comments are left like Changes requested [ATT-19].
|
|
1144
|
-
const ROLE_ICON: Record<PersonRole | "waiting", IconName> = { waiting: "hourglass", author: "pencil", changes: "changes" };
|
|
1145
|
-
|
|
1146
|
-
// The icon sits tight against the faces it explains, apart from the name and time, so they read as one.
|
|
1147
|
-
function Badged({ role, children }: { role: keyof typeof ROLE_ICON; children: ReactNode }) {
|
|
1148
|
-
const styles = useStyles();
|
|
1149
|
-
return (
|
|
1150
|
-
<View style={{ flexDirection: "row", alignItems: "center", gap: 2 }}>
|
|
1151
|
-
<TablerIcon name={ROLE_ICON[role]} size={16} color={styles.c.foregroundMuted} />
|
|
1152
|
-
{children}
|
|
1153
|
-
</View>
|
|
1154
|
-
);
|
|
1155
|
-
}
|
|
1156
|
-
|
|
1157
|
-
// Who is waiting on me, or who I'm waiting on.
|
|
1158
|
-
function PersonQuote({ person, expanded }: { person: NonNullable<Item["person"]>; expanded: boolean }) {
|
|
1159
|
-
const styles = useStyles();
|
|
1160
|
-
const name = <Text style={{ color: styles.c.foreground, fontSize: 12, fontWeight: "600" }}>{person.login}</Text>;
|
|
1161
|
-
// An author line says who, not when: its time meant something different on each tab [ATT-19].
|
|
1162
|
-
if (!person.snippet && person.role) {
|
|
1163
|
-
const text = person.role === "author" ? `Opened by ${person.login}` : `${person.login}'s comments are left to address, since your last push ${ago(person.since)} ago`;
|
|
1164
|
-
return (
|
|
1165
|
-
<Hint text={text}>
|
|
1166
|
-
<View style={styles.row}>
|
|
1167
|
-
<Badged role={person.role}>
|
|
1168
|
-
<Avatar url={person.avatarUrl} bot={person.bot} />
|
|
1169
|
-
</Badged>
|
|
1170
|
-
{name}
|
|
1171
|
-
{person.role === "author" ? null : <Text style={styles.muted}>· {ago(person.since)}</Text>}
|
|
1172
|
-
</View>
|
|
1173
|
-
</Hint>
|
|
1174
|
-
);
|
|
1175
|
-
}
|
|
1176
|
-
const line = (
|
|
1177
|
-
<View style={styles.row}>
|
|
1178
|
-
<Avatar url={person.avatarUrl} bot={person.bot} />
|
|
1179
|
-
{name}
|
|
1180
|
-
<Text style={styles.muted}>· {ago(person.since)}</Text>
|
|
1181
|
-
</View>
|
|
1182
|
-
);
|
|
1183
|
-
if (!person.snippet) return line;
|
|
1184
|
-
return (
|
|
1185
|
-
<View style={styles.quote}>
|
|
1186
|
-
{line}
|
|
1187
|
-
<Text style={{ color: styles.c.foreground, fontSize: 13, lineHeight: 18 }} numberOfLines={expanded ? undefined : 2}>
|
|
1188
|
-
{person.snippet}
|
|
1189
|
-
</Text>
|
|
1190
|
-
</View>
|
|
1191
|
-
);
|
|
1192
|
-
}
|
|
1193
|
-
|
|
1194
|
-
// Pictures on a card before the rest are counted, so a crowd fits a phone; the sheet names everyone.
|
|
1195
|
-
const MAX_FACES = 5;
|
|
1196
|
-
|
|
1197
|
-
// Who my work waits on: one by name, several by picture, named on hover, and each by name in the sheet [WAI-02].
|
|
1198
|
-
// On an issue they're who my question tagged; on a PR, reviewers since my last push or reply [WAI-02, ATT-19].
|
|
1199
|
-
function WaitingOnLine({ people, asked, expanded }: { people: WaitingOn[]; asked: boolean; expanded: boolean }) {
|
|
1200
|
-
const styles = useStyles();
|
|
1201
|
-
const [hovered, setHovered] = useState<string | null>(null);
|
|
1202
|
-
const name = (login: string) => (
|
|
1203
|
-
<Text style={{ color: styles.c.foreground, fontSize: 12, fontWeight: "600", flexShrink: 1 }} numberOfLines={1}>
|
|
1204
|
-
{login}
|
|
1205
|
-
</Text>
|
|
1206
|
-
);
|
|
1207
|
-
const since = (at: string) => <Text style={styles.muted}>· {ago(at)}</Text>;
|
|
1208
|
-
const explain = (logins: string[], at: string) => `Waiting on ${logins.join(", ")} since ${asked ? "you asked" : "your last push or reply"}, ${ago(at)} ago`;
|
|
1209
|
-
if (expanded || people.length === 1) {
|
|
1210
|
-
return (
|
|
1211
|
-
<View style={{ gap: 6 }}>
|
|
1212
|
-
{people.map((who) => (
|
|
1213
|
-
<Hint key={who.login} text={explain([who.login], who.since)}>
|
|
1214
|
-
<View style={styles.row}>
|
|
1215
|
-
<Badged role="waiting">
|
|
1216
|
-
<Avatar url={who.avatarUrl} team={who.team} />
|
|
1217
|
-
</Badged>
|
|
1218
|
-
{name(who.login)}
|
|
1219
|
-
{since(who.since)}
|
|
1220
|
-
</View>
|
|
1221
|
-
</Hint>
|
|
1222
|
-
))}
|
|
1223
|
-
</View>
|
|
1224
|
-
);
|
|
1225
|
-
}
|
|
1226
|
-
const earliest = people.map((who) => who.since).sort()[0];
|
|
1227
|
-
return (
|
|
1228
|
-
<Hint text={explain(people.map((who) => who.login), earliest)}>
|
|
1229
|
-
<View style={styles.row}>
|
|
1230
|
-
<Badged role="waiting">
|
|
1231
|
-
<View style={{ flexDirection: "row", alignItems: "center", gap: 4 }}>
|
|
1232
|
-
{people.slice(0, MAX_FACES).map((who) => (
|
|
1233
|
-
<View key={who.login} onPointerEnter={() => setHovered(who.login)} onPointerLeave={() => setHovered((current) => (current === who.login ? null : current))}>
|
|
1234
|
-
<Avatar url={who.avatarUrl} team={who.team} />
|
|
1235
|
-
</View>
|
|
1236
|
-
))}
|
|
1237
|
-
{people.length > MAX_FACES ? <Text style={styles.muted}>+{people.length - MAX_FACES}</Text> : null}
|
|
1238
|
-
</View>
|
|
1239
|
-
</Badged>
|
|
1240
|
-
{hovered ? name(hovered) : null}
|
|
1241
|
-
{since(earliest)}
|
|
1242
|
-
</View>
|
|
1243
|
-
</Hint>
|
|
1244
|
-
);
|
|
1245
|
-
}
|
|
1246
|
-
|
|
1247
316
|
function Sections({ sections, actions }: { sections: Section[]; actions: Actions }) {
|
|
1248
317
|
return sections.map((section) => (
|
|
1249
318
|
<View key={section.id}>
|
|
@@ -1253,16 +322,6 @@ function Sections({ sections, actions }: { sections: Section[]; actions: Actions
|
|
|
1253
322
|
));
|
|
1254
323
|
}
|
|
1255
324
|
|
|
1256
|
-
function Card({ items, actions, group }: { items: Item[]; actions: Actions; group?: WaitingGroup }) {
|
|
1257
|
-
return (
|
|
1258
|
-
<CardList>
|
|
1259
|
-
{items.map((item, index) => (
|
|
1260
|
-
<ItemRow key={item.key} item={item} first={index === 0} actions={actions} group={group} />
|
|
1261
|
-
))}
|
|
1262
|
-
</CardList>
|
|
1263
|
-
);
|
|
1264
|
-
}
|
|
1265
|
-
|
|
1266
325
|
// Waiting by who it waits on, each with a list to copy for a nudge, oldest first; a bot gets none, as there's nobody to send
|
|
1267
326
|
// it to. Last, the work no person holds up. Cards with an active session lead their group [WAI-01, WAI-03].
|
|
1268
327
|
function Waiting({ groups, actions }: { groups: WaitingGroup[]; actions: Actions }) {
|
|
@@ -1294,164 +353,3 @@ function Waiting({ groups, actions }: { groups: WaitingGroup[]; actions: Actions
|
|
|
1294
353
|
});
|
|
1295
354
|
}
|
|
1296
355
|
|
|
1297
|
-
// Stacked or linked PRs as a connected line; collapsed, only those needing attention [ATT-03, ATT-04].
|
|
1298
|
-
// In the sheet each row opens its PR on GitHub [ATT-12], and the PR an issue's actions apply to is tinted and says so [ATT-06].
|
|
1299
|
-
function StackLine({ rows, merged, links = false, target }: { rows: SubRow[]; merged: boolean; links?: boolean; target?: string }) {
|
|
1300
|
-
const styles = useStyles();
|
|
1301
|
-
return (
|
|
1302
|
-
<View>
|
|
1303
|
-
{rows.map((row, index) => (
|
|
1304
|
-
<StackRow key={row.key} url={row.url} number={row.number} link={links} target={row.key === target}>
|
|
1305
|
-
<View style={{ width: 16, alignItems: "center" }}>
|
|
1306
|
-
<View style={{ width: 2, flex: 1, backgroundColor: index === 0 ? "transparent" : styles.c.border }} />
|
|
1307
|
-
<TablerIcon name={merged ? "merge" : row.draft ? "draft" : "pr"} size={14} color={merged ? styles.c.statusSuccess : row.draft ? styles.c.foregroundMuted : styles.c.statusSuccess} />
|
|
1308
|
-
<View style={{ width: 2, flex: 1, backgroundColor: index === rows.length - 1 ? "transparent" : styles.c.border }} />
|
|
1309
|
-
</View>
|
|
1310
|
-
<View style={{ flex: 1, paddingVertical: 3, gap: 2 }}>
|
|
1311
|
-
<Text style={{ color: styles.c.foreground, fontSize: 13 }} numberOfLines={1}>
|
|
1312
|
-
{row.title}
|
|
1313
|
-
</Text>
|
|
1314
|
-
<View style={[styles.wrap, { columnGap: 10, rowGap: 2 }]}>
|
|
1315
|
-
<Meta lead={<NumberText number={row.number} />} facts={merged && row.mergedBy ? [`merged by ${row.mergedBy}`] : []} chips={row.chips} />
|
|
1316
|
-
{row.key === target ? <Text style={{ color: styles.action, fontSize: 12, fontWeight: "600" }}>actions apply here</Text> : null}
|
|
1317
|
-
</View>
|
|
1318
|
-
</View>
|
|
1319
|
-
{links ? (
|
|
1320
|
-
<View style={{ justifyContent: "center", paddingHorizontal: 4 }}>
|
|
1321
|
-
<TablerIcon name="github" size={14} color={styles.c.foregroundMuted} />
|
|
1322
|
-
</View>
|
|
1323
|
-
) : null}
|
|
1324
|
-
</StackRow>
|
|
1325
|
-
))}
|
|
1326
|
-
</View>
|
|
1327
|
-
);
|
|
1328
|
-
}
|
|
1329
|
-
|
|
1330
|
-
function StackRow({ url, number, link, target = false, children }: { url: string; number: number; link: boolean; target?: boolean; children: ReactNode }) {
|
|
1331
|
-
const styles = useStyles();
|
|
1332
|
-
const { hovered, hover } = useHover();
|
|
1333
|
-
const tinted = target ? { backgroundColor: tint(styles.action, 0.1), borderRadius: 6 } : null;
|
|
1334
|
-
if (!link) return <View style={[styles.row, { alignItems: "stretch" }, tinted]}>{children}</View>;
|
|
1335
|
-
return (
|
|
1336
|
-
<Pressable
|
|
1337
|
-
accessibilityRole="link"
|
|
1338
|
-
accessibilityLabel={`Open PR #${number} on GitHub`}
|
|
1339
|
-
onPress={() => void openExternalUrl(url)}
|
|
1340
|
-
{...hover}
|
|
1341
|
-
style={({ pressed }) => [styles.row, { alignItems: "stretch", borderRadius: 6, backgroundColor: pressed || hovered ? styles.c.surface2 : target ? tint(styles.action, 0.1) : "transparent" }]}
|
|
1342
|
-
>
|
|
1343
|
-
{children}
|
|
1344
|
-
</Pressable>
|
|
1345
|
-
);
|
|
1346
|
-
}
|
|
1347
|
-
|
|
1348
|
-
// Session options in a modal: a bottom sheet on phones [SES-02].
|
|
1349
|
-
function SessionOptions({ spec, actions, onClose }: { spec: OptionsSpec; actions: Actions; onClose: () => void }) {
|
|
1350
|
-
const styles = useStyles();
|
|
1351
|
-
const paseo = usePaseo();
|
|
1352
|
-
const toast = useToast();
|
|
1353
|
-
const { itemKey, kind, target } = spec;
|
|
1354
|
-
const options = useQuery({
|
|
1355
|
-
queryKey: ["attention-span", "options", itemKey, kind],
|
|
1356
|
-
queryFn: async () => {
|
|
1357
|
-
const [{ context }, profiles, checkout, defaults] = await Promise.all([
|
|
1358
|
-
actions.fetchContext({ kind, target }),
|
|
1359
|
-
listProfiles(paseo),
|
|
1360
|
-
findCheckout(paseo, actions.config, target, actions.defaultBranch),
|
|
1361
|
-
// Without a ready provider, still show the options; starting reports the error.
|
|
1362
|
-
resolveAgentConfig(paseo, actions.fetchProviders, kind, actions.config).catch(() => ({ label: "No agent provider is ready" })),
|
|
1363
|
-
]);
|
|
1364
|
-
const workspaces = checkout.project ? await branchWorkspaces(paseo, checkout.project.projectId, checkoutPr(kind, target).head) : [];
|
|
1365
|
-
return { prompt: renderPrompt(kind, target, context, actions.config), profiles, checkout, workspaces, defaultLabel: defaults.label };
|
|
1366
|
-
},
|
|
1367
|
-
staleTime: 60_000,
|
|
1368
|
-
});
|
|
1369
|
-
const [workspaceId, setWorkspaceId] = useState<string>();
|
|
1370
|
-
const [profileId, setProfileId] = useState<string>();
|
|
1371
|
-
const [prompt, setPrompt] = useState<string | null>(null);
|
|
1372
|
-
const [starting, setStarting] = useState(false);
|
|
1373
|
-
const data = options.data;
|
|
1374
|
-
|
|
1375
|
-
async function start() {
|
|
1376
|
-
if (!data) return;
|
|
1377
|
-
setStarting(true);
|
|
1378
|
-
try {
|
|
1379
|
-
await spec.before?.();
|
|
1380
|
-
await actions.started(await startSession(paseo, { itemKey, kind, target, prompt: prompt ?? data.prompt, config: actions.config, fetchProviders: actions.fetchProviders, checkout: data.checkout, profileId, workspaceId }));
|
|
1381
|
-
onClose();
|
|
1382
|
-
} catch (error) {
|
|
1383
|
-
toast.error(`Starting the session failed: ${(error as Error).message}`);
|
|
1384
|
-
} finally {
|
|
1385
|
-
setStarting(false);
|
|
1386
|
-
}
|
|
1387
|
-
}
|
|
1388
|
-
|
|
1389
|
-
return (
|
|
1390
|
-
<Modal title={spec.title} open onOpenChange={(open) => (open ? null : onClose())}>
|
|
1391
|
-
<Modal.Content>
|
|
1392
|
-
<KeepStyles styles={styles}>
|
|
1393
|
-
{options.isLoading ? <Loading text="Loading context…" /> : null}
|
|
1394
|
-
{!options.isLoading && !data ? <Text style={styles.danger}>{(options.error as Error)?.message ?? "No options"}</Text> : null}
|
|
1395
|
-
{data && !data.checkout.project ? <Text style={styles.danger}>{noProjectMessage(data.checkout, target)}</Text> : null}
|
|
1396
|
-
{data?.checkout.project ? (
|
|
1397
|
-
<View style={{ gap: 10 }}>
|
|
1398
|
-
<Text style={styles.muted}>Workspace</Text>
|
|
1399
|
-
<View style={styles.wrap}>
|
|
1400
|
-
<Toggle label="New worktree" active={!workspaceId} onPress={() => setWorkspaceId(undefined)} />
|
|
1401
|
-
{data.workspaces.map((w) => (
|
|
1402
|
-
<Toggle key={w.id} label={w.name} active={workspaceId === w.id} onPress={() => setWorkspaceId(w.id)} />
|
|
1403
|
-
))}
|
|
1404
|
-
</View>
|
|
1405
|
-
<Text style={styles.muted}>Agent profile</Text>
|
|
1406
|
-
<View style={styles.wrap}>
|
|
1407
|
-
<Toggle label={data.defaultLabel} active={!profileId} onPress={() => setProfileId(undefined)} />
|
|
1408
|
-
{data.profiles.map((p) => (
|
|
1409
|
-
<Toggle key={p.id} label={p.name} active={profileId === p.id} onPress={() => setProfileId(p.id)} />
|
|
1410
|
-
))}
|
|
1411
|
-
</View>
|
|
1412
|
-
<Text style={styles.muted}>Prompt</Text>
|
|
1413
|
-
<TextInput style={[styles.input, { minHeight: 180 }]} value={prompt ?? data.prompt} onChangeText={setPrompt} multiline textAlignVertical="top" />
|
|
1414
|
-
<View style={styles.wrap}>
|
|
1415
|
-
<Button label={starting ? "Starting…" : "Start session"} icon="agent" variant="solid" disabled={starting} onPress={() => void start()} />
|
|
1416
|
-
<Button label="Cancel" onPress={onClose} />
|
|
1417
|
-
</View>
|
|
1418
|
-
</View>
|
|
1419
|
-
) : null}
|
|
1420
|
-
</KeepStyles>
|
|
1421
|
-
</Modal.Content>
|
|
1422
|
-
</Modal>
|
|
1423
|
-
);
|
|
1424
|
-
}
|
|
1425
|
-
|
|
1426
|
-
// Where an issue repo's code lives, picked from my Paseo projects and saved to config.json [SES-07].
|
|
1427
|
-
function CodeRepoPicker({ issueRepo, missing, onPick, onClose }: { issueRepo: string; missing: string; onPick: (repo: string) => void; onClose: () => void }) {
|
|
1428
|
-
const styles = useStyles();
|
|
1429
|
-
const paseo = usePaseo();
|
|
1430
|
-
const projects = useQuery({ queryKey: ["attention-span", "github-projects"], queryFn: () => githubProjects(paseo) });
|
|
1431
|
-
return (
|
|
1432
|
-
<Modal title={`Where does the code for ${issueRepo} live?`} open onOpenChange={(open) => (open ? null : onClose())}>
|
|
1433
|
-
<Modal.Content>
|
|
1434
|
-
<KeepStyles styles={styles}>
|
|
1435
|
-
<View style={{ gap: 10 }}>
|
|
1436
|
-
<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>
|
|
1437
|
-
{projects.isLoading ? <Loading text="Loading projects…" /> : null}
|
|
1438
|
-
{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}
|
|
1439
|
-
<View style={styles.wrap}>
|
|
1440
|
-
{projects.data?.map((project) => (
|
|
1441
|
-
<Button key={project.projectId} label={project.repo} icon="play" variant="calm" onPress={() => onPick(project.repo)} />
|
|
1442
|
-
))}
|
|
1443
|
-
</View>
|
|
1444
|
-
<Text style={styles.muted}>Saved to codeRepos in config.json, so the next start goes straight there.</Text>
|
|
1445
|
-
<View style={styles.wrap}>
|
|
1446
|
-
<Button label="Cancel" onPress={onClose} />
|
|
1447
|
-
</View>
|
|
1448
|
-
</View>
|
|
1449
|
-
</KeepStyles>
|
|
1450
|
-
</Modal.Content>
|
|
1451
|
-
</Modal>
|
|
1452
|
-
);
|
|
1453
|
-
}
|
|
1454
|
-
|
|
1455
|
-
function issueTarget(issue: NextUpIssue): Target {
|
|
1456
|
-
return { kind: "issue", repo: issue.repo, number: issue.number, title: issue.title, url: issue.url, defaultBranch: issue.defaultBranch };
|
|
1457
|
-
}
|