paseo-follow-up 2.3.0 → 2.4.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/client/brief.tsx +7 -5
  2. package/client/header.tsx +18 -9
  3. package/client/home-list.tsx +3 -3
  4. package/client/home.tsx +3 -2
  5. package/client/merge-button.tsx +1 -1
  6. package/client/stacks.tsx +24 -2
  7. package/index.client.tsx +1 -1
  8. package/index.server.ts +42 -7
  9. package/package.json +2 -1
  10. package/server/agent-actions.ts +4 -3
  11. package/server/agent-hook.mjs +35 -6
  12. package/server/browser-bridge.ts +20 -2
  13. package/server/check-watches.ts +145 -0
  14. package/server/engine.ts +13 -2
  15. package/server/github.ts +15 -2
  16. package/server/hook-source.ts +35 -6
  17. package/server/mcp-source.ts +8 -5
  18. package/server/mcp.mjs +8 -5
  19. package/server/obligations.ts +18 -2
  20. package/server/pr-actions.ts +17 -11
  21. package/server/pr-owner.ts +30 -13
  22. package/server/pr-stats-gate.ts +102 -0
  23. package/server/pr-stats-store.ts +196 -0
  24. package/server/pr-stats-sync.ts +228 -0
  25. package/server/questions.ts +35 -8
  26. package/server/ranker.ts +3 -2
  27. package/server/wait-for-checks.ts +108 -0
  28. package/shared/activity.ts +2 -2
  29. package/shared/attention.ts +88 -15
  30. package/shared/brief.ts +16 -0
  31. package/shared/chat.ts +1 -1
  32. package/shared/check-watch.ts +129 -0
  33. package/shared/contracts.ts +10 -3
  34. package/shared/errors.ts +34 -0
  35. package/shared/home.ts +51 -13
  36. package/shared/model.ts +17 -2
  37. package/shared/poll.ts +9 -2
  38. package/shared/pr-actions.ts +61 -3
  39. package/shared/pr-stats-records.ts +169 -0
  40. package/shared/questions.ts +75 -0
  41. package/shared/queue.ts +1 -1
  42. package/shared/ranker.ts +3 -2
  43. package/shared/scale.ts +24 -0
  44. package/shared/status-invariants.ts +39 -1
  45. package/shared/task-status.ts +9 -2
package/client/brief.tsx CHANGED
@@ -6,7 +6,8 @@ import { useQuery, useQueryClient } from "@tanstack/react-query";
6
6
  import { openExternalUrl, useRpc, type PluginClientContext, type PluginTimelineItemProps } from "@getpaseo/plugin/client";
7
7
  import { deliveryStatus } from "../shared/queue";
8
8
  import { Icon, TextInput, copyText, useToast } from "@getpaseo/plugin/client/ui";
9
- import { BRIEF_KIND, BRIEF_VERSION, askedDecisions, cardPicks, notedCount, pickedCount, briefSchema, collapsedLine, outcomeLabel, extrasFit, hasOriginal, nothingNeededLine, isTight, pastRows, pastTone, selectsFirst, sendBar, shownBrief, pastAsk, liveBrief, newAnswerId, type Brief, type BriefDecision, type BriefMove } from "../shared/brief";
9
+ import { BRIEF_KIND, briefCardAsk, BRIEF_VERSION, askedDecisions, cardPicks, notedCount, pickedCount, briefSchema, collapsedLine, outcomeLabel, extrasFit, hasOriginal, nothingNeededLine, isTight, pastRows, pastTone, selectsFirst, sendBar, shownBrief, pastAsk, liveBrief, newAnswerId, type Brief, type BriefDecision, type BriefMove } from "../shared/brief";
10
+ import { needsYou } from "../shared/attention";
10
11
  import { age } from "../shared/inbox";
11
12
  import { noReviewReposVersion, onNoReviewRepos } from "../shared/pr-workflow";
12
13
  import { briefKey, HEADLINE_WORD } from "../shared/headline";
