@andrioid/paseo-attention-span 0.4.9 → 0.4.11
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 +3 -1
- package/client/attention-screen.tsx +164 -49
- package/client/card.tsx +25 -9
- package/client/coverage-settings.tsx +36 -1
- package/client/entity.tsx +118 -0
- package/client/feedback.tsx +2 -2
- package/client/icons.ts +5 -0
- package/client/next-up.tsx +148 -76
- package/client/session-menu.ts +2 -1
- package/client/sheet.tsx +141 -23
- package/client/ui.tsx +104 -6
- package/docs/architecture.md +17 -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.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-waiting-too-long.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.server.ts +2 -0
- package/package.json +1 -1
- package/requirements.yaml +4 -2
- package/server/classify.ts +56 -12
- package/server/details.ts +3 -2
- package/server/fixture.ts +50 -10
- package/server/gh.ts +29 -12
- package/server/github-types.ts +19 -2
- package/server/projects.ts +47 -0
- package/server/queries.ts +41 -6
- package/server/service.ts +138 -22
- package/server/store.ts +2 -0
- package/server/view.ts +2 -0
- package/shared/attention.ts +57 -0
- package/shared/checks.ts +66 -0
- package/shared/rpc.ts +5 -1
package/OVERVIEW.md
CHANGED
|
@@ -55,7 +55,9 @@ When someone needs a nudge, **Copy list** next to their name copies their items
|
|
|
55
55
|
|
|
56
56
|
## Next up: for when your plate is clear
|
|
57
57
|
|
|
58
|
-
It does happen. Next up lists issues assigned to you first, because finishing what you've taken seems polite, and then open issues nobody's claimed. If your org uses issue fields for priority and effort, it ranks by those, so the important quick wins float to the top. Fields called Priority, Effort and Scope are picked up on their own; if yours are called something else, pick them in Settings. Each issue shows its repo, priority, effort and scope, and whether someone already has a PR open for it. That last one has saved me from duplicating a colleague's work more than once.
|
|
58
|
+
It does happen. Next up lists issues assigned to you first, because finishing what you've taken seems polite, and then open issues nobody's claimed. If your org uses issue fields for priority and effort, it ranks by those, so the important quick wins float to the top. Fields called Priority, Effort and Scope are picked up on their own; if yours are called something else, pick them in Settings. Each issue shows its repo, priority, effort and scope, and whether someone already has a PR open for it. That last one has saved me from duplicating a colleague's work more than once. Each fact sits in a small pill with an icon, so "Medium" never leaves you guessing whether it's priority or effort, and priority wears the color your org gave it.
|
|
59
|
+
|
|
60
|
+
If your issues live on GitHub project boards, Next up shows which board and column each one is in, and the filter lets you pick boards and their columns: only TODO's Todo, say, and leave Ideas out. That needs one more permission than `gh` asks for by default; Settings tells you the command (`gh auth refresh -s read:project`) and until then everything else works as before.
|
|
59
61
|
|
|
60
62
|

