patchrelay 0.74.4 → 0.74.5

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.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "service": "patchrelay",
3
- "version": "0.74.4",
4
- "commit": "c6959e0ae3d7",
5
- "builtAt": "2026-05-29T01:07:21.410Z"
3
+ "version": "0.74.5",
4
+ "commit": "c495abc1770b",
5
+ "builtAt": "2026-05-29T08:13:54.437Z"
6
6
  }
package/dist/cli/data.js CHANGED
@@ -402,42 +402,7 @@ export class CliDataAccess extends CliOperatorApiClient {
402
402
  });
403
403
  }
404
404
  list(options) {
405
- const conditions = [];
406
- const values = [];
407
- if (options?.project) {
408
- conditions.push("i.project_id = ?");
409
- values.push(options.project);
410
- }
411
- const whereClause = conditions.length > 0 ? `WHERE ${conditions.join(" AND ")}` : "";
412
- const rows = this.db.connection
413
- .prepare(`
414
- SELECT
415
- i.project_id,
416
- i.linear_issue_id,
417
- i.issue_key,
418
- i.title,
419
- i.current_linear_state,
420
- i.factory_state,
421
- i.updated_at,
422
- s.session_state,
423
- s.waiting_reason,
424
- active_run.run_type AS active_run_type,
425
- latest_run.run_type AS latest_run_type,
426
- latest_run.status AS latest_run_status
427
- FROM issues i
428
- LEFT JOIN issue_sessions s
429
- ON s.project_id = i.project_id
430
- AND s.linear_issue_id = i.linear_issue_id
431
- LEFT JOIN runs active_run ON active_run.id = i.active_run_id
432
- LEFT JOIN runs latest_run ON latest_run.id = (
433
- SELECT r.id FROM runs r
434
- WHERE r.project_id = i.project_id AND r.linear_issue_id = i.linear_issue_id
435
- ORDER BY r.id DESC LIMIT 1
436
- )
437
- ${whereClause}
438
- ORDER BY i.updated_at DESC, i.issue_key ASC
439
- `)
440
- .all(...values);
405
+ const rows = this.db.issues.listIssueSummaryRows(options?.project);
441
406
  const items = rows.map((row) => {
442
407
  const detachedActiveRun = row.active_run_type === null
443
408
  && (row.latest_run_status === "queued" || row.latest_run_status === "running");
@@ -292,4 +292,82 @@ export class IssueSessionStore {
292
292
  const lease = this.getActiveIssueSessionLease(projectId, linearIssueId);
293
293
  this.releaseIssueSessionLease(projectId, linearIssueId, lease?.leaseId);
294
294
  }
295
+ /**
296
+ * Raw rows for the tracked-issue read model: one row per issue session joined
297
+ * to its issue, active/latest run, pending session-event count, and blocker
298
+ * rollup. Row shaping into the read model lives in the query layer; this owns
299
+ * only the SQL so schema knowledge stays in the persistence layer.
300
+ */
301
+ listTrackedIssueRows() {
302
+ return this.connection
303
+ .prepare(`SELECT
304
+ s.project_id, s.linear_issue_id, s.issue_key, i.title,
305
+ i.current_linear_state, i.factory_state, i.delegated_to_patchrelay, s.session_state, s.waiting_reason, s.summary_text, s.display_updated_at,
306
+ i.pending_run_type,
307
+ i.orchestration_settle_until,
308
+ i.pr_number, i.pr_state, i.pr_head_sha, i.pr_review_state, i.pr_check_status, i.last_blocking_review_head_sha,
309
+ i.last_github_ci_snapshot_json,
310
+ i.last_github_failure_source,
311
+ i.last_github_failure_head_sha,
312
+ i.last_github_failure_check_name,
313
+ i.last_github_failure_context_json,
314
+ active_run.run_type AS active_run_type,
315
+ active_run.completion_check_thread_id AS active_completion_check_thread_id,
316
+ active_run.completion_check_outcome AS active_completion_check_outcome,
317
+ latest_run.run_type AS latest_run_type,
318
+ latest_run.status AS latest_run_status,
319
+ latest_run.summary_json AS latest_run_summary_json,
320
+ latest_run.report_json AS latest_run_report_json,
321
+ latest_run.completion_check_thread_id AS latest_run_completion_check_thread_id,
322
+ latest_run.completion_check_outcome AS latest_run_completion_check_outcome,
323
+ latest_run.completion_check_summary AS latest_run_completion_check_summary,
324
+ latest_run.completion_check_question AS latest_run_completion_check_question,
325
+ latest_run.completion_check_why AS latest_run_completion_check_why,
326
+ latest_run.completion_check_recommended_reply AS latest_run_completion_check_recommended_reply,
327
+ (
328
+ SELECT COUNT(*)
329
+ FROM issue_session_events e
330
+ WHERE e.project_id = s.project_id
331
+ AND e.linear_issue_id = s.linear_issue_id
332
+ AND e.processed_at IS NULL
333
+ ) AS pending_session_event_count,
334
+ (
335
+ SELECT COUNT(*)
336
+ FROM issue_dependencies d
337
+ LEFT JOIN issues blockers
338
+ ON blockers.project_id = d.project_id
339
+ AND blockers.linear_issue_id = d.blocker_linear_issue_id
340
+ WHERE d.project_id = s.project_id
341
+ AND d.linear_issue_id = s.linear_issue_id
342
+ AND (
343
+ COALESCE(blockers.current_linear_state_type, d.blocker_current_linear_state_type, '') != 'completed'
344
+ AND LOWER(TRIM(COALESCE(blockers.current_linear_state, d.blocker_current_linear_state, ''))) != 'done'
345
+ )
346
+ ) AS blocked_by_count,
347
+ (
348
+ SELECT json_group_array(COALESCE(blockers.issue_key, d.blocker_issue_key, d.blocker_linear_issue_id))
349
+ FROM issue_dependencies d
350
+ LEFT JOIN issues blockers
351
+ ON blockers.project_id = d.project_id
352
+ AND blockers.linear_issue_id = d.blocker_linear_issue_id
353
+ WHERE d.project_id = s.project_id
354
+ AND d.linear_issue_id = s.linear_issue_id
355
+ AND (
356
+ COALESCE(blockers.current_linear_state_type, d.blocker_current_linear_state_type, '') != 'completed'
357
+ AND LOWER(TRIM(COALESCE(blockers.current_linear_state, d.blocker_current_linear_state, ''))) != 'done'
358
+ )
359
+ ) AS blocked_by_keys_json
360
+ FROM issue_sessions s
361
+ LEFT JOIN issues i
362
+ ON i.project_id = s.project_id
363
+ AND i.linear_issue_id = s.linear_issue_id
364
+ LEFT JOIN runs active_run ON active_run.id = COALESCE(s.active_run_id, i.active_run_id)
365
+ LEFT JOIN runs latest_run ON latest_run.id = (
366
+ SELECT r.id FROM runs r
367
+ WHERE r.project_id = s.project_id AND r.linear_issue_id = s.linear_issue_id
368
+ ORDER BY r.id DESC LIMIT 1
369
+ )
370
+ ORDER BY s.display_updated_at DESC, s.issue_key ASC`)
371
+ .all();
372
+ }
295
373
  }
@@ -354,6 +354,44 @@ export class IssueStore {
354
354
  return undefined;
355
355
  }
356
356
  }
357
+ /**
358
+ * Raw rows for the CLI issue-summary read model (one row per issue joined to
359
+ * its session and active/latest run), optionally scoped to a project. Row
360
+ * shaping lives in the CLI layer; this owns only the SQL.
361
+ */
362
+ listIssueSummaryRows(project) {
363
+ const whereClause = project ? "WHERE i.project_id = ?" : "";
364
+ const values = project ? [project] : [];
365
+ return this.connection
366
+ .prepare(`
367
+ SELECT
368
+ i.project_id,
369
+ i.linear_issue_id,
370
+ i.issue_key,
371
+ i.title,
372
+ i.current_linear_state,
373
+ i.factory_state,
374
+ i.updated_at,
375
+ s.session_state,
376
+ s.waiting_reason,
377
+ active_run.run_type AS active_run_type,
378
+ latest_run.run_type AS latest_run_type,
379
+ latest_run.status AS latest_run_status
380
+ FROM issues i
381
+ LEFT JOIN issue_sessions s
382
+ ON s.project_id = i.project_id
383
+ AND s.linear_issue_id = i.linear_issue_id
384
+ LEFT JOIN runs active_run ON active_run.id = i.active_run_id
385
+ LEFT JOIN runs latest_run ON latest_run.id = (
386
+ SELECT r.id FROM runs r
387
+ WHERE r.project_id = i.project_id AND r.linear_issue_id = i.linear_issue_id
388
+ ORDER BY r.id DESC LIMIT 1
389
+ )
390
+ ${whereClause}
391
+ ORDER BY i.updated_at DESC, i.issue_key ASC
392
+ `)
393
+ .all(...values);
394
+ }
357
395
  }
