@andrioid/paseo-attention-span 0.4.10 → 0.4.12
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/client/attention-screen.tsx +150 -51
- package/client/card.tsx +3 -10
- package/client/next-up.tsx +11 -10
- package/client/session-menu.ts +2 -1
- package/client/sheet.tsx +111 -74
- package/client/ui.tsx +10 -3
- package/docs/architecture.md +7 -7
- package/docs/screenshots/desktop-dark-doing-issue-sheet.png +0 -0
- package/docs/screenshots/desktop-dark-doing-sheet.png +0 -0
- package/package.json +1 -1
- package/server/context.ts +69 -21
- package/server/fixture.ts +17 -1
- package/shared/checks.ts +66 -0
- package/shared/prompts.ts +1 -1
- package/shared/opening.ts +0 -31
|
@@ -6,6 +6,7 @@ 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 { failingList, groupLabel, rerunHistory, summarizeRerun } from "../shared/checks";
|
|
9
10
|
import { ago, linkList } from "../shared/format";
|
|
10
11
|
import { isClear } from "../shared/still";
|
|
11
12
|
import { workEmoji } from "../shared/work";
|
|
@@ -20,12 +21,12 @@ import { NumberText, PlaceText } from "./entity";
|
|
|
20
21
|
import { NextUpList } from "./next-up";
|
|
21
22
|
import { Still } from "./still";
|
|
22
23
|
import { agentSignal, sessionEntry, startAnotherEntry } from "./session-menu";
|
|
23
|
-
import { ActionSheet,
|
|
24
|
+
import { ActionSheet, DETAILS_STALE_MS, DetailLines, type DetailsQuery, detailsKey, FadeIn, Modal, type SheetEntry, useArrived, usePrefetchOnRest } from "./sheet";
|
|
24
25
|
import { FeedbackAsk, FeedbackLine, type FeedbackScreen, FeedbackSheet } from "./feedback";
|
|
25
26
|
import { branchWorkspaces, type FetchProviders, findCheckout, githubProjects, itemAgents, listProfiles, noProjectMessage, resolveAgentConfig, startSession } from "./sessions";
|
|
26
27
|
import { SetupChecklist } from "./setup";
|
|
27
28
|
import { UpdateNotice } from "./update";
|
|
28
|
-
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";
|
|
29
30
|
|
|
30
31
|
// The agent icon marks every action that starts an agent session; the rest act on GitHub right away [ATT-13].
|
|
31
32
|
const ACTION_ICONS: Record<ActionId, IconName> = {
|
|
@@ -98,17 +99,70 @@ function actionDetail(action: Exclude<ActionId, "rerun">, item: Item): string {
|
|
|
98
99
|
}[action];
|
|
99
100
|
}
|
|
100
101
|
|
|
101
|
-
//
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
if (
|
|
106
|
-
const
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
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
|
+
);
|
|
112
166
|
}
|
|
113
167
|
|
|
114
168
|
const SECTION_ICONS: Record<SectionId, IconName> = {
|
|
@@ -353,7 +407,19 @@ function AttentionList({
|
|
|
353
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 }));
|
|
354
408
|
},
|
|
355
409
|
// [PRS-09]
|
|
356
|
-
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
|
+
},
|
|
357
423
|
// [PRS-12]
|
|
358
424
|
requestReviewers: (item, reviewers) => {
|
|
359
425
|
const { target } = item;
|
|
@@ -401,7 +467,7 @@ function AttentionList({
|
|
|
401
467
|
<Text style={styles.muted}>{feed.fetchedAt ? `${ago(feed.fetchedAt)} ago` : "never"}</Text>
|
|
402
468
|
</Pressable>
|
|
403
469
|
{openSettings ? (
|
|
404
|
-
<Pressable accessibilityRole="button" accessibilityLabel="Attention Span settings" onPress={
|
|
470
|
+
<Pressable accessibilityRole="button" accessibilityLabel="Attention Span settings" onPress={openSettings} hitSlop={8}>
|
|
405
471
|
<TablerIcon name="settings" size={16} />
|
|
406
472
|
</Pressable>
|
|
407
473
|
) : null}
|
|
@@ -549,7 +615,8 @@ interface Actions {
|
|
|
549
615
|
fetchProviders: FetchProviders;
|
|
550
616
|
act: (item: Item, action: ActionId) => void;
|
|
551
617
|
requestReviewers: (item: Item, reviewers: string[]) => void;
|
|
552
|
-
|
|
618
|
+
// Without run ids, it finds them first: Rerun pressed before the sheet had the failing checks.
|
|
619
|
+
rerun: (item: Item, runIds?: number[]) => void;
|
|
553
620
|
acknowledge: (item: Item, commentIds: string[]) => void;
|
|
554
621
|
confirm: (item: Item, action: "merge" | "close", comment?: string) => void;
|
|
555
622
|
dismiss: (item: Item) => void;
|
|
@@ -600,8 +667,7 @@ function ItemRow({ item, first, actions, group }: { item: Item; first: boolean;
|
|
|
600
667
|
const styles = useStyles();
|
|
601
668
|
// An open session leads; without one, the item's own action does [SES-03].
|
|
602
669
|
const sessions = itemSessions(actions.agents, item);
|
|
603
|
-
const
|
|
604
|
-
const chips = sessions[0] ? [...own, agentSignal(sessions[0])] : own;
|
|
670
|
+
const waits = waitChips(item, !!group, actions.config.waitingTooLongDays);
|
|
605
671
|
// The group names one; the card names the rest [WAI-01].
|
|
606
672
|
const others = group?.who ? (item.waitingOn ?? []).filter((who) => !samePerson(who, group.who!)) : [];
|
|
607
673
|
const waitingOn = group ? null : item.waitingOn ? <WaitingOnLine people={item.waitingOn} asked={item.wait?.reason === "question"} expanded={false} /> : null;
|
|
@@ -609,17 +675,21 @@ function ItemRow({ item, first, actions, group }: { item: Item; first: boolean;
|
|
|
609
675
|
const [sheet, setSheet] = useState<Sheet>(null);
|
|
610
676
|
const [confirm, setConfirm] = useState<"merge" | "close" | null>(null);
|
|
611
677
|
const main = item.actions[0];
|
|
612
|
-
// The full stack is in the sheet; the card shows the PRs that need attention [ATT-04].
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
const
|
|
616
|
-
const
|
|
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].
|
|
687
|
+
const open = () => setSheet("item");
|
|
688
|
+
const prefetch = usePrefetchOnRest(itemDetailsQuery(item, actions.fetchDetails));
|
|
617
689
|
const copy = useCopy();
|
|
618
690
|
const history = SECTIONS[item.section].tab === "history";
|
|
619
691
|
|
|
620
692
|
function perform(action: ActionId) {
|
|
621
|
-
// An action opening its own sheet wins over a details sheet still waiting to open [ATT-06].
|
|
622
|
-
cancelPendingOpen();
|
|
623
693
|
setSheet(null);
|
|
624
694
|
if (action === "merge" || action === "close") setConfirm(action);
|
|
625
695
|
else if (action === "acknowledge") setSheet("acknowledge");
|
|
@@ -650,13 +720,12 @@ function ItemRow({ item, first, actions, group }: { item: Item; first: boolean;
|
|
|
650
720
|
{item.person ? <PersonQuote person={item.person} expanded={false} /> : null}
|
|
651
721
|
{waitingOn}
|
|
652
722
|
{alsoOn}
|
|
653
|
-
{children.length > 0 ? <StackLine rows={children} merged={!!item.closedAt} /> : null}
|
|
723
|
+
{children.length > 0 ? <StackLine rows={children} merged={!!item.closedAt} target={targetRow?.key} /> : null}
|
|
654
724
|
</>
|
|
655
725
|
) : null
|
|
656
726
|
}
|
|
657
727
|
onOpen={open}
|
|
658
|
-
|
|
659
|
-
hover={opener.hover}
|
|
728
|
+
hover={prefetch}
|
|
660
729
|
busy={actions.busy.has(item.key)}
|
|
661
730
|
primary={
|
|
662
731
|
sessions[0]
|
|
@@ -688,7 +757,7 @@ function ItemRow({ item, first, actions, group }: { item: Item; first: boolean;
|
|
|
688
757
|
}
|
|
689
758
|
overlay={
|
|
690
759
|
<>
|
|
691
|
-
{sheet === "item" ? <ItemSheet item={item}
|
|
760
|
+
{sheet === "item" ? <ItemSheet item={item} waitChips={waits} sessions={sessions} actions={actions} {...handlers} /> : null}
|
|
692
761
|
{sheet === "acknowledge" ? <AcknowledgeSheet item={item} onReact={(ids) => (setSheet(null), actions.acknowledge(item, ids))} onClose={() => setSheet(null)} /> : null}
|
|
693
762
|
{sheet === "reviewers" || sheet === "reviewers-after-ready" ? (
|
|
694
763
|
<ReviewerSheet
|
|
@@ -711,17 +780,33 @@ interface SheetHandlers {
|
|
|
711
780
|
}
|
|
712
781
|
|
|
713
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].
|
|
714
|
-
// What an item's sheet fetches when it opens; its card fetches the same ahead
|
|
715
|
-
//
|
|
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.
|
|
716
785
|
function itemDetailsQuery(item: Item, fetchDetails: FetchDetails): DetailsQuery {
|
|
717
786
|
const checks = item.actions.includes("rerun");
|
|
718
787
|
const subject = { kind: item.kind, repo: item.repo, number: item.number };
|
|
719
788
|
return { queryKey: detailsKey(subject, item.target, checks), queryFn: () => fetchDetails({ subject, target: item.target, checks }) };
|
|
720
789
|
}
|
|
721
790
|
|
|
722
|
-
|
|
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) {
|
|
723
804
|
const details = useQuery({ ...itemDetailsQuery(item, actions.fetchDetails), staleTime: DETAILS_STALE_MS });
|
|
724
|
-
const
|
|
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}`] : [];
|
|
725
810
|
// PRs already in the stack line link from there; list only the rest, like someone else's PR closing the same issue.
|
|
726
811
|
const shown = new Set(item.children.map((child) => child.url));
|
|
727
812
|
const extra = details.data && { ...details.data, linked: details.data.linked.filter((link) => !shown.has(link.url)) };
|
|
@@ -732,26 +817,36 @@ function ItemSheet({ item, chips, sessions, actions, ...handlers }: { item: Item
|
|
|
732
817
|
top={
|
|
733
818
|
<>
|
|
734
819
|
{/* Number first, as on the card; the sheet always names the owner, even of my own repos [ATT-20]. */}
|
|
735
|
-
<Meta lead={<PlaceText place={{ repo: item.repo, number: item.number, login: null }} />} facts={meta} chips={
|
|
820
|
+
<Meta lead={<PlaceText place={{ repo: item.repo, number: item.number, login: null }} />} facts={meta} chips={[...waitChips, ...stackMetaChips(item, targetRow)]} />
|
|
736
821
|
{item.person ? <PersonQuote person={item.person} expanded /> : null}
|
|
737
822
|
{item.waitingOn ? <WaitingOnLine people={item.waitingOn} asked={item.wait?.reason === "question"} expanded /> : null}
|
|
738
|
-
{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}
|
|
739
824
|
</>
|
|
740
825
|
}
|
|
741
|
-
entries={sheetEntries(item, sessions, actions, handlers, details)}
|
|
742
|
-
// The PR its actions apply to has a size line; an issue's PRs are in its stack line
|
|
743
|
-
|
|
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
|
+
}
|
|
744
839
|
/>
|
|
745
840
|
);
|
|
746
841
|
}
|
|
747
842
|
|
|
748
|
-
// 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.
|
|
749
844
|
function sheetEntries(
|
|
750
845
|
item: Item,
|
|
751
846
|
sessions: AgentSummary[],
|
|
752
847
|
actions: Actions,
|
|
753
848
|
{ onPerform, onClose }: SheetHandlers,
|
|
754
|
-
details?:
|
|
849
|
+
details?: SheetDetails,
|
|
755
850
|
): SheetEntry[] {
|
|
756
851
|
const inDoing = SECTIONS[item.section].tab === "doing";
|
|
757
852
|
const close = (then: () => void) => () => (onClose(), then());
|
|
@@ -771,10 +866,10 @@ function sheetEntries(
|
|
|
771
866
|
if (running.length) entries.push(...running.map((agent) => sessionEntry(agent, sessionLabel(kind, item), open)));
|
|
772
867
|
else entries.push({ key: action, icon: "agent", label: `${label}…`, detail: actionDetail(action as Exclude<ActionId, "rerun">, item), onPress: withOptions(label, kind) });
|
|
773
868
|
} else if (action === "rerun") {
|
|
774
|
-
|
|
775
|
-
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))()));
|
|
776
870
|
} else {
|
|
777
|
-
|
|
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) });
|
|
778
873
|
}
|
|
779
874
|
}
|
|
780
875
|
// Anything Attention Span doesn't cover [ATT-12], and its link to share [ATT-15].
|
|
@@ -788,7 +883,7 @@ function sheetEntries(
|
|
|
788
883
|
});
|
|
789
884
|
// Nothing's left to start on once it's merged or closed.
|
|
790
885
|
if (!item.closedAt) entries.push(startAnotherEntry(sessions.length > 0, withOptions("Start session", fallbackKind(item))));
|
|
791
|
-
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)) });
|
|
792
887
|
return entries;
|
|
793
888
|
}
|
|
794
889
|
|
|
@@ -1167,13 +1262,13 @@ function History({ items, actions }: { items: Item[]; actions: Actions }) {
|
|
|
1167
1262
|
}
|
|
1168
1263
|
|
|
1169
1264
|
// Stacked or linked PRs as a connected line; collapsed, only those needing attention [ATT-03, ATT-04].
|
|
1170
|
-
// In the sheet each row opens its PR on GitHub [ATT-12].
|
|
1171
|
-
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 }) {
|
|
1172
1267
|
const styles = useStyles();
|
|
1173
1268
|
return (
|
|
1174
1269
|
<View>
|
|
1175
1270
|
{rows.map((row, index) => (
|
|
1176
|
-
<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}>
|
|
1177
1272
|
<View style={{ width: 16, alignItems: "center" }}>
|
|
1178
1273
|
<View style={{ width: 2, flex: 1, backgroundColor: index === 0 ? "transparent" : styles.c.border }} />
|
|
1179
1274
|
<TablerIcon name={merged ? "merge" : row.draft ? "draft" : "pr"} size={14} color={merged ? styles.c.statusSuccess : row.draft ? styles.c.foregroundMuted : styles.c.statusSuccess} />
|
|
@@ -1183,7 +1278,10 @@ function StackLine({ rows, merged, links = false }: { rows: SubRow[]; merged: bo
|
|
|
1183
1278
|
<Text style={{ color: styles.c.foreground, fontSize: 13 }} numberOfLines={1}>
|
|
1184
1279
|
{row.title}
|
|
1185
1280
|
</Text>
|
|
1186
|
-
<
|
|
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>
|
|
1187
1285
|
</View>
|
|
1188
1286
|
{links ? (
|
|
1189
1287
|
<View style={{ justifyContent: "center", paddingHorizontal: 4 }}>
|
|
@@ -1196,17 +1294,18 @@ function StackLine({ rows, merged, links = false }: { rows: SubRow[]; merged: bo
|
|
|
1196
1294
|
);
|
|
1197
1295
|
}
|
|
1198
1296
|
|
|
1199
|
-
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 }) {
|
|
1200
1298
|
const styles = useStyles();
|
|
1201
1299
|
const { hovered, hover } = useHover();
|
|
1202
|
-
|
|
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>;
|
|
1203
1302
|
return (
|
|
1204
1303
|
<Pressable
|
|
1205
1304
|
accessibilityRole="link"
|
|
1206
1305
|
accessibilityLabel={`Open PR #${number} on GitHub`}
|
|
1207
1306
|
onPress={() => void openExternalUrl(url)}
|
|
1208
1307
|
{...hover}
|
|
1209
|
-
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" }]}
|
|
1210
1309
|
>
|
|
1211
1310
|
{children}
|
|
1212
1311
|
</Pressable>
|
package/client/card.tsx
CHANGED
|
@@ -4,7 +4,6 @@ import { ActivityIndicator, Pressable, Text, View } from "react-native";
|
|
|
4
4
|
import type { Chip } from "../shared/attention";
|
|
5
5
|
import type { IconName } from "./icons";
|
|
6
6
|
import { type Place, PlaceText } from "./entity";
|
|
7
|
-
import { cancelPendingOpen } from "./sheet";
|
|
8
7
|
import { Button, HintArea, Meta, TablerIcon, toneColor, useStyles } from "./ui";
|
|
9
8
|
|
|
10
9
|
// Every card in every list has this anatomy; tabs fill it in with data and slots, not layout [ATT-05].
|
|
@@ -42,10 +41,8 @@ export interface CardProps {
|
|
|
42
41
|
meta: { place: Place; when?: string; signals: Chip[] };
|
|
43
42
|
// Defaults to "<title>, more".
|
|
44
43
|
accessibilityLabel?: string;
|
|
45
|
-
// Tapping the card opens its sheet [ATT-06].
|
|
44
|
+
// Tapping the card opens its sheet, at once [ATT-06].
|
|
46
45
|
onOpen: () => void;
|
|
47
|
-
// While its sheet waits for its details, a spinner takes the place of › [ATT-06].
|
|
48
|
-
opening?: boolean;
|
|
49
46
|
// Resting the pointer on the card, to fetch its sheet's details ahead.
|
|
50
47
|
hover?: { onHoverIn: () => void; onHoverOut: () => void };
|
|
51
48
|
// The labelled main action; secondary ones are icon-only (›, copy).
|
|
@@ -65,9 +62,8 @@ export function CardList({ children }: { children: ReactNode }) {
|
|
|
65
62
|
return <View style={styles.card}>{children}</View>;
|
|
66
63
|
}
|
|
67
64
|
|
|
68
|
-
export function CardRow({ first, mark, title, meta, accessibilityLabel, onOpen,
|
|
65
|
+
export function CardRow({ first, mark, title, meta, accessibilityLabel, onOpen, hover, primary, secondary, busy, extra, confirm, overlay }: CardProps & { first: boolean }) {
|
|
69
66
|
const styles = useStyles();
|
|
70
|
-
const chevron = secondary.some((action) => action.icon === "chevronRight");
|
|
71
67
|
const actions = (
|
|
72
68
|
<View style={styles.wrap}>
|
|
73
69
|
{primary ? (
|
|
@@ -77,8 +73,7 @@ export function CardRow({ first, mark, title, meta, accessibilityLabel, onOpen,
|
|
|
77
73
|
icon={primary.icon}
|
|
78
74
|
variant="calm"
|
|
79
75
|
busy={busy}
|
|
80
|
-
|
|
81
|
-
onPress={() => (cancelPendingOpen(), primary.onPress())}
|
|
76
|
+
onPress={primary.onPress}
|
|
82
77
|
/>
|
|
83
78
|
) : busy ? (
|
|
84
79
|
<ActivityIndicator size="small" color={styles.c.foregroundMuted} />
|
|
@@ -91,11 +86,9 @@ export function CardRow({ first, mark, title, meta, accessibilityLabel, onOpen,
|
|
|
91
86
|
icon={action.icon}
|
|
92
87
|
variant="ghost"
|
|
93
88
|
accessibilityLabel={action.accessibilityLabel ?? action.label}
|
|
94
|
-
busy={opening && action.icon === "chevronRight"}
|
|
95
89
|
onPress={action.onPress}
|
|
96
90
|
/>
|
|
97
91
|
))}
|
|
98
|
-
{opening && !chevron ? <ActivityIndicator size="small" color={styles.c.foregroundMuted} accessibilityLabel="Opening" /> : null}
|
|
99
92
|
</View>
|
|
100
93
|
);
|
|
101
94
|
return (
|
package/client/next-up.tsx
CHANGED
|
@@ -20,7 +20,7 @@ import type { IconName } from "./icons";
|
|
|
20
20
|
import type { FetchDetails } from "./attention-screen";
|
|
21
21
|
import { CardList, CardRow, type Tone } from "./card";
|
|
22
22
|
import { sessionEntry, startAnotherEntry } from "./session-menu";
|
|
23
|
-
import { ActionSheet, DETAILS_STALE_MS, DetailLines, type DetailsQuery, detailsKey, Modal, type SheetEntry,
|
|
23
|
+
import { ActionSheet, DETAILS_STALE_MS, DetailLines, type DetailsQuery, detailsKey, Modal, type SheetEntry, usePrefetchOnRest } from "./sheet";
|
|
24
24
|
import { githubColor, IssuePills, PlaceText } from "./entity";
|
|
25
25
|
import { Button, KeepStyles, Meta, SectionHeader, TablerIcon, useHover, useStyles } from "./ui";
|
|
26
26
|
|
|
@@ -286,7 +286,7 @@ function prSignal(issue: NextUpIssue): Chip[] {
|
|
|
286
286
|
return [{ text: `PR by ${first.author ?? "someone"}${more.length ? ` +${more.length}` : ""}`, tone: "warn" }];
|
|
287
287
|
}
|
|
288
288
|
|
|
289
|
-
// What an issue's sheet fetches when it opens; its card fetches the same ahead
|
|
289
|
+
// What an issue's sheet fetches when it opens; resting the pointer on its card fetches the same ahead [ATT-06].
|
|
290
290
|
function issueDetailsQuery(issue: NextUpIssue, fetchDetails: FetchDetails): DetailsQuery {
|
|
291
291
|
const subject = { kind: "issue" as const, repo: issue.repo, number: issue.number };
|
|
292
292
|
return { queryKey: detailsKey(subject, undefined, false), queryFn: () => fetchDetails({ subject, checks: false }) };
|
|
@@ -298,8 +298,9 @@ const TYPE_TONES: Record<string, Tone> = { bug: "bad", feature: "good", epic: "g
|
|
|
298
298
|
// Its main action and ›; tapping it opens the sheet with the description, Claim or Unclaim [ATT-06, NXT-07].
|
|
299
299
|
function IssueRow({ issue, claim, first, agents, login, busy, fetchDetails, onStart, onOptions, onClaim, onCloseIssue, onOpenAgent }: RowProps & { issue: NextUpIssue; claim: boolean; first: boolean }) {
|
|
300
300
|
const [sheet, setSheet] = useState(false);
|
|
301
|
-
// The sheet opens once
|
|
302
|
-
const
|
|
301
|
+
// The sheet opens at once; what it fetches fills in [ATT-06].
|
|
302
|
+
const open = () => setSheet(true);
|
|
303
|
+
const prefetch = usePrefetchOnRest(issueDetailsQuery(issue, fetchDetails));
|
|
303
304
|
// Closing asks first, with the reason and an optional comment [NXT-11, SAFE-01].
|
|
304
305
|
const [closing, setClosing] = useState(false);
|
|
305
306
|
// An open session leads; without one, Start does [SES-03].
|
|
@@ -315,9 +316,8 @@ function IssueRow({ issue, claim, first, agents, login, busy, fetchDetails, onSt
|
|
|
315
316
|
accessibilityLabel={`${issue.type ? `${issue.type}: ` : ""}${issue.title}, more`}
|
|
316
317
|
meta={{ place: { repo: issue.repo, number: issue.number, login }, when: `${ago(issue.createdAt)} old`, signals: prSignal(issue) }}
|
|
317
318
|
extra={<IssuePills issue={issue} />}
|
|
318
|
-
onOpen={
|
|
319
|
-
|
|
320
|
-
hover={opener.hover}
|
|
319
|
+
onOpen={open}
|
|
320
|
+
hover={prefetch}
|
|
321
321
|
busy={busy.has(issue.key)}
|
|
322
322
|
primary={
|
|
323
323
|
sessions[0]
|
|
@@ -325,7 +325,7 @@ function IssueRow({ issue, claim, first, agents, login, busy, fetchDetails, onSt
|
|
|
325
325
|
: // Claim first so teammates see it's taken [NXT-05].
|
|
326
326
|
{ label: startLabel, accessibilityLabel: `${startLabel} ${issue.title}`, icon: "agent", onPress: () => onStart(issue, claim) }
|
|
327
327
|
}
|
|
328
|
-
secondary={[{ label: `Details for #${issue.number}`, icon: "chevronRight", onPress:
|
|
328
|
+
secondary={[{ label: `Details for #${issue.number}`, icon: "chevronRight", onPress: open }]}
|
|
329
329
|
confirm={
|
|
330
330
|
closing
|
|
331
331
|
? {
|
|
@@ -394,10 +394,11 @@ function IssueSheet({
|
|
|
394
394
|
]),
|
|
395
395
|
claim
|
|
396
396
|
? { key: "claim", icon: "claim", label: "Claim", detail: "Assigns you, without starting a session", onPress: close(() => onClaim(issue, true)) }
|
|
397
|
-
: { key: "unclaim", icon: "unclaim", label: "Unclaim", detail: "Removes you as assignee, so it goes back to Unclaimed", onPress: close(() => onClaim(issue, false)) },
|
|
397
|
+
: { key: "unclaim", icon: "unclaim", label: "Unclaim", detail: "Removes you as assignee, so it goes back to Unclaimed", housekeeping: true, onPress: close(() => onClaim(issue, false)) },
|
|
398
398
|
{ key: "github", icon: "github", label: "Open issue on GitHub", detail: `${issue.repo}#${issue.number}`, onPress: close(() => void openExternalUrl(issue.url)) },
|
|
399
399
|
...(sessions.length ? [startAnotherEntry(true, withOptions)] : []),
|
|
400
|
-
|
|
400
|
+
// Giving it up or closing it sits apart, below the work [ATT-06].
|
|
401
|
+
{ key: "close", icon: "issueClosed", label: "Close issue", detail: "Asks first: as completed or not planned, with an optional comment", housekeeping: true, onPress: close(onCloseIssue) },
|
|
401
402
|
];
|
|
402
403
|
return (
|
|
403
404
|
<ActionSheet
|
package/client/session-menu.ts
CHANGED
|
@@ -13,7 +13,8 @@ export function agentSignal(agent: AgentSummary): Chip {
|
|
|
13
13
|
// A session as a sheet line, under the name of what started it: it opens the session, its state at the end [SES-03, ATT-07].
|
|
14
14
|
export function sessionEntry(agent: AgentSummary, label: string, onOpen: (agentId: string) => void): SheetEntry {
|
|
15
15
|
const signal = agentSignal(agent);
|
|
16
|
-
|
|
16
|
+
// Non-breaking, so "2h ago" doesn't split across lines beside a badge on phones.
|
|
17
|
+
const when = agent.lastActivityAt ? `${ago(agent.lastActivityAt)} ago`.replace(/ /g, "\u00a0") : null;
|
|
17
18
|
return {
|
|
18
19
|
key: agent.id,
|
|
19
20
|
icon: "agent",
|
package/client/sheet.tsx
CHANGED
|
@@ -1,21 +1,29 @@
|
|
|
1
1
|
import { openExternalUrl } from "@getpaseo/plugin/client";
|
|
2
|
-
import { Modal
|
|
2
|
+
import { Modal } from "@getpaseo/plugin/client/ui";
|
|
3
3
|
import { useQueryClient } from "@tanstack/react-query";
|
|
4
|
-
import { type ReactNode, useEffect, useRef
|
|
5
|
-
import { Pressable, Text, View } from "react-native";
|
|
4
|
+
import { type ReactNode, useEffect, useRef } from "react";
|
|
5
|
+
import { Animated, Platform, Pressable, Text, View } from "react-native";
|
|
6
6
|
import { type Chip, type ItemDetails, ownStack, type Target } from "../shared/attention";
|
|
7
|
-
import { LatestOnly, type PendingOpen } from "../shared/opening";
|
|
8
7
|
import type { IconName } from "./icons";
|
|
9
|
-
import { Button, HintArea, KeepStyles, LINE_HEIGHT, REST_MS, Signal, Skeleton, TablerIcon, toneColor, useCopy, useHover, useStyles } from "./ui";
|
|
8
|
+
import { Button, Hint, HintArea, KeepStyles, LINE_HEIGHT, REST_MS, Signal, Skeleton, TablerIcon, toneColor, useCopy, useHover, useStyles } from "./ui";
|
|
10
9
|
|
|
11
|
-
//
|
|
12
|
-
|
|
10
|
+
// Every dialog and sheet in the plugin is Paseo's Modal.
|
|
11
|
+
export { Modal };
|
|
12
|
+
|
|
13
|
+
// Tapping a card opens its sheet at once: what the card knows, every action saying what it will do, then what's fetched.
|
|
14
|
+
// Fetched details go last, so the actions don't move when they arrive. A bottom sheet on phones, a dialog on desktop [ATT-06].
|
|
13
15
|
|
|
14
16
|
export interface SheetEntry {
|
|
15
17
|
key: string;
|
|
16
18
|
icon: IconName;
|
|
17
19
|
label: string;
|
|
18
20
|
detail?: string;
|
|
21
|
+
// In place of `detail`, a line drawn in parts, like Rerun's count, checks and history [PRS-09].
|
|
22
|
+
detailNode?: ReactNode;
|
|
23
|
+
// Said on hover, and to screen readers, for a line that can't show everything [ATT-19].
|
|
24
|
+
hint?: string;
|
|
25
|
+
// A line that changes while the sheet is open, so screen readers say it when it does.
|
|
26
|
+
live?: boolean;
|
|
19
27
|
disabled?: boolean;
|
|
20
28
|
onPress: () => void;
|
|
21
29
|
// A copy icon at the end of the line, so copying adds no line to the sheet [ATT-15].
|
|
@@ -24,19 +32,22 @@ export interface SheetEntry {
|
|
|
24
32
|
badge?: Chip;
|
|
25
33
|
// Muted, for a line that's there on purpose but rarely wanted, like starting another session.
|
|
26
34
|
quiet?: boolean;
|
|
35
|
+
// Taking the item off my list or giving it up (Dismiss, Unclaim, Close): kept apart below the work, icons quiet.
|
|
36
|
+
housekeeping?: boolean;
|
|
27
37
|
}
|
|
28
38
|
|
|
29
39
|
export function ActionSheet({ title, top, entries, bottom, onClose }: { title: string; top: ReactNode; entries: SheetEntry[]; bottom: ReactNode; onClose: () => void }) {
|
|
30
40
|
const styles = useStyles();
|
|
41
|
+
const work = entries.filter((entry) => !entry.housekeeping);
|
|
42
|
+
const housekeeping = entries.filter((entry) => entry.housekeeping);
|
|
31
43
|
return (
|
|
32
44
|
<Modal title={title} open onOpenChange={(open) => (open ? null : onClose())}>
|
|
33
45
|
<Modal.Content>
|
|
34
46
|
<KeepStyles styles={styles}>
|
|
35
47
|
<HintArea style={{ gap: 10 }}>{top}</HintArea>
|
|
36
|
-
<View style={
|
|
37
|
-
{
|
|
38
|
-
|
|
39
|
-
))}
|
|
48
|
+
<View style={{ gap: 10 }}>
|
|
49
|
+
<EntryGroup entries={work} />
|
|
50
|
+
<EntryGroup entries={housekeeping} />
|
|
40
51
|
</View>
|
|
41
52
|
<View style={{ gap: 10 }}>{bottom}</View>
|
|
42
53
|
</KeepStyles>
|
|
@@ -45,31 +56,67 @@ export function ActionSheet({ title, top, entries, bottom, onClose }: { title: s
|
|
|
45
56
|
);
|
|
46
57
|
}
|
|
47
58
|
|
|
48
|
-
|
|
59
|
+
// One block of lines. It doesn't clip, so a line's hint can float over the lines above it; each line rounds its own corners.
|
|
60
|
+
function EntryGroup({ entries }: { entries: SheetEntry[] }) {
|
|
61
|
+
const styles = useStyles();
|
|
62
|
+
if (entries.length === 0) return null;
|
|
63
|
+
return (
|
|
64
|
+
<HintArea style={[styles.card, { backgroundColor: styles.c.surface2, overflow: "visible" }]}>
|
|
65
|
+
{entries.map((entry, index) => (
|
|
66
|
+
<Entry key={entry.key} entry={entry} first={index === 0} last={index === entries.length - 1} />
|
|
67
|
+
))}
|
|
68
|
+
</HintArea>
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const INNER_RADIUS = 11;
|
|
73
|
+
|
|
74
|
+
function Entry({ entry, first, last }: { entry: SheetEntry; first: boolean; last: boolean }) {
|
|
49
75
|
const styles = useStyles();
|
|
50
76
|
const { hovered, hover } = useHover();
|
|
51
77
|
const copy = useCopy();
|
|
52
78
|
const muted = styles.c.foregroundMuted;
|
|
53
79
|
const dim = entry.disabled || entry.quiet;
|
|
80
|
+
// The pressed and hovered fill follows the block's rounded corners; the copy icon has its own at the right.
|
|
81
|
+
const corners = {
|
|
82
|
+
borderTopLeftRadius: first ? INNER_RADIUS : 0,
|
|
83
|
+
borderBottomLeftRadius: last ? INNER_RADIUS : 0,
|
|
84
|
+
borderTopRightRadius: first && !entry.copy ? INNER_RADIUS : 0,
|
|
85
|
+
borderBottomRightRadius: last && !entry.copy ? INNER_RADIUS : 0,
|
|
86
|
+
};
|
|
87
|
+
const detail = entry.detailNode ?? (entry.detail ? <Text style={styles.muted}>{entry.detail}</Text> : null);
|
|
54
88
|
return (
|
|
55
89
|
<View style={[styles.row, { gap: 0, alignItems: "stretch" }, first ? null : { borderTopWidth: 1, borderTopColor: styles.c.surface1 }]}>
|
|
56
90
|
<Pressable
|
|
57
91
|
accessibilityRole="button"
|
|
58
|
-
|
|
92
|
+
// The button's name is all a screen reader says of it, so a hint goes in it too.
|
|
93
|
+
accessibilityLabel={entry.hint ? `${entry.label}. ${entry.hint}` : entry.label}
|
|
94
|
+
accessibilityState={{ disabled: !!entry.disabled }}
|
|
59
95
|
disabled={entry.disabled}
|
|
60
96
|
onPress={entry.onPress}
|
|
61
97
|
{...hover}
|
|
62
98
|
style={({ pressed }) => [
|
|
63
99
|
styles.row,
|
|
100
|
+
corners,
|
|
64
101
|
{ flex: 1, alignItems: "flex-start", paddingVertical: 10, paddingHorizontal: 12, backgroundColor: pressed || hovered ? styles.c.border : "transparent" },
|
|
65
102
|
]}
|
|
66
103
|
>
|
|
67
104
|
<View style={{ paddingTop: 1 }}>
|
|
68
|
-
<TablerIcon name={entry.icon} size={16} color={dim ? muted : styles.action} />
|
|
105
|
+
<TablerIcon name={entry.icon} size={16} color={dim || entry.housekeeping ? muted : styles.action} />
|
|
69
106
|
</View>
|
|
70
|
-
<View style={{ flex: 1, gap: 2 }}>
|
|
107
|
+
<View style={{ flex: 1, gap: 2, minWidth: 0 }}>
|
|
71
108
|
<Text style={{ color: dim ? muted : styles.c.foreground, fontSize: 14, fontWeight: entry.quiet ? "500" : "600" }}>{entry.label}</Text>
|
|
72
|
-
{
|
|
109
|
+
{detail ? (
|
|
110
|
+
<View accessibilityLiveRegion={entry.live ? "polite" : undefined}>
|
|
111
|
+
{entry.hint ? (
|
|
112
|
+
<Hint text={entry.hint} inline>
|
|
113
|
+
{detail}
|
|
114
|
+
</Hint>
|
|
115
|
+
) : (
|
|
116
|
+
detail
|
|
117
|
+
)}
|
|
118
|
+
</View>
|
|
119
|
+
) : null}
|
|
73
120
|
</View>
|
|
74
121
|
{entry.badge ? <Badge {...entry.badge} /> : null}
|
|
75
122
|
</Pressable>
|
|
@@ -106,80 +153,70 @@ export function detailsKey(subject: { kind: "pr" | "issue"; repo: string; number
|
|
|
106
153
|
return ["attention-span", "details", subject.kind, `${subject.repo}#${subject.number}`, pr, checks, checks && target ? ownStack(target).map((p) => p.number) : []];
|
|
107
154
|
}
|
|
108
155
|
|
|
109
|
-
// Fetched details stay fresh this long, so a sheet opened again, or after its card was pointed at,
|
|
156
|
+
// Fetched details stay fresh this long, so a sheet opened again, or after its card was pointed at, is complete at once.
|
|
110
157
|
export const DETAILS_STALE_MS = 60_000;
|
|
111
|
-
// Tapped, a card waits this long at most for its details before its sheet opens anyway.
|
|
112
|
-
const OPEN_WAIT_MS = 1_500;
|
|
113
|
-
// Every card's pending open, so the newest tap wins.
|
|
114
|
-
const PENDING_OPENS = new LatestOnly();
|
|
115
|
-
|
|
116
|
-
// Another way into a sheet, like a card's own action opening its picker, takes over from a card still waiting to open its
|
|
117
|
-
// details sheet, which then doesn't open over it [ATT-06].
|
|
118
|
-
export function cancelPendingOpen(): void {
|
|
119
|
-
PENDING_OPENS.cancel();
|
|
120
|
-
}
|
|
121
158
|
|
|
122
|
-
//
|
|
123
|
-
//
|
|
124
|
-
|
|
125
|
-
function TakingOverModal(props: ModalProps) {
|
|
126
|
-
useEffect(cancelPendingOpen, []);
|
|
127
|
-
return <PaseoModal {...props} />;
|
|
128
|
-
}
|
|
129
|
-
export const Modal: ModalComponent = Object.assign(TakingOverModal, { Content: PaseoModal.Content });
|
|
130
|
-
|
|
131
|
-
// Opens a card's sheet once its details are in, so the sheet doesn't change once open; meanwhile the card says it's
|
|
132
|
-
// loading. Past OPEN_WAIT_MS it opens anyway and the skeletons hold the room; a failure opens it with its error line.
|
|
133
|
-
// Resting the pointer on the card fetches them ahead, best effort [ATT-06, GH-01].
|
|
134
|
-
// Another card tapped while one waits supersedes it, so only one sheet opens.
|
|
135
|
-
export function useSheetOpener(query: DetailsQuery, show: () => void) {
|
|
159
|
+
// Resting the pointer on a card fetches its sheet's details ahead, best effort, so on desktop most sheets open complete.
|
|
160
|
+
// Tapping opens the sheet at once either way; what isn't in yet fills in [ATT-06, GH-01].
|
|
161
|
+
export function usePrefetchOnRest(query: DetailsQuery) {
|
|
136
162
|
const client = useQueryClient();
|
|
137
|
-
const [opening, setOpening] = useState(false);
|
|
138
163
|
const rest = useRef<ReturnType<typeof setTimeout> | undefined>(undefined);
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
useEffect(() => {
|
|
142
|
-
alive.current = true;
|
|
143
|
-
return () => {
|
|
144
|
-
alive.current = false;
|
|
145
|
-
clearTimeout(rest.current);
|
|
146
|
-
pending.current?.done();
|
|
147
|
-
};
|
|
148
|
-
}, []);
|
|
149
|
-
const fetch = () => client.fetchQuery({ ...query, staleTime: DETAILS_STALE_MS });
|
|
150
|
-
const open = () => {
|
|
151
|
-
if (opening) return;
|
|
152
|
-
setOpening(true);
|
|
153
|
-
const turn = PENDING_OPENS.start(() => alive.current && setOpening(false));
|
|
154
|
-
pending.current = turn;
|
|
155
|
-
const waited = new Promise((done) => setTimeout(done, OPEN_WAIT_MS));
|
|
156
|
-
void Promise.race([fetch().catch(() => undefined), waited]).then(() => {
|
|
157
|
-
if (!turn.isCurrent() || !alive.current) return;
|
|
158
|
-
turn.done();
|
|
159
|
-
setOpening(false);
|
|
160
|
-
show();
|
|
161
|
-
});
|
|
162
|
-
};
|
|
163
|
-
const hover = {
|
|
164
|
+
useEffect(() => () => clearTimeout(rest.current), []);
|
|
165
|
+
return {
|
|
164
166
|
onHoverIn: () => {
|
|
165
167
|
clearTimeout(rest.current);
|
|
166
|
-
rest.current = setTimeout(() => void
|
|
168
|
+
rest.current = setTimeout(() => void client.prefetchQuery({ ...query, staleTime: DETAILS_STALE_MS }), REST_MS);
|
|
167
169
|
},
|
|
168
170
|
onHoverOut: () => clearTimeout(rest.current),
|
|
169
171
|
};
|
|
170
|
-
return { opening, open, hover };
|
|
171
172
|
}
|
|
172
173
|
|
|
174
|
+
// Whether something that was loading while it showed has just come in, rather than being there from the start.
|
|
175
|
+
export function useArrived(loading: boolean): boolean {
|
|
176
|
+
const waited = useRef(loading);
|
|
177
|
+
if (loading) waited.current = true;
|
|
178
|
+
return waited.current && !loading;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
// Lines that came in while the sheet was open fade in, rather than popping over their placeholders.
|
|
182
|
+
export function FadeIn({ active, children }: { active: boolean; children: ReactNode }) {
|
|
183
|
+
const opacity = useRef(new Animated.Value(active ? 0 : 1)).current;
|
|
184
|
+
useEffect(() => {
|
|
185
|
+
if (active) Animated.timing(opacity, { toValue: 1, duration: 180, useNativeDriver: Platform.OS !== "web" }).start();
|
|
186
|
+
}, [active, opacity]);
|
|
187
|
+
return <Animated.View style={{ opacity, gap: 10 }}>{children}</Animated.View>;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
// Skeletons show only once loading has taken this long, so a quick answer doesn't flash them; their room is held from the start.
|
|
191
|
+
const SKELETON_DELAY_MS = 150;
|
|
192
|
+
|
|
173
193
|
// The PR's size and the linked issues or PRs, once fetched. Until then skeleton lines hold the room of the lines the card
|
|
174
194
|
// expects (`expected`: a PR's size, the PRs it knows close an issue), so the sheet doesn't jump when they arrive [ATT-06].
|
|
175
|
-
|
|
195
|
+
// `sizeOf` names the PR the size is of, where the sheet is an issue's.
|
|
196
|
+
export function DetailLines({
|
|
197
|
+
details,
|
|
198
|
+
loading,
|
|
199
|
+
error,
|
|
200
|
+
linkedLabel,
|
|
201
|
+
expected,
|
|
202
|
+
sizeOf,
|
|
203
|
+
}: {
|
|
204
|
+
details?: ItemDetails;
|
|
205
|
+
loading: boolean;
|
|
206
|
+
error: unknown;
|
|
207
|
+
linkedLabel: string;
|
|
208
|
+
expected: number;
|
|
209
|
+
sizeOf?: number;
|
|
210
|
+
}) {
|
|
176
211
|
const styles = useStyles();
|
|
212
|
+
const arrived = useArrived(loading);
|
|
177
213
|
const line = [styles.muted, { lineHeight: LINE_HEIGHT }];
|
|
178
|
-
if (loading) return <Skeleton lines={expected} label="Loading details" />;
|
|
214
|
+
if (loading) return <Skeleton lines={expected} label="Loading details" delayMs={SKELETON_DELAY_MS} />;
|
|
179
215
|
if (!details) return error ? <Text style={line}>Couldn't load details: {(error as Error).message}</Text> : null;
|
|
216
|
+
const size = sizeText(details.size);
|
|
180
217
|
return (
|
|
181
|
-
|
|
182
|
-
{
|
|
218
|
+
<FadeIn active={arrived}>
|
|
219
|
+
{size ? <Text style={line}>{sizeOf ? `PR #${sizeOf} · ${size}` : size}</Text> : null}
|
|
183
220
|
{details.linked.map((link) => (
|
|
184
221
|
<Pressable key={link.url} accessibilityRole="link" onPress={() => void openExternalUrl(link.url)}>
|
|
185
222
|
<Text style={line} numberOfLines={1}>
|
|
@@ -187,7 +224,7 @@ export function DetailLines({ details, loading, error, linkedLabel, expected }:
|
|
|
187
224
|
</Text>
|
|
188
225
|
</Pressable>
|
|
189
226
|
))}
|
|
190
|
-
|
|
227
|
+
</FadeIn>
|
|
191
228
|
);
|
|
192
229
|
}
|
|
193
230
|
|
package/client/ui.tsx
CHANGED
|
@@ -124,10 +124,17 @@ export function SpinningIcon({ name, size = 16, color, spinning }: { name: IconN
|
|
|
124
124
|
export const LINE_HEIGHT = 16;
|
|
125
125
|
|
|
126
126
|
// Where lines of text will be once they've loaded: quiet bars, gently pulsing, each the height of the line it stands in for,
|
|
127
|
-
// so nothing moves when the text replaces them. Widths vary so they read as text, not boxes.
|
|
128
|
-
|
|
127
|
+
// so nothing moves when the text replaces them. Widths vary so they read as text, not boxes. With `delayMs` the bars show only
|
|
128
|
+
// after that long, holding their room meanwhile, so a quick answer doesn't flash them.
|
|
129
|
+
export function Skeleton({ lines, label, delayMs = 0 }: { lines: number; label: string; delayMs?: number }) {
|
|
129
130
|
const styles = useStyles();
|
|
130
131
|
const pulse = useRef(new Animated.Value(0)).current;
|
|
132
|
+
const [shown, setShown] = useState(delayMs <= 0);
|
|
133
|
+
useEffect(() => {
|
|
134
|
+
if (delayMs <= 0) return;
|
|
135
|
+
const timer = setTimeout(() => setShown(true), delayMs);
|
|
136
|
+
return () => clearTimeout(timer);
|
|
137
|
+
}, [delayMs]);
|
|
131
138
|
useEffect(() => {
|
|
132
139
|
const native = Platform.OS !== "web";
|
|
133
140
|
const half = (toValue: number) => Animated.timing(pulse, { toValue, duration: 700, easing: Easing.inOut(Easing.ease), useNativeDriver: native });
|
|
@@ -138,7 +145,7 @@ export function Skeleton({ lines, label }: { lines: number; label: string }) {
|
|
|
138
145
|
if (lines <= 0) return null;
|
|
139
146
|
const opacity = pulse.interpolate({ inputRange: [0, 1], outputRange: [0.5, 1] });
|
|
140
147
|
return (
|
|
141
|
-
<View accessibilityLabel={label} style={{ gap: 10 }}>
|
|
148
|
+
<View accessibilityLabel={label} style={{ gap: 10, opacity: shown ? 1 : 0 }}>
|
|
142
149
|
{Array.from({ length: lines }, (_, index) => (
|
|
143
150
|
<View key={index} style={{ height: LINE_HEIGHT, justifyContent: "center" }}>
|
|
144
151
|
<Animated.View style={{ height: 10, borderRadius: 5, width: `${[42, 68, 55][index % 3]}%`, backgroundColor: styles.c.surface2, opacity }} />
|
package/docs/architecture.md
CHANGED
|
@@ -55,7 +55,7 @@ The tabs tell the story of my work, left to right: what I finished, what needs m
|
|
|
55
55
|
|
|
56
56
|
Every card in every tab is the same component, `CardRow` in `client/card.tsx` [ATT-05]: a tinted mark for what it is, a title of at most two lines, then the item's number, its repo (the name brighter than the owner, which my own repos leave out) [ATT-20], when it happened and signal chips, then content only some lists have (pills, a quote, a stack line), and its actions: on the right on desktop, labelled under the text on phones. A change on GitHub asks first in a `ConfirmBar` on the card [SAFE-01]. Tabs differ only in what they pass in: each maps its data to the card's mark, meta, actions and slots. Marks and signals take a tone, never a raw theme color, because some themes draw `accent` close to white. How an item itself is shown, its number and repo and an issue's pills, lives in `client/entity.tsx` (`PlaceText`, `IssuePills`, `ProjectPill`, `FieldPill`, GitHub's option colors), so cards and sheets compose the same pieces rather than format their own; `client/ui.tsx` keeps the generic ones (`Meta`, `Pill`, `Signal`).
|
|
57
57
|
|
|
58
|
-
A sheet shows what the card knows on top, in the same pieces as the card, then every action, then what's fetched when it opens (a PR's size, linked PRs or issues).
|
|
58
|
+
A sheet shows what the card knows on top, in the same pieces as the card, then every action, then what's fetched when it opens (a PR's size, linked PRs or issues). Tapping a card opens its sheet at once, with every action, and what's fetched fills in; it comes last, so the actions don't move when it arrives. Resting the pointer on a card for 300 ms fetches it ahead, best effort (`usePrefetchOnRest` in `client/sheet.tsx`), and it stays fresh for a minute, so the card and its sheet share one query and on desktop most sheets open complete. Until then `Skeleton` bars hold the room of the lines the card expects, at the lines' own height: one for the size of the PR its actions apply to, one per open PR a Next up issue is known to have. They show only after 150 ms, holding their room meanwhile, so a quick answer doesn't flash them, and lines that come in while the sheet is open fade in. An issue's sheet lists only its open PRs, as its card knows them. A failed fetch shows its error line. On desktop the sheet is a centered dialog, so the one line it can't expect, someone else's PR closing the same issue, grows it a little when it comes [ATT-06, GH-01].
|
|
59
59
|
|
|
60
60
|
Something whose meaning isn't obvious, like a face on a card or an amber age, explains itself with `Hint` in `client/ui.tsx` [ATT-19, ATT-11]: its text is the screen-reader label, and on desktop it shows after a 300 ms rest of the pointer. It floats over the layout rather than in it, so showing it moves nothing, and it's sized to the room left in the nearest `HintArea` (a card's text column, a sheet's top), beside its content and wrapping upward, or above it where there's too little room beside. A chip takes one through `hint`.
|
|
61
61
|
|
|
@@ -112,9 +112,9 @@ Projects are extra, so they never cost the searches they ride on (`server/projec
|
|
|
112
112
|
|
|
113
113
|
A card shows its main action and ›. Tapping the card or › opens its **sheet**, a bottom sheet on phones and a dialog on desktop [ATT-06]. When the sheet would hold a single action, as on Waiting and History cards where it's only Open PR (or issue) on GitHub, the card shows that action instead of ›; tapping the card still opens the sheet. History cards also have a copy icon that copies the item's URL [ATT-15]. Top to bottom, the sheet has:
|
|
114
114
|
|
|
115
|
-
1. **What the card knows:** repo#number, its chips, the full quote and the full stack. Each PR in the stack opens on GitHub, so an issue's PRs are a tap away [ATT-12].
|
|
116
|
-
2. **Every action,** each with a line saying what it will do, in one list with
|
|
117
|
-
3. **What's fetched when it opens,** in one GraphQL request, so the refresh stays as light as before [GH-01]: the PR's size and the linked issue or PRs, leaving out PRs the stack already shows. It comes last so the actions don't move when it arrives. The description isn't shown; making sense of it takes GitHub anyway.
|
|
115
|
+
1. **What the card knows:** repo#number, its chips, the full quote and the full stack. Each PR in the stack opens on GitHub, so an issue's PRs are a tap away [ATT-12]. On an issue, the PR its actions apply to is tinted in the stack and says "actions apply here", and its chips are said once, on its row: the top keeps only what the row doesn't say [ATT-04].
|
|
116
|
+
2. **Every action,** each with a line saying what it will do, in one list, with what takes the item off my list or gives it up (Dismiss, Unclaim, Close issue, Close PR) apart below the work, icons quiet. A session action's line asks first: it ends in "…" and opens Options, since the card's button is the one-tap start [SES-01, SES-02]. Once a session of that kind runs, the line opens it instead and shows its state as a badge (working, idle, needs you, failed) [SES-03, ATT-07]. Then Open issue or Open PR on GitHub [ATT-12], with a copy icon at its end that copies the URL without adding a line [ATT-15], a muted "Start a session…" ("Start another session…" once there is one) for a session with no action preset [SES-02], and Dismiss [ATT-08].
|
|
117
|
+
3. **What's fetched when it opens,** in one GraphQL request, so the refresh stays as light as before [GH-01]: the PR's size, led by its number on an issue's sheet ("PR #103 · +149 −15 · 5 files"), and the linked issue or PRs, leaving out PRs the stack already shows. It comes last so the actions don't move when it arrives. The description isn't shown; making sense of it takes GitHub anyway.
|
|
118
118
|
|
|
119
119
|
An agent icon (Tabler's `message-ai`, a speech bubble with "AI") marks every action that starts or continues an agent session, marked *(agent)* below; the rest change GitHub right away [ATT-13]. GitHub actions don't ask first, apart from Merge and Close. Instead an Undo row appears, where GitHub can take it back, until I switch tabs [ATT-14].
|
|
120
120
|
|
|
@@ -124,7 +124,7 @@ An agent icon (Tabler's `message-ai`, a speech bubble with "AI") marks every act
|
|
|
124
124
|
| Acknowledge | Mention waiting | Lists every waiting comment in full, rendered as Markdown with Paseo's renderer (cut after whole blocks, up to about 4,000 characters), all ticked; 👍 on the ones I keep ticked (`addReaction`), which clears them [MEN-07]. Undo removes them. |
|
|
125
125
|
| Review *(agent)* | Review requested | Session in a PR checkout using the review profile [SES-01]. For a stack, "Review stack": one session in a checkout of the stack's top, whose prompt lists every branch and asks for a review of only the PRs requesting mine, each against its own base, with their descriptions and recent comments as context [ATT-04] |
|
|
126
126
|
| Fix CI / Address comments *(agent)* | CI failing / changes requested | Session with the failing log or unresolved threads in the prompt [SES-04] |
|
|
127
|
-
| Rerun failed jobs | CI failing, in the sheet | `gh run rerun --failed` for each failing GitHub Actions run of the PR, or of every PR of mine in its stack.
|
|
127
|
+
| Rerun failed jobs | CI failing, in the sheet | `gh run rerun --failed` for each failing GitHub Actions run of the PR, or of every PR of mine in its stack. Its line, fetched when the sheet opens, says in one line how many failed, which (a matrix's jobs as one, "e2e ×3"; a job alone by its full name), and whether they were rerun before (`gh api …/runs/<id>`), in amber once they were, a hint they may not be flaky: "7 failed · lint, e2e ×3, unit ×2 · ↻ rerun once". Hovering it lists every check by full name; on phones it wraps to two lines instead. Other status checks can't be rerun from here, so they're dimmer. It can be pressed before the checks are in: the sheet closes, and it reruns once they are (`shared/checks.ts`) [PRS-09]. |
|
|
128
128
|
| Update branch | Behind with no conflicts, not stacked | `updatePullRequestBranch` (rebase) [UPS-03] |
|
|
129
129
|
| Rebase / Refresh *(agent)* | Conflicts, any stacked PR, stale draft | Agent rebases the PR, or my PRs in the stack with `git rebase --update-refs`; others' branches in it are never pushed [UPS-04]. A clean rebase is pushed with `--force-with-lease` [UPS-06]. After resolving conflicts it stops and explains, and pushes only when I reply "push" in its session [UPS-05]. |
|
|
130
130
|
| Ready for review | My draft with CI not failing, no conflicts, not stale | `markPullRequestReadyForReview` on the bottom PR, then the reviewer picker below; Skip leaves it in *Needs a reviewer*. Undo converts it back to a draft [PRS-11] |
|
|
@@ -136,7 +136,7 @@ An agent icon (Tabler's `message-ai`, a speech bubble with "AI") marks every act
|
|
|
136
136
|
|
|
137
137
|
A tap starts with defaults. An existing workspace for the branch or PR is resumed instead of creating a new one.
|
|
138
138
|
|
|
139
|
-
While an item has an open session, its main action is **Open session** instead, in every tab [SES-03, ATT-07]. A session belongs to an item when it was started on the item or on any PR under it, and isn't archived; none do once the item is merged or closed. With several, it opens one that needs me, else the most recent. In the sheet each session sits in the line of the action that started it, named after it ("Fix CI", "Rebase stack"), one line per session: a session's kind is saved as the `attention-span-kind` label when it starts. Sessions none of the item's actions would start lead the sheet: those started before kinds were saved, as "Continue session", and those whose action is gone, like Fix CI once checks pass. Sessions started outside Attention Span count too, with no kind, so they lead as "Continue session" [SES-08]: an agent in a workspace Paseo linked to a PR (`githubRuntime.pullRequest`) belongs to that PR, and one in a worktree belongs to the item of the Attention Span session there, unless the worktree has sessions for two items. Main and local checkouts never pass an item on, a labelled session keeps its own item, and agents another agent started belong to that agent. Issues get only the sessions Attention Span started: Paseo doesn't record which issue a workspace was started from. Next up's sheet does the same with Start: "Claim & start…" or "Start…" until there's a session, then the sessions as "Continue session" and a muted "Start another session…". Collapsed, a stack shows only the PRs that need attention [ATT-04].
|
|
139
|
+
While an item has an open session, its main action is **Open session** instead, in every tab [SES-03, ATT-07]. A session belongs to an item when it was started on the item or on any PR under it, and isn't archived; none do once the item is merged or closed. With several, it opens one that needs me, else the most recent. In the sheet each session sits in the line of the action that started it, named after it ("Fix CI", "Rebase stack"), one line per session: a session's kind is saved as the `attention-span-kind` label when it starts. Sessions none of the item's actions would start lead the sheet: those started before kinds were saved, as "Continue session", and those whose action is gone, like Fix CI once checks pass. Sessions started outside Attention Span count too, with no kind, so they lead as "Continue session" [SES-08]: an agent in a workspace Paseo linked to a PR (`githubRuntime.pullRequest`) belongs to that PR, and one in a worktree belongs to the item of the Attention Span session there, unless the worktree has sessions for two items. Main and local checkouts never pass an item on, a labelled session keeps its own item, and agents another agent started belong to that agent. Issues get only the sessions Attention Span started: Paseo doesn't record which issue a workspace was started from. Next up's sheet does the same with Start: "Claim & start…" or "Start…" until there's a session, then the sessions as "Continue session" and a muted "Start another session…". Collapsed, a stack shows only the PRs that need attention [ATT-04]; once it shows any, an issue's card shows the PR its actions apply to as well, tinted with "actions apply here", and says that PR's facts on its row rather than in the meta, as the sheet does [ATT-06].
|
|
140
140
|
|
|
141
141
|
## Sessions
|
|
142
142
|
|
|
@@ -144,7 +144,7 @@ While an item has an open session, its main action is **Open session** instead,
|
|
|
144
144
|
- **Issues kept apart from the code** [SES-07]: an issue starts in the repo `codeRepos` maps its repo to, from that repo's default branch (one `gh repo view`). When neither has a project, Start asks which project holds the code, saves the answer to `codeRepos` and carries on. Claim waits until then, so a start that can't go anywhere doesn't leave the issue taken. The prompt and Claim keep using the issue's own repo.
|
|
145
145
|
- **Workspace**: a worktree with `checkout-pr` for PRs, or `branch-off` from the default branch for issues.
|
|
146
146
|
- **Profile**: looked up per reason in `config.json`, then materialised into `create_agent` from `list_profiles`. A missing `review` profile falls back to `default`; a missing `default` starts the agent with Paseo's defaults: the first ready provider and its default model. The plugin's server reads the provider list (`providers.ready`), because the app's own snapshot can arrive compact, with no entries. Options ▾ still offers provider and model [SES-06].
|
|
147
|
-
- **Prompt**: a built-in template per session type, filled with the item's context. A template in `config.json` replaces the built-in one [SES-04]. The context is fetched when the session starts, mostly from `gh`'s JSON output: `gh pr checks` and `gh run view --log-failed` for Fix, `gh pr view`/`gh issue view` for Review and Start, one GraphQL query for unresolved threads for Address. Rebase uses the stack already in the item.
|
|
147
|
+
- **Prompt**: a built-in template per session type, filled with the item's context. A template in `config.json` replaces the built-in one [SES-04]. The context is fetched when the session starts, mostly from `gh`'s JSON output: `gh pr checks` and `gh run view --log-failed` for Fix, `gh pr view`/`gh issue view` for Review and Start, one GraphQL query for unresolved threads for Address. Rebase uses the stack already in the item. Descriptions go in whole; Review of a stack links each PR asking for review instead. Comments and review threads are cut, but a cut keeps the links from the part it drops, and the prompt says how many comments, reviews or threads it left out, with the item's URL.
|
|
148
148
|
|
|
149
149
|
## Feedback
|
|
150
150
|
|
|
Binary file
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@andrioid/paseo-attention-span",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.12",
|
|
4
4
|
"description": "For when your attention is spread thin: the GitHub issues and pull requests waiting on you, grouped by why, with one-tap Paseo sessions.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
package/server/context.ts
CHANGED
|
@@ -4,10 +4,32 @@ import { graphql, runGh } from "./gh";
|
|
|
4
4
|
|
|
5
5
|
// Context for a session prompt, fetched deterministically when a session starts [SES-04].
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
// Cuts long text, but lists every link from the cut part so the agent can still open them, like a Jam recording at the
|
|
8
|
+
// bottom of a support issue.
|
|
9
|
+
export function clip(text: string | null | undefined, max: number): string {
|
|
8
10
|
const value = (text ?? "").trim();
|
|
9
|
-
|
|
10
|
-
|
|
11
|
+
if (value.length <= max) return value;
|
|
12
|
+
const links = (part: string) => [...part.matchAll(/(.?)(https?:\/\/[^\s<>"'`\[\]]+)/gi)].map(([, before, url]) => trimLink(url, before));
|
|
13
|
+
const kept = new Set(links(value.slice(0, max)));
|
|
14
|
+
// A link the cut splits in half is listed whole.
|
|
15
|
+
const cut = [...new Set(links(value))].filter((url) => !kept.has(url));
|
|
16
|
+
const listed = cut.length ? `\nLinks in the cut part:\n${cut.map((url) => `- ${url}`).join("\n")}` : "";
|
|
17
|
+
return `${value.slice(0, max)}\n…(truncated)${listed}`;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// A link runs to the first space, quote or square bracket. Trailing punctuation belongs to the sentence, a closing
|
|
21
|
+
// parenthesis only when the link has no opening one (Markdown's [text](url)), and * or _ only when they also open it
|
|
22
|
+
// (**url**, _url_).
|
|
23
|
+
function trimLink(url: string, before: string): string {
|
|
24
|
+
let link = url;
|
|
25
|
+
for (let previous = ""; previous !== link; ) {
|
|
26
|
+
previous = link;
|
|
27
|
+
link = link.replace(/[.,;:!?]+$/, "");
|
|
28
|
+
if (link.endsWith(")") && (link.match(/\(/g)?.length ?? 0) < (link.match(/\)/g)?.length ?? 0)) link = link.slice(0, -1);
|
|
29
|
+
if ((before === "*" || before === "_") && link.endsWith(before)) link = link.replace(before === "*" ? /\*+$/ : /_+$/, "");
|
|
30
|
+
}
|
|
31
|
+
return link;
|
|
32
|
+
}
|
|
11
33
|
|
|
12
34
|
async function ghJson<T>(args: string[]): Promise<T> {
|
|
13
35
|
// `gh pr checks` exits non-zero when checks fail but still prints the JSON.
|
|
@@ -26,26 +48,30 @@ export async function sessionContext(kind: SessionKind, target: Target): Promise
|
|
|
26
48
|
if (kind === "fix") return failingChecks(ref, target.repo);
|
|
27
49
|
if (kind === "address") return reviewFeedback(target);
|
|
28
50
|
|
|
29
|
-
// Review of a stack: every branch,
|
|
51
|
+
// Review of a stack: every branch, with a link to each PR asking for my review; the agent reads what it needs [ATT-04].
|
|
30
52
|
const stack = target.stack ?? [];
|
|
31
53
|
if (kind === "review" && stack.length > 1) {
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
const prs = await Promise.all(asking.map(async (pr) => `#${pr.number}\n${await conversation([String(pr.number), "--repo", target.repo], "pr")}`));
|
|
35
|
-
return [`Stack, bottom first:\n${lines.join("\n")}`, ...prs].join("\n\n");
|
|
54
|
+
const lines = stack.map((pr) => `${branchLine(pr)}${pr.review ? `, review requested: https://github.com/${target.repo}/pull/${pr.number}` : ", mine"}`);
|
|
55
|
+
return `Stack, bottom first:\n${lines.join("\n")}`;
|
|
36
56
|
}
|
|
37
57
|
|
|
38
|
-
// review, start: the description and the latest comments.
|
|
39
|
-
return conversation(ref, target
|
|
58
|
+
// review, start: the whole description and the latest comments.
|
|
59
|
+
return conversation(ref, target);
|
|
40
60
|
}
|
|
41
61
|
|
|
42
62
|
const branchLine = (pr: StackPr) => `- #${pr.number}: ${pr.head} (on ${pr.base})`;
|
|
43
63
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
64
|
+
const RECENT_COMMENTS = 5;
|
|
65
|
+
|
|
66
|
+
async function conversation(ref: string[], target: Target): Promise<string> {
|
|
67
|
+
type View = { body: string; comments: { author: { login: string } | null; body: string }[] };
|
|
68
|
+
const view = await ghJson<View>([target.kind === "pr" ? "pr" : "issue", "view", ...ref, "--json", "body,comments"]);
|
|
69
|
+
const comments = view.comments.slice(-RECENT_COMMENTS).map((c) => `@${c.author?.login ?? "ghost"}: ${clip(c.body, 800)}`);
|
|
70
|
+
const older = view.comments.length > RECENT_COMMENTS ? `Showing the last ${RECENT_COMMENTS} of ${view.comments.length} comments; the rest are at ${target.url}` : "";
|
|
71
|
+
// The description goes in whole: GitHub caps it at 65,536 characters, and its links are often at the bottom.
|
|
72
|
+
return [`Description:\n${(view.body ?? "").trim() || "(empty)"}`, comments.length ? `Recent comments:\n${[older, ...comments].filter(Boolean).join("\n\n")}` : ""]
|
|
73
|
+
.filter(Boolean)
|
|
74
|
+
.join("\n\n");
|
|
49
75
|
}
|
|
50
76
|
|
|
51
77
|
export async function defaultBranch(repo: string): Promise<string | null> {
|
|
@@ -66,6 +92,13 @@ async function failingChecks(ref: string[], repo: string): Promise<string> {
|
|
|
66
92
|
return [`Failing checks:\n${failed.map((check) => `- ${check.name} ${check.link}`).join("\n")}`, ...logs].join("\n\n");
|
|
67
93
|
}
|
|
68
94
|
|
|
95
|
+
// What one page of a review query leaves out, with where to read the rest.
|
|
96
|
+
const notShown = (count: number, what: string, url: string) => (count > 0 ? `${count} ${what} not shown, see ${url}` : "");
|
|
97
|
+
|
|
98
|
+
const THREADS = 100;
|
|
99
|
+
const THREAD_COMMENTS = 20;
|
|
100
|
+
const REVIEWS = 20;
|
|
101
|
+
|
|
69
102
|
// gh has no command for unresolved review threads, so this one is GraphQL.
|
|
70
103
|
async function reviewFeedback(target: Target): Promise<string> {
|
|
71
104
|
type Author = { login: string } | null;
|
|
@@ -73,16 +106,19 @@ async function reviewFeedback(target: Target): Promise<string> {
|
|
|
73
106
|
const data = await graphql<{
|
|
74
107
|
repository: {
|
|
75
108
|
pullRequest: {
|
|
76
|
-
reviews: { nodes: { author: Author; state: string; body: string }[] };
|
|
77
|
-
reviewThreads: {
|
|
109
|
+
reviews: { totalCount: number; nodes: { author: Author; state: string; body: string }[] };
|
|
110
|
+
reviewThreads: {
|
|
111
|
+
totalCount: number;
|
|
112
|
+
nodes: { isResolved: boolean; path: string; line: number | null; comments: { totalCount: number; nodes: { author: Author; body: string }[] } }[];
|
|
113
|
+
};
|
|
78
114
|
};
|
|
79
115
|
};
|
|
80
116
|
}>(
|
|
81
117
|
`query($owner: String!, $name: String!, $number: Int!) {
|
|
82
118
|
repository(owner: $owner, name: $name) {
|
|
83
119
|
pullRequest(number: $number) {
|
|
84
|
-
reviews(last:
|
|
85
|
-
reviewThreads(first:
|
|
120
|
+
reviews(last: ${REVIEWS}, states: [CHANGES_REQUESTED, COMMENTED]) { totalCount nodes { author { login } state body } }
|
|
121
|
+
reviewThreads(first: ${THREADS}) { totalCount nodes { isResolved path line comments(first: ${THREAD_COMMENTS}) { totalCount nodes { author { login } body } } } }
|
|
86
122
|
}
|
|
87
123
|
}
|
|
88
124
|
}`,
|
|
@@ -93,8 +129,20 @@ async function reviewFeedback(target: Target): Promise<string> {
|
|
|
93
129
|
const summaries = reviews.nodes.filter((r) => r.body.trim()).map((r) => `- ${who(r.author)} (${r.state.toLowerCase()}): ${clip(r.body, 1500)}`);
|
|
94
130
|
const threads = reviewThreads.nodes
|
|
95
131
|
.filter((t) => !t.isResolved)
|
|
96
|
-
.map((t) =>
|
|
97
|
-
|
|
132
|
+
.map((t) => {
|
|
133
|
+
const comments = t.comments.nodes.map((c) => ` ${who(c.author)}: ${clip(c.body, 1500).replace(/\n/g, "\n ")}`);
|
|
134
|
+
const more = notShown(t.comments.totalCount - t.comments.nodes.length, "more comments", target.url);
|
|
135
|
+
return [`- ${t.path}${t.line ? `:${t.line}` : ""}`, ...comments, more && ` ${more}`].filter(Boolean).join("\n");
|
|
136
|
+
});
|
|
137
|
+
// Older reviews and later threads past one page are left out; say so, since some of those threads may be unresolved.
|
|
138
|
+
const olderReviews = notShown(reviews.totalCount - reviews.nodes.length, "older reviews", target.url);
|
|
139
|
+
const laterThreads = notShown(reviewThreads.totalCount - reviewThreads.nodes.length, "more review threads (resolved or not)", target.url);
|
|
140
|
+
return [
|
|
141
|
+
summaries.length ? `Review summaries:\n${summaries.join("\n")}` : "",
|
|
142
|
+
threads.length ? `Unresolved review threads:\n${threads.join("\n")}` : laterThreads ? "" : "No unresolved review threads.",
|
|
143
|
+
olderReviews,
|
|
144
|
+
laterThreads,
|
|
145
|
+
]
|
|
98
146
|
.filter(Boolean)
|
|
99
147
|
.join("\n\n");
|
|
100
148
|
}
|
package/server/fixture.ts
CHANGED
|
@@ -354,6 +354,22 @@ export function fixtureDetails(subject: { kind: "pr" | "issue"; repo: string; nu
|
|
|
354
354
|
return {
|
|
355
355
|
size: pr ? { additions: 84 + (pr.number % 7) * 13, deletions: 12 + (pr.number % 5), files: 2 + (pr.number % 4) } : undefined,
|
|
356
356
|
linked: subject.number === 120 ? [{ number: 200, title: "Customers can't tell when the shop is down", url: `https://github.com/${REPO}/issues/200`, state: "OPEN" }] : [],
|
|
357
|
-
|
|
357
|
+
// A matrix's jobs, a check from outside Actions, and a run rerun once already: "5 failed · lint, e2e ×3, Vercel · ↻ rerun once" [PRS-09].
|
|
358
|
+
failing:
|
|
359
|
+
checks && pr
|
|
360
|
+
? [
|
|
361
|
+
{
|
|
362
|
+
pr: pr.number,
|
|
363
|
+
checks: [
|
|
364
|
+
{ name: "lint", rerunnable: true },
|
|
365
|
+
{ name: "e2e (chromium)", rerunnable: true },
|
|
366
|
+
{ name: "e2e (firefox)", rerunnable: true },
|
|
367
|
+
{ name: "e2e (webkit)", rerunnable: true },
|
|
368
|
+
{ name: "Vercel", rerunnable: false },
|
|
369
|
+
],
|
|
370
|
+
runs: [{ id: 9001, attempt: 2 }],
|
|
371
|
+
},
|
|
372
|
+
]
|
|
373
|
+
: [],
|
|
358
374
|
};
|
|
359
375
|
}
|
package/shared/checks.ts
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import type { FailingChecks } from "./attention";
|
|
2
|
+
|
|
3
|
+
// What Rerun failed jobs says about a PR's failing checks, in one line: how many failed, which, and whether they were rerun
|
|
4
|
+
// before, so a flaky check can be told from a real failure [PRS-09].
|
|
5
|
+
|
|
6
|
+
export interface CheckGroup {
|
|
7
|
+
// A matrix's jobs share the name before " (": e2e (chromium) and e2e (firefox) are e2e. A job alone keeps its full name.
|
|
8
|
+
name: string;
|
|
9
|
+
count: number;
|
|
10
|
+
// Checks from GitHub Actions can be rerun; other status checks can't.
|
|
11
|
+
rerunnable: boolean;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface RerunSummary {
|
|
15
|
+
failed: number;
|
|
16
|
+
// Of those, the ones from GitHub Actions.
|
|
17
|
+
rerunnable: number;
|
|
18
|
+
// How often the failing runs were rerun already: the most of any run.
|
|
19
|
+
reruns: number;
|
|
20
|
+
// Each PR with failing checks, grouped; more than one only for a stack of mine [ATT-04].
|
|
21
|
+
prs: { pr: number; groups: CheckGroup[] }[];
|
|
22
|
+
runIds: number[];
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const matrixName = (name: string) => name.replace(/\s*\(.*\)\s*$/, "") || name;
|
|
26
|
+
|
|
27
|
+
// Checks in the order they came, a matrix's jobs as one group with a count. Ones that can't rerun stay apart from ones that can.
|
|
28
|
+
export function groupChecks(checks: FailingChecks["checks"]): CheckGroup[] {
|
|
29
|
+
const groups = new Map<string, { base: string; names: string[]; rerunnable: boolean }>();
|
|
30
|
+
for (const check of checks) {
|
|
31
|
+
const base = matrixName(check.name);
|
|
32
|
+
const key = `${check.rerunnable}:${base}`;
|
|
33
|
+
const group = groups.get(key) ?? { base, names: [], rerunnable: check.rerunnable };
|
|
34
|
+
group.names.push(check.name);
|
|
35
|
+
groups.set(key, group);
|
|
36
|
+
}
|
|
37
|
+
return [...groups.values()].map(({ base, names, rerunnable }) => ({ name: names.length === 1 ? names[0] : base, count: names.length, rerunnable }));
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export function summarizeRerun(failing: FailingChecks[]): RerunSummary {
|
|
41
|
+
const checks = failing.flatMap((f) => f.checks);
|
|
42
|
+
const runs = failing.flatMap((f) => f.runs);
|
|
43
|
+
return {
|
|
44
|
+
failed: checks.length,
|
|
45
|
+
rerunnable: checks.filter((check) => check.rerunnable).length,
|
|
46
|
+
reruns: Math.max(0, ...runs.map((run) => run.attempt - 1)),
|
|
47
|
+
prs: failing.filter((f) => f.checks.length > 0).map((f) => ({ pr: f.pr, groups: groupChecks(f.checks) })),
|
|
48
|
+
runIds: runs.map((run) => run.id),
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// "e2e ×3", or the job's own name.
|
|
53
|
+
export const groupLabel = (group: CheckGroup) => (group.count > 1 ? `${group.name} ×${group.count}` : group.name);
|
|
54
|
+
|
|
55
|
+
// "rerun once", "rerun 2×", "not rerun".
|
|
56
|
+
export const rerunHistory = (reruns: number) => (reruns === 0 ? "not rerun" : reruns === 1 ? "rerun once" : `rerun ${reruns}×`);
|
|
57
|
+
|
|
58
|
+
// Every failing check by its full name, one per line, under its PR in a stack, saying which can't rerun: the hint, and what a
|
|
59
|
+
// screen reader hears.
|
|
60
|
+
export function failingList(failing: FailingChecks[]): string {
|
|
61
|
+
const stack = failing.filter((f) => f.checks.length > 0).length > 1;
|
|
62
|
+
return failing
|
|
63
|
+
.filter((f) => f.checks.length > 0)
|
|
64
|
+
.flatMap((f) => [...(stack ? [`#${f.pr}`] : []), ...f.checks.map((check) => `${stack ? " " : ""}${check.name}${check.rerunnable ? "" : " · not GitHub Actions, can't rerun"}`)])
|
|
65
|
+
.join("\n");
|
|
66
|
+
}
|
package/shared/prompts.ts
CHANGED
|
@@ -65,7 +65,7 @@ Read the issue and the code it touches, then propose a plan before changing anyt
|
|
|
65
65
|
// Review of a stack, while config.json doesn't replace the review template: one session for every PR asking for my review [ATT-04].
|
|
66
66
|
export const REVIEW_STACK_TEMPLATE = `Review the pull requests {{review}} in {{repo}}, part of the stack {{stack}} (bottom first). You are in a checkout of the top branch, {{head}}, which has every PR's changes.
|
|
67
67
|
|
|
68
|
-
1. Review: for each of {{review}}, read its description and its diff against its own base (\`git diff origin/<base>...origin/<head>\`, branches below). Review only those; the rest of the stack is context.
|
|
68
|
+
1. Review: for each of {{review}}, read its description (linked below) and its diff against its own base (\`git diff origin/<base>...origin/<head>\`, branches below). Review only those; the rest of the stack is context.
|
|
69
69
|
2. Investigate: dig into anything risky or unclear in the code they touch.
|
|
70
70
|
3. ${SWEEP}
|
|
71
71
|
4. Report back, for each PR:
|
package/shared/opening.ts
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
// Only the newest of several pending opens may go through: tapping another card while one waits for its details supersedes
|
|
2
|
-
// it, so two sheets never open on top of each other whichever request finishes first [ATT-06].
|
|
3
|
-
export class LatestOnly {
|
|
4
|
-
private current: { id: number; cancel: () => void } | null = null;
|
|
5
|
-
private next = 0;
|
|
6
|
-
|
|
7
|
-
// Something else took over, like an action that opens its own sheet: whatever was waiting to open won't.
|
|
8
|
-
cancel(): void {
|
|
9
|
-
this.current?.cancel();
|
|
10
|
-
this.current = null;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
// A new pending open; the one before it, if still waiting, is cancelled.
|
|
14
|
-
start(cancel: () => void): PendingOpen {
|
|
15
|
-
this.current?.cancel();
|
|
16
|
-
const id = ++this.next;
|
|
17
|
-
this.current = { id, cancel };
|
|
18
|
-
return {
|
|
19
|
-
isCurrent: () => this.current?.id === id,
|
|
20
|
-
// It opened, or its card went away: nothing is pending any more.
|
|
21
|
-
done: () => {
|
|
22
|
-
if (this.current?.id === id) this.current = null;
|
|
23
|
-
},
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export interface PendingOpen {
|
|
29
|
-
isCurrent: () => boolean;
|
|
30
|
-
done: () => void;
|
|
31
|
-
}
|