@andrioid/paseo-attention-span 0.2.1 → 0.3.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 +11 -7
- package/client/attention-screen.tsx +182 -79
- package/client/card.tsx +5 -15
- package/client/coverage-settings.tsx +35 -4
- package/client/feedback.tsx +173 -0
- package/client/host.ts +8 -0
- package/client/icons.ts +3 -2
- package/client/next-up.tsx +29 -45
- package/client/session-menu.ts +18 -26
- package/client/sessions.ts +5 -2
- package/client/sheet.tsx +17 -72
- package/client/ui.tsx +0 -49
- package/docs/architecture.md +188 -0
- package/docs/screenshots/desktop-dark-doing-acknowledge.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-too-long.png +0 -0
- package/docs/screenshots/desktop-dark-doing.png +0 -0
- package/docs/screenshots/desktop-dark-history-reviewed.png +0 -0
- package/docs/screenshots/desktop-dark-history.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/desktop-dark-setup.png +0 -0
- package/docs/screenshots/desktop-dark-waiting.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 +17 -6
- package/index.server.ts +28 -2
- package/package.json +5 -2
- package/requirements.yaml +128 -0
- package/server/actions.ts +31 -1
- package/server/classify.ts +150 -52
- package/server/feedback.ts +53 -0
- package/server/fixture.ts +48 -16
- package/server/github-types.ts +15 -2
- package/server/queries.ts +15 -4
- package/server/rules.ts +119 -0
- package/server/service.ts +15 -3
- package/server/setup.ts +3 -3
- package/server/store.ts +5 -0
- package/shared/attention.ts +36 -2
- package/shared/config.ts +3 -0
- package/shared/feedback.ts +92 -0
- package/shared/rpc.ts +12 -1
- package/shared/setup.ts +2 -0
- package/docs/screenshots/desktop-dark-doing-session-menu.png +0 -0
package/OVERVIEW.md
CHANGED
|
@@ -6,13 +6,13 @@ There are four tabs. I think of them as a little story: what needs me now, what'
|
|
|
6
6
|
|
|
7
7
|
## Doing: what needs you now
|
|
8
8
|
|
|
9
|
-
This is the one you'll live in. It's split by reason: someone's waiting for your reply, a review's been requested, CI's failing, changes were requested, it's ready to merge, it needs upstream, it's waited too long, or it's one of your drafts.
|
|
9
|
+
This is the one you'll live in. It's split by reason: someone's waiting for your reply, someone answered your question, a review's been requested, CI's failing, changes were requested, it's ready to merge, it needs upstream, it's waited too long, nobody's been asked to review it yet, or it's one of your drafts.
|
|
10
10
|
|
|
11
11
|

|
|
12
12
|
|
|
13
13
|
Each item shows up once, under whichever reason is most urgent. An issue and the PRs that close it count as one item, and so does a stack of PRs. A stack is one change wearing several PRs, so it shouldn't take up five rows.
|
|
14
14
|
|
|
15
|
-
Mentions only count while the person is still waiting for you. Reply or react and it's gone. Team mentions are left out entirely, because "@everyone-in-backend" is not really a question for *me*. And if something's just an FYI, dismiss it. It stays gone until something new happens on it.
|
|
15
|
+
Mentions only count while the person is still waiting for you. Reply or react and it's gone. On your own issues and PRs, a new comment from the last 30 days shows up under **Answered** even if it doesn't tag you. On other people's threads only tags count. The point is to pick out the signal, and most of what happens in threads you once commented on isn't. If you do want those replies, turn on **Follow threads I've commented on** in Settings. Team mentions are left out entirely, because "@everyone-in-backend" is not really a question for *me*. And if something's just an FYI, dismiss it. It stays gone until something new happens on it.
|
|
16
16
|
|
|
17
17
|
Every item has one main button that matches why it's there: Reply, Review, Fix CI, Merge. Open the item and you get every action, each with a line saying what it'll do. I wanted buttons you can press without wondering what's about to happen to your repo.
|
|
18
18
|
|
|
@@ -25,17 +25,21 @@ Some actions start an agent session:
|
|
|
25
25
|
- **Rebase** rebases a PR or a whole stack, and pushes only if there were no conflicts.
|
|
26
26
|
- **Refresh draft** rebases a stale draft and tells you what it still needs. Every draft I've abandoned thanks it.
|
|
27
27
|
|
|
28
|
-
The rest change GitHub right away: rerun failed jobs, update a branch, mark a draft ready, turn on auto-merge, merge, close a draft. Merge and close ask first. **Acknowledge** reacts 👍 to the comments waiting on you, but only after showing you them in full. Thumbs-upping things you haven't read is a hobby, not a workflow.
|
|
28
|
+
The rest change GitHub right away: rerun failed jobs, update a branch, mark a draft ready, request a review, turn on auto-merge, merge, close a draft. Merge and close ask first. **Acknowledge** reacts 👍 to the comments waiting on you, but only after showing you them in full. Thumbs-upping things you haven't read is a hobby, not a workflow.
|
|
29
29
|
|
|
30
30
|

|
|
31
31
|
|
|
32
|
+
A PR you opened isn't waiting on anyone until you've asked someone to review it, so it stays here under **Needs a reviewer**. **Request review** offers GitHub's suggestions, whoever reviewed your other PRs in that repo, and its teams, or you can type a name. Marking a draft ready asks the same question. If nobody reviews in that repo, **Merge** is right there once CI is green.
|
|
33
|
+
|
|
34
|
+