358
396
  export function mapIssueRow(row) {
359
397
  return {
@@ -170,6 +170,10 @@ export class LinearInstallationStore {
170
170
  deleteLinearInstallation(installationId) {
171
171
  this.connection.prepare("DELETE FROM linear_installations WHERE id = ?").run(installationId);
172
172
  }
173
+ deleteCatalogForInstallation(installationId) {
174
+ this.connection.prepare("DELETE FROM linear_catalog_teams WHERE installation_id = ?").run(installationId);
175
+ this.connection.prepare("DELETE FROM linear_catalog_projects WHERE installation_id = ?").run(installationId);
176
+ }
173
177
  getLinearInstallationForProject(projectId) {
174
178
  const row = this.connection
175
179
  .prepare(`
package/dist/service.js CHANGED
@@ -261,8 +261,7 @@ export class PatchRelayService {
261
261
  }
262
262
  this.db.transaction(() => {
263
263
  this.db.linearInstallations.unlinkInstallationProjects(installation.id);
264
- this.db.connection.prepare("DELETE FROM linear_catalog_teams WHERE installation_id = ?").run(installation.id);
265
- this.db.connection.prepare("DELETE FROM linear_catalog_projects WHERE installation_id = ?").run(installation.id);
264
+ this.db.linearInstallations.deleteCatalogForInstallation(installation.id);
266
265
  this.db.linearInstallations.deleteLinearInstallation(installation.id);
267
266
  });
268
267
  return {
@@ -78,76 +78,7 @@ export class TrackedIssueListQuery {
78
78
  this.db = db;
79
79
  }
80
80
  listTrackedIssues() {
81
- const rows = this.db.connection
82
- .prepare(`SELECT
83
- s.project_id, s.linear_issue_id, s.issue_key, i.title,
84
- i.current_linear_state, i.factory_state, i.delegated_to_patchrelay, s.session_state, s.waiting_reason, s.summary_text, s.display_updated_at,
85
- i.pending_run_type,
86
- i.orchestration_settle_until,
87
- i.pr_number, i.pr_state, i.pr_head_sha, i.pr_review_state, i.pr_check_status, i.last_blocking_review_head_sha,
88
- i.last_github_ci_snapshot_json,
89
- i.last_github_failure_source,
90
- i.last_github_failure_head_sha,
91
- i.last_github_failure_check_name,
92
- i.last_github_failure_context_json,
93
- active_run.run_type AS active_run_type,
94
- active_run.completion_check_thread_id AS active_completion_check_thread_id,
95
- active_run.completion_check_outcome AS active_completion_check_outcome,
96
- latest_run.run_type AS latest_run_type,
97
- latest_run.status AS latest_run_status,
98
- latest_run.summary_json AS latest_run_summary_json,
99
- latest_run.report_json AS latest_run_report_json,
100
- latest_run.completion_check_thread_id AS latest_run_completion_check_thread_id,
101
- latest_run.completion_check_outcome AS latest_run_completion_check_outcome,
102
- latest_run.completion_check_summary AS latest_run_completion_check_summary,
103
- latest_run.completion_check_question AS latest_run_completion_check_question,
104
- latest_run.completion_check_why AS latest_run_completion_check_why,
105
- latest_run.completion_check_recommended_reply AS latest_run_completion_check_recommended_reply,
106
- (
107
- SELECT COUNT(*)
108
- FROM issue_session_events e
109
- WHERE e.project_id = s.project_id
110
- AND e.linear_issue_id = s.linear_issue_id
111
- AND e.processed_at IS NULL
112
- ) AS pending_session_event_count,
113
- (
114
- SELECT COUNT(*)
115
- FROM issue_dependencies d
116
- LEFT JOIN issues blockers
117
- ON blockers.project_id = d.project_id
118
- AND blockers.linear_issue_id = d.blocker_linear_issue_id
119
- WHERE d.project_id = s.project_id
120
- AND d.linear_issue_id = s.linear_issue_id
121
- AND (
122
- COALESCE(blockers.current_linear_state_type, d.blocker_current_linear_state_type, '') != 'completed'
123
- AND LOWER(TRIM(COALESCE(blockers.current_linear_state, d.blocker_current_linear_state, ''))) != 'done'
124
- )
125
- ) AS blocked_by_count,
126
- (
127
- SELECT json_group_array(COALESCE(blockers.issue_key, d.blocker_issue_key, d.blocker_linear_issue_id))
128
- FROM issue_dependencies d
129
- LEFT JOIN issues blockers
130
- ON blockers.project_id = d.project_id
131
- AND blockers.linear_issue_id = d.blocker_linear_issue_id
132
- WHERE d.project_id = s.project_id
133
- AND d.linear_issue_id = s.linear_issue_id
134
- AND (
135
- COALESCE(blockers.current_linear_state_type, d.blocker_current_linear_state_type, '') != 'completed'
136
- AND LOWER(TRIM(COALESCE(blockers.current_linear_state, d.blocker_current_linear_state, ''))) != 'done'
137
- )
138
- ) AS blocked_by_keys_json
139
- FROM issue_sessions s
140
- LEFT JOIN issues i
141
- ON i.project_id = s.project_id
142
- AND i.linear_issue_id = s.linear_issue_id
143
- LEFT JOIN runs active_run ON active_run.id = COALESCE(s.active_run_id, i.active_run_id)
144
- LEFT JOIN runs latest_run ON latest_run.id = (
145
- SELECT r.id FROM runs r
146
- WHERE r.project_id = s.project_id AND r.linear_issue_id = s.linear_issue_id
147
- ORDER BY r.id DESC LIMIT 1
148
- )
149
- ORDER BY s.display_updated_at DESC, s.issue_key ASC`)
150
- .all();
81
+ const rows = this.db.issueSessions.listTrackedIssueRows();
151
82
  return rows.map((row) => {
152
83
  const failureContext = parseGitHubFailureContext(typeof row.last_github_failure_context_json === "string" ? row.last_github_failure_context_json : undefined);
153
84
  const prChecksSummary = parseCiSnapshotSummary(typeof row.last_github_ci_snapshot_json === "string" ? row.last_github_ci_snapshot_json : undefined);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "patchrelay",
3
- "version": "0.74.4",
3
+ "version": "0.74.5",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "repository": {