|
|
61
63
|
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import type { RpcInput, RpcOutput } from "@getpaseo/plugin";
|
|
2
2
|
import { openExternalUrl, type PluginScreenProps, usePaseo, useRpc } from "@getpaseo/plugin/client";
|
|
3
|
-
import { Markdown,
|
|
3
|
+
import { Markdown, 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
7
|
import { type ActionId, type AgentSummary, type AttentionView, type Chip, checkoutPr, type FailingChecks, type Item, itemSessions, liftActive, looseSessions, type NextUpIssue, ownStack, type PersonRole, type Reviewer, type Section, type SectionId, SECTIONS, type SubRow, TAB_FEED, type TabId, type Target, type WaitingGroup, type WaitingOn } from "../shared/attention";
|
|
8
8
|
import { type AttentionConfig, nextUpSources, type SessionKind } from "../shared/config";
|
|
9
|
-
import {
|
|
9
|
+
import { failingList, groupLabel, rerunHistory, summarizeRerun } from "../shared/checks";
|
|
10
|
+
import { ago, linkList } from "../shared/format";
|
|
10
11
|
import { isClear } from "../shared/still";
|
|
11
12
|
import { workEmoji } from "../shared/work";
|
|
12
13
|
import { ACTION_SESSION, renderPrompt } from "../shared/prompts";
|
|
@@ -16,15 +17,16 @@ import { blocks } from "../shared/setup";
|
|
|
16
17
|
import { useAttention } from "./data";
|
|
17
18
|
import { CardList, CardRow, type CardProps } from "./card";
|
|
18
19
|
import type { IconName } from "./icons";
|
|
20
|
+
import { NumberText, PlaceText } from "./entity";
|
|
19
21
|
import { NextUpList } from "./next-up";
|
|
20
22
|
import { Still } from "./still";
|
|
21
23
|
import { agentSignal, sessionEntry, startAnotherEntry } from "./session-menu";
|
|
22
|
-
import { ActionSheet, DetailLines, type SheetEntry } from "./sheet";
|
|
24
|
+
import { ActionSheet, DETAILS_STALE_MS, DetailLines, type DetailsQuery, detailsKey, FadeIn, Modal, type SheetEntry, useArrived, usePrefetchOnRest } from "./sheet";
|
|
23
25
|
import { FeedbackAsk, FeedbackLine, type FeedbackScreen, FeedbackSheet } from "./feedback";
|
|
24
26
|
import { branchWorkspaces, type FetchProviders, findCheckout, githubProjects, itemAgents, listProfiles, noProjectMessage, resolveAgentConfig, startSession } from "./sessions";
|
|
25
27
|
import { SetupChecklist } from "./setup";
|
|
26
28
|
import { UpdateNotice } from "./update";
|
|
27
|
-
import { Avatar, Button, Hint, KeepStyles, Loading, Meta, SectionHeader, SpinningIcon, StylesProvider, TablerIcon, Toggle, useCopy, useHover, useStyles } from "./ui";
|
|
29
|
+
import { Avatar, Button, Hint, KeepStyles, LINE_HEIGHT, Loading, Meta, mix, SectionHeader, SpinningIcon, StylesProvider, TablerIcon, Toggle, useCopy, useHover, useStrongText, useStyles } from "./ui";
|
|
28
30
|
|
|
29
31
|
// The agent icon marks every action that starts an agent session; the rest act on GitHub right away [ATT-13].
|
|
30
32
|
const ACTION_ICONS: Record<ActionId, IconName> = {
|
|
@@ -97,17 +99,70 @@ function actionDetail(action: Exclude<ActionId, "rerun">, item: Item): string {
|
|
|
97
99
|
}[action];
|
|
98
100
|
}
|
|
99
101
|
|
|
100
|
-
//
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
if (
|
|
105
|
-
const
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
102
|
+
// Rerun failed jobs as a sheet line: which checks failed and whether they were rerun before, flaky or real? [PRS-09]
|
|
103
|
+
// It can be pressed before the checks are in: the sheet closes, and the rerun goes ahead once they are.
|
|
104
|
+
function rerunEntry(label: string, details: SheetDetails | undefined, rerun: (runIds?: number[]) => void): SheetEntry {
|
|
105
|
+
const base = { key: "rerun", icon: ACTION_ICONS.rerun, label, live: true };
|
|
106
|
+
if (!details || details.isLoading) return { ...base, detail: "Checking which checks failed…", onPress: () => rerun() };
|
|
107
|
+
const failing = details.data?.failing;
|
|
108
|
+
if (!failing) return { ...base, detail: "Couldn't find the failing checks", disabled: true, onPress: () => {} };
|
|
109
|
+
const summary = summarizeRerun(failing);
|
|
110
|
+
if (summary.failed === 0) return { ...base, detail: "No failed checks on the latest commit", disabled: true, onPress: () => {} };
|
|
111
|
+
if (summary.runIds.length === 0)
|
|
112
|
+
return { ...base, detail: `${summary.failed} failed, none in GitHub Actions, so none can be rerun here`, hint: failingList(failing), disabled: true, onPress: () => {} };
|
|
113
|
+
return { ...base, detailNode: <RerunDetail failing={failing} arrived={!!details.arrived} />, hint: failingList(failing), onPress: () => rerun(summary.runIds) };
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
// What an item's sheet has fetched, as its lines need it; `arrived` once it came in while the sheet was open.
|
|
117
|
+
interface SheetDetails {
|
|
118
|
+
data?: { failing: FailingChecks[] };
|
|
119
|
+
isLoading: boolean;
|
|
120
|
+
arrived?: boolean;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// "7 failed · lint, e2e ×3, unit ×2 · ↻ rerun once": the count and names quiet, as the card's red already says CI failed; checks
|
|
124
|
+
// 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
|
|
125
|
+
// and the hint has them all; two on phones, which can't point at a hint [PRS-09].
|
|
126
|
+
function RerunDetail({ failing, arrived }: { failing: FailingChecks[]; arrived: boolean }) {
|
|
127
|
+
const styles = useStyles();
|
|
128
|
+
const summary = summarizeRerun(failing);
|
|
129
|
+
const strong = useStrongText();
|
|
130
|
+
// Dimmer than the quiet text, on the line's own background, so it reads in any theme.
|
|
131
|
+
const dimmer = { color: mix(styles.c.foregroundMuted, styles.c.surface2, 0.55) };
|
|
132
|
+
const stack = summary.prs.length > 1;
|
|
133
|
+
const names = summary.prs.map(({ pr, groups }, index) => (
|
|
134
|
+
<Text key={pr}>
|
|
135
|
+
{index > 0 ? " · " : null}
|
|
136
|
+
{stack ? <Text style={strong}>#{pr} </Text> : null}
|
|
137
|
+
{groups.map((group, at) => (
|
|
138
|
+
<Text key={`${group.name}-${group.rerunnable}`} style={group.rerunnable ? null : dimmer}>
|
|
139
|
+
{at > 0 ? ", " : null}
|
|
140
|
+
{groupLabel(group)}
|
|
141
|
+
</Text>
|
|
142
|
+
))}
|
|
143
|
+
</Text>
|
|
144
|
+
));
|
|
145
|
+
const history = (
|
|
146
|
+
<Text style={summary.reruns ? { color: styles.c.statusWarning, fontWeight: "500" } : null}>{summary.reruns ? `↻ ${rerunHistory(summary.reruns)}` : rerunHistory(0)}</Text>
|
|
147
|
+
);
|
|
148
|
+
const line = [styles.muted, { lineHeight: LINE_HEIGHT }];
|
|
149
|
+
return (
|
|
150
|
+
<FadeIn active={arrived}>
|
|
151
|
+
{styles.compact ? (
|
|
152
|
+
<Text style={line} numberOfLines={2}>
|
|
153
|
+
{summary.failed} failed · {names} · {history}
|
|
154
|
+
</Text>
|
|
155
|
+
) : (
|
|
156
|
+
<View style={{ flexDirection: "row", minWidth: 0 }}>
|
|
157
|
+
<Text style={line}>{summary.failed} failed · </Text>
|
|
158
|
+
<Text style={[line, { flexShrink: 1 }]} numberOfLines={1}>
|
|
159
|
+
{names}
|
|
160
|
+
</Text>
|
|
161
|
+
<Text style={line}> · {history}</Text>
|
|
162
|
+
</View>
|
|
163
|
+
)}
|
|
164
|
+
</FadeIn>
|
|
165
|
+
);
|
|
111
166
|
}
|
|
112
167
|
|
|
113
168
|
const SECTION_ICONS: Record<SectionId, IconName> = {
|
|
@@ -194,6 +249,7 @@ function AttentionList({
|
|
|
194
249
|
const restore = useRpc(rpc.restoreDismissed);
|
|
195
250
|
const saveScopes = useRpc(rpc.setScopes);
|
|
196
251
|
const saveSources = useRpc(rpc.setSources);
|
|
252
|
+
const saveProjects = useRpc(rpc.setProjectFilter);
|
|
197
253
|
const closeIssue = useRpc(rpc.closeIssue);
|
|
198
254
|
const reopenIssue = useRpc(rpc.reopenIssue);
|
|
199
255
|
const update = useRpc(rpc.updateBranch);
|
|
@@ -351,7 +407,19 @@ function AttentionList({
|
|
|
351
407
|
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 }));
|
|
352
408
|
},
|
|
353
409
|
// [PRS-09]
|
|
354
|
-
rerun: (item,
|
|
410
|
+
rerun: (item, known) => {
|
|
411
|
+
if (!known) toast.show("Finding the failed jobs to rerun…");
|
|
412
|
+
change(
|
|
413
|
+
item.key,
|
|
414
|
+
"Rerun",
|
|
415
|
+
async () => {
|
|
416
|
+
const runIds = known ?? summarizeRerun((await queryClient.fetchQuery({ ...itemDetailsQuery(item, fetchDetails), staleTime: DETAILS_STALE_MS })).failing).runIds;
|
|
417
|
+
if (runIds.length === 0) throw new Error("no failed GitHub Actions jobs to rerun");
|
|
418
|
+
return rerunFailed({ key: item.key, repo: item.target.repo, runIds });
|
|
419
|
+
},
|
|
420
|
+
`Rerunning the failed jobs of PR ${item.target.number}`,
|
|
421
|
+
);
|
|
422
|
+
},
|
|
355
423
|
// [PRS-12]
|
|
356
424
|
requestReviewers: (item, reviewers) => {
|
|
357
425
|
const { target } = item;
|
|
@@ -449,12 +517,15 @@ function AttentionList({
|
|
|
449
517
|
selected={view.scopes}
|
|
450
518
|
sources={nextUpSources(view.config)}
|
|
451
519
|
selectedSources={view.sources}
|
|
452
|
-
|
|
520
|
+
projects={view.projects}
|
|
521
|
+
selectedProjects={view.projectFilter}
|
|
522
|
+
// One setView for all, so clearing them together can't put any back.
|
|
453
523
|
onFilter={(change) => {
|
|
454
524
|
attention.setView({ ...view, ...change });
|
|
455
525
|
const failed = (error: Error) => toast.error(`Saving the filter failed: ${error.message}`);
|
|
456
526
|
if (change.scopes) saveScopes({ scopes: change.scopes }).catch(failed);
|
|
457
527
|
if (change.sources) saveSources({ sources: change.sources }).catch(failed);
|
|
528
|
+
if (change.projectFilter) saveProjects({ projects: change.projectFilter }).catch(failed);
|
|
458
529
|
}}
|
|
459
530
|
agents={actions.agents}
|
|
460
531
|
login={view.login}
|
|
@@ -544,7 +615,8 @@ interface Actions {
|
|
|
544
615
|
fetchProviders: FetchProviders;
|
|
545
616
|
act: (item: Item, action: ActionId) => void;
|
|
546
617
|
requestReviewers: (item: Item, reviewers: string[]) => void;
|
|
547
|
-
|
|
618
|
+
// Without run ids, it finds them first: Rerun pressed before the sheet had the failing checks.
|
|
619
|
+
rerun: (item: Item, runIds?: number[]) => void;
|
|
548
620
|
acknowledge: (item: Item, commentIds: string[]) => void;
|
|
549
621
|
confirm: (item: Item, action: "merge" | "close", comment?: string) => void;
|
|
550
622
|
dismiss: (item: Item) => void;
|
|
@@ -595,8 +667,7 @@ function ItemRow({ item, first, actions, group }: { item: Item; first: boolean;
|
|
|
595
667
|
const styles = useStyles();
|
|
596
668
|
// An open session leads; without one, the item's own action does [SES-03].
|
|
597
669
|
const sessions = itemSessions(actions.agents, item);
|
|
598
|
-
const
|
|
599
|
-
const chips = sessions[0] ? [...own, agentSignal(sessions[0])] : own;
|
|
670
|
+
const waits = waitChips(item, !!group, actions.config.waitingTooLongDays);
|
|
600
671
|
// The group names one; the card names the rest [WAI-01].
|
|
601
672
|
const others = group?.who ? (item.waitingOn ?? []).filter((who) => !samePerson(who, group.who!)) : [];
|
|
602
673
|
const waitingOn = group ? null : item.waitingOn ? <WaitingOnLine people={item.waitingOn} asked={item.wait?.reason === "question"} expanded={false} /> : null;
|
|
@@ -604,9 +675,17 @@ function ItemRow({ item, first, actions, group }: { item: Item; first: boolean;
|
|
|
604
675
|
const [sheet, setSheet] = useState<Sheet>(null);
|
|
605
676
|
const [confirm, setConfirm] = useState<"merge" | "close" | null>(null);
|
|
606
677
|
const main = item.actions[0];
|
|
607
|
-
// The full stack is in the sheet; the card shows the PRs that need attention [ATT-04].
|
|
608
|
-
|
|
678
|
+
// 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
|
|
679
|
+
// 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].
|
|
680
|
+
const target = targetUrl(item);
|
|
681
|
+
const needing = item.children.some((child) => child.attention || isRed(child.chips));
|
|
682
|
+
const children = needing ? item.children.filter((child) => child.attention || isRed(child.chips) || child.url === target) : [];
|
|
683
|
+
const targetRow = children.find((child) => child.url === target);
|
|
684
|
+
const shown = [...waits, ...stackMetaChips(item, targetRow)];
|
|
685
|
+
const chips = sessions[0] ? [...shown, agentSignal(sessions[0])] : shown;
|
|
686
|
+
// The sheet opens at once; what it fetches fills in [ATT-06].
|
|
609
687
|
const open = () => setSheet("item");
|
|
688
|
+
const prefetch = usePrefetchOnRest(itemDetailsQuery(item, actions.fetchDetails));
|
|
610
689
|
const copy = useCopy();
|
|
611
690
|
const history = SECTIONS[item.section].tab === "history";
|
|
612
691
|
|
|
@@ -631,7 +710,7 @@ function ItemRow({ item, first, actions, group }: { item: Item; first: boolean;
|
|
|
631
710
|
mark={stateMark(item)}
|
|
632
711
|
title={item.title}
|
|
633
712
|
meta={{
|
|
634
|
-
place:
|
|
713
|
+
place: { repo: item.repo, number: item.number, login: actions.login },
|
|
635
714
|
when: item.closedAt ? `${item.kind === "pr" ? "merged" : "closed"} ${ago(item.closedAt)} ago` : undefined,
|
|
636
715
|
signals: chips,
|
|
637
716
|
}}
|
|
@@ -641,11 +720,12 @@ function ItemRow({ item, first, actions, group }: { item: Item; first: boolean;
|
|
|
641
720
|
{item.person ? <PersonQuote person={item.person} expanded={false} /> : null}
|
|
642
721
|
{waitingOn}
|
|
643
722
|
{alsoOn}
|
|
644
|
-
{children.length > 0 ? <StackLine rows={children} merged={!!item.closedAt} /> : null}
|
|
723
|
+
{children.length > 0 ? <StackLine rows={children} merged={!!item.closedAt} target={targetRow?.key} /> : null}
|
|
645
724
|
</>
|
|
646
725
|
) : null
|
|
647
726
|
}
|
|
648
727
|
onOpen={open}
|
|
728
|
+
hover={prefetch}
|
|
649
729
|
busy={actions.busy.has(item.key)}
|
|
650
730
|
primary={
|
|
651
731
|
sessions[0]
|
|
@@ -677,7 +757,7 @@ function ItemRow({ item, first, actions, group }: { item: Item; first: boolean;
|
|
|
677
757
|
}
|
|
678
758
|
overlay={
|
|
679
759
|
<>
|
|
680
|
-
{sheet === "item" ? <ItemSheet item={item}
|
|
760
|
+
{sheet === "item" ? <ItemSheet item={item} waitChips={waits} sessions={sessions} actions={actions} {...handlers} /> : null}
|
|
681
761
|
{sheet === "acknowledge" ? <AcknowledgeSheet item={item} onReact={(ids) => (setSheet(null), actions.acknowledge(item, ids))} onClose={() => setSheet(null)} /> : null}
|
|
682
762
|
{sheet === "reviewers" || sheet === "reviewers-after-ready" ? (
|
|
683
763
|
<ReviewerSheet
|
|
@@ -700,14 +780,33 @@ interface SheetHandlers {
|
|
|
700
780
|
}
|
|
701
781
|
|
|
702
782
|
// 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].
|
|
703
|
-
|
|
783
|
+
// What an item's sheet fetches when it opens; resting the pointer on its card fetches the same ahead. `checks` asks for
|
|
784
|
+
// failing checks too, for Rerun.
|
|
785
|
+
function itemDetailsQuery(item: Item, fetchDetails: FetchDetails): DetailsQuery {
|
|
704
786
|
const checks = item.actions.includes("rerun");
|
|
705
|
-
const
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
787
|
+
const subject = { kind: item.kind, repo: item.repo, number: item.number };
|
|
788
|
+
return { queryKey: detailsKey(subject, item.target, checks), queryFn: () => fetchDetails({ subject, target: item.target, checks }) };
|
|
789
|
+
}
|
|
790
|
+
|
|
791
|
+
// The PR an item's actions apply to, where that isn't the item itself, like an issue's PR.
|
|
792
|
+
const targetUrl = (item: Item) => (item.target.number !== item.number || item.target.kind !== item.kind ? item.target.url : undefined);
|
|
793
|
+
|
|
794
|
+
// 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
|
|
795
|
+
// 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
|
|
796
|
+
// shows the row; a card only when a PR in the stack needs attention [ATT-04, ATT-06].
|
|
797
|
+
function stackMetaChips(item: Item, targetRow: SubRow | undefined): Chip[] {
|
|
798
|
+
if (!targetRow) return item.chips;
|
|
799
|
+
const onRow = new Set(targetRow.chips.map((chip) => chip.text));
|
|
800
|
+
return item.chips.filter((chip) => !/^PR #\d+$/.test(chip.text) && !/^stack of \d+$/.test(chip.text) && !onRow.has(chip.text));
|
|
801
|
+
}
|
|
802
|
+
|
|
803
|
+
function ItemSheet({ item, waitChips, sessions, actions, ...handlers }: { item: Item; waitChips: Chip[]; sessions: AgentSummary[]; actions: Actions } & SheetHandlers) {
|
|
804
|
+
const details = useQuery({ ...itemDetailsQuery(item, actions.fetchDetails), staleTime: DETAILS_STALE_MS });
|
|
805
|
+
const arrived = useArrived(details.isLoading);
|
|
806
|
+
const elsewhere = !!targetUrl(item);
|
|
807
|
+
// The row of the PR its actions apply to, where it's in the stack line: marked there instead of named on top.
|
|
808
|
+
const targetRow = elsewhere ? item.children.find((child) => child.url === item.target.url) : undefined;
|
|
809
|
+
const meta = elsewhere && !targetRow ? [`actions apply to PR #${item.target.number}`] : [];
|
|
711
810
|
// PRs already in the stack line link from there; list only the rest, like someone else's PR closing the same issue.
|
|
712
811
|
const shown = new Set(item.children.map((child) => child.url));
|
|
713
812
|
const extra = details.data && { ...details.data, linked: details.data.linked.filter((link) => !shown.has(link.url)) };
|
|
@@ -717,25 +816,37 @@ function ItemSheet({ item, chips, sessions, actions, ...handlers }: { item: Item
|
|
|
717
816
|
onClose={handlers.onClose}
|
|
718
817
|
top={
|
|
719
818
|
<>
|
|
720
|
-
|
|
819
|
+
{/* Number first, as on the card; the sheet always names the owner, even of my own repos [ATT-20]. */}
|
|
820
|
+
<Meta lead={<PlaceText place={{ repo: item.repo, number: item.number, login: null }} />} facts={meta} chips={[...waitChips, ...stackMetaChips(item, targetRow)]} />
|
|
721
821
|
{item.person ? <PersonQuote person={item.person} expanded /> : null}
|
|
722
822
|
{item.waitingOn ? <WaitingOnLine people={item.waitingOn} asked={item.wait?.reason === "question"} expanded /> : null}
|
|
723
|
-
{item.children.length > 0 ? <StackLine rows={item.children} merged={!!item.closedAt} links /> : null}
|
|
823
|
+
{item.children.length > 0 ? <StackLine rows={item.children} merged={!!item.closedAt} links target={targetRow?.key} /> : null}
|
|
724
824
|
</>
|
|
725
825
|
}
|
|
726
|
-
entries={sheetEntries(item, sessions, actions, handlers, details)}
|
|
727
|
-
|
|
826
|
+
entries={sheetEntries(item, sessions, actions, handlers, { data: details.data, isLoading: details.isLoading, arrived })}
|
|
827
|
+
// 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
|
|
828
|
+
// already, so few more come [ATT-06].
|
|
829
|
+
bottom={
|
|
830
|
+
<DetailLines
|
|
831
|
+
details={extra}
|
|
832
|
+
loading={details.isLoading}
|
|
833
|
+
error={details.error}
|
|
834
|
+
linkedLabel={item.kind === "issue" ? "PR" : "Closes"}
|
|
835
|
+
expected={item.target.kind === "pr" ? 1 : 0}
|
|
836
|
+
sizeOf={elsewhere ? item.target.number : undefined}
|
|
837
|
+
/>
|
|
838
|
+
}
|
|
728
839
|
/>
|
|
729
840
|
);
|
|
730
841
|
}
|
|
731
842
|
|
|
732
|
-
// Everything an item's sheet offers, each saying what it will do [ATT-06]. Rerun's line
|
|
843
|
+
// Everything an item's sheet offers, each saying what it will do [ATT-06]. Rerun's line says more once the checks are in.
|
|
733
844
|
function sheetEntries(
|
|
734
845
|
item: Item,
|
|
735
846
|
sessions: AgentSummary[],
|
|
736
847
|
actions: Actions,
|
|
737
848
|
{ onPerform, onClose }: SheetHandlers,
|
|
738
|
-
details?:
|
|
849
|
+
details?: SheetDetails,
|
|
739
850
|
): SheetEntry[] {
|
|
740
851
|
const inDoing = SECTIONS[item.section].tab === "doing";
|
|
741
852
|
const close = (then: () => void) => () => (onClose(), then());
|
|
@@ -755,10 +866,10 @@ function sheetEntries(
|
|
|
755
866
|
if (running.length) entries.push(...running.map((agent) => sessionEntry(agent, sessionLabel(kind, item), open)));
|
|
756
867
|
else entries.push({ key: action, icon: "agent", label: `${label}…`, detail: actionDetail(action as Exclude<ActionId, "rerun">, item), onPress: withOptions(label, kind) });
|
|
757
868
|
} else if (action === "rerun") {
|
|
758
|
-
|
|
759
|
-
entries.push({ key: action, icon: ACTION_ICONS.rerun, label, detail, disabled: runIds.length === 0, onPress: close(() => actions.rerun(item, runIds)) });
|
|
869
|
+
entries.push(rerunEntry(label, details, (runIds) => close(() => actions.rerun(item, runIds))()));
|
|
760
870
|
} else {
|
|
761
|
-
|
|
871
|
+
// Closing it sits apart, below the work, with Dismiss [ATT-06].
|
|
872
|
+
entries.push({ key: action, icon: ACTION_ICONS[action], label, detail: actionDetail(action, item), housekeeping: action === "close", onPress: () => onPerform(action) });
|
|
762
873
|
}
|
|
763
874
|
}
|
|
764
875
|
// Anything Attention Span doesn't cover [ATT-12], and its link to share [ATT-15].
|
|
@@ -772,7 +883,7 @@ function sheetEntries(
|
|
|
772
883
|
});
|
|
773
884
|
// Nothing's left to start on once it's merged or closed.
|
|
774
885
|
if (!item.closedAt) entries.push(startAnotherEntry(sessions.length > 0, withOptions("Start session", fallbackKind(item))));
|
|
775
|
-
if (inDoing) entries.push({ key: "dismiss", icon: "dismiss", label: "Dismiss", detail: "Hides it until something new happens on it", onPress: close(() => actions.dismiss(item)) });
|
|
886
|
+
if (inDoing) entries.push({ key: "dismiss", icon: "dismiss", label: "Dismiss", detail: "Hides it until something new happens on it", housekeeping: true, onPress: close(() => actions.dismiss(item)) });
|
|
776
887
|
return entries;
|
|
777
888
|
}
|
|
778
889
|
|
|
@@ -1151,13 +1262,13 @@ function History({ items, actions }: { items: Item[]; actions: Actions }) {
|
|
|
1151
1262
|
}
|
|
1152
1263
|
|
|
1153
1264
|
// Stacked or linked PRs as a connected line; collapsed, only those needing attention [ATT-03, ATT-04].
|
|
1154
|
-
// In the sheet each row opens its PR on GitHub [ATT-12].
|
|
1155
|
-
function StackLine({ rows, merged, links = false }: { rows: SubRow[]; merged: boolean; links?: boolean }) {
|
|
1265
|
+
// 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].
|
|
1266
|
+
function StackLine({ rows, merged, links = false, target }: { rows: SubRow[]; merged: boolean; links?: boolean; target?: string }) {
|
|
1156
1267
|
const styles = useStyles();
|
|
1157
1268
|
return (
|
|
1158
1269
|
<View>
|
|
1159
1270
|
{rows.map((row, index) => (
|
|
1160
|
-
<StackRow key={row.key} url={row.url} number={row.number} link={links}>
|
|
1271
|
+
<StackRow key={row.key} url={row.url} number={row.number} link={links} target={row.key === target}>
|
|
1161
1272
|
<View style={{ width: 16, alignItems: "center" }}>
|
|
1162
1273
|
<View style={{ width: 2, flex: 1, backgroundColor: index === 0 ? "transparent" : styles.c.border }} />
|
|
1163
1274
|
<TablerIcon name={merged ? "merge" : row.draft ? "draft" : "pr"} size={14} color={merged ? styles.c.statusSuccess : row.draft ? styles.c.foregroundMuted : styles.c.statusSuccess} />
|
|
@@ -1167,7 +1278,10 @@ function StackLine({ rows, merged, links = false }: { rows: SubRow[]; merged: bo
|
|
|
1167
1278
|
<Text style={{ color: styles.c.foreground, fontSize: 13 }} numberOfLines={1}>
|
|
1168
1279
|
{row.title}
|
|
1169
1280
|
</Text>
|
|
1170
|
-
<
|
|
1281
|
+
<View style={[styles.wrap, { columnGap: 10, rowGap: 2 }]}>
|
|
1282
|
+
<Meta lead={<NumberText number={row.number} />} facts={[]} chips={row.chips} />
|
|
1283
|
+
{row.key === target ? <Text style={{ color: styles.action, fontSize: 12, fontWeight: "600" }}>actions apply here</Text> : null}
|
|
1284
|
+
</View>
|
|
1171
1285
|
</View>
|
|
1172
1286
|
{links ? (
|
|
1173
1287
|
<View style={{ justifyContent: "center", paddingHorizontal: 4 }}>
|
|
@@ -1180,17 +1294,18 @@ function StackLine({ rows, merged, links = false }: { rows: SubRow[]; merged: bo
|
|
|
1180
1294
|
);
|
|
1181
1295
|
}
|
|
1182
1296
|
|
|
1183
|
-
function StackRow({ url, number, link, children }: { url: string; number: number; link: boolean; children: ReactNode }) {
|
|
1297
|
+
function StackRow({ url, number, link, target = false, children }: { url: string; number: number; link: boolean; target?: boolean; children: ReactNode }) {
|
|
1184
1298
|
const styles = useStyles();
|
|
1185
1299
|
const { hovered, hover } = useHover();
|
|
1186
|
-
|
|
1300
|
+
const tinted = target ? { backgroundColor: tint(styles.action, 0.1), borderRadius: 6 } : null;
|
|
1301
|
+
if (!link) return <View style={[styles.row, { alignItems: "stretch" }, tinted]}>{children}</View>;
|
|
1187
1302
|
return (
|
|
1188
1303
|
<Pressable
|
|
1189
1304
|
accessibilityRole="link"
|
|
1190
1305
|
accessibilityLabel={`Open PR #${number} on GitHub`}
|
|
1191
1306
|
onPress={() => void openExternalUrl(url)}
|
|
1192
1307
|
{...hover}
|
|
1193
|
-
style={({ pressed }) => [styles.row, { alignItems: "stretch", borderRadius: 6, backgroundColor: pressed || hovered ? styles.c.surface2 : "transparent" }]}
|
|
1308
|
+
style={({ pressed }) => [styles.row, { alignItems: "stretch", borderRadius: 6, backgroundColor: pressed || hovered ? styles.c.surface2 : target ? tint(styles.action, 0.1) : "transparent" }]}
|
|
1194
1309
|
>
|
|
1195
1310
|
{children}
|
|
1196
1311
|
</Pressable>
|
package/client/card.tsx
CHANGED
|
@@ -3,12 +3,13 @@ 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 { type Place, PlaceText } from "./entity";
|
|
6
7
|
import { Button, HintArea, Meta, TablerIcon, toneColor, useStyles } from "./ui";
|
|
7
8
|
|
|
8
9
|
// Every card in every list has this anatomy; tabs fill it in with data and slots, not layout [ATT-05].
|
|
9
10
|
//
|
|
10
11
|
// [mark] title (2 lines at most) [actions] ← desktop
|
|
11
|
-
//
|
|
12
|
+
// #number · repo · when · signals
|
|
12
13
|
// extra (slot)
|
|
13
14
|
// [actions] ← phone, labelled
|
|
14
15
|
// confirm bar
|
|
@@ -36,12 +37,14 @@ export interface ConfirmSpec {
|
|
|
36
37
|
export interface CardProps {
|
|
37
38
|
mark: { icon: IconName; tone: Tone };
|
|
38
39
|
title: string;
|
|
39
|
-
// "
|
|
40
|
-
meta: { place:
|
|
40
|
+
// "#number · repo", then when it happened, then signals [ATT-05, ATT-20].
|
|
41
|
+
meta: { place: Place; when?: string; signals: Chip[] };
|
|
41
42
|
// Defaults to "<title>, more".
|
|
42
43
|
accessibilityLabel?: string;
|
|
43
|
-
// Tapping the card opens its sheet [ATT-06].
|
|
44
|
+
// Tapping the card opens its sheet, at once [ATT-06].
|
|
44
45
|
onOpen: () => void;
|
|
46
|
+
// Resting the pointer on the card, to fetch its sheet's details ahead.
|
|
47
|
+
hover?: { onHoverIn: () => void; onHoverOut: () => void };
|
|
45
48
|
// The labelled main action; secondary ones are icon-only (›, copy).
|
|
46
49
|
primary?: CardAction;
|
|
47
50
|
secondary: CardAction[];
|
|
@@ -59,19 +62,32 @@ export function CardList({ children }: { children: ReactNode }) {
|
|
|
59
62
|
return <View style={styles.card}>{children}</View>;
|
|
60
63
|
}
|
|
61
64
|
|
|
62
|
-
export function CardRow({ first, mark, title, meta, accessibilityLabel, onOpen, primary, secondary, busy, extra, confirm, overlay }: CardProps & { first: boolean }) {
|
|
65
|
+
export function CardRow({ first, mark, title, meta, accessibilityLabel, onOpen, hover, primary, secondary, busy, extra, confirm, overlay }: CardProps & { first: boolean }) {
|
|
63
66
|
const styles = useStyles();
|
|
64
67
|
const actions = (
|
|
65
68
|
<View style={styles.wrap}>
|
|
66
69
|
{primary ? (
|
|
67
|
-
<Button
|
|
70
|
+
<Button
|
|
71
|
+
label={primary.label}
|
|
72
|
+
accessibilityLabel={primary.accessibilityLabel}
|
|
73
|
+
icon={primary.icon}
|
|
74
|
+
variant="calm"
|
|
75
|
+
busy={busy}
|
|
76
|
+
onPress={primary.onPress}
|
|
77
|
+
/>
|
|
68
78
|
) : busy ? (
|
|
69
79
|
<ActivityIndicator size="small" color={styles.c.foregroundMuted} />
|
|
70
80
|
) : null}
|
|
71
81
|
{/* On phones › and copy sit at the far edge, apart from the labelled action. */}
|
|
72
82
|
{styles.compact && secondary.length ? <View style={{ flex: 1 }} /> : null}
|
|
73
83
|
{secondary.map((action) => (
|
|
74
|
-
<Button
|
|
84
|
+
<Button
|
|
85
|
+
key={action.accessibilityLabel ?? action.label}
|
|
86
|
+
icon={action.icon}
|
|
87
|
+
variant="ghost"
|
|
88
|
+
accessibilityLabel={action.accessibilityLabel ?? action.label}
|
|
89
|
+
onPress={action.onPress}
|
|
90
|
+
/>
|
|
75
91
|
))}
|
|
76
92
|
</View>
|
|
77
93
|
);
|
|
@@ -80,11 +96,11 @@ export function CardRow({ first, mark, title, meta, accessibilityLabel, onOpen,
|
|
|
80
96
|
<View style={styles.item}>
|
|
81
97
|
<Mark {...mark} />
|
|
82
98
|
<HintArea style={styles.body}>
|
|
83
|
-
<Pressable accessibilityRole="button" accessibilityLabel={accessibilityLabel ?? `${title}, more`} onPress={onOpen} style={{ gap: 6 }}>
|
|
99
|
+
<Pressable accessibilityRole="button" accessibilityLabel={accessibilityLabel ?? `${title}, more`} onPress={onOpen} {...hover} style={{ gap: 6 }}>
|
|
84
100
|
<Text style={styles.title} numberOfLines={2}>
|
|
85
101
|
{title}
|
|
86
102
|
</Text>
|
|
87
|
-
<Meta facts={meta.when ? [meta.
|
|
103
|
+
<Meta lead={<PlaceText place={meta.place} />} facts={meta.when ? [meta.when] : []} chips={meta.signals} />
|
|
88
104
|
{extra}
|
|
89
105
|
</Pressable>
|
|
90
106
|
{/* On phones the actions sit under the text, labelled, so mixed actions stay readable. */}
|
|
@@ -7,11 +7,12 @@ import * as rpc from "../shared/rpc";
|
|
|
7
7
|
import { DEFAULT_FIELD, FIELD_ROLES, type FieldRole, sameField } from "../shared/config";
|
|
8
8
|
import type { ConfigStatus, CoverageKind, IssueField } from "../shared/setup";
|
|
9
9
|
import { VIEW_QUERY_KEY } from "./data";
|
|
10
|
-
import { Button, StylesProvider, useStyles } from "./ui";
|
|
10
|
+
import { Button, StylesProvider, useCopy, useStyles } from "./ui";
|
|
11
11
|
|
|
12
12
|
const COVERAGE_QUERY_KEY = ["attention-span", "coverage"] as const;
|
|
13
13
|
const MY_ORGS_QUERY_KEY = ["attention-span", "my-orgs"] as const;
|
|
14
14
|
const FIELDS_QUERY_KEY = ["attention-span", "issue-fields"] as const;
|
|
15
|
+
const PROJECTS_QUERY_KEY = ["attention-span", "projects-access"] as const;
|
|
15
16
|
// A caption belongs to the card above it, so it sits closer to that card than to the next heading.
|
|
16
17
|
const CAPTION = { marginTop: -24, marginBottom: 16 };
|
|
17
18
|
|
|
@@ -216,6 +217,7 @@ function NextUpFields({ value, disabled, onChange }: { value: ConfigStatus["fiel
|
|
|
216
217
|
/>
|
|
217
218
|
);
|
|
218
219
|
})}
|
|
220
|
+
<ProjectsRow />
|
|
219
221
|
</SettingsCard>
|
|
220
222
|
</SettingsSection>
|
|
221
223
|
<Text style={[styles.muted, CAPTION]}>
|
|
@@ -227,6 +229,39 @@ function NextUpFields({ value, disabled, onChange }: { value: ConfigStatus["fiel
|
|
|
227
229
|
);
|
|
228
230
|
}
|
|
229
231
|
|
|
232
|
+
// Projects need the read:project scope, which gh doesn't ask for by default. Asked again each time Settings opens, so the
|
|
233
|
+
// row turns On once it's fixed. How to fix it depends on where gh's token comes from: its own login takes one command; a
|
|
234
|
+
// token in GH_TOKEN or GITHUB_TOKEN, which gh reads first, needs that permission on GitHub; anything else, like an org's
|
|
235
|
+
// SSO, gets GitHub's own words [NXT-12].
|
|
236
|
+
const SCOPE_COMMAND = "gh auth refresh -s read:project";
|
|
237
|
+
|
|
238
|
+
function ProjectsRow() {
|
|
239
|
+
const styles = useStyles();
|
|
240
|
+
const copy = useCopy();
|
|
241
|
+
const check = useRpc(rpc.projectsAccess);
|
|
242
|
+
const access = useQuery({ queryKey: PROJECTS_QUERY_KEY, queryFn: () => check({}), staleTime: 0 });
|
|
243
|
+
const status = access.data;
|
|
244
|
+
if (status?.state === "missing" && status.token === "gh")
|
|
245
|
+
return <SettingsAction label="Projects" hint={`Needs the read:project scope. Run ${SCOPE_COMMAND} on this host`} actionLabel="Copy command" onPress={() => copy(SCOPE_COMMAND, "Copied the command")} />;
|
|
246
|
+
const hint =
|
|
247
|
+
status?.state === "missing"
|
|
248
|
+
? `Your token comes from ${status.token}. Give it read:project (classic) or Projects: read (fine-grained), then restart the daemon`
|
|
249
|
+
: status?.state === "failed"
|
|
250
|
+
? `Couldn't read projects: ${status.error}`
|
|
251
|
+
: status?.state === "unknown"
|
|
252
|
+
? "Couldn't tell whether projects can be read"
|
|
253
|
+
: // On, but some went wrong last time, like boards an org's SSO hides: in GitHub's words, so it can be fixed.
|
|
254
|
+
status?.warning || status?.error
|
|
255
|
+
? `On, but GitHub said: ${status.warning ?? status.error}`
|
|
256
|
+
: "Shows each issue's project and Status on its card, and adds them to the filter";
|
|
257
|
+
const on = status?.state === "on";
|
|
258
|
+
return (
|
|
259
|
+
<SettingsRow label="Projects" hint={hint} error={access.error ? (access.error as Error).message : null}>
|
|
260
|
+
<Text style={[styles.text, { color: on ? styles.action : styles.c.foregroundMuted }]}>{on ? "On" : access.isLoading ? "Checking…" : "Off"}</Text>
|
|
261
|
+
</SettingsRow>
|
|
262
|
+
);
|
|
263
|
+
}
|
|
264
|
+
|
|
230
265
|
// Each name is checked on GitHub before it's saved; GitHub's exact name is what's kept.
|
|
231
266
|
function AddRow({ kind, placeholder, existing, disabled, onAdd }: { kind: CoverageKind; placeholder?: string; existing: string[]; disabled: boolean; onAdd: (name: string) => Promise<void> }) {
|
|
232
267
|
const styles = useStyles();
|