paseo-follow-up 1.4.0-beta.17 → 1.4.0-beta.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/OVERVIEW.md +4 -2
- package/README.md +13 -5
- package/client/onboarding.tsx +4 -0
- package/client/panel.tsx +2 -1
- package/client/pr-controls.tsx +21 -9
- package/client/pr-sheet.tsx +3 -2
- package/client/settings.tsx +2 -0
- package/client/shipping.tsx +183 -0
- package/client/stacks.tsx +3 -2
- package/index.server.ts +68 -5
- package/package.json +2 -1
- package/server/agent-actions.ts +7 -1
- package/server/agent-hook.mjs +21 -7
- package/server/daemon.ts +8 -0
- package/server/engine.ts +25 -5
- package/server/github.ts +66 -5
- package/server/hook-source.ts +1 -1
- package/server/mcp-source.ts +1 -1
- package/server/mcp.d.mts +3 -1
- package/server/mcp.mjs +42 -7
- package/server/native-tools.ts +3 -2
- package/server/pr-actions.ts +91 -15
- package/server/pr-workflow.ts +188 -0
- package/server/scopes.ts +20 -8
- package/server/tasks.ts +9 -3
- package/shared/activity.ts +3 -1
- package/shared/attention.ts +8 -4
- package/shared/contracts.ts +10 -1
- package/shared/model.ts +7 -0
- package/shared/onboarding.ts +2 -1
- package/shared/pr-actions.ts +26 -4
- package/shared/pr-workflow.ts +133 -0
- package/skills/follow-through/SKILL.md +1 -1
package/OVERVIEW.md
CHANGED
|
@@ -13,14 +13,14 @@ Follow-up watches every pull request a Paseo workspace opens until the work is a
|
|
|
13
13
|
- Questions from the main agent, each with a permanent ref (Q1, Q2…), lettered options, the agent's recommendation and what it does while it waits. Pick an option, add a note and Send it to the agent, or Copy it instead. Answered questions stay listed under their ref, and the question mode setting (Stop, Work around, Keep building) tells agents what to do until you answer.
|
|
14
14
|
- A Spec link in the header to the page that sums up the workspace, usually the Claude artifact the main agent keeps up to date.
|
|
15
15
|
- An Activity card: repairs sent and finished with how long they took, merges, PR actions and questions.
|
|
16
|
-
- Each stack drawn top to base
|
|
16
|
+
- Each stack drawn top to base, merged PRs folded away, and a sheet per PR with checks, reviewers and Merge.
|
|
17
17
|
- Tasks for work that outlives a merge, manual or scheduled after a merge or deploy, with an optional delay.
|
|
18
18
|
- A composer pill and a sidebar count that appear only when something needs you; the pill steps through open questions so you can answer without leaving the chat. Home lists every workspace by who is up next, and a larger view opens a workspace in two columns.
|
|
19
19
|
- Compact rows for Follow-up's own tool calls in agent chats, a card for each repair batch, and a card when the agent declares Done.
|
|
20
20
|
|
|
21
21
|
## Setup
|
|
22
22
|
|
|
23
|
-
Requires Paseo 0.14+, Node 22+ and an authenticated `gh` on the daemon host. Merge uses saved Graphite CLI authentication. Follow-up follows every workspace that has an agent; Settings has per-project and per-workspace exceptions. The optional Send to Paseo browser companion adds Graphite's Merge when ready switch through its existing pairing; it is not needed for anything else.
|
|
23
|
+
Requires Paseo 0.14+, Node 22+ and an authenticated `gh` on the daemon host. Works with plain GitHub; Graphite is optional and picked per repository (Auto chooses Graphite only where the `gt` CLI is installed, signed in and the repository was set up with `gt init`). In Graphite repositories Merge uses saved Graphite CLI authentication; elsewhere it runs `gh pr merge`, and When ready is GitHub auto-merge. Follow-up follows every workspace that has an agent; Settings has per-project and per-workspace exceptions. The optional Send to Paseo browser companion adds Graphite's Merge when ready switch through its existing pairing; it is not needed for anything else.
|
|
24
24
|
|
|
25
25
|
## What it does on its own, and what it never does
|
|
26
26
|
|
|
@@ -36,6 +36,8 @@ This is a trusted, unsandboxed plugin. It reads workspace metadata, saved agent
|
|
|
36
36
|
|
|
37
37
|
Follow-up reads Paseo's agent, workspace and project lists into one in-memory directory shared by discovery, runtime checks, the Needs-you inbox, the Overseer and every client RPC. It reads the lists once at start, then patches the directory from lifecycle events: turn started or ended, permission requested or resolved, agent created, closed or archived, workspace created or archived. A change marks it dirty, and a dirty directory re-reads at most once a minute; a clean one re-reads every ten minutes. Before anything that would load an agent (a timeline or provider-subagent read), Follow-up re-reads that one agent, because the cached copy may predate Paseo unloading it. Provider subagents are asked about only when a send is due or waiting for acknowledgment, or completion is being checked. The Done label is sent only when it changes. In the app, the panel, the larger view and the pill draw from the client's shared workspace poll, which runs every 15 s plus a refresh shortly after Paseo reports an agent change. The inbox runs the same way and passes the tag of the list it holds, so an unchanged list comes back empty. Display preferences re-read once a minute. None of these poll while the app is hidden.
|
|
38
38
|
|
|
39
|
+
The PR workflow setting lives in `plugin-data/follow-through/pr-workflow.json` (owner-only): the default, per-repository overrides, merge methods and the review-fix instruction. Auto-detection reads only files: PATH for a `gt` executable, `~/.config/graphite/auth` for a sign-in token's presence (never sent anywhere by detection), and `<git dir>/.graphite_repo_config` in the checkout of the repository's Paseo project, then in the working directories of tracked workspaces with PRs in that repository (from the agent list Follow-up already has). It never runs `gt` and caches for ten minutes. Repositories that resolve to GitHub get no Graphite API calls; their readiness, merge method and auto-merge come from the same `gh api graphql` query that already reads each PR, so there is no extra polling. The first start with this setting seeds the review-fix instruction to `/fix-pr` when `~/.claude/commands/fix-pr.md` or `~/.claude/skills/fix-pr/SKILL.md` exists, once.
|
|
40
|
+
|
|
39
41
|
Reviewer lists live in `plugin-data/follow-through/reviewers.json` (owner-only), apart from `state.json`. Each list is per repository, plus a default for repositories without one, and each user keeps their own. Collaborator and team suggestions are read with `gh api` only when you open Add reviewer. They are cached for ten minutes, and never polled.
|
|
40
42
|
|
|
41
43
|
The Needs-you inbox (beta) keeps one flag per root agent in `plugin-data/follow-through/inbox.json`. When a turn starts it reads the newest user message from the agent's recent timeline to tell your messages from automation, and it reads, never writes, Defer's `plugin-data/defer/queue.json`, Smart Session's `plugin-data/smart-session/compactions.json`, Session Guard's `plugin-data/session-guard/state.json` and Paseo's schedule records. An unknown or unreadable format counts as your message, which clears a flag rather than adding one. Signing off also clears Paseo's own unread dot for that agent. The first-run import and the restart check read only Paseo's agent list: an agent's last activity is its unread time or your last message to it, never Paseo's `updatedAt` (which the daemon rewrites in bulk), and they don't fetch timelines, which would load every agent. Closed and archived agents are never imported. Turning the inbox off stops all of this.
|
package/README.md
CHANGED
|
@@ -20,7 +20,7 @@ Screenshots use synthetic workspaces and PRs.
|
|
|
20
20
|
paseo plugin install paseo-follow-up
|
|
21
21
|
```
|
|
22
22
|
|
|
23
|
-
Needs Node 22+ and an authenticated GitHub CLI (`gh`) on the daemon host.
|
|
23
|
+
Needs Node 22+ and an authenticated GitHub CLI (`gh`) on the daemon host. The installed plugin ID stays `follow-through`, so existing settings and tracked work carry over.
|
|
24
24
|
|
|
25
25
|
## Getting started
|
|
26
26
|
|
|
@@ -44,12 +44,20 @@ The panel shows this workspace only, top to bottom: a **Home** button, the main
|
|
|
44
44
|
|
|
45
45
|
- **Status.** How many PRs have merged, how many things need you, how many PRs need fixing, and a bar with one segment per PR in merge order. Below it, what the agent is doing right now.
|
|
46
46
|
- **Needs you.** One row per decision, each with its button: answer the agent's question, send repairs to the main agent, merge an approved PR, resume after you stopped the agent, or retry a batch that didn't finish.
|
|
47
|
-
- **Pull requests.** Each stack drawn top to base,
|
|
47
|
+
- **Pull requests.** Each stack drawn top to base, with merged PRs folded away.
|
|
48
48
|
- **Tasks.** Work that outlives a merge, such as a production check or a backfill. Tasks wait for you unless you schedule them for after a merge or deploy.
|
|
49
49
|
- **Activity.** What happened and how long it took: repairs sent and finished, merges, merge and reviewer actions, and every question under its ref.
|
|
50
50
|
|
|
51
51
|
The **Spec** chip in the header opens the page that sums up the workspace, usually the Claude artifact the main agent keeps up to date. The agent registers it with a tool call, Follow-up also picks up artifacts the workspace's sessions publish, and you can set, change or remove it under **Spec, agent and recovery**. Your link wins over the agent's, which wins over detection.
|
|
52
52
|
|
|
53
|
+
## Works with GitHub; Graphite optional
|
|
54
|
+
|
|
55
|
+
Follow-up works with plain GitHub out of the box: readiness comes from GitHub itself (its merge state, required checks, reviews, unresolved threads, branch protection and rulesets, and the merge queue if the repository has one), **Merge** runs `gh pr merge` with a merge method the repository allows, and **Auto-merge** is GitHub's own auto-merge. Stacks are chains of base branches: a PR whose base is another PR's branch sits on top of it, a stack merges bottom to top, and after a parent merges Follow-up retargets the child to trunk with `gh pr edit --base` if GitHub didn't already.
|
|
56
|
+
|
|
57
|
+
If you use [Graphite](https://graphite.dev), Follow-up picks it up per repository: **Auto** chooses Graphite where the `gt` CLI is on the daemon's PATH, signed in, and the repository was set up with `gt init`; everywhere else it's GitHub. Detection only looks at files (it never runs `gt`) and is cached for ten minutes. In Graphite repositories, Merge goes through Graphite with your saved CLI sign-in, and Merge when ready works through the Send to Paseo companion (below).
|
|
58
|
+
|
|
59
|
+
Auto is the default for every repository, and setup's **How do you ship PRs?** step shows what it picked. To change it later, open Follow-up's settings (the gear on Home or in a workspace's panel) → **Following** → **Shipping PRs**: a default for every repository (Auto, Graphite or GitHub), an override per repository showing what Auto picked and why, the merge method, and how agents should address review comments: Follow-up's built-in steps (read the unresolved threads with `gh`, fix, push, reply and resolve) or a skill or command of your own, such as `/fix-pr`. Agents get instructions for the workflow their workspace uses, so a GitHub workspace never hears about Graphite. An install that already had a `/fix-pr` command or skill in `~/.claude` keeps using it.
|
|
60
|
+
|
|
53
61
|

|
|
54
62
|
|
|
55
63
|
### Questions
|
|
@@ -197,7 +205,7 @@ The choices live in `agents.json` in Follow-up's data folder. Anything missing o
|
|
|
197
205
|
Install the beta:
|
|
198
206
|
|
|
199
207
|
```sh
|
|
200
|
-
paseo plugin update follow-through --version 1.4.0-beta.
|
|
208
|
+
paseo plugin update follow-through --version 1.4.0-beta.19
|
|
201
209
|
# or, for a fresh install:
|
|
202
210
|
paseo plugin install npm:paseo-follow-up@beta
|
|
203
211
|
```
|
|
@@ -236,11 +244,11 @@ Tools that act on a list, and merge, return a dry run first and act only when ca
|
|
|
236
244
|
|
|
237
245
|
## Send to Paseo and Graphite
|
|
238
246
|
|
|
239
|
-
With [Send to Paseo](https://github.com/tomgrin10/send-to-paseo) on the same daemon, its composer picks the agent that registered the PR.
|
|
247
|
+
With [Send to Paseo](https://github.com/tomgrin10/send-to-paseo) on the same daemon, its composer picks the agent that registered the PR. In Graphite repositories, with Send to Paseo 2.2+, Follow-up can also toggle Graphite's **Merge when ready** through your existing pairing, while Graphite is open and signed in. Each change is confirmed in Chrome, which can remember the permission per repository. With the next Send to Paseo release, its popover on a PR page also shows which tracked workspaces own the PR, with Follow-up's one line for each (for example "Needs you · Merge ready"), and opens the workspace's main agent in the Paseo app or web app. See the [integration and security contract](https://github.com/tomgrin10/send-to-paseo/blob/main/docs/follow-up-integration.md).
|
|
240
248
|
|
|
241
249
|
## Data and access
|
|
242
250
|
|
|
243
|
-
Paseo plugins run trusted, unsandboxed code on the daemon host. Follow-up reads workspace metadata, agent history and GitHub PR status with your existing credentials, and keeps its state in `$PASEO_HOME/plugin-data/follow-through`. It registers scoped MCP tools and reversible provider hooks only for tracked sessions, plus the action tools for root agents (above). GitHub and Graphite writes happen only after an explicit click, or a root agent's confirmed plan, and a fresh eligibility check.
|
|
251
|
+
Paseo plugins run trusted, unsandboxed code on the daemon host. Follow-up reads workspace metadata, agent history and GitHub PR status with your existing credentials, and keeps its state in `$PASEO_HOME/plugin-data/follow-through`. It registers scoped MCP tools and reversible provider hooks only for tracked sessions, plus the action tools for root agents (above). GitHub (and, in Graphite repositories, Graphite) writes happen only after an explicit click, or a root agent's confirmed plan, and a fresh eligibility check.
|
|
244
252
|
|
|
245
253
|
## Development
|
|
246
254
|
|
package/client/onboarding.tsx
CHANGED
|
@@ -8,6 +8,7 @@ import { displayPreferences } from "../shared/display";
|
|
|
8
8
|
import { ONBOARDING_STEPS, autoSendWrites, checksSummary, type Check, type OnboardingStep, type OnboardingView } from "../shared/onboarding";
|
|
9
9
|
import { Button, IconButton, errorText, text, type Theme } from "./kit";
|
|
10
10
|
import { ReviewerSettings } from "./reviewers";
|
|
11
|
+
import { ShippingStep } from "./shipping";
|
|
11
12
|
import { Spinner, useReducedMotion } from "./motion";
|
|
12
13
|
import { raised, runningColor, tint, withAlpha, type Colors } from "./theme";
|
|
13
14
|
|
|
@@ -37,6 +38,7 @@ const TITLES: Record<OnboardingStep, string> = {
|
|
|
37
38
|
intro: "Follow-up keeps your agents' PRs moving",
|
|
38
39
|
checks: "Check your setup",
|
|
39
40
|
defaults: "What Follow-up does without asking",
|
|
41
|
+
shipping: "How do you ship PRs?",
|
|
40
42
|
reviewers: "Who should review your PRs?",
|
|
41
43
|
helpers: "Helpers, and where things are",
|
|
42
44
|
};
|
|
@@ -75,12 +77,14 @@ export function Setup({ theme, compact, view, deps }: { theme: Theme; compact: b
|
|
|
75
77
|
const body = step === "intro" ? <IntroStep theme={theme} compact={compact} follow={follow.data ?? null} />
|
|
76
78
|
: step === "checks" ? <ChecksStep theme={theme} compact={compact} checks={checks} deps={deps} />
|
|
77
79
|
: step === "defaults" ? <DefaultsStep theme={theme} compact={compact} held={view.holdsAutoSends} />
|
|
80
|
+
: step === "shipping" ? <ShippingStep theme={theme} compact={compact} />
|
|
78
81
|
: step === "reviewers" ? <ReviewerSettings theme={theme} compact={compact} />
|
|
79
82
|
: <HelpersStep theme={theme} compact={compact} deps={deps} checks={checks.data?.checks ?? null} />;
|
|
80
83
|
const lead: Record<OnboardingStep, string> = {
|
|
81
84
|
intro: "It follows your agents' pull requests until the work is done, sends fixes back to them, and asks you only for decisions.",
|
|
82
85
|
checks: "Follow-up reads PRs with the GitHub CLI, and its helper agents run on Claude or Codex. Checking is free.",
|
|
83
86
|
defaults: "These are on now. Change anything here; it saves as you go, and Settings has the same switches.",
|
|
87
|
+
shipping: "Follow-up merges and tracks PRs the way each repository already works. It picked these; change one if it's wrong.",
|
|
84
88
|
reviewers: "When you press Add reviewers on a PR, Follow-up asks these people. Set a default for all repositories, or a list for one. Until then, PRs without reviewers show in Needs you.",
|
|
85
89
|
helpers: "Two optional agents. They read, summarise and rank. They never change code or message anyone.",
|
|
86
90
|
};
|
package/client/panel.tsx
CHANGED
|
@@ -210,7 +210,8 @@ function WorkspaceCard({ workspace: w, theme, compact, open, toggle, openAgent,
|
|
|
210
210
|
</View>
|
|
211
211
|
</View>
|
|
212
212
|
</CardRow>
|
|
213
|
-
{
|
|
213
|
+
{/* Graphite's merge-when-ready needs the browser companion; GitHub repositories use auto-merge and never see this. */}
|
|
214
|
+
{active && browserReady === false && w.prs.some(p => !settledForDisplay(p) && p.snapshot && p.snapshot.prWorkflow !== "github") && <CardRow theme={theme}>
|
|
214
215
|
<View style={{ gap: 8 }}>
|
|
215
216
|
<View style={{ gap: 2 }}>
|
|
216
217
|
<Text style={t.label}>Merge when ready</Text>
|
package/client/pr-controls.tsx
CHANGED
|
@@ -4,22 +4,30 @@ import { useRpc } from "@getpaseo/plugin/client";
|
|
|
4
4
|
import { Icon, useToast } from "@getpaseo/plugin/client/ui";
|
|
5
5
|
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
|
6
6
|
import { confirmPrActionRpc, preparePrActionRpc, prControlStatusRpc, requestReviewersRpc } from "../shared/contracts";
|
|
7
|
-
import { mergeBlockers, prActionBlocks, type ActionPlan, type PrActionKind } from "../shared/pr-actions";
|
|
7
|
+
import { isGithubFlow, mergeBlockers, prActionBlocks, type ActionPlan, type PrActionKind } from "../shared/pr-actions";
|
|
8
|
+
import type { MergeMethod } from "../shared/pr-workflow";
|
|
8
9
|
import { mergeQueued, mergeReady } from "../shared/attention";
|
|
9
10
|
import type { Pr, Workspace } from "../shared/model";
|
|
10
11
|
import { Button, Switch, errorText, text, type Theme } from "./kit";
|
|
11
12
|
import { noReviewers, resolveReviewers, withoutAuthor, type ReviewerEntry } from "../shared/reviewers";
|
|
12
13
|
import { ReviewerPicker, reviewerSettingsKey, useReviewerSettings, willAsk } from "./reviewers";
|
|
13
14
|
|
|
15
|
+
const METHOD_SENTENCE: Record<MergeMethod, string> = { squash: "squash and merge it", merge: "merge it with a merge commit", rebase: "rebase and merge it" };
|
|
16
|
+
/** Blockers read as nouns after "clears:"; proper names (GitHub, Graphite) keep their capital. */
|
|
17
|
+
const lowerFirst = (b: string) => /^(GitHub|Graphite)\b/.test(b) ? b : b[0].toLowerCase() + b.slice(1);
|
|
18
|
+
|
|
14
19
|
/**
|
|
15
20
|
* Merge, merge-when-ready and reviewer requests for one PR. Every write needs a click; Merge always
|
|
16
|
-
* prepares a fresh plan and asks again before anything reaches Graphite.
|
|
21
|
+
* prepares a fresh plan and asks again before anything reaches Graphite or GitHub. In GitHub mode When ready is
|
|
22
|
+
* GitHub's auto-merge, read with the PR, so it needs no browser companion; it's hidden when the repository disallows it.
|
|
17
23
|
*/
|
|
18
|
-
export function PrControls({ pr, workspace, theme, compact, browserReady, intent }: { browserReady: boolean; pr: Pr; workspace: Workspace; theme: Theme; compact: boolean; intent?: "merge" | "reviewers" | null }) {
|
|
24
|
+
export function PrControls({ pr, workspace, theme, compact, browserReady: companionReady, intent }: { browserReady: boolean; pr: Pr; workspace: Workspace; theme: Theme; compact: boolean; intent?: "merge" | "reviewers" | null }) {
|
|
19
25
|
const read = useRpc(prControlStatusRpc); const prepare = useRpc(preparePrActionRpc); const confirm = useRpc(confirmPrActionRpc); const cache = useQueryClient();
|
|
20
26
|
const requestReviewers = useRpc(requestReviewersRpc);
|
|
21
27
|
const toast = useToast();
|
|
22
28
|
const c = theme.colors; const t = text(c);
|
|
29
|
+
const github = isGithubFlow(pr.snapshot);
|
|
30
|
+
const browserReady = github ? !!pr.snapshot?.repoMerge?.autoMerge : companionReady;
|
|
23
31
|
const [plan, setPlan] = useState<ActionPlan | null>(null); const [notice, setNotice] = useState<string | null>(null);
|
|
24
32
|
const statusKey = ["follow-through", "pr-controls", workspace.id, pr.key, pr.snapshot?.head];
|
|
25
33
|
const status = useQuery({ queryKey: statusKey, queryFn: () => read({ workspaceId: workspace.id, prKey: pr.key }), refetchInterval: 10_000, enabled: browserReady });
|
|
@@ -57,7 +65,10 @@ export function PrControls({ pr, workspace, theme, compact, browserReady, intent
|
|
|
57
65
|
const loaded = !!reviewerSettings.data;
|
|
58
66
|
useEffect(() => { if (intent === "reviewers" && loaded && missingReviewers && !pr.snapshot?.draft && !reviewers.length) setPicking(true); }, [intent, loaded]);
|
|
59
67
|
if (pr.snapshot?.state !== "OPEN") return null;
|
|
60
|
-
const waitingFor = mergeBlockers(pr).filter(b => !b.startsWith("Graphite "));
|
|
68
|
+
const waitingFor = mergeBlockers(pr).filter(b => !b.startsWith("Graphite ")).map(lowerFirst);
|
|
69
|
+
// GitHub refuses auto-merge on a PR it can already merge, so the switch shows only while Merge is waiting, or to turn it off.
|
|
70
|
+
const showSwitch = browserReady && (!github || !canMerge || !!enabled);
|
|
71
|
+
const autoMergeOff = github && !!pr.snapshot?.repoMerge && !pr.snapshot.repoMerge.autoMerge && !canMerge && !queued;
|
|
61
72
|
return <View style={{ gap: 10 }}>
|
|
62
73
|
{missingReviewers && <View style={{ flexDirection: "row", alignItems: "center", flexWrap: "wrap", gap: 8 }}>
|
|
63
74
|
<Icon name="UserX" size={14} color={c.statusWarning} />
|
|
@@ -71,15 +82,16 @@ export function PrControls({ pr, workspace, theme, compact, browserReady, intent
|
|
|
71
82
|
onCancel={() => setPicking(false)} onRequest={(picked, remember) => reviewRequest.mutate({ picked, remember })} />}
|
|
72
83
|
{!plan && <View style={{ flexDirection: "row", alignItems: "center", flexWrap: "wrap", gap: 12 }}>
|
|
73
84
|
{(canMerge || queued || recentlySubmitted || busy) ? <Button title={busy ? checking.isPending ? "Checking…" : "Submitting…" : queued ? "Queued to merge" : recentlySubmitted ? "Submitted" : `Merge #${pr.number}`} icon={queued ? "Clock" : "GitMerge"} theme={theme} compact={compact} kind={canMerge ? "primary" : "secondary"} loading={busy} disabled={disabled || !canMerge} onPress={() => begin("merge")} />
|
|
74
|
-
: <Text style={[t.meta, { flex: 1 }]}>{waitingFor.length ? `Merge opens when it clears: ${waitingFor.join(", ")
|
|
75
|
-
{
|
|
85
|
+
: <Text style={[t.meta, { flex: 1 }]}>{waitingFor.length ? `Merge opens when it clears: ${waitingFor.join(", ")}.` : github ? "Waiting for GitHub to confirm it can merge." : "Waiting for Graphite to report it ready to merge."}</Text>}
|
|
86
|
+
{showSwitch && <Switch theme={theme} compact={compact} label={`${github ? "Auto-merge" : "When ready"}${known ? "" : " · unknown"}`} accessibilityLabel={`${github ? "Auto-merge" : "Merge when ready"} for ${pr.repo} pull request ${pr.number}`} value={known ? !!enabled : null} disabled={disabled} onChange={() => begin(enabled ? "disable_mwr" : "enable_mwr")} />}
|
|
76
87
|
</View>}
|
|
88
|
+
{!plan && autoMergeOff && <Text style={t.meta}>Auto-merge is off for this repository. Turn on Allow auto-merge in its GitHub settings.</Text>}
|
|
77
89
|
{error && <Text accessibilityRole="alert" style={[t.meta, { color: c.statusDanger }]}>{error}</Text>}
|
|
78
90
|
{notice && <Text accessibilityLiveRegion="polite" style={t.meta}>{notice}</Text>}
|
|
79
91
|
{plan && (plan.kind === "merge" || browserReady) && <View accessibilityRole="summary" style={{ gap: 8 }}>
|
|
80
92
|
<Text accessibilityRole="header" style={[t.label, { fontSize: 14, lineHeight: 20 }]}>{plan.kind === "merge" ? plan.prs.length > 1 ? "Merge the PRs underneath too?" : "Merge this PR?" : `${plan.kind === "enable_mwr" ? "Enable" : "Disable"} for downstack too?`}</Text>
|
|
81
|
-
<Text style={t.meta}>{plan.kind === "merge" ? plan.prs.length > 1 ? `#${pr.number} depends on ${plan.prs.length - 1} unmerged PR${plan.prs.length === 2 ? "" : "s"}. Merge these ${plan.prs.length} PRs in order:` : "Graphite will merge using this repository’s settings and required protections." : `Change merge when ready for #${pr.number} only, or for all ${plan.prs.length} listed PRs.`}</Text>
|
|
82
|
-
{plan.prs.map((p, i) => <View key={p.key} style={{ flexDirection: "row", gap: 8 }}>
|
|
93
|
+
<Text style={t.meta}>{plan.kind === "merge" ? plan.prs.length > 1 ? `#${pr.number} depends on ${plan.prs.length - 1} unmerged PR${plan.prs.length === 2 ? "" : "s"}. ${plan.mergeQueue ? `This repository merges through a merge queue, so #${plan.prs[0].number} goes in first; merge the next one after it lands:` : `Merge these ${plan.prs.length} PRs in order:`}` : plan.via === "github" ? plan.mergeQueue ? "GitHub adds it to this repository’s merge queue, which merges it once its checks pass." : `GitHub will ${METHOD_SENTENCE[plan.method ?? "squash"]} once this repository’s required protections pass.` : "Graphite will merge using this repository’s settings and required protections." : `Change ${plan.via === "github" ? "auto-merge" : "merge when ready"} for #${pr.number} only, or for all ${plan.prs.length} listed PRs.`}</Text>
|
|
94
|
+
{(plan.via !== "github" || plan.prs.length > 1 || plan.prs.some(p => p.blockers.length > 0)) && plan.prs.map((p, i) => <View key={p.key} style={{ flexDirection: "row", gap: 8 }}>
|
|
83
95
|
<Text style={[t.meta, { width: 16, textAlign: "right", fontVariant: ["tabular-nums"] }]}>{i + 1}.</Text>
|
|
84
96
|
<View style={{ flex: 1, gap: 2 }}>
|
|
85
97
|
<Text style={[t.body, { fontSize: 12, lineHeight: 17 }]}>#{p.number} · {p.title}</Text>
|
|
@@ -88,7 +100,7 @@ export function PrControls({ pr, workspace, theme, compact, browserReady, intent
|
|
|
88
100
|
</View>)}
|
|
89
101
|
{plan.blockers.map(blocker => <Text key={blocker} style={[t.meta, { color: c.statusWarning }]}>{blocker}</Text>)}
|
|
90
102
|
<View style={{ flexDirection: "row", flexWrap: "wrap", gap: 8, marginTop: 2 }}>
|
|
91
|
-
<Button title={plan.kind === "merge" ? plan.prs.length > 1 ? `Merge all ${plan.prs.length} PRs` : `Merge #${pr.number}` : `${plan.kind === "enable_mwr" ? "Enable" : "Disable"} for all ${plan.prs.length} PRs`} kind="primary" theme={theme} compact={compact} loading={submit.isPending} disabled={submit.isPending || scopeBlocked("downstack")} onPress={() => act("downstack")} />
|
|
103
|
+
<Button title={plan.kind === "merge" ? plan.mergeQueue ? `Add #${plan.prs[0].number} to merge queue` : plan.prs.length > 1 ? `Merge all ${plan.prs.length} PRs` : `Merge #${pr.number}` : `${plan.kind === "enable_mwr" ? "Enable" : "Disable"} for all ${plan.prs.length} PRs`} kind="primary" theme={theme} compact={compact} loading={submit.isPending} disabled={submit.isPending || scopeBlocked("downstack")} onPress={() => act("downstack")} />
|
|
92
104
|
{plan.kind !== "merge" && plan.prs.length > 1 && <Button title="Just this PR" theme={theme} compact={compact} disabled={submit.isPending || scopeBlocked("target")} onPress={() => act("target")} />}
|
|
93
105
|
<Button title="Cancel" kind="ghost" theme={theme} compact={compact} disabled={submit.isPending} onPress={() => { setPlan(null); checking.reset(); submit.reset(); }} />
|
|
94
106
|
</View>
|
package/client/pr-sheet.tsx
CHANGED
|
@@ -54,8 +54,9 @@ export function PrSheet({ workspace: w, prKey, intent, theme, compact, browserRe
|
|
|
54
54
|
<PrControls key={`${pr.key}:${intent ?? ""}`} pr={pr} workspace={w} theme={theme} compact={compact} browserReady={browserReady} intent={intent} />
|
|
55
55
|
</View>}
|
|
56
56
|
<View style={{ flexDirection: "row", flexWrap: "wrap", gap: 8, paddingTop: 12, borderTopWidth: 1, borderTopColor: c.border }}>
|
|
57
|
-
<Button theme={theme} compact={compact} icon="ExternalLink" title="Open in Graphite" accessibilityLabel={`Open ${pr.repo} pull request ${pr.number} in Graphite`} onPress={() => open(graphitePrUrl(pr))} />
|
|
58
|
-
{s?.url && <Button theme={theme} compact={compact}
|
|
57
|
+
{s?.prWorkflow !== "github" && <Button theme={theme} compact={compact} icon="ExternalLink" title="Open in Graphite" accessibilityLabel={`Open ${pr.repo} pull request ${pr.number} in Graphite`} onPress={() => open(graphitePrUrl(pr))} />}
|
|
58
|
+
{s?.url && s.prWorkflow === "github" && <Button theme={theme} compact={compact} icon="ExternalLink" title="Open on GitHub" accessibilityLabel={`Open ${pr.repo} pull request ${pr.number} on GitHub`} onPress={() => open(s.url)} />}
|
|
59
|
+
{s?.url && s.prWorkflow !== "github" && <Button theme={theme} compact={compact} kind="ghost" icon="Github" title="GitHub" accessibilityLabel={`Open ${pr.repo} pull request ${pr.number} on GitHub`} onPress={() => open(s.url)} />}
|
|
59
60
|
</View>
|
|
60
61
|
</>}
|
|
61
62
|
</Modal.Content>
|
package/client/settings.tsx
CHANGED
|
@@ -10,6 +10,7 @@ import { Switch, errorText, text, type Theme } from "./kit";
|
|
|
10
10
|
import { DisplaySections, PermissionsSection, PreferenceSwitch } from "./display";
|
|
11
11
|
import { ReviewerSettings, reviewerSettingsKey } from "./reviewers";
|
|
12
12
|
import { AgentSettings, agentSettingsKey } from "./agents";
|
|
13
|
+
import { ShippingSettings } from "./shipping";
|
|
13
14
|
import { BackHeader, CategoryList, CategoryTabs, Disclosure } from "./settings-shell";
|
|
14
15
|
import {
|
|
15
16
|
categoryTitle, followingSummary, hasSavedCategory, projectsOpenByDefault, projectsSummary, readCategory, reviewersSummary, workspaceRows, workspaceState, workspacesOpenByDefault, workspacesSummary,
|
|
@@ -75,6 +76,7 @@ function FollowingCategory({ theme, compact, openSetup }: { theme: Theme; compac
|
|
|
75
76
|
onValueChange={value => change.mutate({ activeWindowDays: Number(value) })} />
|
|
76
77
|
</SettingsCard>}
|
|
77
78
|
</SettingsSection>
|
|
79
|
+
<ShippingSettings theme={theme} compact={compact} />
|
|
78
80
|
<PermissionsSection theme={theme} />
|
|
79
81
|
<ProjectsFold theme={theme} compact={compact} />
|
|
80
82
|
{data && (data.workspaces.length
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
import { useState } from "react";
|
|
2
|
+
import { ActivityIndicator, Text, TextInput, View } from "react-native";
|
|
3
|
+
import { useRpc } from "@getpaseo/plugin/client";
|
|
4
|
+
import { SettingsAction, SettingsCard, SettingsSection, SettingsSelect, useToast } from "@getpaseo/plugin/client/ui";
|
|
5
|
+
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
|
6
|
+
import type { z } from "zod";
|
|
7
|
+
import { prWorkflowRpc, setPrWorkflowRpc } from "../shared/contracts";
|
|
8
|
+
import {
|
|
9
|
+
MERGE_METHOD_LABELS, MERGE_METHOD_SHORT, PR_WORKFLOWS, setupValue, setupWrite, type setPrWorkflowInputSchema, PR_WORKFLOW_LABELS, commandName, repoShippingSummary, reposShippingSummary, reviewFixLabel, shippingSummary, workflowName,
|
|
10
|
+
type MergeMethod, type PrWorkflowSetting, type PrWorkflowView, type RepoWorkflowView, type ReviewFix,
|
|
11
|
+
} from "../shared/pr-workflow";
|
|
12
|
+
import { Button, errorText, text, type Theme } from "./kit";
|
|
13
|
+
import { Disclosure } from "./settings-shell";
|
|
14
|
+
|
|
15
|
+
export const shippingKey = ["follow-through", "pr-workflow"];
|
|
16
|
+
type Write = z.input<typeof setPrWorkflowInputSchema>;
|
|
17
|
+
|
|
18
|
+
/** The section's info tip. Graphite is explained only on a machine where it's in play. */
|
|
19
|
+
export function shippingInfo(view: PrWorkflowView | undefined): string {
|
|
20
|
+
const base = "How Follow-up checks and merges each repository's PRs, and what it tells agents about review comments. Auto picks per repository from what's set up on this machine.";
|
|
21
|
+
const graphite = !!view && (view.gt.installed || view.repos.some(r => r.effective === "graphite" || r.detected === "graphite"));
|
|
22
|
+
return graphite ? `${base} It picks Graphite where the gt CLI is signed in and the repository is initialised, and only reads files to decide.` : base;
|
|
23
|
+
}
|
|
24
|
+
const BUILTIN_HINT = "Agents read the unresolved threads with gh, fix and push, then reply to each thread and resolve it.";
|
|
25
|
+
|
|
26
|
+
/** Where a nested fold's title starts (Disclosure: 36 in, 14 chevron, 8 gap) less a settings row's own 16 padding. */
|
|
27
|
+
const REPO_INSET = 36 + 14 + 8 - 16;
|
|
28
|
+
const ago = (at: number, now = Date.now()) => { const m = Math.round((now - at) / 60_000); return m < 1 ? "just now" : m < 60 ? `${m}m ago` : `${Math.round(m / 60)}h ago`; };
|
|
29
|
+
|
|
30
|
+
/** Settings → Following → Shipping PRs: the default, review comments, then one fold per repository. */
|
|
31
|
+
export function ShippingSettings({ theme, compact }: { theme: Theme; compact: boolean }) {
|
|
32
|
+
const c = theme.colors; const t = text(c);
|
|
33
|
+
const read = useRpc(prWorkflowRpc); const write = useRpc(setPrWorkflowRpc); const cache = useQueryClient(); const toast = useToast();
|
|
34
|
+
const query = useQuery({ queryKey: shippingKey, queryFn: () => read({}), staleTime: 60_000 });
|
|
35
|
+
const recheck = useMutation({ mutationFn: () => read({ refresh: true }), onSuccess: v => { cache.setQueryData(shippingKey, v); toast.show("Checked again", { variant: "success" }); }, onError: e => toast.error(errorText(e)) });
|
|
36
|
+
const change = useMutation({
|
|
37
|
+
mutationFn: (input: Write & { toast?: string }) => { const { toast: _, ...rest } = input; return write(rest); },
|
|
38
|
+
onSuccess: (v, input) => { cache.setQueryData(shippingKey, v); if (input.toast) toast.show(input.toast, { variant: "success" }); void cache.invalidateQueries({ queryKey: ["follow-through", "workspace"] }); },
|
|
39
|
+
onError: e => toast.error(errorText(e)),
|
|
40
|
+
});
|
|
41
|
+
const data = query.data;
|
|
42
|
+
const checked = query.dataUpdatedAt ? ago(query.dataUpdatedAt) : null;
|
|
43
|
+
return <SettingsSection title="Shipping PRs" info={shippingInfo(data)}>
|
|
44
|
+
{query.isPending && <ActivityIndicator accessibilityLabel="Loading how PRs ship" color={c.foregroundMuted} style={{ alignSelf: "flex-start", marginVertical: 8 }} />}
|
|
45
|
+
{query.error && <SettingsCard><SettingsAction label="Couldn't load how PRs ship" hint={errorText(query.error)} actionLabel="Retry" onPress={() => void query.refetch()} /></SettingsCard>}
|
|
46
|
+
{data && <>
|
|
47
|
+
<SettingsCard>
|
|
48
|
+
<SettingsSelect<PrWorkflowSetting> label="Ship PRs with" hint={defaultHint(data)} value={data.default} disabled={change.isPending}
|
|
49
|
+
options={PR_WORKFLOWS.map(w => ({ value: w, label: PR_WORKFLOW_LABELS[w].label }))}
|
|
50
|
+
onValueChange={value => change.mutate({ default: value, toast: `Default: ship with ${PR_WORKFLOW_LABELS[value].label}` })} />
|
|
51
|
+
<ReviewFixSelect label="Review comments" value={data.reviewFix} theme={theme} compact={compact} busy={change.isPending}
|
|
52
|
+
onSave={fix => { if (fix) change.mutate({ reviewFix: fix, toast: `Default: review comments → ${reviewFixLabel(fix)}` }); }} />
|
|
53
|
+
</SettingsCard>
|
|
54
|
+
{signInWarning(data) && <Text accessibilityRole="alert" style={[t.meta, { color: c.statusWarning }]}>{signInWarning(data)}</Text>}
|
|
55
|
+
{data.repos.length ? <Disclosure id="shipping.repos" title="Repositories" summary={reposShippingSummary(data.repos)}
|
|
56
|
+
defaultOpen={data.repos.length <= 6} theme={theme} compact={compact}>
|
|
57
|
+
{data.repos.map((row, i) => <View key={row.repo} style={{ borderTopWidth: i ? 1 : 0, borderTopColor: c.border }}>
|
|
58
|
+
<Disclosure framed={false} id={`shipping.repo.${row.repo}`} title={row.repo} summary={repoShippingSummary(row)} defaultOpen={false} theme={theme} compact={compact}>
|
|
59
|
+
<RepoShipping row={row} view={data} theme={theme} compact={compact} busy={change.isPending} set={(input, label) => change.mutate({ repo: row.repo, ...input, toast: `${row.repo}: ${label}` })} />
|
|
60
|
+
</Disclosure>
|
|
61
|
+
</View>)}
|
|
62
|
+
<View style={{ flexDirection: "row", alignItems: "center", gap: 12, borderTopWidth: 1, borderTopColor: c.border, paddingHorizontal: compact ? 16 : 14, paddingVertical: 8 }}>
|
|
63
|
+
<Text style={[t.meta, { flex: 1 }]}>{`${checked ? `Checked ${checked}` : "Not checked yet"} · looks at what's installed and how each repository is set up.`}</Text>
|
|
64
|
+
<Button theme={theme} compact={compact} title={recheck.isPending ? "Checking…" : "Check again"} disabled={recheck.isPending} loading={recheck.isPending} onPress={() => recheck.mutate()} />
|
|
65
|
+
</View>
|
|
66
|
+
</Disclosure> : <Text style={t.meta}>Repositories show here once Follow-up sees a PR in them or a project with a GitHub remote.</Text>}
|
|
67
|
+
</>}
|
|
68
|
+
</SettingsSection>;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function defaultHint(view: PrWorkflowView): string {
|
|
72
|
+
const now = shippingSummary(view).split(" · ").slice(1).join(" · ");
|
|
73
|
+
return view.default === "auto" ? (now ? `Right now: ${now}.` : PR_WORKFLOW_LABELS.auto.hint) : PR_WORKFLOW_LABELS[view.default].hint;
|
|
74
|
+
}
|
|
75
|
+
/** Only when a repository is on Graphite and the CLI can't merge for it; a missing gt is normal otherwise. */
|
|
76
|
+
function signInWarning(view: PrWorkflowView): string | null {
|
|
77
|
+
if (!view.repos.some(r => r.effective === "graphite") || view.gt.installed && view.gt.signedIn) return null;
|
|
78
|
+
return view.gt.installed ? "The Graphite CLI isn't signed in on this machine. Run gt auth, or merges in Graphite repositories will fail." : "A repository is set to Graphite, but the gt CLI isn't installed on this machine.";
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
function RepoShipping({ row, view, theme, compact, busy, set }: { row: RepoWorkflowView; view: PrWorkflowView; theme: Theme; compact: boolean; busy: boolean; set: (input: Omit<Write, "repo">, label: string) => void }) {
|
|
82
|
+
const c = theme.colors; const t = text(c);
|
|
83
|
+
const fallback = view.default === "auto" ? `Default · Auto → ${workflowName(row.detected)}` : `Default · ${PR_WORKFLOW_LABELS[view.default].label}`;
|
|
84
|
+
const methods = row.github?.methods ?? [];
|
|
85
|
+
const preferred = row.github?.preferred ?? methods[0] ?? null;
|
|
86
|
+
// A hairline that starts on the text column, without shifting the row under it.
|
|
87
|
+
const rule = <View style={{ height: 1, backgroundColor: c.border, marginLeft: 16 }} />;
|
|
88
|
+
const autoMerge = row.effective !== "github" || !row.github ? undefined : row.github.autoMerge ? "Auto-merge is available for PRs here." : "Auto-merge is off in this repository's GitHub settings, so its PRs have no Auto-merge switch.";
|
|
89
|
+
const pinned = !row.inherits && row.setting !== "auto";
|
|
90
|
+
const reason = pinned ? `Set here.${row.detected !== row.effective ? ` Auto would use ${workflowName(row.detected)}.` : ""}` : row.reason;
|
|
91
|
+
// Flat rows inside the fold: no inner card. Text and hairlines start on the repository name's column.
|
|
92
|
+
return <View style={{ paddingLeft: REPO_INSET, paddingBottom: 4 }}>
|
|
93
|
+
<Text style={[t.meta, { paddingHorizontal: 16, paddingBottom: 4 }]}>{reason}</Text>
|
|
94
|
+
<SettingsSelect<"inherit" | PrWorkflowSetting> label="Ship with" hint={autoMerge} value={row.inherits ? "inherit" : row.setting} disabled={busy}
|
|
95
|
+
options={[{ value: "inherit", label: fallback }, ...(view.default !== "auto" ? [{ value: "auto" as const, label: `Auto (picks ${workflowName(row.detected)} here)` }] : []), ...PR_WORKFLOWS.filter(w => w !== "auto").map(w => ({ value: w, label: PR_WORKFLOW_LABELS[w].label }))]}
|
|
96
|
+
onValueChange={value => set({ setting: value === "inherit" ? null : value }, value === "inherit" ? "back to the default" : PR_WORKFLOW_LABELS[value].label)} />
|
|
97
|
+
{row.effective === "github" && <View>{rule}{row.github?.mergeQueue
|
|
98
|
+
? <SettingsAction label="Merge method" hint="This repository merges through a merge queue, which picks the method." actionLabel="GitHub" disabled onPress={() => undefined} />
|
|
99
|
+
: <SettingsSelect<"default" | MergeMethod> label="Merge method" disabled={busy || !row.github}
|
|
100
|
+
hint={!row.github ? "Shows after Follow-up reads a PR here." : `This repository allows ${listMethods(methods)}.`}
|
|
101
|
+
value={row.mergeMethod && methods.includes(row.mergeMethod) ? row.mergeMethod : "default"}
|
|
102
|
+
options={[{ value: "default", label: preferred ? `Default · ${MERGE_METHOD_SHORT[preferred]}` : "Repository default" }, ...methods.map(m => ({ value: m, label: MERGE_METHOD_LABELS[m] }))]}
|
|
103
|
+
onValueChange={value => set({ mergeMethod: value === "default" ? null : value }, value === "default" ? "GitHub's default merge method" : MERGE_METHOD_LABELS[value])} />}</View>}
|
|
104
|
+
<View>{rule}<ReviewFixSelect label="Review comments" value={row.reviewFix} inherited={view.reviewFix} theme={theme} compact={compact} busy={busy}
|
|
105
|
+
onSave={fix => set({ reviewFix: fix }, fix ? `review comments: ${reviewFixLabel(fix)}` : "review comments back to the default")} /></View>
|
|
106
|
+
</View>;
|
|
107
|
+
}
|
|
108
|
+
/** "squash", "squash and rebase", "squash, merge commits and rebase". */
|
|
109
|
+
function listMethods(methods: MergeMethod[]): string {
|
|
110
|
+
const words = methods.map(m => ({ squash: "squash", merge: "merge commits", rebase: "rebase" })[m]);
|
|
111
|
+
return words.length < 2 ? words.join("") : `${words.slice(0, -1).join(", ")} and ${words.at(-1)}`;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Built-in steps or a skill/command name. Choosing "A skill or command" opens a one-line field with Save; an
|
|
116
|
+
* inherited row (`inherited` set) adds "Same as default".
|
|
117
|
+
*/
|
|
118
|
+
function ReviewFixSelect({ label, value, inherited, theme, compact, busy, onSave }: { label: string; value: ReviewFix | null; inherited?: ReviewFix; theme: Theme; compact: boolean; busy: boolean; onSave: (fix: ReviewFix | null) => void }) {
|
|
119
|
+
const c = theme.colors; const t = text(c);
|
|
120
|
+
const current = value ? value.kind : inherited ? "inherit" : "builtin";
|
|
121
|
+
const [editing, setEditing] = useState(false);
|
|
122
|
+
const [draft, setDraft] = useState(value && commandName(value) || "");
|
|
123
|
+
const valid = /^\/?[\w:.-]{1,80}$/.test(draft.trim());
|
|
124
|
+
const shown = editing ? "command" : current;
|
|
125
|
+
const hint = shown === "inherit" ? `Uses the default: ${reviewFixLabel(inherited!)}.` : shown === "builtin" ? BUILTIN_HINT : value?.kind === "command" && !editing ? `Agents run ${commandName(value)} for review comments.` : "The skill or slash command agents run for review comments, such as /fix-pr.";
|
|
126
|
+
return <View>
|
|
127
|
+
<SettingsSelect<"inherit" | "builtin" | "command"> label={label} hint={hint} value={shown} disabled={busy}
|
|
128
|
+
options={[...(inherited ? [{ value: "inherit" as const, label: `Default · ${reviewFixLabel(inherited)}` }] : []), { value: "builtin" as const, label: "Built-in steps" }, { value: "command" as const, label: value?.kind === "command" ? commandName(value)! : "A skill or command…" }]}
|
|
129
|
+
onValueChange={next => { if (next === "command") { setEditing(true); return; } setEditing(false); onSave(next === "inherit" ? null : { kind: "builtin" }); }} />
|
|
130
|
+
{editing && <View style={{ flexDirection: "row", alignItems: "center", gap: 8, paddingHorizontal: 14, paddingBottom: 12 }}>
|
|
131
|
+
<TextInput accessibilityLabel="Skill or command for review comments" value={draft} onChangeText={setDraft} placeholder="/fix-pr" placeholderTextColor={c.foregroundMuted} autoCapitalize="none" autoCorrect={false} autoFocus
|
|
132
|
+
onSubmitEditing={() => { if (valid) { onSave({ kind: "command", command: draft.trim() }); setEditing(false); } }}
|
|
133
|
+
style={{ flex: 1, minWidth: 0, minHeight: compact ? 44 : 32, paddingHorizontal: 10, borderRadius: 6, borderWidth: 1, borderColor: draft && !valid ? c.statusDanger : c.border, color: c.foreground, fontSize: 13, backgroundColor: c.surface0, fontFamily: "monospace" }} />
|
|
134
|
+
<Button theme={theme} compact={compact} kind="primary" title="Save" disabled={!valid || busy} onPress={() => { onSave({ kind: "command", command: draft.trim() }); setEditing(false); }} />
|
|
135
|
+
<Button theme={theme} compact={compact} kind="ghost" title="Cancel" onPress={() => setEditing(false)} />
|
|
136
|
+
</View>}
|
|
137
|
+
{editing && draft !== "" && !valid && <Text style={[t.meta, { color: c.statusDanger, paddingHorizontal: 14, paddingBottom: 10 }]}>Use a name like /fix-pr: letters, digits, dashes, dots or colons.</Text>}
|
|
138
|
+
</View>;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Setup's "How do you ship PRs?" step: one row per repository with what Auto picked and why, and a select that writes
|
|
143
|
+
* the same setting as Settings. Graphite is named only as an option, or on a repository that already ships with it.
|
|
144
|
+
*/
|
|
145
|
+
export function ShippingStep({ theme, compact }: { theme: Theme; compact: boolean }) {
|
|
146
|
+
const c = theme.colors; const t = text(c);
|
|
147
|
+
const read = useRpc(prWorkflowRpc); const write = useRpc(setPrWorkflowRpc); const cache = useQueryClient(); const toast = useToast();
|
|
148
|
+
const query = useQuery({ queryKey: shippingKey, queryFn: () => read({}), staleTime: 60_000 });
|
|
149
|
+
const change = useMutation({
|
|
150
|
+
mutationFn: (input: Write) => write(input),
|
|
151
|
+
onSuccess: v => cache.setQueryData(shippingKey, v),
|
|
152
|
+
onError: e => toast.error(errorText(e)),
|
|
153
|
+
});
|
|
154
|
+
const later = <Text style={t.meta}>Change this later in Settings → Following → Shipping PRs.</Text>;
|
|
155
|
+
if (query.isPending) return <ActivityIndicator accessibilityLabel="Checking how your repositories ship PRs" color={c.foregroundMuted} style={{ alignSelf: "flex-start" }} />;
|
|
156
|
+
if (query.error) return <Text accessibilityRole="alert" style={[t.meta, { color: c.statusDanger }]}>{errorText(query.error)}</Text>;
|
|
157
|
+
const data = query.data!;
|
|
158
|
+
if (!data.repos.length) return <View style={{ gap: 10 }}><Text style={t.body}>Follow-up works this out per repository when it sees the first PR.</Text>{later}</View>;
|
|
159
|
+
const warning = signInWarning(data);
|
|
160
|
+
// Graphite repositories first: they're the ones worth a look.
|
|
161
|
+
const rows = [...data.repos].sort((a, b) => Number(b.effective === "graphite") - Number(a.effective === "graphite"));
|
|
162
|
+
const uniform = rows.every(r => r.effective === "github" && r.inherits);
|
|
163
|
+
const row = (r: RepoWorkflowView) => <SettingsSelect<PrWorkflowSetting> key={r.repo} label={r.repo} hint={r.reason} value={setupValue(data, r)} disabled={change.isPending}
|
|
164
|
+
options={PR_WORKFLOWS.map(w => ({ value: w, label: w === "auto" ? `Auto (${workflowName(r.detected)})` : PR_WORKFLOW_LABELS[w].label }))}
|
|
165
|
+
onValueChange={choice => change.mutate(setupWrite(data, r.repo, choice))} />;
|
|
166
|
+
// Nothing to decide (every repository on GitHub by Auto): one row for the default, the repositories folded.
|
|
167
|
+
if (uniform) return <View style={{ gap: 10 }}>
|
|
168
|
+
<SettingsCard>
|
|
169
|
+
<SettingsSelect<PrWorkflowSetting> label={`All ${rows.length} repositor${rows.length === 1 ? "y ships" : "ies ship"} with GitHub`} hint={rows[0].reason} value={data.default} disabled={change.isPending}
|
|
170
|
+
options={PR_WORKFLOWS.map(w => ({ value: w, label: PR_WORKFLOW_LABELS[w].label }))}
|
|
171
|
+
onValueChange={value => change.mutate({ default: value })} />
|
|
172
|
+
</SettingsCard>
|
|
173
|
+
<Disclosure id="setup.shipping.repos" title="Show repositories" summary={`${rows.length} on GitHub`} defaultOpen={false} theme={theme} compact={compact}>
|
|
174
|
+
{rows.map((r, i) => <View key={r.repo} style={{ borderTopWidth: i ? 1 : 0, borderTopColor: c.border }}>{row(r)}</View>)}
|
|
175
|
+
</Disclosure>
|
|
176
|
+
{later}
|
|
177
|
+
</View>;
|
|
178
|
+
return <View style={{ gap: 10 }}>
|
|
179
|
+
<SettingsCard>{rows.map(row)}</SettingsCard>
|
|
180
|
+
{warning && <Text accessibilityRole="alert" style={[t.meta, { color: c.statusWarning }]}>{warning}</Text>}
|
|
181
|
+
{later}
|
|
182
|
+
</View>;
|
|
183
|
+
}
|
package/client/stacks.tsx
CHANGED
|
@@ -4,6 +4,7 @@ import type { Pr, Workspace } from "../shared/model";
|
|
|
4
4
|
import { compactPrStatus, orderedStacks, settledForDisplay } from "../shared/presentation";
|
|
5
5
|
import { mergeQueued, prTone, stackOrder } from "../shared/attention";
|
|
6
6
|
import { noReviewers } from "../shared/reviewers";
|
|
7
|
+
import { isGithubFlow } from "../shared/pr-actions";
|
|
7
8
|
import { Card, FoldRow, text, type Theme } from "./kit";
|
|
8
9
|
import { Spinner } from "./motion";
|
|
9
10
|
import { mergedColor, tint, toneColor, type Colors } from "./theme";
|
|
@@ -38,7 +39,7 @@ export function PrRow({ pr, theme, first, last, showRepo, onOpen, compact, wide
|
|
|
38
39
|
const line = c.border;
|
|
39
40
|
const extras = [
|
|
40
41
|
s?.state === "OPEN" && noReviewers(pr) ? "No reviewers" : null,
|
|
41
|
-
s?.state === "OPEN" && s.mergeWhenReady === "on" && !mergeQueued(pr) ? "Merge when ready" : null,
|
|
42
|
+
s?.state === "OPEN" && s.mergeWhenReady === "on" && !mergeQueued(pr) ? isGithubFlow(s) ? "Auto-merge" : "Merge when ready" : null,
|
|
42
43
|
].filter(Boolean) as string[];
|
|
43
44
|
return <Pressable accessibilityRole="button" accessibilityLabel={`Pull request ${pr.number}: ${s?.title ?? pr.stack}. ${label}. Open details`} onPress={() => onOpen(pr.key)}
|
|
44
45
|
style={state => ({ flexDirection: "row", gap: 10, paddingHorizontal: 12, minHeight: compact ? 52 : 44, backgroundColor: state.pressed ? c.surface2 : (state as { hovered?: boolean }).hovered ? c.surface1 : "transparent" })}>
|
|
@@ -112,7 +113,7 @@ export function StacksCard({ workspace: w, theme, compact, open, toggle, onOpen,
|
|
|
112
113
|
return <Card theme={theme} compact={compact} icon="GitPullRequest" title="Pull requests" count={openCount ? `${openCount} open` : undefined}>
|
|
113
114
|
{inFlight.map(a => <View key={a.id} style={{ flexDirection: "row", gap: 8, paddingHorizontal: 12, paddingVertical: 8, borderTopWidth: 1, borderTopColor: c.border }}>
|
|
114
115
|
<View style={{ paddingTop: 3 }}><Spinner color={c.accent} size={12} /></View>
|
|
115
|
-
<Text style={[t.meta, { flex: 1, color: c.foreground }]}>{a.result || "Submitting to Graphite…"}</Text>
|
|
116
|
+
<Text style={[t.meta, { flex: 1, color: c.foreground }]}>{a.result || (isGithubFlow(w.prs.find(p => p.key === a.prs[0])?.snapshot) ? "Sending to GitHub…" : "Submitting to Graphite…")}</Text>
|
|
116
117
|
</View>)}
|
|
117
118
|
{!w.prs.length && <View style={{ paddingHorizontal: 12, paddingVertical: 10, borderTopWidth: 1, borderTopColor: c.border, gap: 4 }}>
|
|
118
119
|
<Text style={t.body}>No PRs yet</Text>
|
package/index.server.ts
CHANGED
|
@@ -43,7 +43,10 @@ import { copyFile, readFile, rename, stat } from "node:fs/promises";
|
|
|
43
43
|
import { HistoryCache } from "./server/history-cache";
|
|
44
44
|
import { Governor } from "./server/governor";
|
|
45
45
|
import { ListCache } from "./server/list-cache";
|
|
46
|
-
import { scopeWriter } from "./server/scopes";
|
|
46
|
+
import { scopeWriter, workflowSummary } from "./server/scopes";
|
|
47
|
+
import { PrWorkflowStore } from "./server/pr-workflow";
|
|
48
|
+
import { commandName } from "./shared/pr-workflow";
|
|
49
|
+
import { projectRepo } from "./server/daemon";
|
|
47
50
|
import { batchArchive, pruneUnsent } from "./server/batch-archive";
|
|
48
51
|
import { NO_USAGE } from "./shared/usage";
|
|
49
52
|
import { activeWindowMs, conversationGone, DEFAULT_ACTIVE_WINDOW_DAYS } from "./server/agent-load";
|
|
@@ -99,7 +102,12 @@ export default function contribute(server: PluginServerContext) {
|
|
|
99
102
|
};
|
|
100
103
|
const store = new Store(directory, 1_000);
|
|
101
104
|
const onboarding = new OnboardingStore(directory);
|
|
102
|
-
|
|
105
|
+
// PR workflow (Graphite or plain GitHub) per repository; scopes.json carries each agent's so its instructions match.
|
|
106
|
+
const prWorkflow = new PrWorkflowStore(directory);
|
|
107
|
+
let workspaceRepos: Map<string, string> = new Map();
|
|
108
|
+
const workspaceRepo = (w: Workspace): string | null => (w.prs.find(p => p.snapshot?.state === "OPEN") ?? w.prs.at(-1))?.repo ?? workspaceRepos.get(w.id) ?? null;
|
|
109
|
+
const knownRepos = (state: { workspaces: Workspace[] }) => new Set([...state.workspaces.filter(w => w.enable_tracking && !w.archived).flatMap(w => w.prs.map(p => repoKey(p.repo))), ...[...workspaceRepos.values()].map(repoKey)]);
|
|
110
|
+
store.onChanged = scopeWriter(directory, { agent: w => prWorkflow.agentWorkflow(workspaceRepo(w)), summary: state => workflowSummary([...knownRepos(state)].map(r => prWorkflow.cachedWorkflow(r))) });
|
|
103
111
|
const agentHooks = new AgentHooks(directory, clientEntry());
|
|
104
112
|
const historyCache = HistoryCache.at(directory);
|
|
105
113
|
const gateway = new PaseoGateway(undefined, undefined, undefined, historyCache);
|
|
@@ -108,11 +116,25 @@ export default function contribute(server: PluginServerContext) {
|
|
|
108
116
|
gateway.recoveryRole = () => agentSettings.role("recovery");
|
|
109
117
|
const graphite = new Graphite();
|
|
110
118
|
const github = new Github(undefined, graphite, new Deployments());
|
|
119
|
+
github.workflow = repo => prWorkflow.workflow(repo);
|
|
120
|
+
workspaceRepos = gateway.workspaceRepos;
|
|
121
|
+
prWorkflow.paths = async () => {
|
|
122
|
+
const paths = new Map<string, string[]>();
|
|
123
|
+
const add = (repo: string, path: string) => { const key = repoKey(repo); paths.set(key, [...(paths.get(key) ?? []), path]); };
|
|
124
|
+
const state = await store.snapshot();
|
|
125
|
+
for (const p of await gateway.projects(state)) { const repo = projectRepo(p.key); if (repo && p.path) add(repo, p.path); }
|
|
126
|
+
// Fallback: where tracked workspaces' agents work on that repository's PRs.
|
|
127
|
+
for (const w of state.workspaces) for (const repo of new Set([...w.prs.map(p => p.repo), ...(workspaceRepos.get(w.id) ? [workspaceRepos.get(w.id)!] : [])])) for (const cwd of gateway.workspaceCwds.get(w.id) ?? []) add(repo, cwd);
|
|
128
|
+
return paths;
|
|
129
|
+
};
|
|
130
|
+
prWorkflow.onChanged = () => { void store.snapshot().then(state => store.onChanged(state)).catch(() => undefined); };
|
|
111
131
|
const browser = new BrowserBridge();
|
|
112
132
|
const reviewerStore = new ReviewerConfigStore(directory);
|
|
113
133
|
const reviewerSuggestions = new ReviewerSuggestions();
|
|
114
134
|
const actions = new PrActions(store, github, graphite, browser);
|
|
135
|
+
actions.savedMethod = repo => prWorkflow.current().repos[repoKey(repo)]?.mergeMethod ?? null;
|
|
115
136
|
const engine = new Engine(store, github, gateway);
|
|
137
|
+
engine.wording = { reviewFix: repo => commandName(prWorkflow.reviewFix(repo)) };
|
|
116
138
|
const governor = new Governor();
|
|
117
139
|
const listCache = new ListCache();
|
|
118
140
|
engine.paused = () => !governor.allowsBackground();
|
|
@@ -248,6 +270,9 @@ export default function contribute(server: PluginServerContext) {
|
|
|
248
270
|
await backupActiveScope();
|
|
249
271
|
// Reviewers: the one-time seed from earlier requests, before history is pruned. An unreadable reviewers.json only affects Add reviewers.
|
|
250
272
|
await reviewerStore.migrate(await store.snapshot()).catch(() => undefined);
|
|
273
|
+
// PR workflow: the one-time /fix-pr seed, then resolve every known repository (filesystem checks only, never gt).
|
|
274
|
+
await prWorkflow.migrate().catch(() => undefined);
|
|
275
|
+
await prWorkflow.warm(knownRepos(await store.snapshot())).catch(() => undefined);
|
|
251
276
|
await pruneHistory();
|
|
252
277
|
await store.onChanged(await store.snapshot()).catch(() => undefined);
|
|
253
278
|
hooksStarted = true;
|
|
@@ -275,7 +300,7 @@ export default function contribute(server: PluginServerContext) {
|
|
|
275
300
|
const flags = { recovery, brief: !!brief && !recovery, root: root && !recovery, overseer: overseer && !recovery };
|
|
276
301
|
const env = { ...request.env, FOLLOW_THROUGH_TOOLS: "native", FOLLOW_THROUGH_PROVIDER: request.provider, ...(flags.root ? { FOLLOW_THROUGH_ROOT: "1" } : {}), ...(flags.overseer ? { FOLLOW_THROUGH_OVERSEER: "1" } : {}) };
|
|
277
302
|
if (/^[\w-]+$/.test(request.agentId)) await writeFile(join(directory, "hook-state", `native-${request.agentId}.json`), JSON.stringify({ instance: toolsInstance }), { mode: 0o600 }).catch(() => undefined);
|
|
278
|
-
return { ...request, env, tools: [...request.tools, ...nativeTools(flags, live, invoke)] };
|
|
303
|
+
return { ...request, env, tools: [...request.tools, ...nativeTools(flags, live, invoke, workflowSummary([...knownRepos(await store.snapshot())].map(r => prWorkflow.cachedWorkflow(r))))] };
|
|
279
304
|
}
|
|
280
305
|
return withSessionMcp({ ...request, env: { ...request.env, FOLLOW_THROUGH_TOOLS: "stdio", FOLLOW_THROUGH_PROVIDER: request.provider } }, directory, clientEntry(), paseoHome, recovery, process.env, brief, root, overseer, providers) as R;
|
|
281
306
|
};
|
|
@@ -384,7 +409,7 @@ export default function contribute(server: PluginServerContext) {
|
|
|
384
409
|
await agentHooks.confirm(w.id, agentId, summary);
|
|
385
410
|
return { workspaceId: w.id, synced: true as const };
|
|
386
411
|
});
|
|
387
|
-
handle(rpc.agentStatusRpc, async ({ agentId }, { paseo }) => { await requireReady(); const workspaceId = await callerWorkspaceId(agentId, paseo);
|
|
412
|
+
handle(rpc.agentStatusRpc, async ({ agentId }, { paseo }) => { await requireReady(); const workspaceId = await callerWorkspaceId(agentId, paseo); const w = agentWorkspace(await store.snapshot(), agentId, "read", workspaceId, "pr"); return { ...w, prWorkflow: prWorkflow.agentWorkflow(workspaceRepo(w)) }; });
|
|
388
413
|
handle(rpc.activateRpc, async ({ workspaceId }) => { await requireReady(); return engine.activate(workspaceId); });
|
|
389
414
|
handle(rpc.sendRpc, async ({ workspaceId, batchId }) => { await requireReady(); return engine.sendPending(workspaceId, batchId); });
|
|
390
415
|
handle(rpc.recoverRpc, async ({ workspaceId }) => { await requireReady(); return engine.startRecovery(workspaceId); });
|
|
@@ -565,6 +590,44 @@ export default function contribute(server: PluginServerContext) {
|
|
|
565
590
|
for (const w of (await store.snapshot()).workspaces) for (const p of w.prs) seen.add(repoKey(p.repo));
|
|
566
591
|
return { config, repos: [...seen].sort() };
|
|
567
592
|
};
|
|
593
|
+
const prWorkflowRepos = async () => {
|
|
594
|
+
const repos = new Set((await reviewerSettings()).repos);
|
|
595
|
+
for (const p of await gateway.projects(await store.snapshot()).catch(() => [])) { const repo = projectRepo(p.key); if (repo) repos.add(repoKey(repo)); }
|
|
596
|
+
for (const repo of Object.keys(prWorkflow.current().repos)) repos.add(repo);
|
|
597
|
+
return repos;
|
|
598
|
+
};
|
|
599
|
+
// Each repository's merge settings as GitHub reported them with its newest observed PR (no extra request).
|
|
600
|
+
const repoMerges = async () => {
|
|
601
|
+
const newest = new Map<string, { at: string; value: NonNullable<NonNullable<Workspace["prs"][number]["snapshot"]>["repoMerge"]> }>();
|
|
602
|
+
for (const w of (await store.snapshot()).workspaces) for (const p of w.prs) {
|
|
603
|
+
const s = p.snapshot; if (!s?.repoMerge) continue;
|
|
604
|
+
const key = repoKey(p.repo); const seen = newest.get(key);
|
|
605
|
+
if (!seen || s.observedAt > seen.at) newest.set(key, { at: s.observedAt, value: s.repoMerge });
|
|
606
|
+
}
|
|
607
|
+
return newest;
|
|
608
|
+
};
|
|
609
|
+
const prWorkflowView = async (fresh = false) => { const merges = await repoMerges(); return prWorkflow.view(await prWorkflowRepos(), fresh, repo => merges.get(repo)?.value ?? null); };
|
|
610
|
+
handle(rpc.prWorkflowRpc, async ({ refresh }) => {
|
|
611
|
+
await requireReady();
|
|
612
|
+
const view = await prWorkflowView(!!refresh);
|
|
613
|
+
if (refresh) prWorkflow.onChanged();
|
|
614
|
+
return view;
|
|
615
|
+
});
|
|
616
|
+
handle(rpc.setPrWorkflowRpc, async ({ repo, setting, default: fallback, mergeMethod, reviewFix }) => {
|
|
617
|
+
await requireReady();
|
|
618
|
+
if ((setting !== undefined || mergeMethod !== undefined || (reviewFix !== undefined && repo)) && !repo) throw new Error("Name the repository (owner/name) to change.");
|
|
619
|
+
await prWorkflow.mutate(config => {
|
|
620
|
+
if (fallback !== undefined) config.default = fallback;
|
|
621
|
+
if (!repo) { if (reviewFix) config.reviewFix = reviewFix; return; }
|
|
622
|
+
const own = config.repos[repoKey(repo)] ??= {};
|
|
623
|
+
if (setting !== undefined) { if (setting === null) delete own.workflow; else own.workflow = setting; }
|
|
624
|
+
if (mergeMethod !== undefined) { if (mergeMethod === null) delete own.mergeMethod; else own.mergeMethod = mergeMethod; }
|
|
625
|
+
if (reviewFix !== undefined) { if (reviewFix === null) delete own.reviewFix; else own.reviewFix = reviewFix; }
|
|
626
|
+
});
|
|
627
|
+
// A changed workflow changes readiness and merge: check the PRs again now rather than on the next poll.
|
|
628
|
+
void engine.tick();
|
|
629
|
+
return prWorkflowView();
|
|
630
|
+
});
|
|
568
631
|
handle(rpc.reviewerSettingsRpc, async () => { await requireReady(); return reviewerSettings(); });
|
|
569
632
|
handle(rpc.saveReviewersRpc, async ({ repo, reviewers }) => { await requireReady(); await reviewerStore.save(repo, reviewers); return reviewerSettings(); });
|
|
570
633
|
handle(rpc.reviewerSuggestionsRpc, async ({ repo }) => { await requireReady(); return reviewerSuggestions.suggest(repo); });
|
|
@@ -701,7 +764,7 @@ export default function contribute(server: PluginServerContext) {
|
|
|
701
764
|
if (!stopped) aboutTimer = setTimeout(() => void aboutLoop(), 10 * 60_000);
|
|
702
765
|
};
|
|
703
766
|
aboutTimer = setTimeout(() => void aboutLoop(), 60_000);
|
|
704
|
-
const agentActions = new AgentActions({ store, prActions: actions, engine, inbox, priorities: priorityStore, about, agentSettings });
|
|
767
|
+
const agentActions = new AgentActions({ store, prActions: actions, engine, inbox, priorities: priorityStore, about, agentSettings, prWorkflows: () => prWorkflowView() });
|
|
705
768
|
handle(rpc.prioritiesRpc, async () => ({ items: await priorityStore.read() }));
|
|
706
769
|
// Provider limits are non-essential: at critical memory only the VM meter is served.
|
|
707
770
|
handle(rpc.usageRpc, async () => ({ ...(governor.allowsExtras() ? await usage.read() : NO_USAGE), resources: governor.current() }));
|