patchrelay 0.57.0 → 0.58.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.
@@ -15,7 +15,7 @@ function implementationPlan() {
15
15
  return [
16
16
  { content: "Prepare workspace", status: "pending" },
17
17
  { content: "Implementing", status: "pending" },
18
- { content: "Awaiting verification", status: "pending" },
18
+ { content: "Fresh head pushed", status: "pending" },
19
19
  { content: "Merge", status: "pending" },
20
20
  ];
21
21
  }
@@ -30,8 +30,8 @@ function orchestrationPlan() {
30
30
  function reviewFixPlan() {
31
31
  return [
32
32
  { content: "Prepare workspace", status: "completed" },
33
- { content: "Addressing review feedback", status: "pending" },
34
- { content: "Awaiting re-verification", status: "pending" },
33
+ { content: "Addressing requested changes", status: "pending" },
34
+ { content: "Fresh head pushed", status: "pending" },
35
35
  { content: "Merge", status: "pending" },
36
36
  ];
37
37
  }
@@ -39,7 +39,7 @@ function branchUpkeepPlan() {
39
39
  return [
40
40
  { content: "Prepare workspace", status: "completed" },
41
41
  { content: "Repairing branch upkeep", status: "pending" },
42
- { content: "Awaiting re-verification", status: "pending" },
42
+ { content: "Fresh head pushed", status: "pending" },
43
43
  { content: "Merge", status: "pending" },
44
44
  ];
45
45
  }
@@ -55,7 +55,7 @@ function mainRepairPlan(attempt) {
55
55
  return [
56
56
  { content: "Inspect main failure", status: "pending" },
57
57
  { content: `Repairing main (${attemptLabel(attempt)})`, status: "pending" },
58
- { content: "Awaiting re-verification", status: "pending" },
58
+ { content: "Fresh head pushed", status: "pending" },
59
59
  { content: "Priority merge", status: "pending" },
60
60
  ];
61
61
  }
@@ -152,7 +152,12 @@ export function buildAgentSessionPlan(params) {
152
152
  ? mainRepairPlan(params.ciRepairAttempts ?? 1)
153
153
  : planForRunType("implementation", params), ["completed", "inProgress", "pending", "pending"]);
154
154
  case "pr_open":
155
- return setStatuses(implementationPlan(), ["completed", "completed", "inProgress", "pending"]);
155
+ return setStatuses([
156
+ { content: "Prepare workspace", status: "completed" },
157
+ { content: "Implementing", status: "completed" },
158
+ { content: prOpenGateLabel(params), status: "inProgress" },
159
+ { content: "Merge", status: "pending" },
160
+ ], ["completed", "completed", "inProgress", "pending"]);
156
161
  case "changes_requested":
157
162
  return setStatuses(reviewFixPlan(), ["completed", "inProgress", "pending", "pending"]);
158
163
  case "repairing_ci":
@@ -160,9 +165,9 @@ export function buildAgentSessionPlan(params) {
160
165
  case "awaiting_queue":
161
166
  return setStatuses([
162
167
  { content: "Prepare workspace", status: "completed" },
163
- { content: "Implementing", status: "completed" },
168
+ { content: "Fresh head pushed", status: "completed" },
164
169
  { content: "Verification passed", status: "completed" },
165
- { content: "Awaiting merge", status: "inProgress" },
170
+ { content: "Awaiting queue", status: "inProgress" },
166
171
  ], ["completed", "completed", "completed", "inProgress"]);
167
172
  case "repairing_queue":
168
173
  return setStatuses(queueRepairPlan(params.queueRepairAttempts ?? 1), ["completed", "completed", "completed", "inProgress"]);
@@ -175,12 +180,41 @@ export function buildAgentSessionPlan(params) {
175
180
  case "done":
176
181
  return setStatuses([
177
182
  { content: "Prepare workspace", status: "completed" },
178
- { content: "Implementing", status: "completed" },
183
+ { content: "Fresh head pushed", status: "completed" },
179
184
  { content: "Verification passed", status: "completed" },
180
185
  { content: "Merged", status: "completed" },
181
186
  ], ["completed", "completed", "completed", "completed"]);
182
187
  }
183
188
  }
189
+ function prOpenGateLabel(params) {
190
+ const reviewState = normalizeState(params.prReviewState);
191
+ const checkStatus = normalizeState(params.prCheckStatus);
192
+ if (isPendingCheckStatus(checkStatus)) {
193
+ return "Awaiting checks";
194
+ }
195
+ if (isAwaitingReviewState(reviewState)) {
196
+ return "Awaiting review";
197
+ }
198
+ if (isApprovedReviewState(reviewState) && isPassedCheckStatus(checkStatus)) {
199
+ return "Awaiting queue";
200
+ }
201
+ return "Fresh head pushed";
202
+ }
203
+ function isAwaitingReviewState(value) {
204
+ return value === "review_required" || value === "commented" || value === "changes_requested";
205
+ }
206
+ function isApprovedReviewState(value) {
207
+ return value === "approved";
208
+ }
209
+ function isPendingCheckStatus(value) {
210
+ return value === "pending" || value === "queued" || value === "in_progress" || value === "waiting";
211
+ }
212
+ function isPassedCheckStatus(value) {
213
+ return value === "success" || value === "passed";
214
+ }
215
+ function normalizeState(value) {
216
+ return (value ?? "").trim().toLowerCase().replace(/[-/\s]+/g, "_");
217
+ }
184
218
  function planForRunType(runType, params) {
185
219
  switch (runType) {
186
220
  case "main_repair":
@@ -206,6 +240,8 @@ export function buildAgentSessionPlanForIssue(issue, options) {
206
240
  ...(issue.issueClass ? { issueClass: issue.issueClass } : {}),
207
241
  ...(issue.orchestrationSettleUntil ? { orchestrationSettleUntil: issue.orchestrationSettleUntil } : {}),
208
242
  ...(issue.pendingRunType ? { pendingRunType: issue.pendingRunType } : {}),
243
+ ...(issue.prReviewState ? { prReviewState: issue.prReviewState } : {}),
244
+ ...(issue.prCheckStatus ? { prCheckStatus: issue.prCheckStatus } : {}),
209
245
  ...(options?.activeRunType ? { activeRunType: options.activeRunType } : {}),
210
246
  });
211
247
  }
@@ -2,19 +2,13 @@ import { buildSessionStatusUrl, createSessionStatusToken, deriveSessionStatusSig
2
2
  const SESSION_STATUS_TTL_SECONDS = 60 * 60 * 24 * 7;
3
3
  export function buildAgentSessionExternalUrls(config, params) {
4
4
  const urls = [];
5
- if (params.issueKey && config.server.publicBaseUrl) {
6
- const token = createSessionStatusToken({
7
- issueKey: params.issueKey,
8
- secret: deriveSessionStatusSigningSecret(config.linear.tokenEncryptionKey),
9
- ttlSeconds: SESSION_STATUS_TTL_SECONDS,
10
- });
5
+ const statusUrl = params.issueKey && config.server.publicBaseUrl
6
+ ? buildPublicStatusUrl(config, params.issueKey)
7
+ : undefined;
8
+ if (statusUrl) {
11
9
  urls.push({
12
10
  label: "PatchRelay status",
13
- url: buildSessionStatusUrl({
14
- publicBaseUrl: config.server.publicBaseUrl,
15
- issueKey: params.issueKey,
16
- token: token.token,
17
- }),
11
+ url: statusUrl,
18
12
  });
19
13
  }
20
14
  if (params.prUrl) {
@@ -23,5 +17,98 @@ export function buildAgentSessionExternalUrls(config, params) {
23
17
  url: params.prUrl,
24
18
  });
25
19
  }
20
+ const reviewQuillUrl = buildReviewQuillUrl(params);
21
+ if (reviewQuillUrl) {
22
+ urls.push({
23
+ label: "Review-quill status",
24
+ url: reviewQuillUrl,
25
+ });
26
+ }
27
+ const mergeStewardUrl = buildMergeStewardUrl(params);
28
+ if (mergeStewardUrl) {
29
+ urls.push({
30
+ label: "Merge-steward queue",
31
+ url: mergeStewardUrl,
32
+ });
33
+ }
34
+ if (statusUrl && params.activeRunId !== undefined) {
35
+ urls.push({
36
+ label: "Active run",
37
+ url: withFragment(statusUrl, "current-view"),
38
+ });
39
+ }
26
40
  return urls.length > 0 ? urls : undefined;
27
41
  }
42
+ function buildPublicStatusUrl(config, issueKey) {
43
+ if (!config.server.publicBaseUrl)
44
+ return undefined;
45
+ const token = createSessionStatusToken({
46
+ issueKey,
47
+ secret: deriveSessionStatusSigningSecret(config.linear.tokenEncryptionKey),
48
+ ttlSeconds: SESSION_STATUS_TTL_SECONDS,
49
+ });
50
+ return buildSessionStatusUrl({
51
+ publicBaseUrl: config.server.publicBaseUrl,
52
+ issueKey,
53
+ token: token.token,
54
+ });
55
+ }
56
+ function buildReviewQuillUrl(params) {
57
+ if (isReviewQuillCheck(params.lastGitHubFailureCheckName) && params.lastGitHubFailureCheckUrl) {
58
+ return params.lastGitHubFailureCheckUrl;
59
+ }
60
+ if (!params.prUrl || !hasReviewQuillContext(params)) {
61
+ return undefined;
62
+ }
63
+ return `${trimTrailingSlash(params.prUrl)}/checks`;
64
+ }
65
+ function buildMergeStewardUrl(params) {
66
+ const incidentUrl = parseQueueIncidentUrl(params.lastQueueIncidentJson);
67
+ if (incidentUrl)
68
+ return incidentUrl;
69
+ if (params.lastGitHubFailureSource === "queue_eviction"
70
+ || isMergeStewardCheck(params.lastGitHubFailureCheckName)) {
71
+ return params.lastGitHubFailureCheckUrl;
72
+ }
73
+ return undefined;
74
+ }
75
+ function hasReviewQuillContext(params) {
76
+ if (isReviewQuillCheck(params.lastGitHubFailureCheckName))
77
+ return true;
78
+ const reviewState = normalizeState(params.prReviewState);
79
+ if (reviewState === "review_required" || reviewState === "changes_requested" || reviewState === "commented") {
80
+ return true;
81
+ }
82
+ return normalizeState(params.prCheckStatus).includes("review");
83
+ }
84
+ function isReviewQuillCheck(checkName) {
85
+ return normalizeState(checkName).includes("review_quill");
86
+ }
87
+ function isMergeStewardCheck(checkName) {
88
+ return normalizeState(checkName).includes("merge_steward");
89
+ }
90
+ function parseQueueIncidentUrl(value) {
91
+ if (!value)
92
+ return undefined;
93
+ try {
94
+ const parsed = JSON.parse(value);
95
+ if (!parsed || typeof parsed !== "object")
96
+ return undefined;
97
+ const incidentUrl = parsed.incidentUrl;
98
+ return typeof incidentUrl === "string" && incidentUrl.trim() ? incidentUrl.trim() : undefined;
99
+ }
100
+ catch {
101
+ return undefined;
102
+ }
103
+ }
104
+ function withFragment(url, fragment) {
105
+ const parsed = new URL(url);
106
+ parsed.hash = fragment;
107
+ return parsed.toString();
108
+ }
109
+ function trimTrailingSlash(value) {
110
+ return value.replace(/\/+$/, "");
111
+ }
112
+ function normalizeState(value) {
113
+ return (value ?? "").trim().toLowerCase().replace(/[-/\s]+/g, "_");
114
+ }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "service": "patchrelay",
3
- "version": "0.57.0",
4
- "commit": "d67134a3b377",
5
- "builtAt": "2026-05-01T22:45:14.762Z"
3
+ "version": "0.58.0",
4
+ "commit": "a14713655229",
5
+ "builtAt": "2026-05-02T10:15:39.171Z"
6
6
  }
@@ -43,6 +43,13 @@ export async function syncGitHubLinearSession(params) {
43
43
  const externalUrls = buildAgentSessionExternalUrls(config, {
44
44
  ...(issue.issueKey ? { issueKey: issue.issueKey } : {}),
45
45
  ...(issue.prUrl ? { prUrl: issue.prUrl } : {}),
46
+ ...(issue.activeRunId !== undefined ? { activeRunId: issue.activeRunId } : {}),
47
+ ...(issue.prReviewState ? { prReviewState: issue.prReviewState } : {}),
48
+ ...(issue.prCheckStatus ? { prCheckStatus: issue.prCheckStatus } : {}),
49
+ ...(issue.lastGitHubFailureSource ? { lastGitHubFailureSource: issue.lastGitHubFailureSource } : {}),
50
+ ...(issue.lastGitHubFailureCheckName ? { lastGitHubFailureCheckName: issue.lastGitHubFailureCheckName } : {}),
51
+ ...(issue.lastGitHubFailureCheckUrl ? { lastGitHubFailureCheckUrl: issue.lastGitHubFailureCheckUrl } : {}),
52
+ ...(issue.lastQueueIncidentJson ? { lastQueueIncidentJson: issue.lastQueueIncidentJson } : {}),
46
53
  });
47
54
  await linear.updateAgentSession({
48
55
  agentSessionId: issue.agentSessionId,
package/dist/http.js CHANGED
@@ -578,7 +578,7 @@ function renderAgentSessionStatusPage(params) {
578
578
  <span class="chip"><strong>Latest:</strong> ${latestStage}</span>
579
579
  <span class="chip"><strong>Thread:</strong> ${threadInfo}</span>
580
580
  </div>
581
- <div class="section">
581
+ <div id="current-view" class="section">
582
582
  <h2>Current View</h2>
583
583
  <table>
584
584
  <tbody>
@@ -600,7 +600,7 @@ function renderAgentSessionStatusPage(params) {
600
600
  <span class="chip"><strong>CI repairs:</strong> ${escapeHtml(String(ciAttempts))}</span>
601
601
  <span class="chip"><strong>Steward repairs:</strong> ${escapeHtml(String(queueAttempts))}</span>
602
602
  </div>
603
- <div class="section">
603
+ <div id="recent-stages" class="section">
604
604
  <h2>Recent Stages</h2>
605
605
  <table>
606
606
  <thead>
@@ -75,6 +75,13 @@ export class LinearAgentSessionClient {
75
75
  const externalUrls = buildAgentSessionExternalUrls(this.config, {
76
76
  ...(issue.issueKey ? { issueKey: issue.issueKey } : {}),
77
77
  ...(issue.prUrl ? { prUrl: issue.prUrl } : {}),
78
+ ...(issue.activeRunId !== undefined ? { activeRunId: issue.activeRunId } : {}),
79
+ ...(issue.prReviewState ? { prReviewState: issue.prReviewState } : {}),
80
+ ...(issue.prCheckStatus ? { prCheckStatus: issue.prCheckStatus } : {}),
81
+ ...(issue.lastGitHubFailureSource ? { lastGitHubFailureSource: issue.lastGitHubFailureSource } : {}),
82
+ ...(issue.lastGitHubFailureCheckName ? { lastGitHubFailureCheckName: issue.lastGitHubFailureCheckName } : {}),
83
+ ...(issue.lastGitHubFailureCheckUrl ? { lastGitHubFailureCheckUrl: issue.lastGitHubFailureCheckUrl } : {}),
84
+ ...(issue.lastQueueIncidentJson ? { lastQueueIncidentJson: issue.lastQueueIncidentJson } : {}),
78
85
  });
79
86
  await linear.updateAgentSession({
80
87
  agentSessionId: issue.agentSessionId,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "patchrelay",
3
- "version": "0.57.0",
3
+ "version": "0.58.0",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "repository": {