Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

fix([issue-13198]): link GitHub deployment approvals to the run waiting on you

Adam Eivy8039ee272509
diff --git a/client/src/components/github/GitHubInboxTab.jsx b/client/src/components/github/GitHubInboxTab.jsx
index becb8ebbe8..8ea88d4115 100644
--- a/client/src/components/github/GitHubInboxTab.jsx
+++ b/client/src/components/github/GitHubInboxTab.jsx
@@ -2,7 +2,7 @@ import { useCallback, useEffect, useRef, useState } from 'react';
import { Link, useParams } from 'react-router';
import {
Bell, BellOff, Bot, Check, CheckCheck, CheckCircle2, CircleDot, CircleX, ExternalLink, GitCommitHorizontal, GitPullRequest,
- Inbox, Layers, Mail, MailX, MessagesSquare, RefreshCw, ShieldAlert, Tag,
+ Inbox, Layers, Mail, MailX, MessagesSquare, RefreshCw, Rocket, ShieldAlert, Tag,
} from 'lucide-react';
import Pill from '../ui/Pill';
import OverflowMenu from '../ui/OverflowMenu';
@@ -24,6 +24,7 @@ import {
// GitHub's `reason` vocabulary, phrased for a glance.
const REASON_LABELS = {
+ approval_requested: 'Deploy approval',
assign: 'Assigned',
author: 'You opened',
ci_activity: 'CI',
@@ -75,6 +76,7 @@ const KIND_VIEW = {
Discussion: { icon: MessagesSquare, label: 'Discussion', className: 'text-gray-300' },
Commit: { icon: GitCommitHorizontal, label: 'Commit', className: 'text-gray-300' },
RepositoryInvitation: { icon: Mail, label: 'Invitation', className: 'text-gray-300' },
+ WorkflowRun: { icon: Rocket, label: 'Workflow run', className: 'text-port-warning' },
};
const SECURITY_KIND = { icon: ShieldAlert, label: 'Security alert', className: 'text-port-error' };
const kindOf = (notification) => (notification.reason === 'security_alert'
@@ -175,6 +177,13 @@ function NotificationRow({ notification, accountLabel, busy, onAction }) {
<span className="shrink-0">· {timeAgo(notification.updatedAt)}</span>
{accountLabel && <span className="shrink-0">· {accountLabel}</span>}
</div>
+ {notification.deployment && (
+ <p className="mt-1 min-w-0 break-words text-xs text-gray-300">
+ <span className="text-white">{notification.deployment.name}</span>
+ {notification.deployment.headBranch && <> on <span className="font-mono">{notification.deployment.headBranch}</span></>}
+ {notification.deployment.displayTitle && <> · {notification.deployment.displayTitle}</>}
+ </p>
+ )}
<div className="mt-1.5 flex flex-wrap items-center gap-1.5">
{decision && <Pill tone={decision.tone}>{decision.label}</Pill>}
{notification.yourRepo && <Pill tone="accent">Your repo</Pill>}
diff --git a/client/src/components/github/githubTriageLabels.js b/client/src/components/github/githubTriageLabels.js
index 0d2e4f466b..4d20291a13 100644
--- a/client/src/components/github/githubTriageLabels.js
+++ b/client/src/components/github/githubTriageLabels.js
@@ -24,6 +24,7 @@ export const TRUST_VIEW = {
export const RULE_LABELS = {
'spam-signal': 'A spam check matched, so nothing will act on it automatically',
'security-alert': 'Security alerts always surface first',
+ 'deployment-approval': 'A deployment is waiting for your approval',
'invitation-never-accepted': 'Invitations surface and are never accepted automatically',
'finished-thread': 'The issue or pull request is already closed or merged',
'ci-default-branch': 'CI failed on the default branch',
diff --git a/client/src/pages/GitHub.test.jsx b/client/src/pages/GitHub.test.jsx
index f8dd447902..80ecdb266a 100644
--- a/client/src/pages/GitHub.test.jsx
+++ b/client/src/pages/GitHub.test.jsx
@@ -406,6 +406,21 @@ describe('GitHub inbox tab', () => {
expect(mock.getGitHubRepos).not.toHaveBeenCalled();
});
+ it('links a deployment approval to the run waiting on you', async () => {
+ const runUrl = 'https://github.com/octocat/hello/actions/runs/4242';
+ mock.getGitHubNotifications.mockResolvedValue({
+ notifications: [{
+ ...NOTIFICATION, reason: 'approval_requested', subjectType: 'WorkflowRun', title: 'Someone requested your review to deploy to an environment',
+ decision: 'surface-high', htmlUrl: runUrl, deployment: { runId: 4242, name: 'Deploy (prod)', headBranch: 'main', displayTitle: 'Example change', htmlUrl: runUrl },
+ }],
+ sync: {},
+ });
+ renderTab('inbox');
+ expect(await screen.findByText('Deploy approval')).toBeTruthy();
+ expect(screen.getByText('Deploy (prod)')).toBeTruthy();
+ expect(screen.getByRole('link', { name: 'Open' }).getAttribute('href')).toBe(runUrl);
+ });
+
it('marks a thread done and takes it out of the inbox', async () => {
mock.applyGitHubNotificationAction.mockResolvedValue({ ...NOTIFICATION, state: 'done', unread: false });
renderTab('inbox');
diff --git a/server/lib/githubNotificationParse.js b/server/lib/githubNotificationParse.js
index 539806a75f..589086279d 100644
--- a/server/lib/githubNotificationParse.js
+++ b/server/lib/githubNotificationParse.js
@@ -88,6 +88,13 @@ function notificationHtmlUrl({ subjectApiUrl, repoFullName }, host) {
return SUBJECT_PATHS[kind] ? `${repoUrl}/${SUBJECT_PATHS[kind]}/${id}` : repoUrl;
}
+/** The page of a workflow run on the account's own host, or null for a malformed repo or id. */
+export function workflowRunHtmlUrl(repoFullName, runId, host) {
+ const [owner, repo] = String(repoFullName || '').split('/');
+ if (!REPO_PART_RE.test(owner || '') || !REPO_PART_RE.test(repo || '') || !Number.isInteger(runId) || runId <= 0) return null;
+ return `https://${webHostFor(host)}/${owner}/${repo}/actions/runs/${runId}`;
+}
+
const rawThreadSchema = z.object({
id: z.string().regex(THREAD_ID_RE),
unread: z.boolean(),
diff --git a/server/lib/githubNotificationTriage.js b/server/lib/githubNotificationTriage.js
index 22350e013f..1c1a3db95c 100644
--- a/server/lib/githubNotificationTriage.js
+++ b/server/lib/githubNotificationTriage.js
@@ -36,7 +36,7 @@ export const TRUST_LEVELS = Object.freeze(['yours', 'trusted', 'outside', 'unkno
// Bump when a rule change should re-decide threads that have no new activity;
// open threads triaged under an older version are triaged again.
-export const TRIAGE_RULES_VERSION = 4;
+export const TRIAGE_RULES_VERSION = 5;
// Open threads with nothing left for you: closed or merged, folded into a
// newer CI notice, or owned by a PR workflow. They stay in the inbox (it
@@ -91,16 +91,23 @@ export function parseCiBranch(title) {
/**
* One decision from the fixed rule table (reason × source). First match wins:
- * suspect, security alert, invitation, your own PR in a managed repo,
+ * suspect, security alert, deployment approval, invitation, your own PR in a managed repo,
* finished thread, CI, review request, mention elsewhere, then Needs you.
*
* `commenterTrust` is the latest commenter's trust when it differs from the
* subject author. Activity on your own PR goes to the PR workflow that opened
* and drives it, unless someone outside commented: that waits for you.
*/
-export function decideThread({ reason, subjectType, subjectState, subjectMerged = false, trust, commenterTrust = null, suspect = false, repoOwned = false, repoManaged = false, ciBranch = null, defaultBranch = null }) {
+export function decideThread({ reason, subjectType, subjectState, subjectMerged = false, trust, commenterTrust = null, suspect = false, repoOwned = false, repoManaged = false, ciBranch = null, defaultBranch = null, deploymentWaiting = null }) {
if (suspect) return { decision: 'suspect', rule: 'spam-signal' };
if (reason === 'security_alert') return { decision: 'surface-high', rule: 'security-alert' };
+ // `deploymentWaiting` is null when the forge could not be asked: a
+ // deployment that may still be blocked on you is never assumed finished.
+ if (reason === 'approval_requested' && subjectType === 'WorkflowRun') {
+ return deploymentWaiting === false
+ ? { decision: 'suggest-mark-read', rule: 'finished-thread' }
+ : { decision: 'surface-high', rule: 'deployment-approval' };
+ }
if (reason === 'invitation') return { decision: 'surface', rule: 'invitation-never-accepted' };
if (reason === 'author' && subjectType === 'PullRequest' && trust === 'yours' && repoManaged && commenterTrust !== 'outside') {
return { decision: 'handled-by-pr-workflow', rule: 'own-pr-in-managed-repo' };
@@ -121,6 +128,32 @@ export function decideThread({ reason, subjectType, subjectState, subjectMerged
return { decision: 'needs-you', rule: 'default' };
}
+/**
+ * The waiting run a deployment-approval thread is about. GitHub gives the
+ * thread no subject url; its `updated_at` is the run's at the request. A run
+ * re-requested later is still the one waiting across that time. `undefined`
+ * when the runs could not be read.
+ */
+export function matchWaitingRun(runs, threadUpdatedAt) {
+ if (!Array.isArray(runs)) return undefined;
+ const at = new Date(threadUpdatedAt).getTime();
+ const time = (value) => Date.parse(value || '');
+ const valid = runs.filter((entry) => Number.isInteger(entry?.id) && entry.id > 0);
+ return valid.find((entry) => time(entry.updatedAt) === at)
+ || valid.filter((entry) => time(entry.createdAt) <= at && at <= time(entry.updatedAt))
+ .sort((a, b) => time(b.createdAt) - time(a.createdAt))[0]
+ || null;
+}
+
+/** The run fields the inbox shows, bounded; display only, never trust. */
+export const workflowRunEvidence = (entry) => ({
+ id: entry.id,
+ name: typeof entry.name === 'string' ? entry.name.slice(0, 200) : null,
+ displayTitle: typeof entry.displayTitle === 'string' ? entry.displayTitle.slice(0, 300) : null,
+ headBranch: typeof entry.headBranch === 'string' ? entry.headBranch.slice(0, 255) : null,
+ event: typeof entry.event === 'string' ? entry.event.slice(0, 50) : null,
+});
+
// What a model may answer for a thread the rule table left undecided. Any
// other output fails the response schema and the thread stays with you.
export const ASSIST_VERDICTS = Object.freeze(['surface', 'done', 'suggest-mute']);
@@ -134,7 +167,7 @@ export function decisionFromVerdict(verdict) {
// A learned rule replays the operator's own choice for a repo, reason and
// actor; it never overrides a spam signal, a security alert or an invitation.
const LEARNED_DECISIONS = Object.freeze(['surface', 'suggest-done', 'suggest-mute']);
-const PINNED_RULES = new Set(['spam-signal', 'security-alert', 'invitation-never-accepted']);
+const PINNED_RULES = new Set(['spam-signal', 'security-alert', 'invitation-never-accepted', 'deployment-approval']);
const ACTION_LESSONS = Object.freeze({ done: 'suggest-done', unsubscribe: 'suggest-done', mute: 'suggest-mute', reopen: 'surface', resubscribe: 'surface' });
/** The decision an operator action teaches, or null when it teaches nothing (a plain read). */
diff --git a/server/lib/githubNotificationTriage.test.js b/server/lib/githubNotificationTriage.test.js
index 28cc0281eb..9e0b1b57ec 100644
--- a/server/lib/githubNotificationTriage.test.js
+++ b/server/lib/githubNotificationTriage.test.js
@@ -1,6 +1,6 @@
import { describe, it, expect } from 'vitest';
import {
- agentHandoff, agentRuleScope, applyLearnedRule, assistAction, autopilotHandoff, computeThreadTrust, decideThread, decisionFromVerdict, parseCiBranch,
+ agentHandoff, agentRuleScope, applyLearnedRule, assistAction, autopilotHandoff, computeThreadTrust, decideThread, decisionFromVerdict, matchWaitingRun, parseCiBranch,
selectNotificationProvider, spamSignals,
MASS_MENTION_THRESHOLD,
} from './githubNotificationTriage.js';
@@ -74,6 +74,15 @@ describe('decideThread', () => {
expect(decide({ reason: 'assign', repoOwned: true })).toBe('needs-you');
});
+ it('keeps a deployment approval in front of you until the forge says its run stopped waiting', () => {
+ const deploy = { reason: 'approval_requested', subjectType: 'WorkflowRun', trust: 'yours' };
+ expect(decideThread({ ...deploy, deploymentWaiting: true })).toEqual({ decision: 'surface-high', rule: 'deployment-approval' });
+ expect(decideThread({ ...deploy, deploymentWaiting: null })).toEqual({ decision: 'surface-high', rule: 'deployment-approval' });
+ expect(decideThread({ ...deploy, deploymentWaiting: false })).toEqual({ decision: 'suggest-mark-read', rule: 'finished-thread' });
+ // Neither the operator's past Done taps nor a model can quiet one.
+ expect(applyLearnedRule({ decision: 'surface-high', rule: 'deployment-approval' }, { decision: 'suggest-done', hits: 5 }).rule).toBe('deployment-approval');
+ });
+
it('leaves activity on your own PR in a managed repo to its PR workflow unless someone outside commented', () => {
const ownPr = { reason: 'author', subjectType: 'PullRequest', trust: 'yours', repoOwned: true, repoManaged: true };
expect(decideThread(ownPr)).toEqual({ decision: 'handled-by-pr-workflow', rule: 'own-pr-in-managed-repo' });
@@ -90,6 +99,23 @@ describe('decideThread', () => {
});
});
+describe('matchWaitingRun', () => {
+ const run = (id, createdAt, updatedAt) => ({ id, createdAt, updatedAt });
+ const at = '2026-10-01T10:00:00Z';
+
+ it('matches the run updated when the approval was requested, else the newest one waiting across that time', () => {
+ expect(matchWaitingRun([run(1, '2026-10-01T08:00:00Z', '2026-10-01T11:00:00Z'), run(2, '2026-10-01T09:00:00Z', at)], at).id).toBe(2);
+ expect(matchWaitingRun([run(1, '2026-10-01T08:00:00Z', '2026-10-01T11:00:00Z'), run(3, '2026-10-01T09:30:00Z', '2026-10-01T12:00:00Z')], at).id).toBe(3);
+ });
+
+ it('says none is waiting only when the forge answered, and ignores a malformed run', () => {
+ expect(matchWaitingRun([run(1, '2026-10-01T11:00:00Z', '2026-10-01T12:00:00Z')], at)).toBeNull();
+ expect(matchWaitingRun([], at)).toBeNull();
+ expect(matchWaitingRun([run('x', '2026-10-01T09:00:00Z', at)], at)).toBeNull();
+ expect(matchWaitingRun(null, at)).toBeUndefined();
+ });
+});
+
describe('parseCiBranch', () => {
it('reads the branch from GitHub Actions notice titles', () => {
expect(parseCiBranch('CI workflow run failed for main branch')).toBe('main');
diff --git a/server/services/githubNotificationTriage.js b/server/services/githubNotificationTriage.js
index 26389f904f..af0e5a63c5 100644
--- a/server/services/githubNotificationTriage.js
+++ b/server/services/githubNotificationTriage.js
@@ -12,7 +12,7 @@
*/
import { query, withTransaction } from '../lib/db.js';
import { repoApiPath } from '../lib/githubNotificationParse.js';
-import { applyLearnedRule, computeThreadTrust, decideThread, parseCiBranch, spamSignals, TRIAGE_RULES_VERSION } from '../lib/githubNotificationTriage.js';
+import { applyLearnedRule, computeThreadTrust, decideThread, matchWaitingRun, parseCiBranch, spamSignals, TRIAGE_RULES_VERSION, workflowRunEvidence } from '../lib/githubNotificationTriage.js';
import { parseGitRemoteUrl, readOriginRemoteUrl } from '../lib/gitRemote.js';
import { safeJSONParse } from '../lib/fileUtils.js';
import { toPgJson } from '../lib/pgJson.js';
@@ -27,14 +27,20 @@ const MAX_THREADS_PER_RUN = 60;
// Open threads a rules-version bump re-decides without new activity: version 2
// changed your own PRs and finished threads (now marked done, not just read);
// version 3 leaves a bot's comment on your own PR to the PR workflow; version
-// 4 finishes a review request on a merged or closed PR. A thread
+// 4 finishes a review request on a merged or closed PR; version 5 matches a
+// deployment approval to its waiting run. A thread
// already handed off keeps its hand-off. One an Assist model sorted is not
// read again, except your own PR: the rule table decides those, so a verdict
// from before the rule existed must not keep one in front of you.
const REDECIDE_SQL = `(state = 'open' AND NOT (evidence ? 'handoff')
AND ((reason = 'author' AND subject_type = 'PullRequest' AND trust = 'yours')
OR (decision = 'suggest-mark-read' AND COALESCE(evidence->>'rule', '') NOT LIKE 'ai-%')
- OR (reason = 'review_requested' AND evidence->>'subjectState' IN ('merged', 'closed'))))`;
+ OR (reason = 'review_requested' AND evidence->>'subjectState' IN ('merged', 'closed'))
+ OR reason = 'approval_requested'))`;
+// A deployment waiting on you is re-checked every sync: approving or rejecting
+// it on GitHub does not touch the notification thread.
+const WAITING_DEPLOYMENT_SQL = "(state = 'open' AND evidence->>'rule' = 'deployment-approval')";
+const WAITING_RUNS_JQ = '[.workflow_runs[] | {id, name, displayTitle: .display_title, headBranch: .head_branch, event, actor: .actor.login, createdAt: .created_at, updatedAt: .updated_at}]';
const LOGIN_RE = /^[A-Za-z0-9][A-Za-z0-9_-]{0,99}(?:\[bot\])?$/;
const REPO_RE = /^[A-Za-z0-9_.-]{1,100}\/[A-Za-z0-9_.-]{1,100}$/;
@@ -80,6 +86,9 @@ function createReader(account, env) {
runGh: (args) => execGh(args, GH_TIMEOUT_MS, { env }), host, repoFullName: repo, currentUser: null,
})),
viewer: () => once('viewer', () => run(['user', '--jq', '.login']).then((out) => loginOrNull(out.trim())).catch(() => null)),
+ // null when the forge could not be read, so a failure is never "none waiting".
+ waitingRuns: (repo) => once(`w:${repo}`, () => json(`repos/${repo}/actions/runs?status=waiting&per_page=50`, WAITING_RUNS_JQ)
+ .then((runs) => (Array.isArray(runs) ? runs : null))),
};
}
@@ -114,9 +123,12 @@ async function triageThread(row, ctx) {
const comment = commentPath && commentPath !== subjectPath ? await reader.comment(commentPath) : null;
const subjectAuthor = loginOrNull(subject?.author);
const commenter = loginOrNull(comment?.author);
- // Trust attaches to the subject's author; a later commenter can only add
- // suspicion, never lift an outside PR into the trusted lane.
- const actorLogin = subjectAuthor || commenter;
+ const isDeployment = row.reason === 'approval_requested' && row.subject_type === 'WorkflowRun';
+ const waitingRun = isDeployment && repo ? matchWaitingRun(await reader.waitingRuns(repo), row.gh_updated_at) : undefined;
+ // Trust attaches to the subject's author (for a deployment, whoever started
+ // the run); a later commenter can only add suspicion, never lift an outside
+ // PR into the trusted lane.
+ const actorLogin = subjectAuthor || loginOrNull(waitingRun?.actor) || commenter;
const trustOf = async (login) => {
const isOwn = ownLogins.some((own) => own.toLowerCase() === login.toLowerCase());
@@ -178,6 +190,7 @@ async function triageThread(row, ctx) {
repoManaged,
ciBranch,
defaultBranch,
+ deploymentWaiting: waitingRun === undefined ? null : Boolean(waitingRun),
});
const { decision, rule } = applyLearnedRule(tabled, learnedRules.get(learnedRuleKey(row.repo_full_name, row.reason, actorLogin)));
return {
@@ -193,7 +206,8 @@ async function triageThread(row, ctx) {
repoManaged,
subjectState: subject ? (subject.merged === true ? 'merged' : subject.state || null) : null,
ciBranch,
- metadataMissing: Boolean(subjectPath && !subject),
+ metadataMissing: Boolean(subjectPath && !subject) || (isDeployment && waitingRun === undefined),
+ ...(waitingRun ? { workflowRun: workflowRunEvidence(waitingRun) } : {}),
rulesVersion: TRIAGE_RULES_VERSION,
},
};
@@ -230,7 +244,7 @@ async function foldCiDuplicates(client, accountId) {
export async function triageAccountNotifications(account, env, { now = Date.now() } = {}) {
const { rows } = await query(
`SELECT * FROM github_notifications WHERE account_id = $1 AND (triaged_for IS NULL OR triaged_for < gh_updated_at
- OR (${REDECIDE_SQL} AND COALESCE((evidence->>'rulesVersion')::int, 0) < $2))
+ OR (${REDECIDE_SQL} AND COALESCE((evidence->>'rulesVersion')::int, 0) < $2) OR ${WAITING_DEPLOYMENT_SQL})
ORDER BY gh_updated_at DESC LIMIT ${MAX_THREADS_PER_RUN}`,
[account.id, TRIAGE_RULES_VERSION],
);
diff --git a/server/services/githubNotifications.db.test.js b/server/services/githubNotifications.db.test.js
index 4c2c4d40a3..c0616723bd 100644
--- a/server/services/githubNotifications.db.test.js
+++ b/server/services/githubNotifications.db.test.js
@@ -372,6 +372,41 @@ describe.skipIf(!runDb)('GitHub notifications inbox against Postgres', () => {
expect((await listNotifications({ accountId: account.id })).notifications.map((row) => row.threadId)).toEqual(['702']);
});
+ it('links a deployment approval to its waiting run, keeps it in front of you, and clears it once the run stops waiting', async () => {
+ await updateAccount(account.id, { mode: 'assist' });
+ const login = account.login;
+ const requestedAt = '2026-10-01T10:00:00Z';
+ const runsPath = `repos/${login}/hello/actions/runs?status=waiting&per_page=50`;
+ const waiting = (updatedAt) => [{ id: 4242, name: 'Deploy (prod)', displayTitle: 'Example change', headBranch: 'main', event: 'push', actor: login, createdAt: '2026-10-01T09:00:00Z', updatedAt }];
+ // A run waiting elsewhere in time is not this thread's.
+ const forge = { [runsPath]: [{ ...waiting(requestedAt)[0], id: 77, createdAt: '2026-09-01T09:00:00Z', updatedAt: '2026-09-01T10:00:00Z' }, ...waiting(requestedAt)] };
+ const actions = mockGh(() => listing([
+ thread('2101', { owner: login, reason: 'approval_requested', type: 'WorkflowRun', url: null, updatedAt: requestedAt, title: 'Someone requested your review to deploy to an environment' }),
+ ]), forge);
+
+ await syncAccountNotifications(account.id);
+ const [row] = (await listNotifications({ accountId: account.id })).notifications;
+ expect(row).toMatchObject({
+ decision: 'surface-high',
+ rule: 'deployment-approval',
+ htmlUrl: `https://github.com/${login}/hello/actions/runs/4242`,
+ deployment: { runId: 4242, name: 'Deploy (prod)', headBranch: 'main' },
+ });
+ expect(actions).toEqual([]);
+
+ // An unreadable run list never counts as "no longer waiting".
+ delete forge[runsPath];
+ await syncAccountNotifications(account.id);
+ expect(await getNotification(account.id, '2101')).toMatchObject({ decision: 'surface-high', state: 'open' });
+
+ // Approved on GitHub: the run leaves the waiting list and the thread is finished.
+ forge[runsPath] = [];
+ await syncAccountNotifications(account.id);
+ expect(await getNotification(account.id, '2101')).toMatchObject({ decision: 'suggest-mark-read', state: 'done' });
+ expect(actions).toEqual([['DELETE', 'notifications/threads/2101']]);
+ await updateAccount(account.id, { mode: 'observe' });
+ });
+
it('sorts undecided threads only in Assist, acts only on trusted ones, and undoes into a learned rule', async () => {
const login = account.login;
const pr = (author, state = 'open', merged = false) => ({ author, association: 'NONE', state, merged });
diff --git a/server/services/githubNotifications.js b/server/services/githubNotifications.js
index 2b19feb9e9..72c5c47ce4 100644
--- a/server/services/githubNotifications.js
+++ b/server/services/githubNotifications.js
@@ -17,6 +17,7 @@ import {
parseGhIncludeOutput,
pollIntervalSeconds,
toNotificationRecord,
+ workflowRunHtmlUrl,
} from '../lib/githubNotificationParse.js';
import { execGh } from './github.js';
import { getAccount, listAccounts, resolveGitHubAccountEnv } from './githubAccounts.js';
@@ -315,9 +316,17 @@ const agentView = (account, row) => {
return plan ? { lane: plan.lane, refused: plan.refused || null, pin: plan.pin || null } : null;
};
+// A deployment approval's thread has no subject url; triage found its run.
+const deploymentView = (account, row) => {
+ const run = row.evidence?.workflowRun;
+ const htmlUrl = account && run ? workflowRunHtmlUrl(row.repo_full_name, run.id, account.host) : null;
+ return htmlUrl ? { runId: run.id, name: run.name, displayTitle: run.displayTitle, headBranch: run.headBranch, htmlUrl } : null;
+};
+
const toApi = (row, accountsById) => {
const account = accountsById.get(row.account_id);
const login = account?.login?.toLowerCase();
+ const deployment = row.state === 'open' ? deploymentView(account, row) : null;
return {
accountId: row.account_id,
threadId: row.thread_id,
@@ -327,7 +336,8 @@ const toApi = (row, accountsById) => {
reason: row.reason,
subjectType: row.subject_type,
title: row.subject_title,
- htmlUrl: row.html_url,
+ htmlUrl: deployment?.htmlUrl || row.html_url,
+ deployment,
unread: row.unread,
readOnGithub: Boolean(row.read_on_github_at) && row.state === 'open',
state: row.state,