send-to-paseo 2.2.0 → 2.4.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/paseo-plugin.json CHANGED
@@ -1,5 +1,17 @@
1
1
  {
2
2
  "id": "send-to-paseo",
3
+ "name": "Send to Paseo",
4
+ "icon": "assets/icon.png",
5
+ "description": "Send work from a GitHub or Graphite pull request to the right Paseo workspace and agent, then see in the agent's chat which PR it came from and why it landed there.",
6
+ "media": [
7
+ "docs/media/send-to-paseo-hero-dark.png",
8
+ "docs/media/send-to-paseo-card-dark.png",
9
+ "docs/media/send-to-paseo-overview-dark.png",
10
+ "docs/media/send-to-paseo-setup-dark.png",
11
+ "docs/media/send-to-paseo-mobile.png",
12
+ "docs/media/send-to-paseo-overview-light.png",
13
+ "docs/media/send-to-paseo-card-light.png"
14
+ ],
3
15
  "requirements": {
4
16
  "paseo": ">=0.14.0"
5
17
  }
package/server/bridge.ts CHANGED
@@ -581,7 +581,7 @@ async function onRequest(req: IncomingMessage, res: ServerResponse): Promise<voi
581
581
 
582
582
  function describeListenError(error: NodeJS.ErrnoException, port: number): string {
583
583
  if (error.code === "EADDRINUSE") {
584
- return `Port ${port} is already in use, so the Send to Paseo bridge did not start. Pick another port in Paseo -> Send to Paseo.`;
584
+ return `Port ${port} is already in use, so the Send to Paseo bridge did not start. Pick another port under Connection details on the Send to Paseo screen.`;
585
585
  }
586
586
  if (error.code === "EACCES") {
587
587
  return `Port ${port} needs elevated privileges, so the Send to Paseo bridge did not start. Pick a port above 1024.`;
package/server/daemon.ts CHANGED
@@ -137,7 +137,7 @@ async function resolvePassword(): Promise<string | undefined> {
137
137
  }
138
138
 
139
139
  /** Optional companion RPCs always target this daemon, never a browser-selected host. */
140
- export async function callFollowUp(method: "follow.pr-owner" | "follow.browser-exchange", input: unknown): Promise<unknown> {
140
+ export async function callFollowUp(method: "follow.pr-owner" | "follow.pr-workspaces" | "follow.browser-exchange", input: unknown): Promise<unknown> {
141
141
  const load = typeof require === "function" ? require : createRequire(join(process.cwd(), "noop.cjs"));
142
142
  const { DaemonClient } = load(["@getpaseo", "client", "internal", "daemon-client"].join("/")) as {
143
143
  DaemonClient: new (options: Record<string, unknown>) => {
@@ -1,6 +1,7 @@
1
1
  import { z } from "zod";
2
2
  import { callFollowUp } from "./daemon";
3
3
  import type { ListedAgent } from "./main-agent";
4
+ import { buildAgentDeepLink, buildAgentWebLink, type FollowUpView } from "../shared/contracts";
4
5
 
5
6
  const ownerReply = z.object({ owner: z.object({ workspaceId: z.string().min(1).max(200), agentId: z.string().min(1).max(200) }).nullable() });
6
7
  export type PrOwner = NonNullable<z.infer<typeof ownerReply>["owner"]>;
@@ -13,3 +14,28 @@ export function registeredAgent(agents: readonly ListedAgent[], owner: PrOwner |
13
14
  if (!owner || owner.workspaceId !== workspaceId) return null;
14
15
  return agents.find(a => a.id === owner.agentId && a.workspaceId === workspaceId && a.archivedAt == null) ?? null;
15
16
  }
17
+
18
+ const text = (max: number) => z.string().max(max);
19
+ const workspacesReply = z.object({
20
+ tracked: z.boolean(), more: z.number().int().nonnegative().max(10_000),
21
+ workspaces: z.array(z.object({ workspaceId: text(200).min(1), agentId: text(200).min(1), title: text(200), agentStatus: text(40), group: text(20), state: text(200) })).max(3),
22
+ });
23
+ export type PrWorkspaces = Omit<z.infer<typeof workspacesReply>, "tracked">;
24
+ /**
25
+ * Follow-up's owners of a PR, or null when there is nothing to show: Follow-up absent, older than this RPC,
26
+ * broken, or the repository outside the scope it tracks (and therefore advertises to the browser).
27
+ */
28
+ export async function lookupPrWorkspaces(owner: string, repo: string, number: number): Promise<PrWorkspaces | null> {
29
+ try {
30
+ const reply = workspacesReply.parse(await callFollowUp("follow.pr-workspaces", { repo: `${owner}/${repo}`, number }));
31
+ return reply.tracked ? { workspaces: reply.workspaces, more: reply.more } : null;
32
+ } catch { return null; }
33
+ }
34
+ /** Adds this machine's open links and Paseo's own workspace names. Without a server id no link can be built, so nothing is shown. */
35
+ export function followUpView(found: PrWorkspaces | null, serverId: string | null, names: ReadonlyMap<string, string>): FollowUpView | undefined {
36
+ if (!found || !serverId) return undefined;
37
+ return {
38
+ more: found.more,
39
+ workspaces: found.workspaces.map(w => ({ ...w, title: names.get(w.workspaceId) || w.title || w.workspaceId, deepLink: buildAgentDeepLink({ serverId, agentId: w.agentId }), webUrl: buildAgentWebLink({ serverId, agentId: w.agentId }) })),
40
+ };
41
+ }
package/server/resolve.ts CHANGED
@@ -13,8 +13,8 @@ import {
13
13
  type ResolveResponse,
14
14
  type StackPrState,
15
15
  } from "../shared/contracts";
16
- import { withPaseo } from "./daemon";
17
- import { lookupPrOwner, registeredAgent, type PrOwner } from "./follow-up";
16
+ import { requireServerId, withPaseo } from "./daemon";
17
+ import { followUpView, lookupPrOwner, lookupPrWorkspaces, registeredAgent, type PrOwner } from "./follow-up";
18
18
  import {
19
19
  ANCESTRY_STACK_DISTANCE,
20
20
  UNKNOWN_STACK_DISTANCE,
@@ -979,6 +979,10 @@ export async function handleResolve(request: ResolveRequest): Promise<ResolveRes
979
979
  // starts this work before the popover opens).
980
980
  const workspacesPromise = paseo.workspaces.list();
981
981
  const ownerPromise = lookupPrOwner(ref.owner, ref.repo, ref.number);
982
+ // Asked for only by an extension with Follow-up browser access on; absent or failing is "no section".
983
+ const followUpPromise = request.followUp === true
984
+ ? Promise.all([lookupPrWorkspaces(ref.owner, ref.repo, ref.number), requireServerId().catch(() => null)])
985
+ : Promise.resolve([null, null] as const);
982
986
  const projectPromise = Promise.all([workspacesPromise, ownerPromise]).then(([all, owner]) =>
983
987
  resolveProject(paseo, ref, all.entries.find(w => w.id === owner?.workspaceId && w.archivingAt === null)?.projectId),
984
988
  );
@@ -1036,7 +1040,10 @@ export async function handleResolve(request: ResolveRequest): Promise<ResolveRes
1036
1040
  effectiveProvider === undefined
1037
1041
  ? undefined
1038
1042
  : await resolveDefaultMode(paseo, effectiveProvider, { profile, catalog });
1043
+ const [ownersFound, serverId] = await followUpPromise;
1044
+ const followUp = followUpView(ownersFound, serverId, new Map(allWorkspaces.entries.map(w => [w.id, typeof w.name === "string" ? w.name : ""])));
1039
1045
  return {
1046
+ ...(followUp ? { followUp } : {}),
1040
1047
  pr,
1041
1048
  project,
1042
1049
  candidates,
package/server/send.ts CHANGED
@@ -428,6 +428,7 @@ export async function handleSend(request: SendRequest): Promise<SendResponse> {
428
428
  dryRun,
429
429
  outcome: "ok",
430
430
  error: null,
431
+ dispatch,
431
432
  })
432
433
  .catch((error: unknown) => {
433
434
  console.error("[send-to-paseo] could not record the send", String(error));
package/shared/chat.ts ADDED
@@ -0,0 +1,159 @@
1
+ import { z } from "zod";
2
+
3
+ /**
4
+ * Send to Paseo as it appears inside an agent's chat, reduced to what a card or a
5
+ * one-line row needs. Pure, so the transformers and the tests read the same rules.
6
+ *
7
+ * The provenance card is parsed back out of the header `composePrompt` writes
8
+ * (CONTRACT.md, "Prompt header"). The header itself is unchanged: agents still
9
+ * read exactly the same text; only the person sees the card.
10
+ */
11
+ export const PROVENANCE_CARD_KIND = "send-to-paseo-provenance";
12
+ export const TOOL_ROW_KIND = "send-to-paseo-tool";
13
+
14
+ export const ProvenanceSchema = z.object({
15
+ forge: z.string(),
16
+ repo: z.string(),
17
+ number: z.number(),
18
+ /** Null when `gh` could not describe the PR (the degraded header). */
19
+ title: z.string().nullable(),
20
+ head: z.string().nullable(),
21
+ base: z.string().nullable(),
22
+ prUrl: z.string(),
23
+ pageUrl: z.string().nullable(),
24
+ /** Where the user pressed Send, from the Page: line. */
25
+ site: z.enum(["github", "graphite"]).nullable(),
26
+ /** Set only when the workspace is not on the PR's own branch, or when gh was unavailable. */
27
+ workspaceBranch: z.string().nullable(),
28
+ /** How the workspace branch relates to the PR, when the header says. */
29
+ branchState: z.enum(["sibling", "merged", "closed"]).nullable(),
30
+ degraded: z.boolean(),
31
+ instruction: z.string(),
32
+ text: z.string(),
33
+ });
34
+ export type Provenance = z.infer<typeof ProvenanceSchema>;
35
+
36
+ const HEADER = /^\[Sent from Graphite — ([a-z]+)\/([^/\s]+)\/(\S+) PR #(\d+)\]$/;
37
+
38
+ function siteOf(url: string | null): Provenance["site"] {
39
+ if (url === null) return null;
40
+ try {
41
+ const host = new URL(url).hostname.toLowerCase();
42
+ if (host === "github.com" || host.endsWith(".github.com")) return "github";
43
+ if (/(^|\.)graphite\.(dev|com)$/.test(host)) return "graphite";
44
+ } catch {
45
+ // Not a URL; say nothing about the site rather than guess.
46
+ }
47
+ return null;
48
+ }
49
+
50
+ /** The card for a message Send to Paseo wrote, or null for anything else. */
51
+ export function provenance(text: string): Provenance | null {
52
+ const split = text.indexOf("\n\n");
53
+ if (split < 0) return null;
54
+ const lines = text.slice(0, split).split("\n");
55
+ const header = HEADER.exec(lines[0] ?? "");
56
+ if (!header) return null;
57
+ const field = (name: string) => {
58
+ const line = lines.find((entry) => entry.startsWith(`${name}: `));
59
+ return line === undefined ? null : line.slice(name.length + 2).trim();
60
+ };
61
+ const prUrl = field("PR");
62
+ if (prUrl === null) return null;
63
+ const branch = field("Branch");
64
+ const arrow = branch === null ? null : /^(.*) -> (.*)$/.exec(branch);
65
+ const rawWorkspace = field("Workspace branch");
66
+ const workspaceBranch = rawWorkspace === null ? null : rawWorkspace.replace(/\s*\(NOT this PR's branch.*\)$/, "");
67
+ const branchState: Provenance["branchState"] =
68
+ rawWorkspace === null || !/NOT this PR's branch/.test(rawWorkspace)
69
+ ? null
70
+ : /already merged/.test(rawWorkspace)
71
+ ? "merged"
72
+ : /closed without merging/.test(rawWorkspace)
73
+ ? "closed"
74
+ : "sibling";
75
+ const pageUrl = field("Page");
76
+ return {
77
+ forge: header[1]!,
78
+ repo: `${header[2]}/${header[3]}`,
79
+ number: Number(header[4]),
80
+ title: field("Title"),
81
+ head: arrow?.[1] ?? null,
82
+ base: arrow?.[2] ?? null,
83
+ prUrl,
84
+ pageUrl,
85
+ site: siteOf(pageUrl),
86
+ workspaceBranch,
87
+ branchState,
88
+ degraded: field("Title") === null,
89
+ instruction: text.slice(split + 2).trim(),
90
+ text,
91
+ };
92
+ }
93
+
94
+ export const ToolRowSchema = z.object({
95
+ state: z.enum(["running", "done", "failed"]),
96
+ /** "Checked the bridge · running · paired". */
97
+ line: z.string(),
98
+ detail: z.string(),
99
+ /** Muted unless something needs attention. */
100
+ tone: z.enum(["neutral", "warning", "danger"]),
101
+ });
102
+ export type ToolRow = z.infer<typeof ToolRowSchema>;
103
+
104
+ /** Claude records mcp__paseo__send_to_paseo_bridge_status; Codex paseo.send_to_paseo_bridge_status. */
105
+ export function isBridgeStatusTool(name: string): boolean {
106
+ return /(^|__|\.|\/|:)send_to_paseo_bridge_status$/.test(name);
107
+ }
108
+
109
+ function record(value: unknown): value is Record<string, unknown> {
110
+ return typeof value === "object" && value !== null && !Array.isArray(value);
111
+ }
112
+
113
+ /** The text a tool result carries, however the provider wrapped it. */
114
+ export function readText(value: unknown): string {
115
+ if (value === null || value === undefined) return "";
116
+ if (typeof value === "string") return value;
117
+ if (Array.isArray(value)) return value.map(readText).join("\n");
118
+ if (!record(value)) return "";
119
+ if (typeof value.type === "string" && typeof value.text === "string") return value.text;
120
+ const key = ["content", "output", "text", "message", "result", "structuredContent"].find((name) => name in value);
121
+ if (key) return readText(value[key]);
122
+ return JSON.stringify(value);
123
+ }
124
+
125
+ const BridgeResultSchema = z.object({
126
+ state: z.string(),
127
+ port: z.number().optional(),
128
+ paired: z.boolean().optional(),
129
+ dryRun: z.boolean().optional(),
130
+ dependencies: z.array(z.object({ name: z.string(), state: z.string() })).optional(),
131
+ });
132
+
133
+ /** One line for the agent tool, from its JSON result. */
134
+ export function bridgeToolRow(status: string, output: unknown, error: unknown): ToolRow {
135
+ if (status === "running" || status === "pending") {
136
+ return { state: "running", line: "Checking the Send to Paseo bridge", detail: "", tone: "neutral" };
137
+ }
138
+ const text = readText(output).trim();
139
+ if (status === "failed" || (typeof error === "string" && error !== "")) {
140
+ return { state: "failed", line: "Couldn't check the Send to Paseo bridge", detail: typeof error === "string" && error !== "" ? error : text, tone: "danger" };
141
+ }
142
+ let parsed: z.infer<typeof BridgeResultSchema> | null = null;
143
+ try {
144
+ const json = BridgeResultSchema.safeParse(JSON.parse(text.slice(text.indexOf("{"))));
145
+ parsed = json.success ? json.data : null;
146
+ } catch {
147
+ parsed = null;
148
+ }
149
+ if (parsed === null) return { state: "done", line: "Checked the Send to Paseo bridge", detail: text, tone: "neutral" };
150
+ const missing = (parsed.dependencies ?? []).filter((dep) => dep.state !== "ok").map((dep) => dep.name);
151
+ const parts = [
152
+ parsed.state === "running" ? `listening on ${parsed.port ?? "its port"}` : parsed.state,
153
+ parsed.paired ? "paired" : "not paired yet",
154
+ ...(missing.length === 0 ? [] : [`${missing.join(", ")} missing`]),
155
+ ...(parsed.dryRun ? ["dry run"] : []),
156
+ ];
157
+ const tone: ToolRow["tone"] = parsed.state !== "running" ? "danger" : !parsed.paired || missing.length > 0 ? "warning" : "neutral";
158
+ return { state: "done", line: `Checked the Send to Paseo bridge · ${parts.join(" · ")}`, detail: text, tone };
159
+ }
@@ -9,7 +9,7 @@ import { z } from "zod";
9
9
 
10
10
  /** Advertised in `GET /v1/ping`. Keep in step with `package.json`. */
11
11
  export const PLUGIN_NAME = "send-to-paseo";
12
- export const PLUGIN_VERSION = "2.2.0";
12
+ export const PLUGIN_VERSION = "2.4.0";
13
13
  /** Bumped only for an incompatible bridge API; the paths stay `/v1`. */
14
14
  export const CONTRACT_VERSION = 1;
15
15
 
@@ -110,6 +110,12 @@ export type PrRef = z.infer<typeof PrRefSchema>;
110
110
  export const ResolveRequestSchema = PrRefSchema.extend({
111
111
  /** Sibling PRs in the Graphite stack, excluding this one. Best-effort. */
112
112
  stackPrNumbers: z.array(z.number().int().positive().max(10_000_000)).max(64).optional(),
113
+ /**
114
+ * Additive. Ask for the Follow-up view of this PR (`followUp` on the answer).
115
+ * The extension sets it only while "Use Graphite with Follow Up" is on, so
116
+ * turning that off stops the lookup instead of hiding its result.
117
+ */
118
+ followUp: z.boolean().optional(),
113
119
  });
114
120
  export type ResolveRequest = z.infer<typeof ResolveRequestSchema>;
115
121
 
@@ -352,6 +358,39 @@ export interface LocalResolveResponse {
352
358
  * Additive: absent means the older `new` behavior.
353
359
  */
354
360
  agentDispatch?: AgentDispatch;
361
+ /**
362
+ * Additive. The Paseo workspaces Follow-up says own this PR, on THIS machine.
363
+ * Present only when the request asked for it, Follow-up is installed and
364
+ * answers, and the repository is one Follow-up tracks (the same scope it
365
+ * advertises to the browser). Absent otherwise; never an error.
366
+ */
367
+ followUp?: FollowUpView;
368
+ }
369
+
370
+ /** One workspace that owns the PR, as the popover shows it. Titles, ids, status and one line: nothing else. */
371
+ export interface FollowUpWorkspace {
372
+ workspaceId: string;
373
+ /** The workspace's main agent: the one the open links land on. */
374
+ agentId: string;
375
+ /** As Paseo shows the workspace, else Follow-up's own title. */
376
+ title: string;
377
+ /** Paseo lifecycle status of the main agent (`running`, `idle`, `error`, ...) or `permission`. */
378
+ agentStatus: string;
379
+ /** Follow-up's Home group: needs | fixing | running | waiting | later | quiet. */
380
+ group: string;
381
+ /** Follow-up's one line, e.g. "Needs you · Merge ready". */
382
+ state: string;
383
+ /** Opens the main agent in the Paseo desktop app. */
384
+ deepLink: string;
385
+ /** Opens the same agent in the Paseo web app. */
386
+ webUrl: string;
387
+ }
388
+
389
+ export interface FollowUpView {
390
+ /** Most urgent first, at most three. Empty means Follow-up tracks the repository and no workspace owns this PR. */
391
+ workspaces: FollowUpWorkspace[];
392
+ /** How many more owners were left out. */
393
+ more: number;
355
394
  }
356
395
 
357
396
  /** One Paseo machine reached through the primary machine's bridge. */
@@ -418,6 +457,12 @@ export const RecentSendSchema = z.object({
418
457
  dryRun: z.boolean(),
419
458
  outcome: z.enum(["ok", "failed"]),
420
459
  error: z.string().nullable(),
460
+ /**
461
+ * Additive: whether the send started an agent or messaged the workspace's main
462
+ * one. Optional so rows written before it existed keep validating (a failed
463
+ * parse regenerates settings.json and with it the pairing token).
464
+ */
465
+ dispatch: AgentDispatchSchema.optional(),
421
466
  });
422
467
  export type RecentSend = z.infer<typeof RecentSendSchema>;
423
468
 
@@ -533,6 +578,28 @@ export const getStatus = defineRpc({
533
578
  }),
534
579
  });
535
580
 
581
+ /**
582
+ * The sends that reached one agent, for the provenance card in its chat. Rows
583
+ * carry no prompt text beyond the title the agent already shows.
584
+ */
585
+ export const dispatchesForAgent = defineRpc({
586
+ name: "send-to-paseo.dispatches.for-agent",
587
+ input: SurfaceTargetSchema.extend({ agentId: z.string().min(1).max(200) }),
588
+ output: z.object({ sends: z.array(RecentSendSchema) }),
589
+ });
590
+
591
+ /** Cheap enough for a sidebar row to poll: no provider, mode or dependency probes. */
592
+ export const getSummary = defineRpc({
593
+ name: "send-to-paseo.summary",
594
+ input: SurfaceTargetSchema,
595
+ output: z.object({
596
+ state: BridgeStatusSchema.shape.state,
597
+ paired: z.boolean(),
598
+ lastSendAt: z.string().nullable(),
599
+ lastSendFailed: z.boolean(),
600
+ }),
601
+ });
602
+
536
603
  export const revealToken = defineRpc({
537
604
  name: "send-to-paseo.token.reveal",
538
605
  input: SurfaceTargetSchema,
@@ -658,6 +725,19 @@ export function buildAgentDeepLink(target: { serverId: string; agentId: string }
658
725
  return `paseo://h/${encodeURIComponent(serverId)}/agent/${encodeURIComponent(agentId)}`;
659
726
  }
660
727
 
728
+ /**
729
+ * The Paseo web app's link for the same agent. The web app's
730
+ * `/h/<serverId>/agent/<agentId>` route (Paseo 0.15.2,
731
+ * `packages/app/src/app/h/[serverId]/agent/[agentId].tsx`) looks the agent's
732
+ * workspace up and redirects there, exactly as the desktop app does for the
733
+ * `paseo://` link, so both land in the workspace with its main agent open.
734
+ * It opens only where that browser already has this server paired.
735
+ */
736
+ export const PASEO_WEB_APP = "https://app.paseo.sh";
737
+ export function buildAgentWebLink(target: { serverId: string; agentId: string }): string {
738
+ return `${PASEO_WEB_APP}${buildAgentDeepLink(target).slice("paseo:/".length)}`;
739
+ }
740
+
661
741
  /** `github:acmegizmos/gizmo-poc#942`, the value of the `send-to-paseo/pr` label. */
662
742
  export function prLabelValue(ref: PrRef): string {
663
743
  return `${ref.forge}:${ref.owner}/${ref.repo}#${ref.number}`;
@@ -0,0 +1,76 @@
1
+ import type { BridgeStatus, RecentSend } from "./contracts";
2
+
3
+ export const CHROME_WEB_STORE_URL = "https://chromewebstore.google.com/detail/send-to-paseo/blflbbgkckbabbkoigpocilbkkmfijfg";
4
+
5
+ export type Lead =
6
+ | { kind: "down"; text: string; detail: string }
7
+ | { kind: "setup"; text: string; detail: string }
8
+ | { kind: "ready"; text: string; detail: string };
9
+
10
+ /** "4m ago", "just now". Absolute dates past a day. */
11
+ export function ago(iso: string | null, now = Date.now()): string {
12
+ if (iso === null) return "never";
13
+ const at = Date.parse(iso);
14
+ if (Number.isNaN(at)) return "never";
15
+ const seconds = Math.round((now - at) / 1000);
16
+ if (seconds < 45) return "just now";
17
+ const minutes = Math.round(seconds / 60);
18
+ if (minutes < 60) return `${minutes}m ago`;
19
+ const hours = Math.round(minutes / 60);
20
+ if (hours < 24) return `${hours}h ago`;
21
+ return new Date(at).toLocaleDateString(undefined, { month: "short", day: "numeric" });
22
+ }
23
+
24
+ /** The one sentence at the top of the screen: is it working, and what is next. */
25
+ export function lead(status: BridgeStatus, sends: RecentSend[], now = Date.now()): Lead {
26
+ if (status.state === "failed" || status.state === "stopped") {
27
+ return {
28
+ kind: "down",
29
+ text: "The bridge isn't running",
30
+ detail: status.error !== null && /already in use/i.test(status.error)
31
+ ? `Port ${status.configuredPort} is taken by another program. Choose another port under Connection details below, or quit the program using it.`
32
+ : status.error ?? `Nothing is listening on port ${status.configuredPort}. Reload the plugin, or pick another port under Connection details.`,
33
+ };
34
+ }
35
+ if (status.state === "starting") return { kind: "ready", text: "Starting the bridge…", detail: "" };
36
+ if (!status.paired) {
37
+ return { kind: "setup", text: "Pair Chrome to start sending", detail: "Three steps, once. Then a Send to Paseo button appears on every GitHub and Graphite pull request." };
38
+ }
39
+ const today = new Date(now).toDateString();
40
+ const sentToday = sends.filter((send) => send.outcome === "ok" && new Date(send.at).toDateString() === today).length;
41
+ if (sends.length === 0) {
42
+ return { kind: "ready", text: "Paired with Chrome", detail: "Open a pull request on GitHub or Graphite and press Send to Paseo. Your sends show up here." };
43
+ }
44
+ const count = sentToday === 0 ? "nothing sent today" : `${sentToday} send${sentToday === 1 ? "" : "s"} today`;
45
+ return { kind: "ready", text: `Paired with Chrome · ${count}`, detail: `Last send ${ago(sends[0]!.at, now)}.` };
46
+ }
47
+
48
+ /** The second line of a send row: where it went and how. */
49
+ /** A failed send's cause and the one thing that fixes it, instead of the raw upstream message. */
50
+ export function failure(send: RecentSend): string {
51
+ const error = send.error ?? "";
52
+ const repo = send.prLabel.replace(/#\d+$/, "");
53
+ const number = /#(\d+)$/.exec(send.prLabel)?.[1] ?? "";
54
+ if (/could not create a worktree|Unable to resolve GitHub repository/i.test(error)) {
55
+ return `Paseo couldn't check out PR #${number}. Add ${repo} as a project in Paseo (a clone with its GitHub remote), then send again.`;
56
+ }
57
+ if (/not a registered Paseo project|project_not_found/i.test(error)) return `${repo} isn't a Paseo project yet. Add it in Paseo, then send again.`;
58
+ if (/no longer available/i.test(error)) return "That workspace was archived or removed. Reopen the composer to pick another one.";
59
+ if (/Follow Up registration changed/i.test(error)) return "The agent Follow Up registered for this PR changed. Reopen the composer and send again.";
60
+ return error === "" ? "Not sent." : error;
61
+ }
62
+
63
+ export function destination(send: RecentSend): string {
64
+ if (send.outcome === "failed") return failure(send);
65
+ const parts = [
66
+ send.workspaceCreated ? `New worktree · ${send.workspaceLabel}` : send.workspaceLabel,
67
+ send.dispatch === "main" ? `messaged ${send.title}` : "new agent",
68
+ ...(send.dryRun ? ["dry run"] : []),
69
+ ];
70
+ return parts.join(" · ");
71
+ }
72
+
73
+ /** "acme/billing-service#421" → "acme/billing-service #421". */
74
+ export function prLabel(label: string): string {
75
+ return label.replace(/#(\d+)$/, " #$1");
76
+ }
@@ -0,0 +1,33 @@
1
+ import type { Provenance } from "./chat";
2
+ import type { RecentSend } from "./contracts";
3
+
4
+ /** "GitHub" / "Graphite", or null when the send carried no page URL. */
5
+ export function siteLabel(site: Provenance["site"]): string | null {
6
+ return site === "github" ? "GitHub" : site === "graphite" ? "Graphite" : null;
7
+ }
8
+
9
+ /**
10
+ * Why the send landed where it did, in one line. The prompt header says which
11
+ * branch the workspace is on; the recorded send (when this host still has it)
12
+ * adds the workspace name, whether a worktree was created, and whether the
13
+ * message started an agent or reached the workspace's main one.
14
+ */
15
+ export function routeLine(card: Provenance, send: RecentSend | null): { text: string; attention: boolean } {
16
+ const parts: string[] = [];
17
+ let attention = false;
18
+ if (send?.workspaceCreated) parts.push(`New worktree for #${card.number}`);
19
+ else if (send !== null) parts.push(send.workspaceLabel);
20
+ if (!send?.workspaceCreated) {
21
+ if (card.branchState === "merged") { parts.push(`on ${card.workspaceBranch}, a merged branch of this stack`); attention = true; }
22
+ else if (card.branchState === "closed") { parts.push(`on ${card.workspaceBranch}, a closed branch of this stack`); attention = true; }
23
+ else if (card.branchState === "sibling") parts.push(`on ${card.workspaceBranch}, another branch of this stack`);
24
+ else if (card.degraded) parts.push(card.workspaceBranch === null ? "PR details unavailable (gh)" : `on ${card.workspaceBranch} · PR details unavailable (gh)`);
25
+ else parts.push("on the PR's branch");
26
+ }
27
+ if (send?.dispatch === "main") parts.push("sent to this agent");
28
+ else if (send?.dispatch === "new" || send?.workspaceCreated) parts.push("new agent");
29
+ const text = parts.join(" · ");
30
+ // Capitalise only our own leading phrase; a workspace name is shown as Paseo shows it.
31
+ const ours = send === null || send.workspaceCreated;
32
+ return { text: ours ? text.charAt(0).toUpperCase() + text.slice(1) : text, attention };
33
+ }
@@ -0,0 +1,14 @@
1
+ export interface Summary {
2
+ state: "starting" | "running" | "failed" | "stopped";
3
+ paired: boolean;
4
+ lastSendAt: string | null;
5
+ lastSendFailed: boolean;
6
+ }
7
+
8
+ /** What the sidebar dot says, or null when nothing needs the person. */
9
+ export function summaryAttention(summary: Summary): { tone: "warning" | "danger"; label: string } | null {
10
+ if (summary.state === "failed" || summary.state === "stopped") return { tone: "danger", label: "Bridge is not running" };
11
+ if (summary.lastSendFailed) return { tone: "danger", label: "The last send failed" };
12
+ if (!summary.paired) return { tone: "warning", label: "Not paired with Chrome yet" };
13
+ return null;
14
+ }
@@ -1,14 +0,0 @@
1
- import type { ComponentType } from "react";
2
- import type { PluginClientContext, PluginSurfaceProps } from "@getpaseo/plugin/client";
3
- import { Pressable, Text, View } from "react-native";
4
-
5
- export function withNavigation<P extends PluginSurfaceProps>(Component: ComponentType<P>, client: PluginClientContext, home: string, active = "overview") {
6
- return function PluginView(props: P) {
7
- return <View style={{ flex: 1, backgroundColor: props.theme.colors.surface0 }}>
8
- <View accessibilityRole="toolbar" style={{ flexDirection: "row", flexWrap: "wrap", gap: 4, padding: 8, borderBottomWidth: 1, borderColor: props.theme.colors.border }}>
9
- {[{ id: "overview", title: "Overview", target: home }, { id: "display", title: "Display settings", target: "display-settings" }].map(item => <Pressable key={item.id} accessibilityRole="button" accessibilityState={{ selected: active === item.id }} onPress={() => client.openSurface(item.target)} style={({ pressed }) => ({ minHeight: 44, paddingHorizontal: 12, justifyContent: "center", borderRadius: 6, backgroundColor: pressed || active === item.id ? props.theme.colors.surface2 : "transparent" })}><Text style={{ color: active === item.id ? props.theme.colors.foreground : props.theme.colors.foregroundMuted, fontSize: 13, fontWeight: active === item.id ? "600" : "400" }}>{item.title}</Text></Pressable>)}
10
- </View>
11
- <Component {...props} />
12
- </View>;
13
- };
14
- }