paseo-follow-up 2.0.1 → 2.0.2-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/client/brief.tsx +9 -4
- package/client/home.tsx +11 -3
- package/client/linked.tsx +1 -1
- package/client/live-copies.ts +19 -1
- package/client/live.tsx +16 -12
- package/client/merge-button.tsx +1 -1
- package/client/needs-you.tsx +1 -1
- package/client/pill.tsx +13 -9
- package/client/questions.tsx +8 -7
- package/client/spec.tsx +1 -1
- package/client/workspace-data.ts +36 -19
- package/package.json +1 -1
- package/server/daemon.ts +18 -33
- package/server/deployments.ts +55 -20
- package/server/feeds.ts +3 -2
- package/server/list-cache.ts +21 -10
- package/shared/activity.ts +1 -1
- package/shared/attention.ts +8 -7
- package/shared/brief.ts +5 -5
- package/shared/contracts.ts +3 -2
- package/shared/follow-up.ts +2 -2
- package/shared/home.ts +4 -3
- package/shared/list.ts +86 -0
- package/shared/merge-click.ts +1 -1
- package/shared/model.ts +8 -7
- package/shared/overseer.ts +3 -3
- package/shared/poll.ts +1 -1
- package/shared/pr-actions.ts +7 -6
- package/shared/presentation.ts +6 -5
- package/shared/questions.ts +9 -7
- package/shared/reviewers.ts +1 -1
- package/shared/row-menu.ts +1 -1
- package/shared/search.ts +3 -3
- package/shared/send-decision.ts +2 -1
- package/shared/sending.ts +1 -1
- package/shared/status-invariants.ts +1 -1
- package/shared/status.ts +1 -1
- package/shared/task-rows.ts +4 -2
- package/shared/task-status.ts +2 -1
- package/shared/task-trigger.ts +1 -1
package/server/deployments.ts
CHANGED
|
@@ -11,17 +11,22 @@ type Run = (command: string, args: string[]) => Promise<string>;
|
|
|
11
11
|
type Fleet = { commits: string[]; evidence: string; observedAt: string };
|
|
12
12
|
/** The deploy check's configuration for a repository (host settings, pr-workflow.json); undefined: no deploy check. */
|
|
13
13
|
export type DeployConfigFor = (repo: string) => DeployConfig | undefined;
|
|
14
|
+
/** How long one `gcloud auth print-access-token` is reused: under the token's hour, with margin. */
|
|
15
|
+
export const TOKEN_MS = 2_700_000;
|
|
16
|
+
/** Every registry and Cloud Run read is aborted after this long. */
|
|
17
|
+
export const READ_TIMEOUT_MS = 8_000;
|
|
18
|
+
const IMAGE_ACCEPT = "application/vnd.oci.image.manifest.v1+json, application/vnd.docker.distribution.manifest.v2+json";
|
|
14
19
|
const escape = (text: string) => text.replace(/[.*+?^${}()|[\]\\/]/g, "\\$&");
|
|
15
20
|
|
|
16
21
|
/** Messages this probe throws itself. Anything else (gcloud, gh, fetch) is summarized so no transport detail leaks. */
|
|
17
|
-
const OWN_REASONS = new Set(["Deployment image unavailable", "Deployment image metadata exceeds the read limit", "Serving image must have an immutable production digest", "Serving image config unavailable", "Serving source revision is unknown", "Production service catalog incomplete", "Production traffic is not ready", "Serving revision unavailable", "Serving revision is not ready"]);
|
|
22
|
+
const OWN_REASONS = new Set(["Deployment image unavailable", "Deployment image metadata exceeds the read limit", "Serving image must have an immutable production digest", "Serving image config unavailable", "Serving source revision is unknown", "Production service catalog incomplete", "Production traffic is not ready", "Serving revision unavailable", "Serving revision is not ready", "Production services unavailable", "Production services exceed the read limit", "Serving revision exceeds the read limit"]);
|
|
18
23
|
export function probeReason(error: unknown): string {
|
|
19
24
|
const message = error instanceof Error ? error.message : "";
|
|
20
25
|
if (OWN_REASONS.has(message)) return message;
|
|
21
26
|
const command = (error as { cmd?: unknown; path?: unknown } | null)?.cmd ?? (error as { path?: unknown } | null)?.path;
|
|
22
27
|
if (typeof command === "string" && /^(gcloud|gh)\b/.test(command)) return `${command.split(" ")[0]} call failed`;
|
|
23
28
|
if (error instanceof SyntaxError) return "unreadable response";
|
|
24
|
-
if (error instanceof Error && error.name === "AbortError") return "
|
|
29
|
+
if (error instanceof Error && error.name === "AbortError") return "read timed out";
|
|
25
30
|
return "lookup failed";
|
|
26
31
|
}
|
|
27
32
|
|
|
@@ -35,7 +40,10 @@ export class Deployments {
|
|
|
35
40
|
private ancestry = new Map<string, Promise<boolean>>();
|
|
36
41
|
private token: { value: string; until: number } | null = null;
|
|
37
42
|
constructor(
|
|
38
|
-
/**
|
|
43
|
+
/**
|
|
44
|
+
* gcloud only, and only for the access token (cached TOKEN_MS): the registry and Cloud Run are read in process with
|
|
45
|
+
* it (cloud-run-reads-in-process). GitHub reads go through `api`, in process (worker-reads-github-in-process).
|
|
46
|
+
*/
|
|
39
47
|
private run: Run = async (command, args) => (await exec(command, args, { env: process.env, timeout: 25_000, maxBuffer: 4 * 1024 * 1024 })).stdout,
|
|
40
48
|
private request: typeof fetch = fetch,
|
|
41
49
|
private now = Date.now,
|
|
@@ -45,17 +53,35 @@ export class Deployments {
|
|
|
45
53
|
) {}
|
|
46
54
|
/** Whether `repo` has a deploy check on this machine. */
|
|
47
55
|
configured(repo: string): boolean { return !!this.configFor(repo); }
|
|
48
|
-
private async
|
|
49
|
-
if (!this.token || this.token.until <= this.now()) this.token = { value: (await this.run("gcloud", ["auth", "print-access-token"])).trim(), until: this.now() +
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
56
|
+
private async accessToken(): Promise<string> {
|
|
57
|
+
if (!this.token || this.token.until <= this.now()) this.token = { value: (await this.run("gcloud", ["auth", "print-access-token"])).trim(), until: this.now() + TOKEN_MS };
|
|
58
|
+
return this.token.value;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* One authorized JSON read (the registry and Cloud Run), each under READ_TIMEOUT_MS. A 401/403 drops the cached
|
|
62
|
+
* token and retries once with a fresh one; any other failure throws `failure`, and a body over `limit` throws
|
|
63
|
+
* `tooLarge`: each caller names what it read, with no transport detail.
|
|
64
|
+
*/
|
|
65
|
+
private async json(url: string, failure: string, o: { tooLarge: string; accept?: string; limit?: number }): Promise<Node> {
|
|
66
|
+
for (let attempt = 0; ; attempt++) {
|
|
67
|
+
const token = await this.accessToken();
|
|
68
|
+
const abort = new AbortController(); const timeout = setTimeout(() => abort.abort(), READ_TIMEOUT_MS);
|
|
69
|
+
let body: string;
|
|
70
|
+
try {
|
|
71
|
+
const response = await this.request(url, { headers: { Authorization: `Bearer ${token}`, ...(o.accept ? { Accept: o.accept } : {}) }, redirect: "error", signal: abort.signal });
|
|
72
|
+
if (response.status === 401 || response.status === 403) { this.token = null; if (attempt === 0) continue; }
|
|
73
|
+
if (!response.ok) throw new Error(failure);
|
|
74
|
+
body = await response.text();
|
|
75
|
+
} finally { clearTimeout(timeout); }
|
|
76
|
+
if (body.length > (o.limit ?? 1_000_000)) throw new Error(o.tooLarge);
|
|
77
|
+
return JSON.parse(body);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
/** Cloud Run's v1 (Knative) API: the global endpoint lists every region; a revision is read from its region's. */
|
|
81
|
+
private runUrl(region: string | null, path: string): string {
|
|
82
|
+
// FOLLOW_UP_CLOUD_RUN_API points harness runs (scripts/poll-cost.mjs) at a fake Cloud Run.
|
|
83
|
+
const fake = process.env.FOLLOW_UP_CLOUD_RUN_API?.replace(/\/$/, "");
|
|
84
|
+
return `${fake || (region ? `https://${region}-run.googleapis.com` : "https://run.googleapis.com")}/apis/serving.knative.dev/v1/${path}`;
|
|
59
85
|
}
|
|
60
86
|
private imageCommit(image: string, deploy: DeployConfig): Promise<string> {
|
|
61
87
|
const cached = this.images.get(image); if (cached) return cached;
|
|
@@ -64,9 +90,9 @@ export class Deployments {
|
|
|
64
90
|
if (!match) throw new Error("Serving image must have an immutable production digest");
|
|
65
91
|
// FOLLOW_UP_DEPLOY_REGISTRY points harness runs (scripts/poll-cost.mjs) at a fake registry.
|
|
66
92
|
const base = `${(process.env.FOLLOW_UP_DEPLOY_REGISTRY || `https://${deploy.registry}`).replace(/\/$/, "")}/v2/${match[1]}`;
|
|
67
|
-
const manifest = await this.json(`${base}/manifests/${match[2]}
|
|
93
|
+
const manifest = await this.json(`${base}/manifests/${match[2]}`, "Deployment image unavailable", { tooLarge: "Deployment image metadata exceeds the read limit", accept: IMAGE_ACCEPT });
|
|
68
94
|
if (!/^sha256:[a-f0-9]{64}$/.test(manifest.config?.digest)) throw new Error("Serving image config unavailable");
|
|
69
|
-
const config = (await this.json(`${base}/blobs/${manifest.config.digest}
|
|
95
|
+
const config = (await this.json(`${base}/blobs/${manifest.config.digest}`, "Deployment image unavailable", { tooLarge: "Deployment image metadata exceeds the read limit", accept: IMAGE_ACCEPT })).config;
|
|
70
96
|
const revision = config?.Labels?.["org.opencontainers.image.revision"];
|
|
71
97
|
const baked = (config?.Env ?? []).find((v: string) => (deploy.buildShaEnv && v.startsWith(`${deploy.buildShaEnv}=`)) || v.startsWith("GIT_SHA="))?.split("=")[1];
|
|
72
98
|
if (!sha.test(revision ?? baked ?? "") || (revision && baked && revision !== baked)) throw new Error("Serving source revision is unknown");
|
|
@@ -77,13 +103,14 @@ export class Deployments {
|
|
|
77
103
|
}
|
|
78
104
|
/**
|
|
79
105
|
* A Cloud Run revision is immutable: its image (so its commit) never changes. Once a revision has been read ready,
|
|
80
|
-
* its commit is reused, so a fleet read costs one
|
|
81
|
-
*
|
|
106
|
+
* its commit is reused, so a fleet read costs one services list instead of one read per serving revision as well
|
|
107
|
+
* (cpu-load REPORT.md §5: 6 gcloud calls a minute). Failures and unready revisions aren't cached.
|
|
82
108
|
*/
|
|
83
109
|
private revisionCommit(name: string, region: string, config: DeployConfig): Promise<string> {
|
|
84
110
|
const key = `${config.gcpProject}/${region}/${name}`; const cached = this.revisions.get(key); if (cached) return cached;
|
|
85
111
|
const work = (async () => {
|
|
86
|
-
|
|
112
|
+
if (!/^[a-z0-9-]+$/.test(region)) throw new Error("Serving revision unavailable");
|
|
113
|
+
const revision = await this.json(this.runUrl(region, `namespaces/${encodeURIComponent(config.gcpProject)}/revisions/${encodeURIComponent(name)}`), "Serving revision unavailable", { tooLarge: "Serving revision exceeds the read limit" });
|
|
87
114
|
if (!revision.status?.conditions?.some((c: Node) => c.type === "Ready" && c.status === "True")) throw new Error("Serving revision is not ready");
|
|
88
115
|
const image = revision.spec?.containers?.find((c: Node) => c.name === "app")?.image;
|
|
89
116
|
return this.imageCommit(image ?? "", config);
|
|
@@ -92,7 +119,15 @@ export class Deployments {
|
|
|
92
119
|
this.revisions.set(key, work); void work.catch(() => this.revisions.delete(key)); return work;
|
|
93
120
|
}
|
|
94
121
|
private async readFleet(config: DeployConfig): Promise<Fleet> {
|
|
95
|
-
|
|
122
|
+
// One list (paged by `continue`), filtered by the configured label on the server, as `gcloud run services list
|
|
123
|
+
// --filter` was. 2026-11-13 live: that list spawned gcloud ~0.8 times a minute, ~1 s CPU and ~97 MB each.
|
|
124
|
+
const services: Node[] = []; let next = "";
|
|
125
|
+
for (let page = 0; page < 20; page++) {
|
|
126
|
+
const list = await this.json(this.runUrl(null, `namespaces/${encodeURIComponent(config.gcpProject)}/services?labelSelector=${encodeURIComponent(config.serviceLabel)}${next ? `&continue=${encodeURIComponent(next)}` : ""}`), "Production services unavailable", { tooLarge: "Production services exceed the read limit", limit: 4 * 1024 * 1024 });
|
|
127
|
+
services.push(...(Array.isArray(list.items) ? list.items : []));
|
|
128
|
+
next = typeof list.metadata?.continue === "string" ? list.metadata.continue : "";
|
|
129
|
+
if (!next) break;
|
|
130
|
+
}
|
|
96
131
|
const named = (s: Node, role: string) => typeof s.metadata?.name === "string" && s.metadata.name.startsWith(`${config.servicePrefix}${role}-`);
|
|
97
132
|
if (!Array.isArray(services) || config.roles.some(role => !services.some(s => named(s, role)))) throw new Error("Production service catalog incomplete");
|
|
98
133
|
const targets = services.filter(s => config.roles.some(role => named(s, role)));
|
package/server/feeds.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { ListCache } from "./list-cache";
|
|
2
|
-
import type { State
|
|
2
|
+
import type { State } from "../shared/model";
|
|
3
|
+
import type { ListEntry } from "../shared/list";
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* Pushes instead of client polling (Paseo 0.16 subscriptions, plan item 6). A feed is one shared serve per topic: a
|
|
@@ -53,7 +54,7 @@ export class ValueFeed<E> {
|
|
|
53
54
|
}
|
|
54
55
|
}
|
|
55
56
|
|
|
56
|
-
export type WorkspacesEvent = { revision: number; full: boolean; workspaces:
|
|
57
|
+
export type WorkspacesEvent = { revision: number; full: boolean; workspaces: ListEntry[]; removed: string[]; error: string | null };
|
|
57
58
|
|
|
58
59
|
/**
|
|
59
60
|
* follow.list as a feed: each subscriber holds a revision, and a change sends it only the workspaces changed since,
|
package/server/list-cache.ts
CHANGED
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
import type { State, Workspace } from "../shared/model";
|
|
2
|
+
import { listEntry, type ListEntry } from "../shared/list";
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* Diffed answers for follow.list (1.3.0-beta.4). Clients send the revision they hold and get back only the
|
|
5
6
|
* workspaces that changed since then, plus the ids that left the list, instead of every tracked workspace's full
|
|
6
7
|
* state on every poll. Work is done once per saved-state change (the store hands out the same object until a
|
|
7
8
|
* mutation), not once per client or poll.
|
|
9
|
+
*
|
|
10
|
+
* Each workspace goes out in its list form (shared/list.ts, a-list-carries-only-what-lists-draw). The store keeps an
|
|
11
|
+
* unchanged workspace's saved object across mutations (a-mutation-copies-only-what-it-changes), so the list form and
|
|
12
|
+
* its JSON are computed once per changed workspace, not for every workspace on every change.
|
|
8
13
|
*/
|
|
9
14
|
export class ListCache {
|
|
10
15
|
private state: State | null = null;
|
|
@@ -15,36 +20,42 @@ export class ListCache {
|
|
|
15
20
|
private objects = new Map<string, Workspace>();
|
|
16
21
|
private changedAt = new Map<string, number>();
|
|
17
22
|
private removedAt = new Map<string, number>();
|
|
18
|
-
private current:
|
|
23
|
+
private current: ListEntry[] = [];
|
|
24
|
+
/** Each listed workspace's list form, as last projected from `objects`. */
|
|
25
|
+
private entries = new Map<string, ListEntry>();
|
|
19
26
|
/** The oldest revision a diff can be computed from; older clients get the full list. */
|
|
20
27
|
private floor = this.revision;
|
|
21
28
|
constructor(private select: (state: State) => Workspace[] = state => state.workspaces.filter(w => w.enable_tracking)) {}
|
|
22
29
|
private update(state: State): void {
|
|
23
30
|
if (state === this.state) return;
|
|
24
31
|
this.state = state;
|
|
25
|
-
const next =
|
|
32
|
+
const next: ListEntry[] = [];
|
|
26
33
|
const seen = new Set<string>();
|
|
27
34
|
let changed = false;
|
|
28
35
|
const revision = this.revision + 1;
|
|
29
|
-
for (const w of
|
|
36
|
+
for (const w of this.select(state)) {
|
|
30
37
|
seen.add(w.id);
|
|
31
38
|
// a-list-answer-serializes-only-what-changed: the store keeps an unchanged workspace's frozen object
|
|
32
|
-
// (a-mutation-copies-only-what-it-changes), so the same object is the same workspace and isn't
|
|
33
|
-
// 2026-11-13 (run W, live copy under live load): every state change stringified every tracked
|
|
34
|
-
// to find the one a turn touched, 23 MB of garbage every 5 minutes.
|
|
35
|
-
|
|
39
|
+
// (a-mutation-copies-only-what-it-changes), so the same object is the same workspace and isn't projected or
|
|
40
|
+
// serialised again. 2026-11-13 (run W, live copy under live load): every state change stringified every tracked
|
|
41
|
+
// workspace (1.4 MB) to find the one a turn touched, 23 MB of garbage every 5 minutes.
|
|
42
|
+
const held = this.entries.get(w.id);
|
|
43
|
+
if (held && this.objects.get(w.id) === w && Object.isFrozen(w)) { next.push(held); continue; }
|
|
36
44
|
this.objects.set(w.id, w);
|
|
37
|
-
const
|
|
45
|
+
const entry = listEntry(w);
|
|
46
|
+
const text = JSON.stringify(entry);
|
|
47
|
+
this.entries.set(w.id, entry);
|
|
48
|
+
next.push(entry);
|
|
38
49
|
if (this.json.get(w.id) !== text) { this.json.set(w.id, text); this.changedAt.set(w.id, revision); this.removedAt.delete(w.id); changed = true; }
|
|
39
50
|
}
|
|
40
|
-
for (const id of [...this.json.keys()]) if (!seen.has(id)) { this.json.delete(id); this.objects.delete(id); this.changedAt.delete(id); this.removedAt.set(id, revision); changed = true; }
|
|
51
|
+
for (const id of [...this.json.keys()]) if (!seen.has(id)) { this.json.delete(id); this.objects.delete(id); this.entries.delete(id); this.changedAt.delete(id); this.removedAt.set(id, revision); changed = true; }
|
|
41
52
|
// Removal records are kept for a while so slow clients still learn about them; past that they resync fully.
|
|
42
53
|
if (this.removedAt.size > 500) { const cut = [...this.removedAt.values()].sort((a, b) => a - b)[this.removedAt.size - 500]; for (const [id, at] of this.removedAt) if (at < cut) this.removedAt.delete(id); this.floor = cut; }
|
|
43
54
|
this.current = next;
|
|
44
55
|
if (changed) this.revision = revision;
|
|
45
56
|
}
|
|
46
57
|
/** Everything when `since` is absent, unknown or too old; otherwise only what changed after it. */
|
|
47
|
-
answer(state: State, since?: number): { revision: number; full: boolean; workspaces:
|
|
58
|
+
answer(state: State, since?: number): { revision: number; full: boolean; workspaces: ListEntry[]; removed: string[] } {
|
|
48
59
|
this.update(state);
|
|
49
60
|
if (since === undefined || since > this.revision || since < this.floor) return { revision: this.revision, full: true, workspaces: this.current, removed: [] };
|
|
50
61
|
return {
|
package/shared/activity.ts
CHANGED
package/shared/attention.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { batchView, FINISH_LINE, perSnapshot, stuckLine, unconfirmedRefs } from "./status";
|
|
2
|
-
import { blockedOnDeveloper, completionCheck, liveWorkingTask, statusKnown, summary, type
|
|
2
|
+
import { blockedOnDeveloper, completionCheck, liveWorkingTask, statusKnown, summary, type Task, type Status } from "./model";
|
|
3
|
+
import type { ListBatch as Batch, ListPr as Pr, ListWorkspace as Workspace } from "./list";
|
|
3
4
|
import { IDLE_REASON, NO_PROGRESS_CAP } from "./send-decision";
|
|
4
5
|
import { workingLine } from "./task-status";
|
|
5
6
|
import { followUpObligations, recoveryBatch } from "./follow-up";
|
|
@@ -17,8 +18,8 @@ export function prTone(pr: Pr): PrTone {
|
|
|
17
18
|
if (!s?.complete) return "unknown";
|
|
18
19
|
if (s.state === "MERGED") return "merged";
|
|
19
20
|
if (s.state === "CLOSED") return "closed";
|
|
20
|
-
if (s.conflict || s.failedChecks
|
|
21
|
-
if (s.threads
|
|
21
|
+
if (s.conflict || s.failedChecks?.length) return "danger";
|
|
22
|
+
if (s.threads?.length || s.reviewDecision === "CHANGES_REQUESTED" || s.otherFailedChecks?.length) return "warning";
|
|
22
23
|
if (s.draft) return "draft";
|
|
23
24
|
return s.reviewDecision === "APPROVED" ? "approved" : "pending";
|
|
24
25
|
}
|
|
@@ -26,7 +27,7 @@ export function prTone(pr: Pr): PrTone {
|
|
|
26
27
|
/** PRs that still need repairs from the agent: conflicts, required checks or review feedback. */
|
|
27
28
|
export function needsRepair(pr: Pr): boolean {
|
|
28
29
|
const s = pr.snapshot;
|
|
29
|
-
return !pr.error && !!s?.complete && s.state === "OPEN" && !s.draft && (s.conflict || s.failedChecks
|
|
30
|
+
return !pr.error && !!s?.complete && s.state === "OPEN" && !s.draft && (s.conflict || !!s.failedChecks?.length || !!s.threads?.length || s.reviewDecision === "CHANGES_REQUESTED");
|
|
30
31
|
}
|
|
31
32
|
|
|
32
33
|
/**
|
|
@@ -84,7 +85,7 @@ export function mergeReady(pr: Pr, w: Pick<Workspace, "prActions">, now = Date.n
|
|
|
84
85
|
const recentlySubmitted = w.prActions.some(a => a.kind === "merge" && a.state === "submitted" && a.heads[pr.key] === s?.head && now - Date.parse(a.createdAt) < 30_000);
|
|
85
86
|
// GitHub mode: the same verdict Needs you and the merge plan use, so the sheet never offers Merge on a draft, conflict or red check.
|
|
86
87
|
if (isGithubFlow(s)) return mergeBlockers(pr).length === 0 && !recentlySubmitted;
|
|
87
|
-
return !pr.error && !!s?.complete && s.state === "OPEN" && s.reviewDecision === "APPROVED" && !s.draft && !s.conflict && !s.failedChecks
|
|
88
|
+
return !pr.error && !!s?.complete && s.state === "OPEN" && s.reviewDecision === "APPROVED" && !s.draft && !s.conflict && !s.failedChecks?.length && !s.checksPending && !queued && !recentlySubmitted;
|
|
88
89
|
}
|
|
89
90
|
export const mergeQueued = (pr: Pr) => isGithubFlow(pr.snapshot) ? !!pr.snapshot?.inMergeQueue : QUEUED.includes(pr.snapshot?.graphiteMergeStatus ?? "");
|
|
90
91
|
/** Whether the workflow that ships this PR says it can merge now: Graphite's readiness, or GitHub's own verdict. */
|
|
@@ -242,10 +243,10 @@ function holdReason(p: Pr): string {
|
|
|
242
243
|
const s = p.snapshot;
|
|
243
244
|
if (!s?.complete || p.error) return "status unknown";
|
|
244
245
|
if (s.conflict) return "conflicts";
|
|
245
|
-
if (s.failedChecks
|
|
246
|
+
if (s.failedChecks?.length) return "checks failing";
|
|
246
247
|
if (s.checksPending) return "checks running";
|
|
247
248
|
if (s.draft) return "a draft";
|
|
248
|
-
if (s.threads
|
|
249
|
+
if (s.threads?.length) return "open threads";
|
|
249
250
|
if (s.reviewDecision !== "APPROVED") return "not approved yet";
|
|
250
251
|
return isGithubFlow(s) ? "GitHub can't merge it yet" : "Graphite can't merge it yet";
|
|
251
252
|
}
|
package/shared/brief.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { prLink } from "./presentation";
|
|
2
2
|
import { z } from "zod";
|
|
3
|
-
import type { Pr, Workspace } from "./
|
|
3
|
+
import type { ListPr as Pr, ListWorkspace as Workspace } from "./list";
|
|
4
4
|
import { agentMergesKey } from "./pr-workflow";
|
|
5
5
|
import { reviewersAsk } from "./reviewers";
|
|
6
6
|
import { ANSWER_PREFIX, OTHER_LABEL, answerLabel, answerTitle, isOther, type Question } from "./questions";
|
|
@@ -348,15 +348,15 @@ export function prStates(w: Pick<Workspace, "prs"> | null | undefined): PrState[
|
|
|
348
348
|
function prFactsOf(pr: Pr, event: string | null): PrState {
|
|
349
349
|
const s = pr.snapshot!;
|
|
350
350
|
const facts: BriefFact[] = [];
|
|
351
|
-
if (s.failedChecks
|
|
351
|
+
if (s.failedChecks?.length) facts.push({ icon: "CircleX", label: `Checks failed · ${s.failedChecks.slice(0, 2).join(", ")}`, tone: "bad" });
|
|
352
352
|
else if (s.checksPending) facts.push({ icon: "Clock", label: "Checks running", tone: "muted" });
|
|
353
353
|
else facts.push({ icon: "CircleCheck", label: "Required checks pass", tone: "ok" });
|
|
354
354
|
const approved = s.reviewDecision === "APPROVED";
|
|
355
355
|
facts.push(s.conflict ? { icon: "TriangleAlert", label: "Conflicts with its base", tone: "warn" }
|
|
356
|
-
: s.threads
|
|
356
|
+
: s.threads?.length ? { icon: "MessageSquare", label: `${s.threads?.length} open thread${s.threads?.length === 1 ? "" : "s"}`, tone: "warn" }
|
|
357
357
|
: { icon: approved ? "UserCheck" : "User", label: approved ? "Approved · no conflicts" : "Review required", tone: approved ? "ok" : "muted" });
|
|
358
358
|
if (s.draft) facts.push({ icon: "FilePen", label: "Draft", tone: "muted" });
|
|
359
|
-
const mergeable = !s.draft && !s.conflict && !s.failedChecks
|
|
359
|
+
const mergeable = !s.draft && !s.conflict && !s.failedChecks?.length && !s.checksPending && approved && !s.threads?.length;
|
|
360
360
|
return { key: pr.key, number: pr.number, url: prLink(pr).url, title: s.title, facts, mergeable, event };
|
|
361
361
|
}
|
|
362
362
|
|
|
@@ -557,7 +557,7 @@ export const undeliveredReason = (error: string | null | undefined): string => {
|
|
|
557
557
|
* - every question it points at is answered: answered, even if the stored brief hasn't caught up.
|
|
558
558
|
* Decisions backed by a stored question show that question's live, full text and its recorded answer.
|
|
559
559
|
*/
|
|
560
|
-
export function shownBrief(row: Brief, live: { brief: Brief | null } | undefined, questions: readonly Question[] = []): { brief: Brief; actionable: boolean } {
|
|
560
|
+
export function shownBrief(row: Brief, live: { brief: Brief | null } | undefined, questions: readonly Pick<Question, "id" | "question" | "options" | "answer">[] = []): { brief: Brief; actionable: boolean } {
|
|
561
561
|
const mine = live?.brief?.id === row.id ? live.brief! : row;
|
|
562
562
|
const byId = new Map(questions.map(q => [q.id, q]));
|
|
563
563
|
const decisions = mine.decisions.map(d => {
|
package/shared/contracts.ts
CHANGED
|
@@ -13,6 +13,7 @@ import { z } from "zod";
|
|
|
13
13
|
import { inboxRowSchema } from "./inbox";
|
|
14
14
|
import { briefSchema } from "./brief";
|
|
15
15
|
import { idSchema, textSchema, workspaceSchema } from "./model";
|
|
16
|
+
import { listEntrySchema } from "./list";
|
|
16
17
|
import { communicationSchema } from "./communication";
|
|
17
18
|
import { taskTriggerSchema } from "./task-trigger";
|
|
18
19
|
import { QUESTION_MODES, questionSchema } from "./questions";
|
|
@@ -32,7 +33,7 @@ const agentCommunicationSchema = z.strictObject({
|
|
|
32
33
|
* Tracked workspaces. 1.3.0-beta.4: pass the `revision` you hold as `since` to get only what changed (`full` false,
|
|
33
34
|
* plus `removed` ids). Without it, or when it's too old, the answer is the full list.
|
|
34
35
|
*/
|
|
35
|
-
export const listRpc = defineRpc({ name: "follow.list", input: z.object({ since: z.number().optional() }), output: z.object({ workspaces: z.array(
|
|
36
|
+
export const listRpc = defineRpc({ name: "follow.list", input: z.object({ since: z.number().optional() }), output: z.object({ workspaces: z.array(listEntrySchema), error: z.string().nullable(), revision: z.number().optional(), full: z.boolean().optional(), removed: z.array(z.string()).optional() }) });
|
|
36
37
|
export const getRpc = defineRpc({ name: "follow.get", input: z.object({ workspaceId: idSchema }), output: z.object({ workspace: workspaceSchema.nullable(), error: z.string().nullable() }) });
|
|
37
38
|
/** `prWorkflow` (1.4.0-beta.14): how this workspace ships PRs (graphite | github) and its review-fix command (null: built-in steps). */
|
|
38
39
|
export const agentStatusRpc = defineRpc({ name: "follow.agent-status", input: z.strictObject({ agentId: idSchema, detail: z.enum(["summary", "full"]).optional() }), output: workspaceSchema.extend({ prWorkflow: z.object({ mode: z.enum(["graphite", "github"]), reviewFix: z.string().nullable() }).optional(), /** The next message: recipient, tasks, exact text, and when and why it goes (Preview's agent form). */ nextMessageInfo: z.object({ to: z.string(), tasks: z.array(z.string()), text: z.string(), reason: z.string(), eta: z.string().nullable() }).nullable().optional(),
|
|
@@ -281,7 +282,7 @@ export const createdItemsRpc = defineRpc({ name: "follow.created-items",
|
|
|
281
282
|
*/
|
|
282
283
|
const subscription = <I extends z.ZodType, E extends z.ZodType>(name: string, input: I, event: E): PluginSubscriptionContract<I, E> => ({ name, input, event });
|
|
283
284
|
export const workspacesFeed = subscription("follow.workspaces-feed", z.object({ since: z.number().optional() }),
|
|
284
|
-
z.object({ revision: z.number(), full: z.boolean(), workspaces: z.array(
|
|
285
|
+
z.object({ revision: z.number(), full: z.boolean(), workspaces: z.array(listEntrySchema), removed: z.array(z.string()), error: z.string().nullable() }));
|
|
285
286
|
export const inboxFeed = subscription("follow.inbox-feed", z.object({}), inboxListRpc.output);
|
|
286
287
|
/** Home's extras: priorities, the ranker, the Overseer and the usage meters (without the worker's live resources). */
|
|
287
288
|
export const homeFeed = subscription("follow.home-feed", z.object({}), z.object({
|
package/shared/follow-up.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Obligation, Pr, Workspace, Batch } from "./
|
|
1
|
+
import type { ListObligation as Obligation, ListPr as Pr, ListWorkspace as Workspace, ListBatch as Batch } from "./list";
|
|
2
2
|
|
|
3
3
|
export const recoveryBatch = (batch: Pick<Batch, "tasks">): boolean => batch.tasks.length > 0 && batch.tasks.every(t => t.kind === "inventory");
|
|
4
4
|
|
|
@@ -7,7 +7,7 @@ export function lifecycleOnly(o: Pick<Obligation, "title" | "afterPrs" | "catego
|
|
|
7
7
|
if (!o.afterPrs.length || /\b(verify|confirm|check|test|run|decide|decision|monitor|resolve|reconcile)\b/i.test(o.title)) return false;
|
|
8
8
|
return /^(merge|approve|publish|land|deploy)\b/i.test(o.title) || /^#\d+.*\bneeds?\b.*\b(approval|merge)\b/i.test(o.title);
|
|
9
9
|
}
|
|
10
|
-
export const followUpObligations = (w:
|
|
10
|
+
export const followUpObligations = <W extends Workspace>(w: W): W["obligations"] => w.obligations.filter(o => !lifecycleOnly(o));
|
|
11
11
|
/**
|
|
12
12
|
* Where a merged PR stands against its deploy target.
|
|
13
13
|
* - deployed: Follow-up saw its merge commit serving. Latched by deploymentAnchor: a probe error or an old
|
package/shared/home.ts
CHANGED
|
@@ -4,7 +4,8 @@ import { activity, type Activity } from "./activity";
|
|
|
4
4
|
import { followUpObligations, recoveryBatch } from "./follow-up";
|
|
5
5
|
import { sayNew, flagHeadline, HEADLINE_ICON, HEADLINE_TONE, HEADLINE_WORD, workspaceHeadline, withoutBriefQuestions, type Headline, type HeadlineKey, type HeadlineTone } from "./headline";
|
|
6
6
|
import { rowTitle, sectionOf, type InboxRow } from "./inbox";
|
|
7
|
-
import { settled, summary
|
|
7
|
+
import { settled, summary } from "./model";
|
|
8
|
+
import type { ListPr as Pr, ListWorkspace as Workspace } from "./list";
|
|
8
9
|
import { isOpen as questionOpen } from "./questions";
|
|
9
10
|
import { taskSchedule } from "./task-trigger";
|
|
10
11
|
import { freshPriorities, priorityRow, type Priority, type PrioritySourceKind } from "./priorities";
|
|
@@ -114,10 +115,10 @@ export function prChip(w: Workspace | undefined): PrChip | null {
|
|
|
114
115
|
const checks = !s?.complete ? null
|
|
115
116
|
: s.state === "MERGED" ? { text: "merged", tone: "merged" as const }
|
|
116
117
|
: s.state === "CLOSED" ? { text: "closed", tone: "muted" as const }
|
|
117
|
-
: s.failedChecks
|
|
118
|
+
: s.failedChecks?.length ? { text: `✗ ${s.failedChecks?.length}`, tone: "danger" as const }
|
|
118
119
|
: s.checksPending ? { text: "running", tone: "muted" as const }
|
|
119
120
|
: s.draft ? { text: "draft", tone: "muted" as const }
|
|
120
|
-
: s.threads
|
|
121
|
+
: s.threads?.length ? { text: plural(s.threads?.length, "thread"), tone: "warning" as const }
|
|
121
122
|
: { text: "✓", tone: "success" as const };
|
|
122
123
|
return { label: `#${pr.number}${more > 0 ? `+${more}` : ""}`, tone: prTone(pr), checks, url: s?.url ?? null };
|
|
123
124
|
}
|
package/shared/list.ts
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { batchSchema, deploymentSchema, obligationSchema, prObjectSchema, snapshotSchema, workspaceSchema, type Workspace } from "./model";
|
|
3
|
+
import { isOpen, questionSchema } from "./questions";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* What follow.list and the workspaces feed carry: each followed workspace as the list views draw it (Home, the pill,
|
|
7
|
+
* the sidebar count, header dots, search), never its detail. Invariant a-list-carries-only-what-lists-draw.
|
|
8
|
+
*
|
|
9
|
+
* 2026-11-13 (live 2.0.1-beta.4, 139 followed workspaces): a full follow.list answer was 1.41 MB, and a burst of them
|
|
10
|
+
* stepped the worker's RSS 204 → 236 MB. Most of it was detail only the panel, the PR sheet and agent tools read:
|
|
11
|
+
* deployment evidence, inventory, task evidence, question background, settled batch results, and archived
|
|
12
|
+
* workspaces in full although search only reads their title and PRs. The detail stays one follow.get away
|
|
13
|
+
* (client/workspace-data.ts useWorkspace), and agent tools read the stored workspace on the worker.
|
|
14
|
+
*
|
|
15
|
+
* Each schema below is the stored one minus named fields, so a new stored field reaches the lists by default and
|
|
16
|
+
* the budget test (tests/list-reply-budget.test.ts) says when the list outgrows LIST_REPLY_BUDGET_KB. The types
|
|
17
|
+
* are the enforcement: a list view takes a ListWorkspace, so reading a dropped field there doesn't compile.
|
|
18
|
+
*/
|
|
19
|
+
const DEPLOYMENT_DETAIL = { evidence: true, commits: true } as const;
|
|
20
|
+
// repoMerge stays: Home's Merge button reads it to say "Add to merge queue" (shared/merge-click.ts mergeScope).
|
|
21
|
+
const SNAPSHOT_DETAIL = { base: true, trunk: true, headBranch: true } as const;
|
|
22
|
+
const PR_DETAIL = { discoveredFromSubmission: true } as const;
|
|
23
|
+
const OBLIGATION_DETAIL = { evidence: true, previousTitles: true } as const;
|
|
24
|
+
const BATCH_DETAIL = { contextPath: true, recoveryHandoffs: true, acknowledgmentError: true } as const;
|
|
25
|
+
const QUESTION_DETAIL = { background: true, links: true } as const;
|
|
26
|
+
const WORKSPACE_DETAIL = { inventory: true, excludedStacks: true, nextMessage: true } as const;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* What only an open PR's line reads. A merged PR is terminal: its list form keeps identity, title, url, when it merged
|
|
30
|
+
* and its deploy state (stack bars, "N merged below", deploy waits, search), never its checks, threads or reviewers.
|
|
31
|
+
* Optional in the list type, so a list view that reads one must handle a merged PR without it.
|
|
32
|
+
*/
|
|
33
|
+
const OPEN_ONLY = { head: true, draft: true, graphiteMergeStatus: true, conflict: true, reviewDecision: true, reviewers: true, mergeWhenReady: true, threads: true, failedChecks: true, otherFailedChecks: true, checksPending: true, checksRunning: true, mergeStateStatus: true, inMergeQueue: true } as const;
|
|
34
|
+
export const listSnapshotSchema = snapshotSchema.omit(SNAPSHOT_DETAIL).partial(OPEN_ONLY).extend({
|
|
35
|
+
deployment: deploymentSchema.omit(DEPLOYMENT_DETAIL).nullable().optional(),
|
|
36
|
+
// Defaulted in the stored schema; a merged PR's list form leaves them out, so parsing mustn't put them back.
|
|
37
|
+
graphiteMergeStatus: z.string().nullable().optional(), mergeWhenReady: z.enum(["on", "off", "unknown"]).optional(),
|
|
38
|
+
});
|
|
39
|
+
export const listPrSchema = prObjectSchema.omit(PR_DETAIL).extend({ snapshot: listSnapshotSchema.nullable() });
|
|
40
|
+
export const listBatchSchema = batchSchema.omit(BATCH_DETAIL).extend({});
|
|
41
|
+
// An open question keeps its background and links: Needs you shows it inline (client/questions.tsx QuestionBody).
|
|
42
|
+
export const listQuestionSchema = questionSchema.omit(QUESTION_DETAIL).extend({ background: questionSchema.shape.background.unwrap().optional(), links: questionSchema.shape.links.unwrap().optional() });
|
|
43
|
+
export const listWorkspaceSchema = workspaceSchema.omit(WORKSPACE_DETAIL).extend({
|
|
44
|
+
// A task's evidence goes out only while it's blocked: the list line reads "Blocked · waits for Q1" from it (shared/task-status.ts blockedLine).
|
|
45
|
+
prs: z.array(listPrSchema), obligations: z.array(obligationSchema.omit(OBLIGATION_DETAIL).extend({ evidence: obligationSchema.shape.evidence.optional() })), batches: z.array(listBatchSchema),
|
|
46
|
+
questions: z.array(listQuestionSchema).default([]),
|
|
47
|
+
});
|
|
48
|
+
/** An archived workspace, only for search ("Archived" at the bottom of results): its name and its PRs' numbers, titles and stacks. */
|
|
49
|
+
export const archivedListWorkspaceSchema = z.object({
|
|
50
|
+
id: workspaceSchema.shape.id, title: workspaceSchema.shape.title, updatedAt: z.string(), archived: z.literal(true), enable_tracking: z.boolean(),
|
|
51
|
+
prs: z.array(z.object({ key: z.string(), number: z.number(), stack: z.string(), snapshot: z.object({ title: z.string() }).nullable() })),
|
|
52
|
+
});
|
|
53
|
+
export const listEntrySchema = z.union([listWorkspaceSchema, archivedListWorkspaceSchema]);
|
|
54
|
+
|
|
55
|
+
export type ListWorkspace = z.infer<typeof listWorkspaceSchema>;
|
|
56
|
+
export type ArchivedListWorkspace = z.infer<typeof archivedListWorkspaceSchema>;
|
|
57
|
+
export type ListEntry = ListWorkspace | ArchivedListWorkspace;
|
|
58
|
+
export const isArchivedEntry = (w: ListEntry): w is ArchivedListWorkspace => w.archived;
|
|
59
|
+
|
|
60
|
+
const drop = <T extends object, K extends string>(value: T, keys: Readonly<Record<K, true>>): Omit<T, K> => {
|
|
61
|
+
const out = { ...value } as Record<string, unknown>;
|
|
62
|
+
for (const k of Object.keys(keys)) delete out[k];
|
|
63
|
+
return out as Omit<T, K>;
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
/** The list form of one stored workspace. Pure; ListCache keeps one per saved workspace object, so an unchanged workspace isn't projected again. */
|
|
67
|
+
export function listEntry(w: Workspace): ListEntry {
|
|
68
|
+
if (w.archived) return { id: w.id, title: w.title, updatedAt: w.updatedAt, archived: true, enable_tracking: w.enable_tracking,
|
|
69
|
+
prs: w.prs.map(p => ({ key: p.key, number: p.number, stack: p.stack, snapshot: p.snapshot ? { title: p.snapshot.title } : null })) };
|
|
70
|
+
return {
|
|
71
|
+
...drop(w, WORKSPACE_DETAIL),
|
|
72
|
+
prs: w.prs.map(p => ({ ...drop(p, PR_DETAIL), snapshot: p.snapshot && {
|
|
73
|
+
...drop(p.snapshot.state === "MERGED" && p.snapshot.complete ? drop(p.snapshot, OPEN_ONLY) : p.snapshot, SNAPSHOT_DETAIL),
|
|
74
|
+
...(p.snapshot.deployment !== undefined ? { deployment: p.snapshot.deployment && drop(p.snapshot.deployment, DEPLOYMENT_DETAIL) } : {}),
|
|
75
|
+
} })),
|
|
76
|
+
obligations: w.obligations.map(o => o.status === "blocked" ? { ...drop(o, OBLIGATION_DETAIL), evidence: o.evidence } : drop(o, OBLIGATION_DETAIL)),
|
|
77
|
+
batches: w.batches.map(b => drop(b, BATCH_DETAIL)),
|
|
78
|
+
questions: w.questions.map(q => isOpen(q) ? q : drop(q, QUESTION_DETAIL)),
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export type ListPr = ListWorkspace["prs"][number];
|
|
83
|
+
export type ListSnapshot = NonNullable<ListPr["snapshot"]>;
|
|
84
|
+
export type ListObligation = ListWorkspace["obligations"][number];
|
|
85
|
+
export type ListBatch = ListWorkspace["batches"][number];
|
|
86
|
+
export type ListQuestion = ListWorkspace["questions"][number];
|
package/shared/merge-click.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { downstack, isGithubFlow, type ActionPlan, type MergeStage } from "./pr-actions";
|
|
2
|
-
import type { Pr, Workspace } from "./
|
|
2
|
+
import type { ListPr as Pr, ListWorkspace as Workspace } from "./list";
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* a-click-on-merge-merges (2026-11-13): Merge on a Needs-you row opened the PR sheet, which ran a read-only check and
|
package/shared/model.ts
CHANGED
|
@@ -5,6 +5,7 @@ import { communicationSchema, replyRecorded } from "./communication";
|
|
|
5
5
|
import { taskTriggerSchema } from "./task-trigger";
|
|
6
6
|
import { isOpen as questionOpen, questionSchema } from "./questions";
|
|
7
7
|
import { artifactSchema, specSchema } from "./spec";
|
|
8
|
+
import type { ListPr, ListWorkspace } from "./list";
|
|
8
9
|
|
|
9
10
|
/** Why a main-agent turn ended canceled (shared/status.ts cancelCause). */
|
|
10
11
|
export const CANCEL_CAUSES = ["stop", "replaced", "compaction", "reload", "closed"] as const;
|
|
@@ -41,7 +42,7 @@ export const snapshotSchema = z.object({
|
|
|
41
42
|
/** What the repository allows, read with the PR (no extra request): merge methods, auto-merge and a merge queue. */
|
|
42
43
|
repoMerge: z.object({ methods: z.array(z.enum(["squash", "merge", "rebase"])), preferred: z.enum(["squash", "merge", "rebase"]).nullable(), autoMerge: z.boolean(), mergeQueue: z.boolean() }).optional(),
|
|
43
44
|
});
|
|
44
|
-
const prObjectSchema = z.object({
|
|
45
|
+
export const prObjectSchema = z.object({
|
|
45
46
|
key: idSchema, repo: z.string().regex(/^[\w.-]+\/[\w.-]+$/), number: z.number().int().positive(),
|
|
46
47
|
stack: textSchema, parent: idSchema.nullable(), disposition: z.string().nullable(),
|
|
47
48
|
snapshot: snapshotSchema.nullable(), error: z.string().nullable(),
|
|
@@ -186,7 +187,7 @@ export type Batch = z.infer<typeof batchSchema>;
|
|
|
186
187
|
export type Workspace = z.infer<typeof workspaceSchema>;
|
|
187
188
|
export type State = z.infer<typeof stateSchema>;
|
|
188
189
|
|
|
189
|
-
export function settled(pr:
|
|
190
|
+
export function settled(pr: ListPr): boolean {
|
|
190
191
|
return pr.snapshot?.state === "MERGED" || (pr.snapshot?.state === "CLOSED" && !!pr.disposition);
|
|
191
192
|
}
|
|
192
193
|
/**
|
|
@@ -202,7 +203,7 @@ export type Blocker = { text: string; owner: BlockerOwner; contrary?: true };
|
|
|
202
203
|
export type CompletionGate = { blockers: Blocker[]; unconfirmed: string[] };
|
|
203
204
|
/** A completion check is the nudge to declare Done; it never blocks Done itself. */
|
|
204
205
|
export const completionCheck = (b: Pick<Batch, "tasks">): boolean => b.tasks.length > 0 && b.tasks.every(t => t.kind === "completion");
|
|
205
|
-
export function completionGate(w:
|
|
206
|
+
export function completionGate(w: ListWorkspace, now = Date.now()): CompletionGate {
|
|
206
207
|
const blockers: Blocker[] = [];
|
|
207
208
|
const unconfirmed: string[] = [];
|
|
208
209
|
const add = (owner: BlockerOwner, text: string, contrary?: true) => blockers.push(contrary ? { owner, text, contrary } : { owner, text });
|
|
@@ -233,19 +234,19 @@ export function completionGate(w: Workspace, now = Date.now()): CompletionGate {
|
|
|
233
234
|
if (w.runtimeReason) add("wait", w.runtimeReason);
|
|
234
235
|
return { blockers, unconfirmed };
|
|
235
236
|
}
|
|
236
|
-
export function completionBlockers(w:
|
|
237
|
+
export function completionBlockers(w: ListWorkspace, now = Date.now()): string[] {
|
|
237
238
|
return completionGate(w, now).blockers.map(b => b.text);
|
|
238
239
|
}
|
|
239
240
|
/** Only new work or contrary evidence takes a Done back; waiting and observation gaps never do. */
|
|
240
|
-
export function revokesDone(w:
|
|
241
|
+
export function revokesDone(w: ListWorkspace, now = Date.now()): boolean {
|
|
241
242
|
return completionGate(w, now).blockers.some(b => b.owner !== "wait" || b.contrary);
|
|
242
243
|
}
|
|
243
244
|
export type Status = "active" | "handling" | "waiting" | "needs-you" | "done";
|
|
244
245
|
/** The first working task whose recorded agent is running right now (invariant `a-task-only-says-working-when-its-agent-is`). */
|
|
245
|
-
export function liveWorkingTask(w:
|
|
246
|
+
export function liveWorkingTask<W extends ListWorkspace>(w: W): W["obligations"][number] | undefined {
|
|
246
247
|
return followUpObligations(w).find(o => o.status === "working" && !!o.workingAgentId && w.taskAgents?.[o.workingAgentId]?.state === "working");
|
|
247
248
|
}
|
|
248
|
-
export function summary(w:
|
|
249
|
+
export function summary(w: ListWorkspace, now = Date.now()): { status: Status; label: string; reason: string } {
|
|
249
250
|
const obligations = followUpObligations(w);
|
|
250
251
|
if (w.hold) return { status: "needs-you", label: "Needs you", reason: w.hold };
|
|
251
252
|
const blocked = w.batches.find(b => !recoveryBatch(b) && ["blocked", "uncertain"].includes(b.state) && !(w.completion && completionCheck(b)));
|
package/shared/overseer.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { parseAnswersMessage } from "./questions";
|
|
|
3
3
|
import { z } from "zod";
|
|
4
4
|
import { HOME_GROUPS, buildHome, type HomeGroupId, type PaseoWorkspaceLite, type Workstream } from "./home";
|
|
5
5
|
import type { InboxRow } from "./inbox";
|
|
6
|
-
import type { Workspace } from "./
|
|
6
|
+
import type { ListWorkspace as Workspace } from "./list";
|
|
7
7
|
import type { Priority } from "./priorities";
|
|
8
8
|
|
|
9
9
|
/**
|
|
@@ -84,7 +84,7 @@ export const linearKeys = (...texts: (string | null | undefined)[]): string[] =>
|
|
|
84
84
|
const prChecks = (p: Workspace["prs"][number]): WorkstreamPr["checks"] => {
|
|
85
85
|
const s = p.snapshot;
|
|
86
86
|
if (!s?.complete) return "unknown";
|
|
87
|
-
return s.failedChecks
|
|
87
|
+
return s.failedChecks?.length ? "failed" : s.checksPending ? "pending" : "passed";
|
|
88
88
|
};
|
|
89
89
|
|
|
90
90
|
/**
|
|
@@ -129,7 +129,7 @@ function resting(r: WorkstreamRow, w: Workspace | undefined, now: number, window
|
|
|
129
129
|
}
|
|
130
130
|
|
|
131
131
|
function rowOf(s: Workstream, w: Workspace | undefined, p: PaseoWorkspaceLite | undefined, status: string | null): WorkstreamRow {
|
|
132
|
-
const prs = (w?.prs ?? []).map(pr => ({ key: pr.key, number: pr.number, state: pr.snapshot?.state ?? "unknown", checks: prChecks(pr), threads: pr.snapshot?.threads
|
|
132
|
+
const prs = (w?.prs ?? []).map(pr => ({ key: pr.key, number: pr.number, state: pr.snapshot?.state ?? "unknown", checks: prChecks(pr), threads: pr.snapshot?.threads?.length ?? 0, url: pr.snapshot?.url ?? null }));
|
|
133
133
|
const needs = s.group === "needs";
|
|
134
134
|
return {
|
|
135
135
|
workspaceId: s.workspaceId!, key: s.key, title: s.title, project: s.project, branch: p?.branch ?? null, group: s.group,
|
package/shared/poll.ts
CHANGED