@@ -38,6 +39,8 @@ export type BriefDeps = {
38
39
  openAgent(agentId: string): void;
39
40
  /** The workspace's list form (shared/list.ts); the PR sheet reads the full one itself. */
40
41
  workspace(id: string): ListWorkspace | undefined;
42
+ /** The agent's Needs-you inbox row, so a card knows whether its brief is an ask (briefAsks). */
43
+ row?(agentId: string): { needs?: unknown } | null;
41
44
  /** Opens Follow-up's panel for a workspace whose record this client hasn't loaded yet. */
42
45
  openPanel(workspaceId: string): void;
43
46
  /** Done's Undo window, so the composer pill says Done (and its Undo cancels the same toast) until it ends. */
@@ -371,10 +374,9 @@ function BriefCardBody({ item, theme, layout, agentId, deps, embedded = false, s
371
374
  const unverifiable = live.isError || !agentId;
372
375
  const shown = row.state !== "open" ? { brief: row, actionable: false } : unverifiable && checked.brief.state === "open" ? { ...checked, actionable: true } : checked;
373
376
  const b = shown.brief;
374
- // "No ask stated" while this workspace has an open question would tell the developer there's nothing to do: the
375
- // fallback points at the questions instead (Needs you asks them; one ask, one surface each).
376
- const waitingOn = b.source === "none" && b.state === "open" ? (workspace?.questions ?? []).filter(q => !q.answer && !q.closed).map(q => q.id) : [];
377
- const askText = waitingOn.length ? `Waiting on your answer to ${waitingOn.join(", ")}` : b.ask;
377
+ // One predicate decides whether the brief's own words draw (briefCardShown, inside briefCardAsk): beside what Needs you
378
+ // holds, a brief without an ask points at it instead (a-brief-without-an-ask-never-sits-beside-needs-you).
379
+ const askText = briefCardAsk(b, agentId ? deps.row?.(agentId) : null, workspace ? needsYou(workspace, Date.now()) : []);
378
380
  // A refusal that means "already answered or replaced" isn't a failure: re-read, and the card shows what happened.
379
381
  const reconcile = (e?: unknown) => { if (e !== undefined) notice(mootNote(e), toast); setError(null); void cache.invalidateQueries({ queryKey: liveBriefKey(agentId) }); if (row.workspaceId) void cache.invalidateQueries({ queryKey: workspaceKey(row.workspaceId) }); };
380
382
  const now = useNow(60_000);
package/client/header.tsx CHANGED
@@ -4,7 +4,7 @@ import { View } from "react-native";
4
4
  import { Pressable, Text } from "./text";
5
5
  import { Icon } from "@getpaseo/plugin/client/ui";
6
6
  import type { Workspace } from "../shared/model";
7
- import { ago, headline, headerLine, stackBar, type LiveIcon } from "../shared/attention";
7
+ import { ago, barMarks, headline, headerLine, stackBar, type LiveIcon } from "../shared/attention";
8
8
  import { Button, IconButton, Switch, text, type Theme } from "./kit";
9
9
  import { VersionMark } from "./updates";
10
10
  import { IconSwap, Spinner } from "./motion";
@@ -15,21 +15,29 @@ import { SummaryLine } from "./about";
15
15
  /** PR status older than this means the poll has stopped working; say so instead of looking current. */
16
16
  export const STALE_MS = 10 * 60_000;
17
17
 
18
- /** One segment per PR in stack order, coloured by state. The signature of the panel; a segment opens its PR. */
18
+ /**
19
+ * One mark per PR in stack order, coloured by state; past STACK_BAR_BUDGET PRs, runs or slices of the stack as wide as
20
+ * their share (`barMarks`, stack-bar-reads-at-any-size). The signature of the panel. A mark opens its loudest PR on
21
+ * desktop only: on a phone the marks are 6-8 pt wide and 2 pt apart, far under the 44 pt touch rule, and the Pull
22
+ * requests card's rows right below open every PR, so the compact header draws it without `onOpen` (one progress bar,
23
+ * no buttons).
24
+ */
19
25
  export function StackBar({ workspace, theme, height = 6, onOpen }: { workspace: Pick<Workspace, "prs">; theme: Theme; height?: number; onOpen?: (key: string) => void }) {
20
26
  const bar = stackBar(workspace);
21
27
  if (!bar.total) return null;
22
- return <View accessibilityRole="progressbar" accessibilityLabel={`${bar.merged} of ${bar.total} PRs merged`} accessibilityValue={{ min: 0, max: bar.total, now: bar.merged }}
28
+ // The label says what the marks show, so a phone's bar (no per-mark buttons) still tells a screen reader what is red (failed checks or a conflict: the header's "to fix").
29
+ const failing = bar.segments.filter(s => s.tone === "danger").length;
30
+ return <View accessibilityRole="progressbar" accessibilityLabel={`${bar.merged} of ${bar.total} PRs merged${failing ? `, ${failing} to fix` : ""}`} accessibilityValue={{ min: 0, max: bar.total, now: bar.merged }}
23
31
  style={{ flexDirection: "row", gap: 2, height, borderRadius: height / 2, overflow: onOpen ? "visible" : "hidden" }}>
24
- {bar.segments.map((s, i) => {
32
+ {barMarks(bar.segments).map((s, i, marks) => {
25
33
  const paint = segmentPaint(theme.colors, s.tone);
26
- const r = height / 2, first = i === 0, last = i === bar.segments.length - 1;
27
- const fill = { flex: 1, justifyContent: "center" as const, alignItems: "center" as const, overflow: "hidden" as const, backgroundColor: paint.fill, borderTopLeftRadius: first ? r : 0, borderBottomLeftRadius: first ? r : 0, borderTopRightRadius: last ? r : 0, borderBottomRightRadius: last ? r : 0 };
34
+ const r = height / 2, first = i === 0, last = i === marks.length - 1;
35
+ const fill = { flex: s.count, minWidth: 6, justifyContent: "center" as const, alignItems: "center" as const, overflow: "hidden" as const, backgroundColor: paint.fill, borderTopLeftRadius: first ? r : 0, borderBottomLeftRadius: first ? r : 0, borderTopRightRadius: last ? r : 0, borderBottomRightRadius: last ? r : 0 };
28
36
  // A short centred dash marks the state without filling the slot, so unmerged work never reads as done.
29
37
  const mark = Math.max(2, Math.round(height / 3));
30
38
  const line = paint.line ? <View style={{ width: "36%", minWidth: 6, height: mark, borderRadius: mark / 2, backgroundColor: paint.line }} /> : null;
31
39
  return onOpen
32
- ? <Pressable key={s.key} accessibilityRole="button" accessibilityLabel={`Open pull request ${s.number}`} hitSlop={{ top: 8, bottom: 8 }} onPress={() => onOpen(s.key)} style={state => [fill, (state as { hovered?: boolean }).hovered ? { opacity: 0.75 } : null]}>{line}</Pressable>
40
+ ? <Pressable key={s.key} accessibilityRole="button" accessibilityLabel={s.count === 1 ? `Open pull request ${s.number}` : `${s.count} pull requests, #${s.from} to #${s.to}: open #${s.number}`} hitSlop={{ top: 8, bottom: 8 }} onPress={() => onOpen(s.key)} style={state => [fill, (state as { hovered?: boolean }).hovered ? { opacity: 0.75 } : null]}>{line}</Pressable>
33
41
  : <View key={s.key} style={fill}>{line}</View>;
34
42
  })}
35
43
  </View>;
@@ -42,6 +50,7 @@ function LiveGlyph({ icon, colors }: { icon: LiveIcon; colors: Colors }) {
42
50
  case "done": return <Icon name="CircleCheck" size={12} color={colors.statusSuccess} />;
43
51
  case "paused": return <Icon name="CirclePause" size={12} color={colors.statusWarning} />;
44
52
  case "alert": return <Icon name="TriangleAlert" size={12} color={colors.statusWarning} />;
53
+ case "failing": return <Icon name="CircleX" size={12} color={colors.statusDanger} />;
45
54
  case "waiting": return <Icon name="Clock" size={12} color={colors.foregroundMuted} />;
46
55
  default: return <Icon name="Circle" size={12} color={colors.foregroundMuted} />;
47
56
  }
@@ -106,7 +115,7 @@ export function WorkspaceHeader({ workspace: w, theme, compact, now, onSettings,
106
115
  <Text accessibilityLiveRegion="polite" style={[t.ask, { color: c.foregroundMuted }]}>
107
116
  {parts.map((part, i) => <Text key={part.text} style={toneOf(part.tone) ? { color: toneOf(part.tone) } : { color: c.foreground }}>{i ? <Text style={{ color: c.foregroundMuted, fontWeight: "400" }}>{" · "}</Text> : null}{part.text}</Text>)}
108
117
  </Text>
109
- <StackBar workspace={w} theme={theme} onOpen={onOpenPr} />
118
+ <StackBar workspace={w} theme={theme} onOpen={compact ? undefined : onOpenPr} />
110
119
  {tail}
111
120
  </View>;
112
121
  return <View style={{ paddingHorizontal: pad, paddingTop: compact ? 14 : 12, paddingBottom: 10, gap: 6, borderBottomWidth: 1, borderBottomColor: c.border }}>
@@ -123,7 +132,7 @@ export function WorkspaceHeader({ workspace: w, theme, compact, now, onSettings,
123
132
  <Text accessibilityLiveRegion="polite" style={[t.meta, { color: c.foregroundMuted, marginTop: 2 }]}>
124
133
  {parts.map((part, i) => <Text key={part.text} style={toneOf(part.tone) ? { color: toneOf(part.tone), fontWeight: "600" } : { color: c.foreground }}>{i ? <Text style={{ color: c.foregroundMuted, fontWeight: "400" }}>{" · "}</Text> : null}{part.text}</Text>)}
125
134
  </Text>
126
- <StackBar workspace={w} theme={theme} onOpen={onOpenPr} />
135
+ <StackBar workspace={w} theme={theme} onOpen={compact ? undefined : onOpenPr} />
127
136
  {tail}
128
137
  </View>;
129
138
  }
@@ -2,7 +2,7 @@ import { memo, useCallback, useEffect, useMemo, useRef, useState, type ReactNode
2
2
  import { View, type FlatList as NativeFlatList } from "react-native";
3
3
  import { Pressable, Text } from "./text";
4
4
  import { Icon, FlatList } from "@getpaseo/plugin/client/ui";
5
- import { type Badge, type HomeGroupId, type HomeModel, type Workstream, railChips } from "../shared/home";
5
+ import { type Badge, type HomeGroupId, type HomeModel, type Workstream, prChipSpoken, railChips } from "../shared/home";
6
6
  import { ASK_KEY, excerpt, FIELD_LABEL, type OmniboxItem, type Range, type RowHit, type SearchHit } from "../shared/search";
7
7
  import { AskRow, PriorityLine } from "./home-chrome";
8
8
  import { age, wakeLabel, wakeShort } from "../shared/inbox";
@@ -260,7 +260,7 @@ export function BadgeView({ b, c }: { b: Badge; c: Colors }) {
260
260
  export function PrChipView({ s, c }: { s: Workstream; c: Colors }) {
261
261
  if (!s.pr) return null;
262
262
  const checks = s.pr.checks;
263
- return <View testID="follow-up-row-chip" style={{ flexShrink: 1, minWidth: 0, flexDirection: "row", alignItems: "center", gap: 4, paddingHorizontal: 6, height: 20, borderRadius: 4, borderWidth: 1, borderColor: c.border }}>
263
+ return <View testID="follow-up-row-chip" role="img" aria-label={prChipSpoken(s.pr)} style={{ flexShrink: 1, minWidth: 0, flexDirection: "row", alignItems: "center", gap: 4, paddingHorizontal: 6, height: 20, borderRadius: 4, borderWidth: 1, borderColor: c.border }}>
264
264
  <Icon name="GitPullRequest" size={11} color={toneColor(c, s.pr.tone)} />
265
265
  <Text numberOfLines={1} style={{ flexShrink: 0, color: c.foreground, fontSize: 11, lineHeight: 14, fontVariant: ["tabular-nums"] }}>{s.pr.label}</Text>
266
266
  {checks && <Text numberOfLines={1} style={{ flexShrink: 1, minWidth: 0, color: checks.tone === "muted" ? c.foregroundMuted : badgeColor({ text: "", tone: checks.tone }, c), fontSize: 11, lineHeight: 14 }}>{checks.text}</Text>}
@@ -343,7 +343,7 @@ const Row = memo(function Row({ s, theme, dense, touch, selected, onSelect, onMe
343
343
  const waited = s.group === "later" && s.at ? age(s.at, Date.now()) : "";
344
344
  const label = [s.title + (s.agent ? ` › ${s.agent}` : ""), s.word, s.line, hit?.via && `${FIELD_LABEL[hit.via.field]}: ${hit.via.text}`,
345
345
  // Every chip, even one a narrow row hides (row-chips-never-cover-the-time).
346
- ...s.badges.map(b => b.text), s.pr && `Pull request ${s.pr.label}${s.pr.checks ? ` ${s.pr.checks.text}` : ""}`, wake && `Later until ${wake}`, waited && (waited === "now" ? "just now" : `waiting ${waited}`)].filter(Boolean).join(". ");
346
+ ...s.badges.map(b => b.text), s.pr && prChipSpoken(s.pr), wake && `Later until ${wake}`, waited && (waited === "now" ? "just now" : `waiting ${waited}`)].filter(Boolean).join(". ");
347
347
  return <Pressable ref={trigger.ref} nativeID={rowDomId(s.key)} accessibilityRole="button" accessibilityState={{ selected }} accessibilityLabel={label} accessibilityHint={quickActionsHint(touch)}
348
348
  onPress={() => onSelect(s.key)} onLongPress={trigger.onLongPress} delayLongPress={450}
349
349
  style={state => ({ ...focusRing((state as { focused?: boolean }).focused, c, true), flexDirection: "row", alignItems: dense ? "flex-start" : "center", gap: touch ? 10 : dense ? 8 : 10, minHeight: touch ? 56 : dense ? 36 : 38, paddingLeft: touch ? 14 : dense ? 8 : 16, paddingRight: touch ? 16 : dense ? 8 : 16, paddingVertical: touch ? 12 : dense ? 6 : 0,
package/client/home.tsx CHANGED
@@ -8,7 +8,7 @@ import { useQuery } from "@tanstack/react-query";
8
8
  import { browserStatusRpc, controlRpc, inboxBriefRpc, sendRpc } from "../shared/contracts";
9
9
  import { needsYou, workspaceSnoozed } from "../shared/attention";
10
10
  import { briefAsks, briefCardShown, liveBrief } from "../shared/brief";
11
- import { briefPane, followUpLog, lastWorkdayEnd, nextNeeds, paneButtons, sameText, sinceLabel, tailSteps, type HomeGroupId, type HomeModel, type LogLine, type TailStep, type Workstream } from "../shared/home";
11
+ import { briefPane, followUpLog, lastWorkdayEnd, nextNeeds, paneButtons, prChipSpoken, sameText, sinceLabel, tailSteps, type HomeGroupId, type HomeModel, type LogLine, type TailStep, type Workstream } from "../shared/home";
12
12
  import { age, backLabel, snoozeUntil, type InboxRow } from "../shared/inbox";
13
13
  import { errorText } from "../shared/errors";
14
14
  import { isLoaded, type LoadSignals } from "../shared/agent-load";
@@ -489,7 +489,8 @@ function DetailPane({ s, model, theme, compact, deps, openFull, signOffNext, ask
489
489
  {!writing && s.workspaceId && w && <View style={{ marginTop: 6 }}><ReferencesLine key={`refs:${s.workspaceId}`} workspace={w} theme={theme} compact /></View>}
490
490
  {!writing && <View style={{ flexDirection: "row", alignItems: "center", gap: 6, minHeight: 44 }}>
491
491
  <Icon name={s.icon} size={14} color={color} />
492
- <Text numberOfLines={1} style={[t.meta, { flex: 1, minWidth: 0 }]}>
492
+ {/* Read as one line, with the PR summary in words: a nested Text can't carry its own label. */}
493
+ <Text numberOfLines={1} accessibilityLabel={[s.word, metaRest, s.pr && prChipSpoken(s.pr)].filter(Boolean).join(" · ")} style={[t.meta, { flex: 1, minWidth: 0 }]}>
493
494
  {!!s.word && <Text style={{ color, fontWeight: "600" }}>{s.word}</Text>}
494
495
  {metaRest ? (s.word ? ` · ${metaRest}` : metaRest) : ""}
495
496
  <PrSummaryText s={s} c={c} lead=" · " />
@@ -88,7 +88,7 @@ export function useMergeButtons(w: Workspace | undefined): MergeButtons {
88
88
  }
89
89
 
90
90
  /**
91
- * "#143 approved · waits on #142 (checks failing)": an approved PR that Merge isn't offered on because a PR under it
91
+ * "#143 approved · waits on #142 (checks failed)": an approved PR that Merge isn't offered on because a PR under it
92
92
  * can't merge yet (heldMerges). Quiet, not an ask; both numbers open their PRs. The panel's Pull requests card and
93
93
  * Home's detail pane draw it, so an approved PR never goes invisible.
94
94
  */
package/client/stacks.tsx CHANGED
@@ -3,7 +3,7 @@ import { Pressable, Text } from "./text";
3
3
  import { Icon } from "@getpaseo/plugin/client/ui";
4
4
  import type { Pr, Workspace } from "../shared/model";
5
5
  import { compactPrStatus, githubWaitLine, orderedStacks, settledForDisplay } from "../shared/presentation";
6
- import { mergeQueued, prTone, stackOrder } from "../shared/attention";
6
+ import { mergeQueued, prTone, quietFold, stackOrder, type StackItem } from "../shared/attention";
7
7
  import { reviewersMissing } from "../shared/pr-workflow";
8
8
  import { isGithubFlow } from "../shared/pr-actions";
9
9
  import { Card, FoldRow, text, type Theme } from "./kit";
@@ -93,6 +93,8 @@ function StackRows({ name, prs, theme, open, toggle, onOpen, compact, showRepo,
93
93
  const showDone = settled || open(foldKey);
94
94
  const rows = hits ? ordered.filter(p => hits.has(p)) : settled ? ordered : [...active, ...(showDone ? done : [])];
95
95
  const fold = !hits && !settled && done.length > 0;
96
+ // A long stack folds its quiet runs (a-long-stack-shows-its-problems); a search shows its hits as they are.
97
+ const items: StackItem<Pr>[] = hits || settled ? rows.map(pr => ({ kind: "pr", pr })) : [...quietFold(active, open), ...(showDone ? done : []).map(pr => ({ kind: "pr" as const, pr }))];
96
98
  if (!rows.length) return null;
97
99
  const merged = prs.filter(p => p.snapshot?.state === "MERGED").length;
98
100
  return <View style={{ borderTopWidth: 1, borderTopColor: c.border }}>
@@ -100,7 +102,27 @@ function StackRows({ name, prs, theme, open, toggle, onOpen, compact, showRepo,
100
102
  <Text numberOfLines={1} style={[t.label, { flex: 1, fontSize: 12, lineHeight: 17 }]}>{name}</Text>
101
103
  <Text style={[t.small, { fontVariant: ["tabular-nums"] }]}>{settled ? `${prs.length} PR${prs.length === 1 ? "" : "s"}` : `${merged} of ${prs.length} merged`}</Text>
102
104
  </View>
103
- {rows.map((pr, i) => <PrRow key={pr.key} pr={pr} theme={theme} first={i === 0} last={i === rows.length - 1 && !fold} showRepo={showRepo} onOpen={onOpen} compact={compact} wide={wide} hit={hits?.get(pr)} />)}
105
+ {items.map((item, i) => {
106
+ const first = i === 0, last = i === items.length - 1 && !fold;
107
+ if (item.kind === "pr") return <PrRow key={item.pr.key} pr={item.pr} theme={theme} first={first} last={last} showRepo={showRepo} onOpen={onOpen} compact={compact} wide={wide} hit={hits?.get(item.pr)} />;
108
+ const expanded = open(item.key), n = item.prs.length;
109
+ const range = `#${item.prs[0]!.number} to #${item.prs.at(-1)!.number}`;
110
+ return <Pressable key={item.key} accessibilityRole="button" aria-expanded={expanded} accessibilityState={{ expanded }} accessibilityLabel={`${expanded ? "Hide" : "Show"} ${n} PRs in review, ${range}, in ${name}`} onPress={() => toggle(item.key)}
111
+ style={state => ({ flexDirection: "row", gap: 10, paddingHorizontal: 12, minHeight: compact ? 44 : 32, backgroundColor: state.pressed ? c.surface2 : (state as { hovered?: boolean }).hovered ? c.surface1 : "transparent" })}>
112
+ {/* The node and the words sit on the row's middle (the rail runs through both ends), and the ring and chevron
113
+ take the in-review nodes' muted ink, not the border's, so the fold reads as a row you can open. */}
114
+ <View style={{ width: NODE, alignItems: "center" }}>
115
+ <View style={{ width: 2, flex: 1, minHeight: 4, backgroundColor: first ? "transparent" : c.border }} />
116
+ <View style={{ width: NODE, height: NODE, borderRadius: NODE / 2, alignItems: "center", justifyContent: "center", borderWidth: 1, borderColor: c.foregroundMuted, backgroundColor: c.surface0 }}>
117
+ <Icon name={expanded ? "ChevronUp" : "ChevronsUpDown"} size={12} color={c.foregroundMuted} />
118
+ </View>
119
+ <View style={{ width: 2, flex: 1, minHeight: 4, backgroundColor: last ? "transparent" : c.border }} />
120
+ </View>
121
+ <View style={{ flex: 1, justifyContent: "center", paddingVertical: 4 }}>
122
+ <Text style={[t.meta, { color: c.foreground, fontVariant: ["tabular-nums"] }]}>{expanded ? `Hide ${n} in review` : `+${n} in review`}<Text style={{ color: c.foregroundMuted }}>{` · #${item.prs[0]!.number}–#${item.prs.at(-1)!.number}`}</Text></Text>
123
+ </View>
124
+ </Pressable>;
125
+ })}
104
126
  {fold && <Pressable accessibilityRole="button" aria-expanded={showDone} accessibilityState={{ expanded: showDone }} accessibilityLabel={`${showDone ? "Hide" : "Show"} ${done.length} merged PR${done.length === 1 ? "" : "s"} in ${name}`} onPress={() => toggle(foldKey)}
105
127
  style={state => ({ flexDirection: "row", gap: 10, paddingHorizontal: 12, minHeight: compact ? 44 : 30, backgroundColor: state.pressed ? c.surface2 : (state as { hovered?: boolean }).hovered ? c.surface1 : "transparent" })}>
106
128
  <View style={{ width: NODE, alignItems: "center" }}>
package/index.client.tsx CHANGED
@@ -98,7 +98,7 @@ export default function contribute(host: PluginClientContext) {
98
98
  const briefDeps: BriefDeps = {
99
99
  signOff: agentId => void inbox.signOff([agentId]), openNext,
100
100
  openAgent: agentId => client.openScreen({ screenId: OVERVIEW, params: { next: String(++nextToken), open: agentId } }),
101
- workspace: id => store.get(id), openPanel,
101
+ workspace: id => store.get(id), openPanel, row: agentId => inbox.rows().find(r => r.agentId === agentId) ?? null,
102
102
  noteDone: (agentId, cancel) => inbox.noteDone(agentId, cancel), endDone: agentId => inbox.endDone(agentId),
103
103
  };
104
104
  const openItem = (key: string, extra: { question?: string } = {}) => client.openScreen({ screenId: OVERVIEW, params: { item: key, ...(extra.question ? { question: extra.question } : {}) } });
package/index.server.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import { plainError } from "./shared/errors";
1
2
  import { TranscriptTitleLookup, TranscriptTitleStore, trackedTitleTranscripts } from "./server/transcript-titles";
2
3
  import { fillLinkedTitles, fillWorkspaceTitles, localTitles, workspaceNeedsTitles, type TitleIndex } from "./shared/local-titles";
3
4
  import { stopWorker } from "./server/teardown";
@@ -9,7 +10,7 @@ import { moveData, dataDirs, writeLegacyHeartbeat, type DataMove } from "./serve
9
10
  import { isRecovery, withRuntimePrelude, invokeSelf, PLUGIN_ID } from "./shared/legacy";
10
11
  import { displayPreferences } from "./shared/display";
11
12
  import { DEFAULT_QUESTION_MODE, QUESTION_DEDUPE_MIGRATION, awaitingSend, collapseDuplicateQuestions, questionPreferences, signedOffAnswers, type QuestionMode } from "./shared/questions";
12
- import { answerRecipients, askQuestion, needsYouQuestions, recordAnswer, syncTaskQuestions, withdrawQuestion } from "./server/questions";
13
+ import { answerRecipients, askQuestion, coverNote, needsYouQuestions, recordAnswer, syncTaskQuestions, withdrawQuestion } from "./server/questions";
13
14
  import { dismissItem, dismissedNeeds, undoDismissItem } from "./server/dismiss";
14
15
  import { agentSetSpec, developerSetSpec } from "./server/spec";
15
16
  import type { PluginServerContext, PluginHandlerContext, PluginHookContext, PluginSessionOpenRequest } from "@getpaseo/plugin/server";
@@ -94,6 +95,8 @@ import { hostFeature, type ServerInfo } from "./server/host-features";
94
95
  import { newWorkspaceTarget, sendReport, type ReportSendDeps } from "./server/report-send";
95
96
  type ServerInfoClient = { getLastServerInfoMessage?: () => ServerInfo };
96
97
  import { inboxAnswer } from "./server/etag";
98
+ import { CheckWatches } from "./server/check-watches";
99
+ import { waitForChecksAnswer } from "./server/wait-for-checks";
97
100
  import { jobAgentRunner, type JobPaseo } from "./server/job-agent";
98
101
  import { AiJobs } from "./server/ai-jobs";
99
102
  import { liveRankSources, planningUrl, Ranker, RANKER_ROLE_DEFAULT } from "./server/ranker";
@@ -162,7 +165,10 @@ export default function contribute(server: PluginServerContext) {
162
165
  const handle = <I extends ZodType, O extends ZodType>(contract: PluginRpcContract<I, O>, handler: (input: zOutput<I>, context: PluginHandlerContext) => unknown) => {
163
166
  // Main-agent work by a successor makes its handover stick (see handBackMainAgent): noted after the call succeeds.
164
167
  const run = MAIN_WORK.has(contract.name) ? (async (input: { agentId?: string }, context: PluginHandlerContext) => { const out = await (handler as (i: unknown, c: PluginHandlerContext) => unknown)(input, context); if (input?.agentId) await noteMainWork(input.agentId).catch(() => undefined); return out; }) as typeof handler : handler;
165
- handlers.set(contract.name, { input: contract.input, run: run as never }); server.handle(contract, rpcTiming.timed(contract.name, run as (i: unknown, c: PluginHandlerContext) => unknown) as never);
168
+ // A schema error inside a handler (an internal cap, a stored record that no longer fits) reaches the caller as one
169
+ // plain sentence, its issues logged; never as the validator's JSON (invariant pr-scale-lists-batch-not-throw).
170
+ const plain = async (input: unknown, context: PluginHandlerContext) => { try { return await (run as (i: unknown, c: PluginHandlerContext) => unknown)(input, context); } catch (error) { throw plainError(error); } };
171
+ handlers.set(contract.name, { input: contract.input, run: plain as never }); server.handle(contract, rpcTiming.timed(contract.name, plain) as never);
166
172
  };
167
173
  // What each subscription feed is made of may have changed (wired to the feeds below, server/feeds.ts). Cheap: a feed
168
174
  // with no subscriber does nothing, and an unchanged value pushes nothing.
@@ -224,6 +230,17 @@ export default function contribute(server: PluginServerContext) {
224
230
  const actions = new PrActions(store, github, graphite, browser);
225
231
  actions.savedMethod = repo => prWorkflow.current().repos[repoKey(repo)]?.mergeMethod ?? null;
226
232
  const engine = new Engine(store, github, gateway);
233
+ // Wait for checks (docs/wait-for-checks.md): judged after each engine pass from the reads it made; a verdict is one
234
+ // queued message. The agent is read from the directory's list (no load), live only when the list lacks it.
235
+ const checkWatches = new CheckWatches(directory, {
236
+ snapshot: () => store.snapshot(),
237
+ quietSince: key => github.quietSince(key),
238
+ agent: async id => {
239
+ const a = gateway.directory.cached(id) ?? (await gateway.directory.read({ fresh: "agents" })).agents.find(r => r.agent.id === id)?.agent;
240
+ return a ? { status: a.status, archived: !!a.archivedAt, workspaceId: a.workspaceId ?? null } : null;
241
+ },
242
+ });
243
+ engine.checkWatches = checkWatches;
227
244
  engine.wording = { reviewFix: repo => commandName(prWorkflow.reviewFix(repo)) };
228
245
  actions.settleTasks = w => engine.settleTasks(w);
229
246
  const governor = new Governor();
@@ -320,6 +337,7 @@ export default function contribute(server: PluginServerContext) {
320
337
  // a-message-is-saved-before-sent-and-arrives-once: every message to an agent goes through one queue (queue.json).
321
338
  const queue = new MessageQueue(directory, { deliverTo: (target, text, messageId, by) => gateway.deliverTo(target, text, messageId, by), arrived: (agentId, messageId, since, marker) => gateway.arrivedMessage(agentId, messageId, since, marker), probe: () => gateway.probe() }, { health: writeHealth });
322
339
  engine.attachQueue(queue);
340
+ checkWatches.attachQueue(queue);
323
341
  inbox.attachQueue(queue);
324
342
  // Overseer forwards and reports handed to an agent: no record of their own, so the queue item is their status
325
343
  // (follow_queue_list). Archived agents cancel, with the reason on the item.
@@ -628,10 +646,13 @@ export default function contribute(server: PluginServerContext) {
628
646
  const state = await store.snapshot();
629
647
  if (!browserRepositories(state).includes(repo.toLowerCase())) return { tracked: false, workspaces: [], more: 0 };
630
648
  const entries = await Promise.all(prClaims(state, repo, number).map(async workspace => {
631
- const agent = (await paseo.agents.ref(workspace.mainAgentId).refresh().catch(() => null))?.agent;
649
+ // A read that fails says nothing about the agent: leave that claim out rather than call its agent closed.
650
+ const read = await paseo.agents.ref(workspace.mainAgentId).refresh().then(r => ({ agent: r?.agent }), () => null);
651
+ if (!read) return null;
652
+ const agent = read.agent;
632
653
  return { workspace, agent: agent && !agent.archivedAt && agent.workspaceId === workspace.id ? agent : null };
633
654
  }));
634
- const view = browserWorkspaces(entries);
655
+ const view = browserWorkspaces(entries.filter(e => e !== null));
635
656
  return { tracked: true, ...view, workspaces: view.workspaces.map(w => ({ ...w, title: w.title.slice(0, 200), agentStatus: w.agentStatus.slice(0, 40), state: w.state.slice(0, 200) })) };
636
657
  });
637
658
  handle(rpc.listRpc, async ({ since }) => { if (waiting) return { workspaces: [], full: false, removed: [], error: waiting }; await ready; return { ...listCache.answer(await store.snapshot(), since), error: loadError ?? hookError ?? writeHealth.message() ?? engine.error }; });
@@ -711,7 +732,9 @@ export default function contribute(server: PluginServerContext) {
711
732
  const w = agentWorkspace(state, agentId, "write", workspaceId);
712
733
  const obligation = updateObligation(w, { ...input, caller: agentId, workingAgentId });
713
734
  syncTaskQuestions(w, Date.now());
714
- changed(w); return { ...w, updatedObligationId: obligation.id };
735
+ // one-decision-one-card: say so when the blocked task is already asked (or answered) as a question.
736
+ const note = coverNote(w, obligation.id);
737
+ changed(w); return { ...w, updatedObligationId: obligation.id, ...(note ? { note } : {}) };
715
738
  });
716
739
  void engine.nudge(result.id); return result;
717
740
  });
@@ -723,7 +746,8 @@ export default function contribute(server: PluginServerContext) {
723
746
  const w = agentWorkspace(state, agentId, "write", workspaceId);
724
747
  const { supersedes, ...ask } = input;
725
748
  const { question, instruction, outcome, of } = askQuestion(w, agentId, ask, mode, Date.now(), { via: "ask", ...(supersedes ? { supersedes } : {}) });
726
- if (outcome !== "duplicate") changed(w);
749
+ // A card a blocked task made for this decision closes now (one-decision-one-card), not on the next tick.
750
+ if (outcome !== "duplicate") { syncTaskQuestions(w, Date.now()); changed(w); }
727
751
  return { workspaceId: w.id, question, mode, instruction, outcome, of };
728
752
  });
729
753
  });
@@ -998,6 +1022,16 @@ export default function contribute(server: PluginServerContext) {
998
1022
  }) };
999
1023
  });
1000
1024
  handle(rpc.contextListRpc, async ({ workspaceId }) => ({ requests: await contextRequests.list(workspaceId ? { workspaceId } : {}) }));
1025
+ // Paseo 0.17's own PR watch (subscribe_change_request): named only for PRs Follow-up can't see. No feature flag says
1026
+ // it's there; server_info's version does, read from the connection's last hello (no request).
1027
+ const hostVersion = async () => { try { return String(((await withDaemon(async client => (client as ServerInfoClient).getLastServerInfoMessage?.())) as { version?: unknown } | null)?.version ?? ""); } catch { return ""; } };
1028
+ handle(rpc.waitForChecksRpc, async (input, { paseo }) => {
1029
+ await requireReady();
1030
+ return waitForChecksAnswer(input, {
1031
+ state: () => store.snapshot(), watches: checkWatches, nudge: id => engine.nudge(id), hostVersion,
1032
+ register: (repo, number) => handlers.get(rpc.registerPrRpc.name)!.run({ agentId: input.agentId, repo, number, stack: `${repo}#${number}` }, { paseo } as PluginHandlerContext) as Promise<unknown>,
1033
+ });
1034
+ });
1001
1035
  handle(rpc.contextReplyRpc, async ({ agentId, requestId, text }) => {
1002
1036
  await requireReady();
1003
1037
  await contextRequests.reply(requestId, agentId, text);
@@ -1427,6 +1461,7 @@ export default function contribute(server: PluginServerContext) {
1427
1461
  const linked = await store.mutate(state => {
1428
1462
  const w = findWorkspace(state, tracked.id);
1429
1463
  const result = needsYouQuestions(w, agentId, call, mode, Date.now(), sameTurn ? previous : null);
1464
+ if (result.createdIds.length) syncTaskQuestions(w, Date.now());
1430
1465
  if (result.questionIds.length || sameTurn) changed(w);
1431
1466
  return { ...result, ask: foldedAsk(call.ask, result.questionIds, w.questions) };
1432
1467
  });
@@ -1652,7 +1687,7 @@ export default function contribute(server: PluginServerContext) {
1652
1687
  // One deadline for every wait (worker-stop-never-waits-on-a-stuck-pass, server/teardown.ts): start-up and the work
1653
1688
  // in flight may be stuck on a daemon or CLI that never answers. Work that ends inside the deadline is saved; what
1654
1689
  // outlives it can't write, because the store closes before the lock is released.
1655
- await stopWorker({ files: [contextRequests, reviewerStore, agentSettings, prWorkflow, queue], ready, hooks: hooksStarted ? () => agentHooks.stop() : undefined, actions, closeConnections, engine, store, inbox: inbox.store, unlock });
1690
+ await stopWorker({ files: [contextRequests, checkWatches, reviewerStore, agentSettings, prWorkflow, queue], ready, hooks: hooksStarted ? () => agentHooks.stop() : undefined, actions, closeConnections, engine, store, inbox: inbox.store, unlock });
1656
1691
  })();
1657
1692
  return stop;
1658
1693
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "paseo-follow-up",
3
3
  "private": false,
4
- "version": "2.3.0",
4
+ "version": "2.4.0-beta.1",
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": [
@@ -41,6 +41,7 @@
41
41
  "release:notes": "node scripts/release-notes.mjs",
42
42
  "test:feeds": "node scripts/screenshots.mjs --only feeds --out .feeds-check",
43
43
  "test:wait": "node scripts/check-wait.mjs",
44
+ "test:wait-checks": "node scripts/check-wait-for-checks.mjs",
44
45
  "test:wait-live": "node scripts/check-wait.mjs --live",
45
46
  "shots": "node scripts/screenshots.mjs",
46
47
  "shots:readme": "sh scripts/readme-shots.sh",
@@ -26,6 +26,7 @@ import type { RenameStatus } from "../shared/rename";
26
26
  import { DISPLAY_KEYS, displayPreferences, HOME_DETAIL_DEFAULT, CATCH_UP_RAIL_DEFAULT } from "../shared/display";
27
27
  import { DEFAULT_SEARCH_SHORTCUT, SEARCH_SHORTCUTS } from "../shared/search-key";
28
28
  import { DEFAULT_SORT, SORT_MODES } from "../shared/sort";
29
+ import { SCALE } from "../shared/scale";
29
30
 
30
31
  /**
31
32
  * Agent parity: every action the developer can click in Follow-up has a tool that runs the same server path.
@@ -155,10 +156,10 @@ const login = reviewerLoginSchema;
155
156
  const prKey = z.string().trim().regex(/^[\w.-]+\/[\w.-]+#\d+$/, "Use owner/repo#number keys from list_prs.");
156
157
  const id = z.string().trim().min(1).max(200);
157
158
  const confirm = { planId: id.optional(), confirm: z.boolean().optional() };
158
- const agentIds = z.array(id).min(1).max(100);
159
+ const agentIds = z.array(id).min(1).max(SCALE.agents);
159
160
  export const TOOL_INPUT = {
160
161
  list_prs: z.strictObject({ workspace: id.optional(), needs_reviewers: z.boolean().optional(), ready_to_merge: z.boolean().optional(), include_closed: z.boolean().optional() }),
161
- add_reviewers: z.strictObject({ prs: z.array(prKey).min(1).max(50).optional(), reviewers: z.array(login).min(1).max(15).optional(), ...confirm }),
162
+ add_reviewers: z.strictObject({ prs: z.array(prKey).min(1).max(SCALE.perWorkspace).optional(), reviewers: z.array(login).min(1).max(15).optional(), ...confirm }),
162
163
  merge: z.strictObject({ pr: prKey.optional(), scope: z.enum(["target", "downstack"]).optional(), ...confirm }),
163
164
  enable_merge_when_ready: z.strictObject({ pr: prKey.optional(), scope: z.enum(["target", "downstack"]).optional(), ...confirm }),
164
165
  disable_merge_when_ready: z.strictObject({ pr: prKey.optional(), scope: z.enum(["target", "downstack"]).optional(), ...confirm }),
@@ -175,7 +176,7 @@ export const TOOL_INPUT = {
175
176
  ai_rename: z.strictObject({ workspaceId: id.optional(), title: z.string().trim().min(1).max(300).optional(), undo: z.boolean().optional(), ...confirm }),
176
177
  snooze_workspace: z.strictObject({ workspace: id.optional(), until: z.string().trim().min(1).max(200).optional(), bring_back: z.boolean().optional(), ...confirm }),
177
178
  set_finish_flags: z.strictObject({ agentIds: agentIds.optional(), value: z.boolean().optional(), ...confirm }),
178
- set_priorities: z.strictObject({ priorities: z.array(priorityInputSchema).max(200).optional(), replace: z.boolean().optional(), ...confirm }),
179
+ set_priorities: z.strictObject({ priorities: z.array(priorityInputSchema).max(SCALE.workspaces).optional(), replace: z.boolean().optional(), ...confirm }),
179
180
  display_settings: z.strictObject({}),
180
181
  make_main_agent: z.strictObject({ agentId: id.optional(), reason: z.string().trim().min(1).max(200).optional(), requested: z.enum(["developer", "self"]).optional(), ...confirm }),
181
182
  set_display: z.strictObject({ values: z.record(z.string(), z.union([z.boolean(), z.string(), z.number()])).optional(), ...confirm }),
@@ -13,7 +13,7 @@ const directory = dirname(fileURLToPath(import.meta.url));
13
13
  /** 1.4.0-beta.2: launched with Follow-up's tools served by Paseo's MCP (follow_<name>), or the follow-up bridge (<name>). Agents opened before the upgrade carry no flag and keep the bridge names. */
14
14
  let native = env("TOOLS") === "native";
15
15
  // Tool names that read unambiguously in prose; kept identical to server/mcp.mjs's underscore names (a test checks it).
16
- export const TOOL_NAMES = ["workspace_status", "sync_workspace", "enroll_workspace", "register_pr", "exclude_stack", "update_obligation", "acknowledge_batch", "ask_question", "record_answer", "withdraw_question", "set_spec", "link_item", "unlink_item", "link_items", "set_linked_items", "workspace_about", "agent_settings", "needs_you", "declare_done", "list_prs", "add_reviewers", "enable_merge_when_ready", "disable_merge_when_ready", "send_repairs", "set_auto_send", "clear_hold", "retry_batch", "inbox_list", "sign_off", "snooze_workspace", "set_finish_flags", "set_priorities", "agent_digest", "route_candidates", "send_to_agent", "start_workspace", "display_settings", "set_display", "follow_settings", "set_follow_settings", "project_settings", "set_project_tracking", "pr_workflow", "set_pr_workflow", "reviewer_settings", "reviewer_suggestions", "save_reviewers", "set_agent_setting", "set_wait_for_jobs", "onboarding_status", "onboarding_checks", "set_onboarding", "rank_status", "rerank_priorities", "overseer_status", "overseer_start", "overseer_restart", "overseer_ask", "inbox_brief", "brief_action", "queue_list", "queue_action", "inbox_act", "answer_question", "dismiss_question", "dismiss_item", "run_recovery", "set_workspace_spec", "set_task_trigger", "pr_controls", "browser_status", "trust_bypass_status", "release_notes", "updates_status", "check_updates", "set_updates", "install_update", "make_main_agent", "retry_move", "report_issue", "report_send", "ai_rename", "catch_up_deck", "context_requests", "ask_context", "context_reply"];
16
+ export const TOOL_NAMES = ["workspace_status", "sync_workspace", "enroll_workspace", "register_pr", "exclude_stack", "update_obligation", "acknowledge_batch", "ask_question", "record_answer", "withdraw_question", "set_spec", "link_item", "unlink_item", "link_items", "set_linked_items", "workspace_about", "agent_settings", "needs_you", "declare_done", "list_prs", "add_reviewers", "enable_merge_when_ready", "disable_merge_when_ready", "send_repairs", "set_auto_send", "clear_hold", "retry_batch", "inbox_list", "sign_off", "snooze_workspace", "set_finish_flags", "set_priorities", "agent_digest", "route_candidates", "send_to_agent", "start_workspace", "display_settings", "set_display", "follow_settings", "set_follow_settings", "project_settings", "set_project_tracking", "pr_workflow", "set_pr_workflow", "reviewer_settings", "reviewer_suggestions", "save_reviewers", "set_agent_setting", "set_wait_for_jobs", "onboarding_status", "onboarding_checks", "set_onboarding", "rank_status", "rerank_priorities", "overseer_status", "overseer_start", "overseer_restart", "overseer_ask", "inbox_brief", "brief_action", "queue_list", "queue_action", "inbox_act", "answer_question", "dismiss_question", "dismiss_item", "run_recovery", "set_workspace_spec", "set_task_trigger", "pr_controls", "browser_status", "trust_bypass_status", "release_notes", "updates_status", "check_updates", "set_updates", "install_update", "make_main_agent", "retry_move", "report_issue", "report_send", "ai_rename", "catch_up_deck", "context_requests", "ask_context", "context_reply", "wait_for_checks"];
17
17
  const toolPattern = new RegExp(`(?<![\\w])(${TOOL_NAMES.join("|")})(?![\\w])`, "g");
18
18
  /** Names Follow-up's tools the way this agent has them. */
19
19
  export function named(text, isNative = native) { return isNative ? text.replace(toolPattern, "follow_$1") : text; }
@@ -124,6 +124,32 @@ export function batchParagraph(workflow) {
124
124
  export const NO_REVIEW_MERGE = "This repository has no review: merge your own PR once CI is green, without asking the developer. Archiving remains the developer's action.";
125
125
  /** Who merges, closing the batch paragraph: the developer (team review, unchanged text), or the agent in a No review repository. */
126
126
  export const mergeLine = workflow => workflow?.noReview ? NO_REVIEW_MERGE : "Merging and archiving remain the developer's actions.";
127
+ /**
128
+ * Wait for checks (docs/wait-for-checks.md). One SessionStart line for root agents, and a PostToolUse nudge when a
129
+ * shell command polls GitHub for CI: said at most once per turn, never blocking (the-polling-nudge-never-blocks).
130
+ * The hook already runs on every PostToolUse (no matcher), so this costs no new process.
131
+ */
132
+ export const checksLine = "To wait for CI, don't poll GitHub (gh pr checks --watch, gh run watch, sleep loops over gh): call wait_for_checks with the PR after pushing and end your turn; Follow-up messages you when the checks finish.";
133
+ export const pollNudge = "That command polls GitHub for CI, which spends the developer's shared GitHub budget. Stop it, call wait_for_checks with the PR (no prs = every open PR of this workspace) and end your turn: Follow-up messages you once when the checks finish, from reads it already makes. A single gh pr checks to look once is fine.";
134
+ const SHELL_TOOL = /(bash|shell|exec_command|write_stdin|monitor|terminal)/i;
135
+ const GH_QUERY = /\bgh\s+(?:pr\s+(?:checks|view|status)\b|run\s+(?:list|view)\b|api\b[^\n;|&]*(?:graphql|\/pulls\b|check-runs|check-suites|\/statuses\b|\/status\b|\/actions\/runs))/;
136
+ const GH_WATCH = /\bgh\s+(?:pr\s+checks\b[^\n;|&]*--watch\b|run\s+watch\b)/;
137
+ // A for loop over PRs (reading each one once) isn't polling; a wait between reads is.
138
+ const LOOP = /(?:^|[\s;&|({])(?:while|until)\b[\s\S]*?\bdo\b|\bsleep\s+\d|\bwatch\s+-n\b|\bsetInterval\b|\btime\.sleep\(/;
139
+ /** The text a tool call runs: every string in its input (Bash command, Codex cmd, Monitor's command, a script). */
140
+ function commandText(input) {
141
+ const out = [];
142
+ const walk = v => { if (typeof v === "string") out.push(v); else if (Array.isArray(v)) v.forEach(walk); else if (v && typeof v === "object") Object.values(v).forEach(walk); };
143
+ walk(input);
144
+ return out.join("\n").slice(0, 20_000);
145
+ }
146
+ /** Whether a shell tool call polls GitHub for CI: a watch command, or a loop or sleep around a gh status read. */
147
+ export function pollsGithub(tool, input) {
148
+ if (!SHELL_TOOL.test(String(tool ?? ""))) return false;
149
+ const text = commandText(input);
150
+ if (GH_WATCH.test(text)) return true;
151
+ return GH_QUERY.test(text) && LOOP.test(text);
152
+ }
127
153
  const quote = value => "'" + value.replaceAll("'", "'\\''") + "'";
128
154
  async function json(path) { return JSON.parse(await readFile(path, "utf8")); }
129
155
  async function save(path, value) {
@@ -151,7 +177,7 @@ function paragraphs(lease, contributor, workflow) {
151
177
  "When a decision needs the developer, call ask_question with a short title, the question, lettered options with what each means, and your recommendation; mark it big only when building ahead would leave this computer, set something others rely on, or most remaining work depends on it. Follow the question mode in its reply. Ask each decision once: asking it again returns the open question, and at a turn's end you point at it (needs_you questions=[\"Q<n>\"]) instead of restating it. Answers arrive as messages starting \"Follow-up answer Q<n>\" and are already recorded; several decisions from one card arrive together in one message, one line per decision, with skipped ones marked \"skipped\" and still open. An answer of Something else — \"…\" means none of your options: the quoted words are the developer's answer. Every card already offers Something else, so don't add an Other option. If the developer answers in chat, call record_answer (choice \"other\" with words when it matches none of your options). Withdraw questions that stop mattering. " + ENVELOPE_GUIDANCE,
152
178
  linkInstruction,
153
179
  "If you keep a Claude artifact (or doc) summarizing this workspace's goal, decisions and status, register its link once with set_spec after the first publish. Republish to the same URL; call set_spec again only if the link changes.",
154
- "Keep actual follow-up tasks current with update_obligation: production behavior checks, migrations and decisions, with concise titles, PR dependencies and evidence. Do not add merge/approval/deploy checklist tasks. Deployment-dependent work waits for verified serving revisions and existing production permissions. A task waiting on a PR or another agent is status=waiting; blocked is only for the developer, with ask set to the question they must answer.",
180
+ "Keep actual follow-up tasks current with update_obligation: production behavior checks, migrations and decisions, with concise titles, PR dependencies and evidence. Do not add merge/approval/deploy checklist tasks. Deployment-dependent work waits for verified serving revisions and existing production permissions. A task waiting on a PR or another agent is status=waiting; blocked is only for the developer. One decision, one card: ask it once with ask_question (task set to the task), then mark the task blocked with question=\"Q<n>\"; ask= is only for a decision you haven't asked. Once it is answered, act on the answer and move the task.",
155
181
  "Stakeholder replies are follow-up too. When asked to update a requester, capture the original Slack threadUrl, recipient and explicit developer authorization in the task's communication field; referenced messages alone do not authorize posting. Use a concise progress task now and, when needed, a verify-and-reply task with purpose=verified after the relevant deployed PRs. Read existing thread replies and refresh evidence before posting; distinguish fixed, deployed and verified. Record the actual sent replyUrl and result before marking done. If posting is unavailable or its outcome is uncertain, keep the task blocked and check the thread before any retry; never claim a draft was sent. Auto authorizes delivery to you, not external messages. Communication-only requests do not authorize repairs, benchmarks, migrations or other production writes.",
156
182
  "Tasks are manual unless explicitly scheduled with trigger={event:\"now\"|\"merge\"|\"deploy\",delayDays:0}. Only set a trigger from the developer\u2019s requested timing; never infer timing from a title or enable_follow_up alone. Merge/deploy triggers require owned afterPrs; delayDays=14 waits fourteen days after the last dependency event. Now requires no PR dependencies or delay. Deployment timing starts at the first verified fully serving observation and remains conservative when history is unknown. Preserve existing trigger fields on updates; trigger=null makes a task manual. Auto controls delivery, not timing or production permissions.",
157
183
  batchParagraph(workflow) + " For post-deploy tasks, verify the currently serving revision contains every dependency and record behavioral results separately. Acknowledge the header's batch ID with acknowledge_batch before finishing: completed with the result, or blocked with the reason (humanOnly=true when only a person can move it, such as a stale review the reviewer must re-review or dismiss). Verify the entire goal and post-merge work before declare_done; acknowledge a completion batch first. " + mergeLine(workflow),
@@ -247,7 +273,7 @@ async function main() {
247
273
  return;
248
274
  }
249
275
  const context = () => instructions(lease, contributor, workflow);
250
- const sessionText = async () => [workspace ? context() : null, ...await nativeExtras(brief), ...await waitExtras()].filter(Boolean).join("\n\n");
276
+ const sessionText = async () => [workspace ? context() : null, ...await nativeExtras(brief), ...await waitExtras(), workspace || env("ROOT") === "1" ? named(checksLine) : null].filter(Boolean).join("\n\n");
251
277
  const name = event.hook_event_name;
252
278
  if (!["SessionStart", "UserPromptSubmit", "PostToolUse", "Stop"].includes(name)) return;
253
279
  const session = createHash("sha256").update(String(event.session_id ?? agentId)).digest("hex").slice(0, 24);
@@ -272,8 +298,11 @@ async function main() {
272
298
  if (name === "PostToolUse") {
273
299
  // Said once per session per worker: the tools stay detached until the session reopens.
274
300
  const notice = detached && turn?.detachedNotice !== instance.instance;
301
+ // Once per turn (the turn's start, or the session's when no prompt was seen), and never a block.
302
+ const turnId = turn?.startedAt || 0;
303
+ const polling = (workspace || env("ROOT") === "1") && turn?.pollNudged !== turnId && pollsGithub(event.tool_name, event.tool_input);
275
304
  if (!workspace) {
276
- if (notice) { await save(path, { ...turn, detachedNotice: instance.instance }); emit(detachedNotice); }
305
+ if (notice || polling) { await save(path, { ...turn, ...(notice ? { detachedNotice: instance.instance } : {}), ...(polling ? { pollNudged: turnId } : {}) }); emit([notice ? detachedNotice : null, polling ? named(pollNudge) : null].filter(Boolean).join("\n\n")); }
277
306
  return;
278
307
  }
279
308
  const tool = String(event.tool_name ?? "");
@@ -286,8 +315,8 @@ async function main() {
286
315
  // sync record the RPC handler wrote rather than tool names.
287
316
  const now = Date.now();
288
317
  const callStart = turn?.lastToolAt || turn?.startedAt || now;
289
- await save(path, { ...turn, startedAt: turn?.startedAt ?? (dirty ? callStart : 0), stopped: turn?.stopped ?? false, ...(dirty ? { dirtyAt: callStart } : {}), quietRevision, lastToolAt: now, ...(notice ? { detachedNotice: instance.instance } : {}) });
290
- const text = [upgrade ? quietInstruction : null, notice ? detachedNotice : null].filter(Boolean).join("\n\n");
318
+ await save(path, { ...turn, startedAt: turn?.startedAt ?? (dirty ? callStart : 0), stopped: turn?.stopped ?? false, ...(dirty ? { dirtyAt: callStart } : {}), quietRevision, lastToolAt: now, ...(notice ? { detachedNotice: instance.instance } : {}), ...(polling ? { pollNudged: turnId } : {}) });
319
+ const text = [upgrade ? quietInstruction : null, notice ? detachedNotice : null, polling ? named(pollNudge) : null].filter(Boolean).join("\n\n");
291
320
  if (text) emit(text);
292
321
  return;
293
322
  }
@@ -1,5 +1,5 @@
1
1
  import { randomUUID } from "node:crypto";
2
- import { browserCommandSchema, type BrowserCommand, type BrowserPr, type BrowserResult } from "../shared/pr-actions";
2
+ import { browserBatches, browserCommandSchema, type BrowserCommand, type BrowserPr, type BrowserResult } from "../shared/pr-actions";
3
3
 
4
4
  type Pending = { command: BrowserCommand; clientId: string | null; timer: ReturnType<typeof setTimeout>; resolve: (r: BrowserResult) => void };
5
5
  export class BrowserBridge {
@@ -41,7 +41,25 @@ export class BrowserBridge {
41
41
  for (const job of jobs) job.clientId = clientId;
42
42
  return { jobs: jobs.map(j => j.command), accepted };
43
43
  }
44
- request(op: BrowserCommand["op"], repo: string, prs: BrowserCommand["prs"]): Promise<BrowserResult> {
44
+ /**
45
+ * Any number of PRs: a stack longer than BROWSER_BATCH goes as consecutive commands, one at a time, and the results
46
+ * merge into one (invariant pr-scale-lists-batch-not-throw). It stops at the first batch that doesn't complete; a
47
+ * write that already changed earlier batches then reads as uncertain, so the caller checks state before retrying.
48
+ */
49
+ async request(op: BrowserCommand["op"], repo: string, prs: BrowserCommand["prs"]): Promise<BrowserResult> {
50
+ if (!prs.length) throw new Error("No PRs to send to Graphite.");
51
+ const merged: BrowserResult[] = [];
52
+ for (const batch of browserBatches(prs)) {
53
+ const r = await this.requestOne(op, repo, batch); merged.push(r);
54
+ if (r.outcome !== "completed") break;
55
+ }
56
+ const last = merged.at(-1)!;
57
+ if (merged.length === 1) return last;
58
+ const applied = merged.flatMap(r => r.applied);
59
+ const outcome = last.outcome === "failed" && op !== "read" && applied.length ? "uncertain" : last.outcome;
60
+ return { id: last.id, nonce: last.nonce, outcome, prs: merged.flatMap(r => r.prs), applied, error: last.error };
61
+ }
62
+ private requestOne(op: BrowserCommand["op"], repo: string, prs: BrowserCommand["prs"]): Promise<BrowserResult> {
45
63
  if (!this.status(repo).ready) return Promise.reject(new Error(this.status(repo).reason!));
46
64
  if (this.pending.size >= 50) return Promise.reject(new Error("Too many browser requests are pending."));
47
65
  const budget = op === "read" ? 20_000 : 120_000;