paseo-follow-up 2.4.0-beta.6 → 2.4.0-beta.7
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/brief.tsx +14 -5
- package/client/needs-you.tsx +32 -14
- package/client/reviewers-button.tsx +114 -0
- package/package.json +2 -1
- package/shared/keep-in-place.ts +22 -0
- package/shared/reviewers-click.ts +59 -0
- package/shared/status-invariants.ts +14 -0
package/client/brief.tsx
CHANGED
|
@@ -23,6 +23,7 @@ import { useDetailGate, useWorkspace } from "./workspace-data";
|
|
|
23
23
|
import { SubmitScope, focusRing, submitHint, text, useNow } from "./kit";
|
|
24
24
|
import { PrLinksProvider, RichText } from "./rich-text";
|
|
25
25
|
import { useMergeButtons } from "./merge-button";
|
|
26
|
+
import { useReviewerButtons } from "./reviewers-button";
|
|
26
27
|
import { prLinksByNumber } from "../shared/presentation";
|
|
27
28
|
import { cardStore } from "./card-store";
|
|
28
29
|
import { PrSheet } from "./pr-sheet";
|
|
@@ -381,6 +382,7 @@ function BriefCardBody({ item, theme, layout, agentId, deps, embedded = false, s
|
|
|
381
382
|
const live = useQuery({ queryKey: liveBriefKey(agentId), queryFn: () => readBrief({ agentId }), enabled: row.state === "open" && !!agentId, refetchInterval: LIVE_BRIEF_POLL_MS, staleTime: 5_000 });
|
|
382
383
|
const workspace = row.workspaceId ? deps.workspace(row.workspaceId) : undefined;
|
|
383
384
|
const merges = useMergeButtons(workspace);
|
|
385
|
+
const asks = useReviewerButtons(workspace);
|
|
384
386
|
const checked = shownBrief(row, live.data, workspace?.questions ?? []);
|
|
385
387
|
// The check itself failed (or there's no agent to ask): don't leave a dead card. The server still validates every
|
|
386
388
|
// action against the stored brief, and a moot refusal reconciles, so acting on the row is safe.
|
|
@@ -473,11 +475,18 @@ function BriefCardBody({ item, theme, layout, agentId, deps, embedded = false, s
|
|
|
473
475
|
if (id !== null) deps.noteDone?.(agentId, () => { dismissToast(id); setMarked(null); });
|
|
474
476
|
};
|
|
475
477
|
// A merge move reads what its click merges ("Merge 3 PRs"), then "Merging…".
|
|
476
|
-
|
|
477
|
-
|
|
478
|
+
// An add-reviewers move that names whom it asks reads "Add reviewers", "Requesting…", then "Requested"
|
|
479
|
+
// (a-click-on-add-reviewers-asks), and a move that is done stays done.
|
|
480
|
+
const oneClick = (m: BriefMove) => !m.prKey ? null : m.kind === "merge" ? merges.view(m.prKey) : m.kind === "add_reviewers" ? asks.view(m.prKey) : null;
|
|
481
|
+
const moveLabel = (m: BriefMove) => (m.kind === "merge" || m.kind === "add_reviewers" ? oneClick(m)?.label : null) ?? (busy === m.kind ? `${m.label}…` : m.label);
|
|
482
|
+
const moveDone = (m: BriefMove) => { const one = oneClick(m); return !!one && ("done" in one ? one.done : one.submitted); };
|
|
483
|
+
const moveIcon = (m: BriefMove) => moveDone(m) ? "Check" : MOVE_ICON[m.kind];
|
|
484
|
+
const moveOff = (m: BriefMove) => !!busy || !!oneClick(m)?.running || moveDone(m);
|
|
485
|
+
const mergeWhy = b.moves.map(m => oneClick(m)?.why).find(Boolean) ?? null;
|
|
478
486
|
const press = (m: BriefMove) => {
|
|
479
487
|
// Merge is one click (a-click-on-merge-merges); the sheet's confirm only for a PR whose scope can't be known.
|
|
480
|
-
|
|
488
|
+
// Add reviewers is one click too when there is someone to ask; the sheet's picker only when nobody is set.
|
|
489
|
+
const one = oneClick(m);
|
|
481
490
|
if (one) one.run();
|
|
482
491
|
else if ((m.kind === "merge" || m.kind === "add_reviewers") && m.prKey) { if (workspace?.prs.some(p => p.key === m.prKey)) setSheet({ key: m.prKey, intent: m.kind === "merge" ? "merge" : "reviewers" }); else if (b.workspaceId) deps.openPanel(b.workspaceId); }
|
|
483
492
|
else if (m.kind === "open_pr" && m.url) void openExternalUrl(m.url).catch(() => undefined);
|
|
@@ -516,7 +525,7 @@ function BriefCardBody({ item, theme, layout, agentId, deps, embedded = false, s
|
|
|
516
525
|
<View style={{ flexDirection: "row", flexWrap: "wrap", alignItems: "center", columnGap: 10, rowGap: 8 }}>
|
|
517
526
|
<RichText numberOfLines={3} tooltip={askText}
|
|
518
527
|
style={{ flexGrow: 1, flexShrink: 1, flexBasis: 200, minWidth: 0, color: acts ? c.foreground : c.foregroundMuted, fontSize: 14, lineHeight: 20, fontWeight: acts ? "600" : "400" }}>{askText}</RichText>
|
|
519
|
-
{!embedded && moves.map(m => <Btn key={m.kind} label={moveLabel(m)} icon={
|
|
528
|
+
{!embedded && moves.map(m => <Btn key={m.kind} label={moveLabel(m)} icon={moveIcon(m)} disabled={moveOff(m)} onPress={() => press(m)} c={c} compact={compact} hint={MOVE_HINT[m.kind]} />)}
|
|
520
529
|
</View>
|
|
521
530
|
{!!error && <Text accessibilityRole="alert" style={{ color: c.statusDanger, fontSize: 13, lineHeight: 18 }}>{error}</Text>}
|
|
522
531
|
{!!mergeWhy && <Text accessibilityRole="alert" style={{ color: c.statusWarning, fontSize: 13, lineHeight: 18 }}>{mergeWhy}</Text>}
|
|
@@ -585,7 +594,7 @@ function BriefCardBody({ item, theme, layout, agentId, deps, embedded = false, s
|
|
|
585
594
|
{multi && <SendBar b={b} picks={sendable} noted={notedCount(sendable, openNotes)} busy={busy} error={error} onSend={sendAll} c={c} compact={compact} />}
|
|
586
595
|
|
|
587
596
|
{!embedded && moves.length > 0 && <View style={{ flexDirection: "row", flexWrap: "wrap", alignItems: "center", gap: 8, columnGap: 14 }}>
|
|
588
|
-
{moves.map((m, i) => <Btn key={m.kind} shortcut={m === doneMove} label={moveLabel(m)} icon={
|
|
597
|
+
{moves.map((m, i) => <Btn key={m.kind} shortcut={m === doneMove} label={moveLabel(m)} icon={moveIcon(m)} primary={i === 0 && !multi} disabled={moveOff(m)} onPress={() => press(m)} c={c} compact={compact} hint={MOVE_HINT[m.kind]} />)}
|
|
589
598
|
{/* one-done-button: the quiet choices sit beside Done, never above the context, away from it. */}
|
|
590
599
|
{doneQ && !notesOpen[doneQ.id] && !isOther(picks[doneQ.id]) && <NoteLink icon="MessageSquarePlus" label="Add note" a11y="Add a note, sent with Done" disabled={!!busy} onPress={() => noteOpenStore.set(b.id, doneQ.id, "1")} c={c} compact={compact} />}
|
|
591
600
|
{doneQ && !isOther(picks[doneQ.id]) && <NoteLink icon="Reply" label="Reply instead" a11y="Write a reply instead of Done" disabled={!!busy} onPress={() => pickStore.set(b.id, doneQ.id, OTHER)} c={c} compact={compact} />}
|
package/client/needs-you.tsx
CHANGED
|
@@ -26,6 +26,7 @@ import { DismissX, RevealScope, useDismiss } from "./dismiss";
|
|
|
26
26
|
import { overviewKey, workspaceKey } from "./keys";
|
|
27
27
|
import { PrLinksProvider, RichText } from "./rich-text";
|
|
28
28
|
import { useMergeButtons } from "./merge-button";
|
|
29
|
+
import { reviewerClick, useHeldNeeds, useReviewerButtons } from "./reviewers-button";
|
|
29
30
|
import { mergeScope } from "../shared/merge-click";
|
|
30
31
|
import { prLinksByNumber } from "../shared/presentation";
|
|
31
32
|
import { deliveryStatus } from "../shared/queue";
|
|
@@ -99,7 +100,11 @@ export function NeedsYouList({ workspace: w, theme, compact, actions, now = Date
|
|
|
99
100
|
const queueAct = useMutation({ mutationFn: (input: { itemId: string; action: "retry" | "cancel" }) => queueAction(input),
|
|
100
101
|
onSuccess: (_r, input) => { toast.show(input.action === "retry" ? "Sending it again" : "Cancelled; it won't be sent", { variant: "info" }); refresh(); actions.after?.(); }, onError: fail });
|
|
101
102
|
const inspect = useMutation({ mutationFn: (actionId: string) => check({ workspaceId: w.id, actionId }), onSuccess: reply => { toast.show(reply.result, { variant: reply.state === "failed" ? "warning" : "info" }); refresh(); }, onError: fail });
|
|
102
|
-
const
|
|
103
|
+
const reviewerControl = useReviewerButtons(w);
|
|
104
|
+
// a-clicked-row-holds-its-place: a row clicked here keeps its spot (with its outcome) after the next read drops it,
|
|
105
|
+
// so a run of clicks down the list lands on the rows aimed at. A surface passing `rows` held them itself (the block).
|
|
106
|
+
const held = useHeldNeeds(w.id, rows ? [] : needsYou(w, now));
|
|
107
|
+
const items = rows ?? held;
|
|
103
108
|
const mergeControl = useMergeButtons(w);
|
|
104
109
|
const dismiss = useDismiss();
|
|
105
110
|
if (!items.length) return null;
|
|
@@ -145,7 +150,8 @@ export function NeedsYouList({ workspace: w, theme, compact, actions, now = Date
|
|
|
145
150
|
case "send": return <Button theme={theme} compact={compact} kind="primary" icon="Send" title={item.finish ? "Ask to finish" : sendButton(item.what)} accessibilityLabel={item.finish ? `Ask to finish: ${FINISH_ASK}` : `Send ${item.what} to ${agentName(w)}`} accessibilityHint={item.blocker ?? undefined} loading={deliver.isPending} disabled={busy || !!item.blocker} onPress={() => deliver.mutate(item.batchId)} />;
|
|
146
151
|
// One click merges what the button names (a-click-on-merge-merges); the sheet's confirm only when the scope can't be known.
|
|
147
152
|
case "merge": return mergeControl(item.prKey, { theme, compact, fallback: actions.openPr ? () => actions.openPr!(item.prKey, "merge") : undefined }).button;
|
|
148
|
-
|
|
153
|
+
// One click asks the people the row names (a-click-on-add-reviewers-asks); the sheet's picker only when nobody is set.
|
|
154
|
+
case "reviewers": return reviewerControl(item.prKey, { theme, compact, after: actions.after, fallback: actions.openPr ? () => actions.openPr!(item.prKey, "reviewers") : undefined })?.button ?? null;
|
|
149
155
|
}
|
|
150
156
|
};
|
|
151
157
|
// A second, quieter action after the primary and its PR link, so the link never wraps onto a line of its own.
|
|
@@ -164,28 +170,32 @@ export function NeedsYouList({ workspace: w, theme, compact, actions, now = Date
|
|
|
164
170
|
const merging = item.kind === "merge" ? mergeControl(item.prKey, { theme, compact }) : null;
|
|
165
171
|
const scopeLine = item.kind === "merge" ? mergeScope(w, item.prKey)?.detail ?? null : null;
|
|
166
172
|
const notice = merging?.notice ?? null;
|
|
173
|
+
// A reviewers row's why-not sits in its own text column on phones too, so the row never changes layout under the next tap.
|
|
174
|
+
const asked = item.kind === "reviewers" ? reviewerControl(item.prKey, { theme, compact })?.notice ?? null : null;
|
|
167
175
|
// The action and its link are one group, so the link never wraps under the button (a long "Add reviewers").
|
|
168
176
|
const pair = act && link ? <View style={{ flexDirection: "row", alignItems: "center", gap: 4, flexShrink: 0 }}>{act}{link}</View> : null;
|
|
169
177
|
const more = secondary(item);
|
|
170
178
|
const button = act || link || more ? <>{pair ?? <>{act}{link}</>}{more}</> : null;
|
|
171
179
|
const said = !!untitled?.has(item.key);
|
|
180
|
+
// A reviewers row whose request went out reads as a receipt: muted title, nothing left to remove.
|
|
181
|
+
const receipt = item.kind === "reviewers" && reviewerClick(w.id, item.prKey)?.outcome?.state === "submitted";
|
|
182
|
+
const titleStyle = (base: object) => receipt ? [base, { color: c.foregroundMuted }] : base;
|
|
172
183
|
// The small x, top right, on every kind (dismissing-anything-in-needs-you-sends-the-agent-nothing).
|
|
173
|
-
const x = <DismissX theme={theme} compact={compact} label={`Remove ${item.kind === "question" ? item.questionId : item.title}`}
|
|
184
|
+
const x = receipt ? null : <DismissX theme={theme} compact={compact} label={`Remove ${item.kind === "question" ? item.questionId : item.title}`}
|
|
174
185
|
onPress={() => dismiss({ workspaceId: w.id, key: item.key }, { onDismissed: actions.after })} />;
|
|
175
186
|
// Phones: the action sits at the row's right edge so rows never grow a second line of controls. A send batch
|
|
176
187
|
// (the primary, with its task list) and Retry's pair keep their buttons full width under the row.
|
|
177
188
|
// A stack's scope line and a blocker need the row's full width, so those rows put their button under the text.
|
|
178
|
-
|
|
189
|
+
// So does a reviewers row: its one click asks the people its title names, so the title shows them in full.
|
|
190
|
+
const inline = compact && button && item.kind !== "send" && !(item.kind === "retry" && !item.exhausted) && item.kind !== "person" && item.kind !== "reviewers" && !scopeLine && !notice;
|
|
179
191
|
if (inline) return <CardRow key={item.key} theme={theme} compact first={index === 0 && flush} style={flush ? { paddingHorizontal: 0 } : undefined}>
|
|
180
192
|
<RevealScope style={{ flexDirection: "row", alignItems: "center", gap: 10 }}>
|
|
181
|
-
{
|
|
182
|
-
<View style={item.kind === "reviewers" ? { alignSelf: "flex-start", paddingTop: 2 } : undefined}><Icon name={g.name} size={16} color={g.color} /></View>
|
|
193
|
+
<View><Icon name={g.name} size={16} color={g.color} /></View>
|
|
183
194
|
<View style={{ flex: 1, minWidth: 0, gap: 2 }}>
|
|
184
|
-
{!said && <RichText numberOfLines={2} style={t.label}>{item.title}</RichText>}
|
|
195
|
+
{!said && <RichText numberOfLines={2} style={titleStyle(t.label)}>{item.title}</RichText>}
|
|
185
196
|
{"detail" in item && !!item.detail && !sameText(item.detail, item.title.replace(/^Q\d+ · /, "")) && <RichText linkColor={c.foreground} numberOfLines={item.kind === "answer" || item.kind === "message" ? 3 : 1} style={t.meta}>{item.detail}</RichText>}
|
|
186
|
-
{item.kind === "reviewers" && <NoReviewLink repo={item.prKey.split("#")[0]} theme={theme} compact />}
|
|
187
197
|
</View>
|
|
188
|
-
<View
|
|
198
|
+
<View>{pair ?? button}</View>
|
|
189
199
|
{/* Top right, a step away from the action so a thumb aimed at it doesn't land here. */}
|
|
190
200
|
{/* Flush (Catch up's bordered card): no pull to the edge, so the armed Dismiss pill keeps clear of the border. */}
|
|
191
201
|
<View style={{ alignSelf: "flex-start", marginTop: -4, marginRight: flush ? 0 : -6, marginLeft: 2 }}>{x}</View>
|
|
@@ -195,7 +205,7 @@ export function NeedsYouList({ workspace: w, theme, compact, actions, now = Date
|
|
|
195
205
|
<RevealScope style={{ flexDirection: "row", gap: 9 }}>
|
|
196
206
|
<View style={{ paddingTop: 2 }}><Icon name={g.name} size={14} color={g.color} /></View>
|
|
197
207
|
<View style={{ flex: 1, minWidth: 0, gap: 3 }}>
|
|
198
|
-
{!said && <RichText style={compact ? t.label : t.body}>{item.title}</RichText>}
|
|
208
|
+
{!said && <RichText style={titleStyle(compact ? t.label : t.body)}>{item.title}</RichText>}
|
|
199
209
|
{"detail" in item && !!item.detail && !sameText(item.detail, item.title.replace(/^Q\d+ · /, "")) && <RichText linkColor={c.foreground} numberOfLines={item.kind === "question" ? 2 : 3} style={t.meta}>{item.detail}</RichText>}
|
|
200
210
|
{scopeLine && <RichText style={t.meta}>{scopeLine}</RichText>}
|
|
201
211
|
{item.kind === "question" && <QuestionState workspace={w} questionId={item.questionId} theme={theme} />}
|
|
@@ -204,7 +214,7 @@ export function NeedsYouList({ workspace: w, theme, compact, actions, now = Date
|
|
|
204
214
|
{button}
|
|
205
215
|
{item.kind === "send" && item.blocker && <Text style={[t.small, { flexShrink: 1 }]}>{item.blocker}</Text>}
|
|
206
216
|
</View>}
|
|
207
|
-
{notice}
|
|
217
|
+
{notice ?? asked}
|
|
208
218
|
</View>
|
|
209
219
|
<View style={{ marginTop: -3, marginRight: flush ? 2 : -5 }}>{x}</View>
|
|
210
220
|
</RevealScope>
|
|
@@ -238,14 +248,22 @@ export function NeedsYouBlock({ workspace: w, theme, compact, actions, now, brie
|
|
|
238
248
|
/** That brief's own card, drawn when it points at no open question. */ briefCard?: ReactNode; style?: StyleProp<ViewStyle>;
|
|
239
249
|
}) {
|
|
240
250
|
useReviewerSettings(); // re-renders on a No review change, so the block's rows and count drop the asks at once
|
|
241
|
-
|
|
251
|
+
// Held before grouping: a clicked reviewers row keeps its place, and the brief it folds stays folded.
|
|
252
|
+
const live = needsYou(w, now);
|
|
253
|
+
const all = useHeldNeeds(w.id, live);
|
|
242
254
|
const block = needsYouBlock(all, brief && briefCard ? brief : null, w.questions);
|
|
255
|
+
// The count is the rows still open or still in flight; a held row whose request is done is drawn as a receipt, not
|
|
256
|
+
// counted. Mid-run the number matches the rows on screen; once every held row is done the card says so.
|
|
257
|
+
const held = all.filter(i => !live.includes(i));
|
|
258
|
+
const inFlight = held.filter(i => i.kind === "reviewers" && reviewerClick(w.id, i.prKey)?.running).length;
|
|
259
|
+
const count = block.count - held.length + inFlight;
|
|
260
|
+
const asked = !count && held.length > 0 && held.every(i => i.kind === "reviewers");
|
|
243
261
|
// An accordion: one question open at a time (the block's first by default); its header closes it again.
|
|
244
262
|
const [openId, setOpenId] = useState<string | null | undefined>(undefined);
|
|
245
|
-
if (!block.count) return null;
|
|
263
|
+
if (!block.count) return null; // held rows keep the block drawn after its last ask is done
|
|
246
264
|
// In Later the block stays (its moves still work) but reads Later, without the attention border.
|
|
247
265
|
const later = workspaceSnoozed(w, all, now) && w.snooze ? laterLabel(w.snooze.until, now) : null;
|
|
248
|
-
return <Card theme={theme} compact={compact} icon={later ? "AlarmClock" : "CircleAlert"} title={later ? `Later ${later}` : "Needs you"} tone={later ? "plain" : "attention"} count={
|
|
266
|
+
return <Card theme={theme} compact={compact} icon={later ? "AlarmClock" : asked ? "Check" : "CircleAlert"} title={later ? `Later ${later}` : asked ? "Reviewers requested" : "Needs you"} tone={later || !count ? "plain" : "attention"} count={count || undefined} style={style}>
|
|
249
267
|
{block.cards.map(card => card.kind === "brief"
|
|
250
268
|
? <View key="brief" style={{ borderTopWidth: 1, borderTopColor: theme.colors.border }}>{briefCard}</View>
|
|
251
269
|
: <QuestionAsk key={card.questionId} workspace={w} questionId={card.questionId} context={card.brief ? brief?.context ?? null : null} theme={theme} compact={compact} now={now} openAgent={actions.openAgent}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { useRef, useSyncExternalStore, type ReactNode } from "react";
|
|
2
|
+
import { useRpc } from "@getpaseo/plugin/client";
|
|
3
|
+
import { useQueryClient } from "@tanstack/react-query";
|
|
4
|
+
import { requestReviewersRpc } from "../shared/contracts";
|
|
5
|
+
import { workspaceKey } from "./keys";
|
|
6
|
+
import { reviewersScope, reviewersWords, type ReviewersOutcome } from "../shared/reviewers-click";
|
|
7
|
+
import type { ListWorkspace as Workspace } from "../shared/list";
|
|
8
|
+
import type { NeedItem } from "../shared/attention";
|
|
9
|
+
import { keepInPlace } from "../shared/keep-in-place";
|
|
10
|
+
import { Button, errorText, text, type ButtonKind, type Theme } from "./kit";
|
|
11
|
+
import { Text } from "./text";
|
|
12
|
+
import { View } from "react-native";
|
|
13
|
+
|
|
14
|
+
type Control = { button: ReactNode; notice: ReactNode; /** Asked: the row reads as a receipt, not an ask. */ done: boolean };
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Each PR's click, for the session: in flight, or what came of it. One store for every surface (the panel's block and
|
|
18
|
+
* its rows, the chat's brief card, Home's detail pane, the pill), keyed by workspace and PR, so a click on one shows on
|
|
19
|
+
* all, and a surface that regroups its rows (the block folds a brief into a row) never loses it. Memory only.
|
|
20
|
+
*/
|
|
21
|
+
type Entry = { running: boolean; outcome: ReviewersOutcome | null };
|
|
22
|
+
let asked: Record<string, Entry> = {};
|
|
23
|
+
const subscribers = new Set<() => void>();
|
|
24
|
+
const keyOf = (workspaceId: string, prKey: string) => `${workspaceId}|${prKey}`;
|
|
25
|
+
const setEntry = (k: string, e: Entry) => { asked = { ...asked, [k]: e }; for (const f of subscribers) f(); };
|
|
26
|
+
const subscribe = (f: () => void) => { subscribers.add(f); return () => { subscribers.delete(f); }; };
|
|
27
|
+
const snapshot = () => asked;
|
|
28
|
+
/** One PR's click as the session holds it, for a list deciding how to draw and count a held row. */
|
|
29
|
+
export const reviewerClick = (workspaceId: string, prKey: string): Entry | undefined => asked[keyOf(workspaceId, prKey)];
|
|
30
|
+
/** Tests: forget every click. */
|
|
31
|
+
export const resetReviewerClicks = () => { asked = {}; for (const f of subscribers) f(); };
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* a-clicked-row-holds-its-place: the Needs-you items a surface draws, with every reviewers row clicked here kept where
|
|
35
|
+
* it was after the next read drops it, until the surface unmounts. Call it on the items before anything groups them
|
|
36
|
+
* (the block's cards and rows), so the grouping never changes under the developer's next click either.
|
|
37
|
+
*/
|
|
38
|
+
export function useHeldNeeds(workspaceId: string, items: readonly NeedItem[]): NeedItem[] {
|
|
39
|
+
const all = useSyncExternalStore(subscribe, snapshot, snapshot);
|
|
40
|
+
const drawn = useRef<readonly NeedItem[]>([]);
|
|
41
|
+
const out = keepInPlace(drawn.current, items, i => i.key, key => key.startsWith("reviewers:") && !!all[keyOf(workspaceId, key.slice("reviewers:".length))]);
|
|
42
|
+
drawn.current = out;
|
|
43
|
+
return out;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Every Add reviewers button that names its people (a Needs-you row, Catch up's card, a brief's move): one click asks
|
|
48
|
+
* the saved reviewers the row names, with no sheet (a-click-on-add-reviewers-asks, shared/reviewers-click.ts). Each
|
|
49
|
+
* PR has its own pending and outcome, so clicks on several rows one after another all run, and none waits on or
|
|
50
|
+
* disables another (no shared busy lock: a single `useMutation` tracks only its latest call). `fallback` opens the
|
|
51
|
+
* PR sheet's picker, only when nobody is set for the PR. `held(prKey)` says a row has a local outcome to keep
|
|
52
|
+
* showing, so the list keeps it in place (keep-in-place.ts).
|
|
53
|
+
*/
|
|
54
|
+
export type ReviewerButtons = ((prKey: string, o: { theme: Theme; compact: boolean; kind?: ButtonKind; fallback?: () => void; after?: () => void }) => Control | null) & {
|
|
55
|
+
held: (prKey: string) => boolean;
|
|
56
|
+
/** For a surface with its own buttons (the brief card): label and one-click run. Null: nobody set, or the PR isn't tracked. */
|
|
57
|
+
view: (prKey: string, after?: () => void) => { label: string; a11y: string; running: boolean; done: boolean; why: string | null; run: () => void } | null;
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
export function useReviewerButtons(w: Pick<Workspace, "id" | "prs"> | undefined): ReviewerButtons {
|
|
61
|
+
const request = useRpc(requestReviewersRpc);
|
|
62
|
+
const cache = useQueryClient();
|
|
63
|
+
const all = useSyncExternalStore(subscribe, snapshot, snapshot);
|
|
64
|
+
const entry = (prKey: string) => w ? all[keyOf(w.id, prKey)] : undefined;
|
|
65
|
+
const refresh = () => w ? Promise.all([
|
|
66
|
+
cache.invalidateQueries({ queryKey: workspaceKey(w.id) }),
|
|
67
|
+
...[["follow-up", "pr-controls", w.id], ["follow-up", "overview"]].map(key => cache.invalidateQueries({ queryKey: key })),
|
|
68
|
+
]).catch(() => undefined) : Promise.resolve();
|
|
69
|
+
|
|
70
|
+
const run = (prKey: string, after?: () => void) => {
|
|
71
|
+
if (!w) return;
|
|
72
|
+
// Read the store, not this render's copy, so a double click never sends twice.
|
|
73
|
+
const k = keyOf(w.id, prKey); const now = asked[k];
|
|
74
|
+
if (now?.running || now?.outcome?.state === "submitted" || now?.outcome?.state === "uncertain") return;
|
|
75
|
+
setEntry(k, { running: true, outcome: null });
|
|
76
|
+
// No reviewers argument: the server asks the saved list, the same people the row names.
|
|
77
|
+
void request({ workspaceId: w.id, prKey })
|
|
78
|
+
.then(reply => ({ state: reply.state, result: reply.result }) as ReviewersOutcome, (e: unknown) => ({ state: "error", result: errorText(e) }) as ReviewersOutcome)
|
|
79
|
+
.then(outcome => {
|
|
80
|
+
setEntry(k, { running: false, outcome });
|
|
81
|
+
void refresh();
|
|
82
|
+
if (outcome.state === "submitted") after?.();
|
|
83
|
+
});
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
const stateOf = (prKey: string, compact = false) => {
|
|
87
|
+
const pr = w?.prs.find(p => p.key === prKey);
|
|
88
|
+
const scope = pr ? reviewersScope(pr) : null;
|
|
89
|
+
if (!scope) return null;
|
|
90
|
+
const e = entry(prKey);
|
|
91
|
+
const words = reviewersWords(scope, e?.outcome ?? null, !!e?.running, compact);
|
|
92
|
+
return { scope, words, running: !!e?.running };
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
const control = (prKey: string, { theme, compact, kind = "secondary", fallback, after }: Parameters<ReviewerButtons>[1]): Control | null => {
|
|
96
|
+
const c = theme.colors; const t = text(c, compact);
|
|
97
|
+
const s = stateOf(prKey, compact);
|
|
98
|
+
if (!s) return fallback ? { done: false, notice: null, button: <Button theme={theme} compact={compact} kind={kind} icon="UserPlus" title="Add reviewers…" accessibilityLabel="Pick reviewers for this PR" onPress={fallback} /> } : null;
|
|
99
|
+
const { scope, words } = s;
|
|
100
|
+
// As wide as its widest word, so the PR link beside it never moves under the next click.
|
|
101
|
+
const button = <View style={{ minWidth: compact ? 118 : 146 }}><Button theme={theme} compact={compact} kind={kind} icon={words.done ? "Check" : "UserPlus"} title={words.button}
|
|
102
|
+
accessibilityLabel={words.done && words.button !== "Unconfirmed" ? scope.doneA11y : words.done ? `Unconfirmed: ${scope.a11y}` : scope.a11y}
|
|
103
|
+
loading={s.running} disabled={s.running || words.done} onPress={() => run(prKey, after)} /></View>;
|
|
104
|
+
const notice = words.line ? <Text accessibilityRole={words.tone === "warning" ? "alert" : undefined} style={[t.meta, words.tone === "warning" ? { color: c.statusWarning } : null]}>{words.line}</Text> : null;
|
|
105
|
+
return { button, notice, done: words.done };
|
|
106
|
+
};
|
|
107
|
+
const held = (prKey: string) => !!entry(prKey);
|
|
108
|
+
const view: ReviewerButtons["view"] = (prKey, after) => {
|
|
109
|
+
const s = stateOf(prKey);
|
|
110
|
+
if (!s) return null;
|
|
111
|
+
return { label: s.words.button, a11y: s.scope.a11y, running: s.running, done: s.words.done, why: s.words.tone === "warning" ? s.words.line : null, run: () => run(prKey, after) };
|
|
112
|
+
};
|
|
113
|
+
return Object.assign(control, { held, view });
|
|
114
|
+
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "paseo-follow-up",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "2.4.0-beta.
|
|
4
|
+
"version": "2.4.0-beta.7",
|
|
5
5
|
"description": "Follows every workspace your coding agents work in until it's done: one list of what needs you.",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"files": [
|
|
@@ -47,6 +47,7 @@
|
|
|
47
47
|
"shots": "node scripts/screenshots.mjs",
|
|
48
48
|
"shots:readme": "sh scripts/readme-shots.sh",
|
|
49
49
|
"video": "node scripts/demo-video.mjs",
|
|
50
|
+
"video:v2:take": "node scripts/demo-video-v2.mjs",
|
|
50
51
|
"check:paseo-keys": "tsx scripts/check-paseo-keys.ts"
|
|
51
52
|
},
|
|
52
53
|
"devDependencies": {
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* a-clicked-row-holds-its-place (2026-11-24): a row the developer acted on leaves the list on the next read (a
|
|
3
|
+
* reviewer request in flight drops the "Add reviewers" ask), and every row under it moved up, so the next click
|
|
4
|
+
* landed on the row below the one aimed at. A list keeps an acted-on row where it was, showing its outcome, until
|
|
5
|
+
* the list unmounts; only rows nobody touched come and go.
|
|
6
|
+
*
|
|
7
|
+
* `prev`: what the list drew last. `next`: what it would draw now. `held(key)`: whether a row has a local outcome to
|
|
8
|
+
* keep showing. A held row missing from `next` goes back after the row that preceded it last time (or first).
|
|
9
|
+
*/
|
|
10
|
+
export function keepInPlace<T>(prev: readonly T[], next: readonly T[], keyOf: (row: T) => string, held: (key: string) => boolean): T[] {
|
|
11
|
+
const out = [...next];
|
|
12
|
+
const has = new Set(out.map(keyOf));
|
|
13
|
+
for (const [i, row] of prev.entries()) {
|
|
14
|
+
const key = keyOf(row);
|
|
15
|
+
if (has.has(key) || !held(key)) continue;
|
|
16
|
+
// After the nearest earlier row still drawn; none: at the top.
|
|
17
|
+
let at = 0;
|
|
18
|
+
for (let j = i - 1; j >= 0; j--) { const k = out.findIndex(r => keyOf(r) === keyOf(prev[j])); if (k >= 0) { at = k + 1; break; } }
|
|
19
|
+
out.splice(at, 0, row); has.add(key);
|
|
20
|
+
}
|
|
21
|
+
return out;
|
|
22
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import type { ListPr as Pr } from "./list";
|
|
2
|
+
import { configuredReviewers, reviewerLabel, withoutAuthor } from "./reviewers";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* a-click-on-add-reviewers-asks (2026-11-24, Tom: "make it so when I click Add Reviewers it just does that, no popup,
|
|
6
|
+
* and make sure it allows me doing it for a lot of prs one after the other"): "Add reviewers to #240: Ravi" opened the
|
|
7
|
+
* PR sheet, where a second Add reviewers sent the request. The row already names who it asks, so its click asks
|
|
8
|
+
* exactly them, at once. The sheet and its picker open only when there is nobody to name (no saved list, or only the
|
|
9
|
+
* author on it). Each row keeps its own pending and done state, so clicks on five rows in a row all land, and a row
|
|
10
|
+
* the developer clicked holds its place until they leave (keep-in-place.ts). Agent tools keep dry run, then confirm.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
/** What one click on Add reviewers asks, known when the button draws. */
|
|
14
|
+
export type ReviewersScope = {
|
|
15
|
+
prKey: string;
|
|
16
|
+
number: number;
|
|
17
|
+
/** The saved logins the click asks (the repository's list, else the default), minus the PR's author. */
|
|
18
|
+
logins: string[];
|
|
19
|
+
/** The same people as a person reads them (reviewerLabel), in order: the names the row shows. */
|
|
20
|
+
names: string[];
|
|
21
|
+
/** A screen reader's name for the button: who it asks, on which PR. */
|
|
22
|
+
a11y: string;
|
|
23
|
+
/** The same once asked: "Requested Ravi and Mina on pull request #240". */
|
|
24
|
+
doneA11y: string;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
const both = (names: readonly string[]) => names.length < 3 ? names.join(" and ") : `${names.slice(0, -1).join(", ")} and ${names.at(-1)}`;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* The click's scope from the saved lists, or null when nobody is set for this PR (then the button opens the picker:
|
|
31
|
+
* there's nothing to name). Reads the same lists as the row's title (suggestedReviewers), so the two never differ.
|
|
32
|
+
*/
|
|
33
|
+
export function reviewersScope(pr: Pick<Pr, "key" | "number" | "repo" | "snapshot">, saved = configuredReviewers(pr.repo)): ReviewersScope | null {
|
|
34
|
+
const asked = withoutAuthor(saved, pr.snapshot?.reviewers?.author);
|
|
35
|
+
if (!asked.length) return null;
|
|
36
|
+
const names = asked.map(reviewerLabel);
|
|
37
|
+
return { prKey: pr.key, number: pr.number, logins: asked.map(r => r.login), names, a11y: `Ask ${both(names)} to review pull request #${pr.number}`, doneA11y: `Requested ${both(names)} on pull request #${pr.number}` };
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/** What came of one click: the request RPC's reply, or the error it threw. */
|
|
41
|
+
export type ReviewersOutcome = { state: "submitted" | "uncertain" | "failed" | "error"; result: string };
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* One source for the button and the line under it (a-click-on-add-reviewers-asks). `running`: the click is in flight.
|
|
45
|
+
* A done row says "Requested" on the button and nothing more; an unconfirmed one "Unconfirmed", with GitHub's reply under it; a
|
|
46
|
+
* refused one keeps "Add reviewers" (try again) with why under it. `compact`: a phone's button sits on the row's line
|
|
47
|
+
* beside the title that names the PR and the people, so it keeps one short word ("Request", "Sending…", "Requested")
|
|
48
|
+
* and the title keeps the room to say whom the click asks; its accessible name still says it in full (scope.a11y).
|
|
49
|
+
* Never a bare "Ask": in Follow-up an ask is the developer's question or decision, not a review request.
|
|
50
|
+
*/
|
|
51
|
+
export function reviewersWords(scope: ReviewersScope, outcome: ReviewersOutcome | null, running = false, compact = false): { button: string; line: string | null; tone: "warning" | null; done: boolean } {
|
|
52
|
+
const idle = compact ? "Request" : "Add reviewers";
|
|
53
|
+
if (running) return { button: compact ? "Sending…" : "Requesting…", line: null, tone: null, done: false };
|
|
54
|
+
// Done says it on the button alone, so the row keeps its height and the rows under it don't move.
|
|
55
|
+
if (outcome?.state === "submitted") return { button: "Requested", line: null, tone: null, done: true };
|
|
56
|
+
if (outcome?.state === "uncertain") return { button: "Unconfirmed", line: `Unconfirmed: ${outcome.result}`, tone: "warning", done: true };
|
|
57
|
+
if (outcome) return { button: idle, line: `Not requested: ${outcome.result}`, tone: "warning", done: false };
|
|
58
|
+
return { button: idle, line: null, tone: null, done: false };
|
|
59
|
+
}
|
|
@@ -23,6 +23,7 @@ import { foldedAsk, needsYouBlock, onceViolation } from "./needs-block";
|
|
|
23
23
|
import { compactPrStatus, prLink, prPresentation } from "./presentation";
|
|
24
24
|
import { agentMerges } from "./pr-workflow";
|
|
25
25
|
import { mergeScope } from "./merge-click";
|
|
26
|
+
import { reviewersScope } from "./reviewers-click";
|
|
26
27
|
import { GONE_REASON } from "./queue";
|
|
27
28
|
import { taskSchedule } from "./task-trigger";
|
|
28
29
|
import { taskDue } from "./task-due";
|
|
@@ -554,6 +555,19 @@ export const INVARIANTS: Invariant[] = [
|
|
|
554
555
|
return null;
|
|
555
556
|
},
|
|
556
557
|
},
|
|
558
|
+
{
|
|
559
|
+
id: "a-click-on-add-reviewers-asks",
|
|
560
|
+
why: "2026-11-24: Add reviewers on a Needs you row (\"Add reviewers to #240: Ravi\") opened the PR sheet, where a second Add reviewers asked. The row's click now asks exactly the people its title names, so the title and the click read one list; a row that names nobody opens the picker",
|
|
561
|
+
check(w, now) {
|
|
562
|
+
for (const i of needsYou(w, now)) {
|
|
563
|
+
if (i.kind !== "reviewers") continue;
|
|
564
|
+
const pr = w.prs.find(p => p.key === i.prKey);
|
|
565
|
+
const asked = pr ? reviewersScope(pr)?.names ?? [] : [];
|
|
566
|
+
if (asked.join("\n") !== i.suggested.join("\n")) return `${i.key}: names ${i.suggested.join(", ") || "nobody"} but its click asks ${asked.join(", ") || "nobody"}`;
|
|
567
|
+
}
|
|
568
|
+
return null;
|
|
569
|
+
},
|
|
570
|
+
},
|
|
557
571
|
{
|
|
558
572
|
id: "only-a-stop-holds",
|
|
559
573
|
why: "2026-11-11 wks_5dfd3a653ad3c305: a /compact replaced by an agent's message read as \"You stopped the main agent\" and paused auto-sends until Resume. Of every cancel cause (shared/status.ts CANCEL_CAUSES) only the developer's Stop holds.",
|