|
|
35
|
+
|
|
32
36
|
Anything that's sat in Waiting for more than three days moves back here under **Waiting too long**. Usually that means someone forgot, and sometimes the someone is me.
|
|
33
37
|
|
|
34
38
|

|
|
35
39
|
|
|
36
40
|
## Waiting: out of your hands
|
|
37
41
|
|
|
38
|
-
This is your work where someone else has the next move: waiting for review, waiting for the reviewer to look again, CI running, or a question you asked that nobody's answered yet.
|
|
42
|
+
This is your work where someone else has the next move: waiting for the review you asked for, waiting for the reviewer to look again, CI running, or a question you asked that nobody's answered yet.
|
|
39
43
|
|
|
40
44
|
There's nothing to do here. That's the point. It's tracked, so you can stop holding it in your head.
|
|
41
45
|
|
|
@@ -71,9 +75,9 @@ There's a copy button per week that gives you a Markdown list of links. That's m
|
|
|
71
75
|
|
|
72
76
|
Actions with an agent icon start a session; the rest change GitHub right away. Where GitHub allows it, an Undo shows up afterwards, because I mis-tap more than I'd like to admit.
|
|
73
77
|
|
|
74
|
-
Sessions run in a worktree of the registered project, or pick up the existing workspace for that branch. They start with the item's context already in the prompt: failing checks, unresolved comments, the issue's discussion. Once an item has a session, its main button opens that session instead of starting another
|
|
78
|
+
Sessions run in a worktree of the registered project, or pick up the existing workspace for that branch. They start with the item's context already in the prompt: failing checks, unresolved comments, the issue's discussion. Once an item has a session, its main button opens that session instead of starting another. Open the item and each session sits where the action that started it was, with its state: working, idle, or needs you. Starting another one is there too, on purpose and out of the way.
|
|
75
79
|
|
|
76
|
-

|
|
77
81
|
|
|
78
82
|
## However you use GitHub
|
|
79
83
|
|
|
@@ -127,7 +131,7 @@ Everything else lives in `~/.config/paseo-attention-span/config.json` on the dae
|
|
|
127
131
|
|
|
128
132
|
## Your data
|
|
129
133
|
|
|
130
|
-
- **GitHub:** it reads your PRs, review requests, mentions and issues through `gh`, limited to the orgs and repos you've configured. By default it refreshes every 15 minutes, which uses
|
|
134
|
+
- **GitHub:** it reads your PRs, review requests, mentions and issues through `gh`, limited to the orgs and repos you've configured. By default it refreshes every 15 minutes, which uses about 7% of GitHub's hourly API allowance. I checked.
|
|
131
135
|
- **Local files:** a cache of what it shows, your dismissals and your Next up filter live in `~/.config/paseo-attention-span/state.json` on the daemon host. That's it.
|
|
132
136
|
- **Agent providers:** when a session starts, the item's context goes into the agent's prompt: descriptions, comments, review threads, failing CI logs. That prompt goes to whichever provider your agent profile uses, so it's worth knowing which one that is.
|
|
133
137
|
|
|
@@ -4,21 +4,23 @@ 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 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";
|
|
7
|
+
import { type ActionId, type AgentSummary, type AttentionView, type Chip, type FailingChecks, type Item, itemSessions, looseSessions, type NextUpIssue, type Reviewer, type Section, type SectionId, SECTIONS, type SubRow, TAB_FEED, type TabId, type Target } from "../shared/attention";
|
|
8
8
|
import { type AttentionConfig, nextUpSources, type SessionKind } from "../shared/config";
|
|
9
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
|
+
import { type FeedbackKind, themeName } from "../shared/feedback";
|
|
12
13
|
import { blocks } from "../shared/setup";
|
|
13
14
|
import { useAttention } from "./data";
|
|
14
15
|
import { CardList, CardRow, type CardProps } from "./card";
|
|
15
16
|
import type { IconName } from "./icons";
|
|
16
17
|
import { NextUpList } from "./next-up";
|
|
17
|
-
import { agentSignal,
|
|
18
|
-
import { ActionSheet, DetailLines, type
|
|
18
|
+
import { agentSignal, sessionEntry, startAnotherEntry } from "./session-menu";
|
|
19
|
+
import { ActionSheet, DetailLines, type SheetEntry } from "./sheet";
|
|
20
|
+
import { FeedbackAsk, FeedbackLine, type FeedbackScreen, FeedbackSheet } from "./feedback";
|
|
19
21
|
import { branchWorkspaces, findCheckout, githubProjects, itemAgents, listProfiles, noProjectMessage, resolveAgentConfig, startSession } from "./sessions";
|
|
20
22
|
import { SetupChecklist } from "./setup";
|
|
21
|
-
import {
|
|
23
|
+
import { Avatar, Button, KeepStyles, Loading, Meta, SectionHeader, SpinningIcon, StylesProvider, TablerIcon, Toggle, useCopy, useHover, useStyles } from "./ui";
|
|
22
24
|
|
|
23
25
|
// The agent icon marks every action that starts an agent session; the rest act on GitHub right away [ATT-13].
|
|
24
26
|
const ACTION_ICONS: Record<ActionId, IconName> = {
|
|
@@ -32,6 +34,7 @@ const ACTION_ICONS: Record<ActionId, IconName> = {
|
|
|
32
34
|
rebase: "agent",
|
|
33
35
|
refresh: "agent",
|
|
34
36
|
ready: "pr",
|
|
37
|
+
request_review: "claim",
|
|
35
38
|
automerge: "clock",
|
|
36
39
|
merge: "merge",
|
|
37
40
|
close: "close",
|
|
@@ -51,6 +54,7 @@ function actionLabel(action: ActionId, item: Item): string {
|
|
|
51
54
|
rebase: stacked ? "Rebase stack" : "Rebase",
|
|
52
55
|
refresh: "Refresh draft",
|
|
53
56
|
ready: "Ready for review",
|
|
57
|
+
request_review: "Request review",
|
|
54
58
|
automerge: "Auto-merge",
|
|
55
59
|
merge: "Merge",
|
|
56
60
|
close: "Close draft",
|
|
@@ -75,7 +79,8 @@ function actionDetail(action: Exclude<ActionId, "rerun">, item: Item): string {
|
|
|
75
79
|
update: `GitHub rebases ${pr} onto ${base}`,
|
|
76
80
|
rebase: `An agent rebases ${stacked ? "the stack" : pr} onto ${base}. It pushes only if there were no conflicts`,
|
|
77
81
|
refresh: `An agent rebases the draft onto ${base} and says what it still needs`,
|
|
78
|
-
ready: `Takes ${pr} out of draft,
|
|
82
|
+
ready: `Takes ${pr} out of draft, then asks who should review it`,
|
|
83
|
+
request_review: `Pick people or teams to review ${pr}`,
|
|
79
84
|
automerge: `GitHub merges ${pr} into ${base} (${target.mergeMethod}) once checks pass`,
|
|
80
85
|
merge: `Merges ${pr} into ${base} (${target.mergeMethod}) now`,
|
|
81
86
|
close: `Closes ${pr}. A comment is posted only if you write one`,
|
|
@@ -98,12 +103,14 @@ function rerunEntry(failing: FailingChecks[] | undefined, loading: boolean): { d
|
|
|
98
103
|
|
|
99
104
|
const SECTION_ICONS: Record<SectionId, IconName> = {
|
|
100
105
|
reply: "reply",
|
|
106
|
+
answered: "replyArrow",
|
|
101
107
|
review: "review",
|
|
102
108
|
ci: "ci",
|
|
103
109
|
changes: "changes",
|
|
104
110
|
ready: "merge",
|
|
105
111
|
upstream: "branch",
|
|
106
112
|
too_long: "hourglass",
|
|
113
|
+
needs_reviewer: "claim",
|
|
107
114
|
drafts: "pencil",
|
|
108
115
|
wait_review: "review",
|
|
109
116
|
wait_reviewer: "replyArrow",
|
|
@@ -124,6 +131,7 @@ const AGENTS_QUERY_KEY = ["attention-span", "agents"] as const;
|
|
|
124
131
|
type FetchContext = (input: RpcInput<typeof rpc.sessionContext>) => Promise<RpcOutput<typeof rpc.sessionContext>>;
|
|
125
132
|
export type FetchDetails = (input: RpcInput<typeof rpc.itemDetails>) => Promise<RpcOutput<typeof rpc.itemDetails>>;
|
|
126
133
|
type DefaultBranch = (repo: string) => Promise<string | null>;
|
|
134
|
+
type FetchReviewers = (input: RpcInput<typeof rpc.reviewerChoices>) => Promise<RpcOutput<typeof rpc.reviewerChoices>>;
|
|
127
135
|
|
|
128
136
|
// A start held back until I say where the issue's code lives [SES-07].
|
|
129
137
|
interface Placing {
|
|
@@ -156,12 +164,16 @@ interface Undoable {
|
|
|
156
164
|
export function AttentionScreen({ theme, layout, navigation, openSettings }: PluginScreenProps & { openSettings?: () => void }) {
|
|
157
165
|
return (
|
|
158
166
|
<StylesProvider theme={theme} compact={layout.compact}>
|
|
159
|
-
<AttentionList navigation={navigation} openSettings={openSettings} />
|
|
167
|
+
<AttentionList navigation={navigation} openSettings={openSettings} device={{ device: layout.compact ? "phone" : "desktop", platform: layout.platform, theme: themeName(theme.colors.surface0) }} />
|
|
160
168
|
</StylesProvider>
|
|
161
169
|
);
|
|
162
170
|
}
|
|
163
171
|
|
|
164
|
-
function AttentionList({
|
|
172
|
+
function AttentionList({
|
|
173
|
+
navigation,
|
|
174
|
+
openSettings,
|
|
175
|
+
device,
|
|
176
|
+
}: Pick<PluginScreenProps, "navigation"> & { openSettings?: () => void; device: Omit<FeedbackScreen, "tab" | "refreshError"> }) {
|
|
165
177
|
const styles = useStyles();
|
|
166
178
|
const paseo = usePaseo();
|
|
167
179
|
const toast = useToast();
|
|
@@ -184,6 +196,8 @@ function AttentionList({ navigation, openSettings }: Pick<PluginScreenProps, "na
|
|
|
184
196
|
const setReady = useRpc(rpc.setReady);
|
|
185
197
|
const setAutoMerge = useRpc(rpc.setAutoMerge);
|
|
186
198
|
const react = useRpc(rpc.react);
|
|
199
|
+
const requestReviewers = useRpc(rpc.requestReviewers);
|
|
200
|
+
const fetchReviewers = useRpc(rpc.reviewerChoices);
|
|
187
201
|
const rerunFailed = useRpc(rpc.rerunFailed);
|
|
188
202
|
const fetchDetails = useRpc(rpc.itemDetails);
|
|
189
203
|
const setCodeRepo = useRpc(rpc.setCodeRepo);
|
|
@@ -195,6 +209,8 @@ function AttentionList({ navigation, openSettings }: Pick<PluginScreenProps, "na
|
|
|
195
209
|
const [undoable, setUndoable] = useState<Undoable[]>([]);
|
|
196
210
|
const [placing, setPlacing] = useState<Placing | null>(null);
|
|
197
211
|
const [options, setOptions] = useState<OptionsSpec | null>(null);
|
|
212
|
+
// The feedback sheet, then the first words for the kind picked in it [FB-01].
|
|
213
|
+
const [feedback, setFeedback] = useState<"sheet" | FeedbackKind | null>(null);
|
|
198
214
|
const view = attention.data;
|
|
199
215
|
// Only when something fails: is it setup, and what's missing [SET-01]?
|
|
200
216
|
const fetchSetup = useRpc(rpc.setupStatus);
|
|
@@ -302,6 +318,7 @@ function AttentionList({ navigation, openSettings }: Pick<PluginScreenProps, "na
|
|
|
302
318
|
login: view.login,
|
|
303
319
|
fetchContext,
|
|
304
320
|
fetchDetails,
|
|
321
|
+
fetchReviewers,
|
|
305
322
|
defaultBranch,
|
|
306
323
|
openAgent,
|
|
307
324
|
started,
|
|
@@ -320,6 +337,14 @@ function AttentionList({ navigation, openSettings }: Pick<PluginScreenProps, "na
|
|
|
320
337
|
},
|
|
321
338
|
// [PRS-09]
|
|
322
339
|
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}`),
|
|
340
|
+
// [PRS-12]
|
|
341
|
+
requestReviewers: (item, reviewers) => {
|
|
342
|
+
const { target } = item;
|
|
343
|
+
const names = reviewers.length === 1 ? reviewers[0] : `${reviewers.length} reviewers`;
|
|
344
|
+
change(item.key, "Request review", () => requestReviewers({ key: item.key, target, reviewers, on: true }), `Asked ${names} to review PR ${target.number}`, () =>
|
|
345
|
+
requestReviewers({ key: item.key, target, reviewers, on: false }),
|
|
346
|
+
);
|
|
347
|
+
},
|
|
323
348
|
// [MEN-07]
|
|
324
349
|
acknowledge: (item, ids) =>
|
|
325
350
|
change(item.key, "Acknowledge", () => react({ key: item.key, subjectIds: ids, on: true }), `Acknowledged ${ids.length === 1 ? "a comment" : `${ids.length} comments`} on #${item.number}`, () =>
|
|
@@ -446,6 +471,18 @@ function AttentionList({ navigation, openSettings }: Pick<PluginScreenProps, "na
|
|
|
446
471
|
}}
|
|
447
472
|
/>
|
|
448
473
|
) : null}
|
|
474
|
+
<FeedbackLine onPress={() => setFeedback("sheet")} />
|
|
475
|
+
{feedback === "sheet" ? <FeedbackSheet agents={actions.agents} onOpenAgent={openAgent} onAsk={setFeedback} onClose={() => setFeedback(null)} /> : null}
|
|
476
|
+
{feedback && feedback !== "sheet" ? (
|
|
477
|
+
<FeedbackAsk
|
|
478
|
+
kind={feedback}
|
|
479
|
+
config={view.config}
|
|
480
|
+
screen={{ ...device, tab, refreshError: feed.error ?? null }}
|
|
481
|
+
onStarted={started}
|
|
482
|
+
onBack={() => setFeedback("sheet")}
|
|
483
|
+
onClose={() => setFeedback(null)}
|
|
484
|
+
/>
|
|
485
|
+
) : null}
|
|
449
486
|
{options ? <SessionOptions spec={options} actions={actions} onClose={() => setOptions(null)} /> : null}
|
|
450
487
|
{placing ? <CodeRepoPicker issueRepo={placing.target.repo} missing={placing.missing} onPick={place} onClose={() => setPlacing(null)} /> : null}
|
|
451
488
|
</ScrollView>
|
|
@@ -479,8 +516,10 @@ interface Actions {
|
|
|
479
516
|
login: string | null;
|
|
480
517
|
fetchContext: FetchContext;
|
|
481
518
|
fetchDetails: FetchDetails;
|
|
519
|
+
fetchReviewers: FetchReviewers;
|
|
482
520
|
defaultBranch: DefaultBranch;
|
|
483
521
|
act: (item: Item, action: ActionId) => void;
|
|
522
|
+
requestReviewers: (item: Item, reviewers: string[]) => void;
|
|
484
523
|
rerun: (item: Item, runIds: number[]) => void;
|
|
485
524
|
acknowledge: (item: Item, commentIds: string[]) => void;
|
|
486
525
|
confirm: (item: Item, action: "merge" | "close", comment?: string) => void;
|
|
@@ -496,11 +535,11 @@ function stateMark(item: Item): CardProps["mark"] {
|
|
|
496
535
|
return item.draft ? { icon: "draft", tone: "neutral" } : { icon: "pr", tone: "good" };
|
|
497
536
|
}
|
|
498
537
|
|
|
499
|
-
// A card that works collapsed: its main action and
|
|
538
|
+
// A card that works collapsed: its main action and ›. Tapping it opens the sheet with everything else [ATT-05, ATT-06].
|
|
500
539
|
const isRed = (chips: Chip[]) => chips.some((chip) => chip.tone === "bad");
|
|
501
540
|
|
|
502
|
-
// The sheet, Acknowledge, or
|
|
503
|
-
type Sheet = "item" | "acknowledge" |
|
|
541
|
+
// The sheet, Acknowledge, or the reviewer picker (after Ready for review, or on its own).
|
|
542
|
+
type Sheet = "item" | "acknowledge" | "reviewers" | "reviewers-after-ready" | null;
|
|
504
543
|
|
|
505
544
|
// A session on an item that has no session action of its own starts with this prompt; it's editable first.
|
|
506
545
|
const fallbackKind = (item: Item): SessionKind => (item.target.kind === "issue" ? "start" : "review");
|
|
@@ -512,26 +551,26 @@ function ItemRow({ item, first, actions }: { item: Item; first: boolean; actions
|
|
|
512
551
|
const [sheet, setSheet] = useState<Sheet>(null);
|
|
513
552
|
const [confirm, setConfirm] = useState<"merge" | "close" | null>(null);
|
|
514
553
|
const main = item.actions[0];
|
|
515
|
-
const mainKind = main ? ACTION_SESSION[main] : undefined;
|
|
516
554
|
// The full stack is in the sheet; the card shows the PRs that need attention [ATT-04].
|
|
517
555
|
const children = item.children.filter((child) => child.attention || isRed(child.chips));
|
|
518
556
|
const open = () => setSheet("item");
|
|
519
557
|
const copy = useCopy();
|
|
520
|
-
const history = item.section
|
|
558
|
+
const history = SECTIONS[item.section].tab === "history";
|
|
521
559
|
|
|
522
560
|
function perform(action: ActionId) {
|
|
523
561
|
setSheet(null);
|
|
524
562
|
if (action === "merge" || action === "close") setConfirm(action);
|
|
525
563
|
else if (action === "acknowledge") setSheet("acknowledge");
|
|
564
|
+
else if (action === "request_review") setSheet("reviewers");
|
|
565
|
+
// A draft made ready goes straight on to who should review it [PRS-11].
|
|
566
|
+
else if (action === "ready") (actions.act(item, action), setSheet("reviewers-after-ready"));
|
|
526
567
|
else actions.act(item, action);
|
|
527
568
|
}
|
|
528
|
-
const
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
const
|
|
532
|
-
const only = entries.length === 1 ? entries[0] : undefined;
|
|
569
|
+
const handlers: SheetHandlers = { onPerform: perform, onClose: () => setSheet(null) };
|
|
570
|
+
// 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].
|
|
571
|
+
const loud = sheetEntries(item, sessions, actions, handlers).filter((entry) => !entry.quiet);
|
|
572
|
+
const only = loud.length === 1 ? loud[0] : undefined;
|
|
533
573
|
const confirmed = (action: "merge" | "close") => (comment: string) => (setConfirm(null), actions.confirm(item, action, comment));
|
|
534
|
-
const sessionMenu = { label: "Session choices", onPress: onMenu() };
|
|
535
574
|
|
|
536
575
|
return (
|
|
537
576
|
<CardRow
|
|
@@ -555,18 +594,13 @@ function ItemRow({ item, first, actions }: { item: Item; first: boolean; actions
|
|
|
555
594
|
busy={actions.busy.has(item.key)}
|
|
556
595
|
primary={
|
|
557
596
|
sessions[0]
|
|
558
|
-
? { label: "Open session", icon: "agent", onPress: () => actions.openAgent(sessions[0].id)
|
|
597
|
+
? { label: "Open session", icon: "agent", onPress: () => actions.openAgent(sessions[0].id) }
|
|
559
598
|
: main
|
|
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
|
-
}
|
|
599
|
+
? { label: actionLabel(main, item), icon: ACTION_ICONS[main], onPress: () => perform(main) }
|
|
566
600
|
: undefined
|
|
567
601
|
}
|
|
568
602
|
secondary={[
|
|
569
|
-
only ? { label: only.label, icon: only.icon, onPress: only.onPress } : { label:
|
|
603
|
+
only ? { label: only.label, icon: only.icon, onPress: only.onPress } : { label: `Details for #${item.number}`, icon: "chevronRight", onPress: open },
|
|
570
604
|
// History is where I report from, so its cards copy their link in one tap [ATT-15].
|
|
571
605
|
...(history ? [{ label: `Copy link to #${item.number}`, icon: "copy" as const, onPress: () => copy(item.url, `Copied link to #${item.number}`) }] : []),
|
|
572
606
|
]}
|
|
@@ -590,8 +624,14 @@ function ItemRow({ item, first, actions }: { item: Item; first: boolean; actions
|
|
|
590
624
|
<>
|
|
591
625
|
{sheet === "item" ? <ItemSheet item={item} sessions={sessions} actions={actions} {...handlers} /> : null}
|
|
592
626
|
{sheet === "acknowledge" ? <AcknowledgeSheet item={item} onReact={(ids) => (setSheet(null), actions.acknowledge(item, ids))} onClose={() => setSheet(null)} /> : null}
|
|
593
|
-
{sheet
|
|
594
|
-
<
|
|
627
|
+
{sheet === "reviewers" || sheet === "reviewers-after-ready" ? (
|
|
628
|
+
<ReviewerSheet
|
|
629
|
+
item={item}
|
|
630
|
+
afterReady={sheet === "reviewers-after-ready"}
|
|
631
|
+
fetchReviewers={actions.fetchReviewers}
|
|
632
|
+
onRequest={(reviewers) => (setSheet(null), actions.requestReviewers(item, reviewers))}
|
|
633
|
+
onClose={() => setSheet(null)}
|
|
634
|
+
/>
|
|
595
635
|
) : null}
|
|
596
636
|
</>
|
|
597
637
|
}
|
|
@@ -599,43 +639,8 @@ function ItemRow({ item, first, actions }: { item: Item; first: boolean; actions
|
|
|
599
639
|
);
|
|
600
640
|
}
|
|
601
641
|
|
|
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
|
-
|
|
636
642
|
interface SheetHandlers {
|
|
637
643
|
onPerform: (action: ActionId) => void;
|
|
638
|
-
onMenu: (kind?: SessionKind) => (anchor: Anchor | undefined) => void;
|
|
639
644
|
onClose: () => void;
|
|
640
645
|
}
|
|
641
646
|
|
|
@@ -673,29 +678,26 @@ function sheetEntries(
|
|
|
673
678
|
item: Item,
|
|
674
679
|
sessions: AgentSummary[],
|
|
675
680
|
actions: Actions,
|
|
676
|
-
{ onPerform,
|
|
681
|
+
{ onPerform, onClose }: SheetHandlers,
|
|
677
682
|
details?: { data?: { failing: FailingChecks[] }; isLoading: boolean },
|
|
678
683
|
): SheetEntry[] {
|
|
679
|
-
const inDoing =
|
|
684
|
+
const inDoing = SECTIONS[item.section].tab === "doing";
|
|
680
685
|
const close = (then: () => void) => () => (onClose(), then());
|
|
681
686
|
|
|
682
|
-
|
|
683
|
-
const
|
|
684
|
-
|
|
685
|
-
|
|
687
|
+
const open = (agentId: string) => close(() => actions.openAgent(agentId))();
|
|
688
|
+
const withOptions = (label: string, kind: SessionKind) => close(() => actions.startWithOptions({ itemKey: item.key, title: `${label}: ${item.title}`, kind, target: item.target }));
|
|
689
|
+
// Sessions none of its actions would start lead, needs me first [SES-03].
|
|
690
|
+
const kinds = item.actions.flatMap((action) => ACTION_SESSION[action] ?? []);
|
|
691
|
+
const entries: SheetEntry[] = looseSessions(sessions, kinds).map((agent) => sessionEntry(agent, sessionLabel(agent.kind, item), open));
|
|
686
692
|
for (const action of item.actions) {
|
|
687
693
|
const kind = ACTION_SESSION[action];
|
|
688
694
|
const label = actionLabel(action, item);
|
|
689
|
-
if (kind
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
detail: actionDetail(action as Exclude<ActionId, "rerun">, item),
|
|
696
|
-
onPress: () => onPerform(action),
|
|
697
|
-
menu: { label: `${label} choices`, onPress: onMenu(kind) },
|
|
698
|
-
});
|
|
695
|
+
if (kind) {
|
|
696
|
+
// An action's session takes its line once it runs, so work on it stays in one place [SES-03].
|
|
697
|
+
// Until then it asks first: the card's button is the one-tap start [SES-01, SES-02].
|
|
698
|
+
const running = sessions.filter((agent) => agent.kind === kind);
|
|
699
|
+
if (running.length) entries.push(...running.map((agent) => sessionEntry(agent, sessionLabel(kind, item), open)));
|
|
700
|
+
else entries.push({ key: action, icon: "agent", label: `${label}…`, detail: actionDetail(action as Exclude<ActionId, "rerun">, item), onPress: withOptions(label, kind) });
|
|
699
701
|
} else if (action === "rerun") {
|
|
700
702
|
const { detail, runIds } = rerunEntry(details?.data?.failing, details?.isLoading ?? true);
|
|
701
703
|
entries.push({ key: action, icon: ACTION_ICONS.rerun, label, detail, disabled: runIds.length === 0, onPress: close(() => actions.rerun(item, runIds)) });
|
|
@@ -712,10 +714,15 @@ function sheetEntries(
|
|
|
712
714
|
onPress: close(() => void openExternalUrl(item.url)),
|
|
713
715
|
copy: { text: item.url, label: `Copy link to #${item.number}`, done: `Copied link to #${item.number}` },
|
|
714
716
|
});
|
|
717
|
+
// Nothing's left to start on once it's merged or closed.
|
|
718
|
+
if (!item.closedAt) entries.push(startAnotherEntry(sessions.length > 0, withOptions("Start session", fallbackKind(item))));
|
|
715
719
|
if (inDoing) entries.push({ key: "dismiss", icon: "dismiss", label: "Dismiss", detail: "Hides it until something new happens on it", onPress: close(() => actions.dismiss(item)) });
|
|
716
720
|
return entries;
|
|
717
721
|
}
|
|
718
722
|
|
|
723
|
+
// A session is named for what started it; one of no kind, or a Start's, just continues.
|
|
724
|
+
const sessionLabel = (kind: SessionKind | undefined, item: Item) => (kind && kind !== "start" ? actionLabel(kind, item) : "Continue session");
|
|
725
|
+
|
|
719
726
|
// Pick which waiting comments get a 👍, after reading them in full; all are picked to start [MEN-07].
|
|
720
727
|
function AcknowledgeSheet({ item, onReact, onClose }: { item: Item; onReact: (ids: string[]) => void; onClose: () => void }) {
|
|
721
728
|
const styles = useStyles();
|
|
@@ -765,6 +772,102 @@ function AcknowledgeSheet({ item, onReact, onClose }: { item: Item; onReact: (id
|
|
|
765
772
|
);
|
|
766
773
|
}
|
|
767
774
|
|
|
775
|
+
// Who should review a PR: GitHub's suggestions, who reviewed my other PRs in the repo, its teams, or anyone typed in.
|
|
776
|
+
// All start unticked; requesting keeps whoever is already asked [PRS-12].
|
|
777
|
+
function ReviewerSheet({
|
|
778
|
+
item,
|
|
779
|
+
afterReady,
|
|
780
|
+
fetchReviewers,
|
|
781
|
+
onRequest,
|
|
782
|
+
onClose,
|
|
783
|
+
}: {
|
|
784
|
+
item: Item;
|
|
785
|
+
afterReady: boolean;
|
|
786
|
+
fetchReviewers: FetchReviewers;
|
|
787
|
+
onRequest: (reviewers: string[]) => void;
|
|
788
|
+
onClose: () => void;
|
|
789
|
+
}) {
|
|
790
|
+
const styles = useStyles();
|
|
791
|
+
const choices = useQuery({ queryKey: ["attention-span", "reviewers", item.target.repo, item.target.number], queryFn: () => fetchReviewers({ target: item.target }), staleTime: 60_000 });
|
|
792
|
+
const [picked, setPicked] = useState<ReadonlySet<string>>(new Set());
|
|
793
|
+
const [typed, setTyped] = useState<Reviewer[]>([]);
|
|
794
|
+
const [text, setText] = useState("");
|
|
795
|
+
const toggle = (login: string) => setPicked((now) => (now.has(login) ? new Set([...now].filter((other) => other !== login)) : new Set([...now, login])));
|
|
796
|
+
// Each person or team once, in the first group that has them.
|
|
797
|
+
const seen = new Set<string>();
|
|
798
|
+
const once = (list: Reviewer[]) => list.filter((reviewer) => !seen.has(reviewer.login.toLowerCase()) && seen.add(reviewer.login.toLowerCase()));
|
|
799
|
+
const groups = [
|
|
800
|
+
{ title: "Added", list: once(typed) },
|
|
801
|
+
{ title: "Suggested by GitHub", list: once(choices.data?.suggested ?? []) },
|
|
802
|
+
{ title: "Recent on your PRs here", list: once(choices.data?.recent ?? []) },
|
|
803
|
+
{ title: "Teams", list: once(choices.data?.teams ?? []) },
|
|
804
|
+
];
|
|
805
|
+
const add = () => {
|
|
806
|
+
const login = text.trim().replace(/^@/, "");
|
|
807
|
+
if (!login) return;
|
|
808
|
+
setTyped((now) => [...now, { login, team: login.includes("/") }]);
|
|
809
|
+
setPicked((now) => new Set([...now, login]));
|
|
810
|
+
setText("");
|
|
811
|
+
};
|
|
812
|
+
const count = `${picked.size} reviewer${picked.size === 1 ? "" : "s"}`;
|
|
813
|
+
return (
|
|
814
|
+
<Modal title={`${afterReady ? "Ready for review" : "Request review"}: ${item.title}`} open onOpenChange={(open) => (open ? null : onClose())}>
|
|
815
|
+
<Modal.Content>
|
|
816
|
+
<KeepStyles styles={styles}>
|
|
817
|
+
<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>
|
|
818
|
+
{choices.isLoading ? <Loading text="Loading suggestions…" /> : null}
|
|
819
|
+
{choices.error ? <Text style={styles.danger}>Couldn't load suggestions: {(choices.error as Error).message}</Text> : null}
|
|
820
|
+
{groups.map(({ title, list }) =>
|
|
821
|
+
list.length > 0 ? (
|
|
822
|
+
<View key={title} style={{ gap: 4 }}>
|
|
823
|
+
<Text style={[styles.muted, { fontSize: 12 }]}>{title}</Text>
|
|
824
|
+
{list.map((reviewer) => (
|
|
825
|
+
<Pressable
|
|
826
|
+
key={reviewer.login}
|
|
827
|
+
accessibilityRole="checkbox"
|
|
828
|
+
accessibilityState={{ checked: picked.has(reviewer.login) }}
|
|
829
|
+
accessibilityLabel={reviewer.login}
|
|
830
|
+
onPress={() => toggle(reviewer.login)}
|
|
831
|
+
style={[styles.row, { paddingVertical: 4 }]}
|
|
832
|
+
>
|
|
833
|
+
<TablerIcon name={picked.has(reviewer.login) ? "squareCheck" : "square"} size={18} color={picked.has(reviewer.login) ? styles.action : styles.c.foregroundMuted} />
|
|
834
|
+
{reviewer.team ? <TablerIcon name="claim" size={18} color={styles.c.foregroundMuted} /> : <Avatar url={reviewer.avatarUrl} />}
|
|
835
|
+
<Text style={{ color: styles.c.foreground, fontSize: 13 }}>{reviewer.login}</Text>
|
|
836
|
+
</Pressable>
|
|
837
|
+
))}
|
|
838
|
+
</View>
|
|
839
|
+
) : null,
|
|
840
|
+
)}
|
|
841
|
+
{choices.data?.teamsNote ? <Text style={styles.muted}>{choices.data.teamsNote}</Text> : null}
|
|
842
|
+
<View style={styles.row}>
|
|
843
|
+
<TextInput
|
|
844
|
+
style={[styles.input, { flex: 1 }]}
|
|
845
|
+
placeholder="Login, or org/team"
|
|
846
|
+
placeholderTextColor={styles.c.foregroundMuted}
|
|
847
|
+
value={text}
|
|
848
|
+
onChangeText={setText}
|
|
849
|
+
onSubmitEditing={add}
|
|
850
|
+
autoCapitalize="none"
|
|
851
|
+
autoCorrect={false}
|
|
852
|
+
/>
|
|
853
|
+
<Button label="Add" variant="calm" disabled={!text.trim()} onPress={add} />
|
|
854
|
+
</View>
|
|
855
|
+
<View style={styles.wrap}>
|
|
856
|
+
<Button
|
|
857
|
+
label={`Request ${count}`}
|
|
858
|
+
icon="claim"
|
|
859
|
+
variant="solid"
|
|
860
|
+
disabled={picked.size === 0}
|
|
861
|
+
onPress={() => onRequest([...picked])}
|
|
862
|
+
/>
|
|
863
|
+
<Button label={afterReady ? "Skip" : "Cancel"} onPress={onClose} />
|
|
864
|
+
</View>
|
|
865
|
+
</KeepStyles>
|
|
866
|
+
</Modal.Content>
|
|
867
|
+
</Modal>
|
|
868
|
+
);
|
|
869
|
+
}
|
|
870
|
+
|
|
768
871
|
// Who is waiting on me, or who I'm waiting on.
|
|
769
872
|
function PersonQuote({ person, expanded }: { person: NonNullable<Item["person"]>; expanded: boolean }) {
|
|
770
873
|
const styles = useStyles();
|
package/client/card.tsx
CHANGED
|
@@ -3,7 +3,7 @@ import { type ReactNode, useState } from "react";
|
|
|
3
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 {
|
|
6
|
+
import { Button, Meta, 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,8 +23,6 @@ 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 };
|
|
28
26
|
}
|
|
29
27
|
|
|
30
28
|
export interface ConfirmSpec {
|
|
@@ -44,7 +42,7 @@ export interface CardProps {
|
|
|
44
42
|
accessibilityLabel?: string;
|
|
45
43
|
// Tapping the card opens its sheet [ATT-06].
|
|
46
44
|
onOpen: () => void;
|
|
47
|
-
// The labelled main action; secondary ones are icon-only (
|
|
45
|
+
// The labelled main action; secondary ones are icon-only (›, copy).
|
|
48
46
|
primary?: CardAction;
|
|
49
47
|
secondary: CardAction[];
|
|
50
48
|
// "working…" in place of the actions while a GitHub change runs.
|
|
@@ -65,21 +63,13 @@ export function CardRow({ first, mark, title, meta, accessibilityLabel, onOpen,
|
|
|
65
63
|
const styles = useStyles();
|
|
66
64
|
const actions = (
|
|
67
65
|
<View style={styles.wrap}>
|
|
68
|
-
{primary
|
|
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
|
-
/>
|
|
78
|
-
) : primary ? (
|
|
66
|
+
{primary ? (
|
|
79
67
|
<Button label={primary.label} accessibilityLabel={primary.accessibilityLabel} icon={primary.icon} variant="calm" busy={busy} onPress={primary.onPress} />
|
|
80
68
|
) : busy ? (
|
|
81
69
|
<ActivityIndicator size="small" color={styles.c.foregroundMuted} />
|
|
82
70
|
) : null}
|
|
71
|
+
{/* On phones › and copy sit at the far edge, apart from the labelled action. */}
|
|
72
|
+
{styles.compact && secondary.length ? <View style={{ flex: 1 }} /> : null}
|
|
83
73
|
{secondary.map((action) => (
|
|
84
74
|
<Button key={action.accessibilityLabel ?? action.label} icon={action.icon} variant="ghost" accessibilityLabel={action.accessibilityLabel ?? action.label} onPress={action.onPress} />
|
|
85
75
|
))}
|