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

feat: show why a GitHub inbox thread needs you and what state it is in (#13359)

[._.]/3b891cce1482
diff --git a/client/src/components/github/GitHubInboxTab.jsx b/client/src/components/github/GitHubInboxTab.jsx
index ebe0b49a6d..dd9bc65d17 100644
--- a/client/src/components/github/GitHubInboxTab.jsx
+++ b/client/src/components/github/GitHubInboxTab.jsx
@@ -1,7 +1,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,
+ Bell, BellOff, Bot, Check, CheckCheck, CheckCircle2, CircleDot, CircleX, ExternalLink, GitCommitHorizontal, GitMerge, GitPullRequest, GitPullRequestClosed, GitPullRequestDraft,
Inbox, Layers, ListPlus, Mail, MailX, MessagesSquare, RefreshCw, Rocket, ShieldAlert, Tag,
} from 'lucide-react';
import Pill from '../ui/Pill';
@@ -10,7 +10,7 @@ import GitHubThreadDrawer from './GitHubThreadDrawer';
import GitHubDeploymentReview from './GitHubDeploymentReview';
import GitHubAgentPinForm from './GitHubAgentPinForm';
import GitHubPullRequestActions from './GitHubPullRequestActions';
-import { AGENT_REFUSED_LABELS, DECISION_ACTIONS, DECISION_VIEW, TRUST_VIEW } from './githubTriageLabels';
+import { AGENT_REFUSED_LABELS, DECISION_ACTIONS, DECISION_VIEW, REASON_WHY, TONE_EDGE, TRUST_VIEW, subjectStatusChip } from './githubTriageLabels';
import socket from '../../services/socket';
import LoadFailedState from '../ui/LoadFailedState';
import PageSkeleton from '../ui/PageSkeleton';
@@ -81,9 +81,30 @@ const KIND_VIEW = {
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'
- ? SECURITY_KIND
- : KIND_VIEW[notification.subjectType] || { icon: Bell, label: notification.subjectType || 'Notification', className: 'text-gray-400' });
+// A PR or issue's icon and color follow its state, as on GitHub: green open,
+// gray draft, purple merged or resolved, red closed.
+const STATE_KIND = {
+ PullRequest: {
+ merged: { icon: GitMerge, label: 'Merged pull request', className: 'text-purple-400' },
+ closed: { icon: GitPullRequestClosed, label: 'Closed pull request', className: 'text-port-error' },
+ draft: { icon: GitPullRequestDraft, label: 'Draft pull request', className: 'text-gray-400' },
+ open: { icon: GitPullRequest, label: 'Open pull request', className: 'text-port-success' },
+ },
+ Issue: {
+ merged: { icon: CheckCircle2, label: 'Resolved issue', className: 'text-purple-400' },
+ closed: { icon: CheckCircle2, label: 'Closed issue', className: 'text-purple-400' },
+ open: { icon: CircleDot, label: 'Open issue', className: 'text-port-success' },
+ },
+};
+const kindOf = (notification) => {
+ if (notification.reason === 'security_alert') return SECURITY_KIND;
+ const status = notification.subjectStatus;
+ const byState = STATE_KIND[notification.subjectType];
+ if (byState && status?.state) {
+ return byState[status.state === 'open' && status.draft ? 'draft' : status.state] || byState.open;
+ }
+ return KIND_VIEW[notification.subjectType] || { icon: Bell, label: notification.subjectType || 'Notification', className: 'text-gray-400' };
+};
// Summary tiles double as the view picker. Counts come from the server for
// every view at once; tone follows meaning, and every tile also has a label.
@@ -177,6 +198,8 @@ function NotificationRow({ notification, accountLabel, busy, onAction, onUpdated
const trust = TRUST_VIEW[notification.trust];
const decision = DECISION_VIEW[notification.decision];
const kind = kindOf(notification);
+ const why = REASON_WHY[notification.reason];
+ const statusChip = subjectStatusChip(notification.subjectType, notification.subjectStatus);
// Every open row offers the button; a refused lane disables it with its reason.
const agent = handled ? null : notification.agent;
const canResolve = Boolean(agent) && !agent.refused;
@@ -194,7 +217,7 @@ function NotificationRow({ notification, accountLabel, busy, onAction, onUpdated
...(notification.ruleKind ? [{ id: 'add-rule', label: 'Add automation rule…', icon: ListPlus, to: automationRuleLink(notification) }] : []),
];
return (
- <article className="flex min-w-0 gap-3 px-3 py-3 @3xl/page:px-4">
+ <article className={`flex min-w-0 gap-3 border-l-4 px-3 py-3 @3xl/page:px-4 ${TONE_EDGE[handled ? 'muted' : why?.tone] || TONE_EDGE.muted}`}>
<span className="relative mt-0.5 shrink-0">
<kind.icon size={18} className={kind.className} aria-label={kind.label} role="img" />
{notification.unread && <span className="absolute -right-1 -top-1 h-2 w-2 rounded-full bg-port-accent ring-2 ring-port-card" aria-label="Unread" />}
@@ -208,11 +231,13 @@ function NotificationRow({ notification, accountLabel, busy, onAction, onUpdated
{notification.title}
</Link>
<div className="mt-1 flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1 text-xs text-gray-400">
- <span className="text-gray-300">{REASON_LABELS[notification.reason] || notification.reason}</span>
+ <Pill tone={why?.tone || 'muted'} size="xs">{REASON_LABELS[notification.reason] || notification.reason}</Pill>
+ {statusChip && <Pill tone={statusChip.tone} size="xs">{statusChip.label}</Pill>}
{notification.repoFullName && <span className="min-w-0 truncate font-mono">{notification.repoFullName}</span>}
<span className="shrink-0">· {timeAgo(notification.updatedAt)}</span>
{accountLabel && <span className="shrink-0">· {accountLabel}</span>}
</div>
+ {why && <p className="mt-1 text-xs text-gray-400">{why.text}</p>}
{notification.deployment && (
<p className="mt-1 min-w-0 break-words text-xs text-gray-300">
<span className="text-white">{notification.deployment.name}</span>
diff --git a/client/src/components/github/githubTriageLabels.js b/client/src/components/github/githubTriageLabels.js
index 3cd8f6d024..7678a18ae6 100644
--- a/client/src/components/github/githubTriageLabels.js
+++ b/client/src/components/github/githubTriageLabels.js
@@ -149,3 +149,59 @@ export const SIGNAL_LABELS = {
'mass-mention': 'The latest comment mentions many people',
'unrelated-repo': 'First notification from a repo you have no tie to',
};
+
+// Why you are on a thread, as a sentence plus the color that marks how it asks
+// for action: red needs a fix or a decision now, amber wants a reply, blue wants
+// a review, green is your own work, gray is background.
+export const REASON_WHY = {
+ approval_requested: { tone: 'error', text: 'A deployment is waiting for your approval' },
+ assign: { tone: 'warning', text: 'Assigned to you' },
+ author: { tone: 'success', text: 'You opened this and it has new activity' },
+ ci_activity: { tone: 'error', text: 'A CI run or check finished' },
+ comment: { tone: 'warning', text: 'Someone commented on a thread you follow' },
+ invitation: { tone: 'warning', text: 'You were invited to a repository' },
+ manual: { tone: 'muted', text: 'You subscribed to this thread' },
+ mention: { tone: 'warning', text: 'You were mentioned' },
+ review_requested: { tone: 'accent', text: 'Your review was requested' },
+ security_alert: { tone: 'error', text: 'A security alert on your dependencies' },
+ state_change: { tone: 'muted', text: 'It was opened, closed or merged' },
+ subscribed: { tone: 'muted', text: 'You are watching this repository' },
+ team_mention: { tone: 'warning', text: 'Your team was mentioned' },
+};
+
+// The row's left accent edge per tone.
+export const TONE_EDGE = {
+ error: 'border-l-port-error',
+ warning: 'border-l-port-warning',
+ accent: 'border-l-port-accent',
+ success: 'border-l-port-success',
+ muted: 'border-l-port-border',
+};
+
+// GitHub's mergeable_state for an open PR, as what it means for you.
+export const MERGE_STATE_VIEW = {
+ clean: { tone: 'success', label: 'Ready to merge' },
+ has_hooks: { tone: 'success', label: 'Ready to merge' },
+ unstable: { tone: 'warning', label: 'Checks failing' },
+ blocked: { tone: 'error', label: 'Blocked: needs review or checks' },
+ behind: { tone: 'warning', label: 'Behind base branch' },
+ dirty: { tone: 'error', label: 'Merge conflicts' },
+ draft: { tone: 'muted', label: 'Draft' },
+};
+
+/**
+ * The state chip for a thread's issue or pull request, or null when the forge
+ * did not report one (CI, releases, invitations).
+ */
+export function subjectStatusChip(subjectType, status) {
+ if (!status?.state) return null;
+ if (status.state === 'merged') return { tone: 'accent', label: 'Merged', key: 'merged' };
+ // A closed issue is resolved work (the row icon is purple); only an unmerged closed PR reads as a failure.
+ if (status.state === 'closed') return { tone: subjectType === 'PullRequest' ? 'error' : 'muted', label: 'Closed', key: 'closed' };
+ if (subjectType === 'PullRequest' && status.draft) return { tone: 'muted', label: 'Draft', key: 'draft' };
+ if (subjectType === 'PullRequest') {
+ const merge = MERGE_STATE_VIEW[status.mergeState];
+ return merge ? { ...merge, key: status.mergeState } : { tone: 'success', label: 'Open', key: 'open' };
+ }
+ return status.state === 'open' ? { tone: 'success', label: 'Open', key: 'open' } : null;
+}
diff --git a/client/src/pages/GitHub.test.jsx b/client/src/pages/GitHub.test.jsx
index 40b950daa7..7b4d1a13aa 100644
--- a/client/src/pages/GitHub.test.jsx
+++ b/client/src/pages/GitHub.test.jsx
@@ -449,6 +449,15 @@ describe('GitHub inbox tab', () => {
mock.getGitHubNotifications.mockResolvedValue({ notifications: [NOTIFICATION], sync: {} });
});
+ it('says why a thread is here and what state its pull request is in', async () => {
+ mock.getGitHubNotifications.mockResolvedValue({ notifications: [{ ...NOTIFICATION,
+ subjectStatus: { state: 'open', draft: false, mergeState: 'blocked' } }], sync: {} });
+ await renderInbox();
+ expect(screen.getByText('Your review was requested')).toBeTruthy();
+ expect(screen.getByText('Blocked: needs review or checks')).toBeTruthy();
+ expect(screen.getByRole('img', { name: 'Open pull request' })).toBeTruthy();
+ });
+
it('uses the shared PR merge choices and applies a successful merge to the inbox immediately', async () => {
const notification = { ...NOTIFICATION, ruleKind: 'dependabot-pr', trust: 'trusted',
pullRequestAction: { action: 'do-review', taskId: 'previous-review' },
diff --git a/server/lib/githubNotificationTriage.js b/server/lib/githubNotificationTriage.js
index f5d9ef5f28..fcb6d7b160 100644
--- a/server/lib/githubNotificationTriage.js
+++ b/server/lib/githubNotificationTriage.js
@@ -45,7 +45,7 @@ export const notificationAgentAccountBinding = (account, origin = 'user') => ({
// 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 = 8;
+export const TRIAGE_RULES_VERSION = 9;
// 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
diff --git a/server/services/githubNotificationTriage.js b/server/services/githubNotificationTriage.js
index 3814a7677c..0b2a16eeb2 100644
--- a/server/services/githubNotificationTriage.js
+++ b/server/services/githubNotificationTriage.js
@@ -30,7 +30,8 @@ const MAX_THREADS_PER_RUN = 60;
// 4 finishes a review request on a merged or closed PR; version 5 matches a
// deployment approval to its waiting run; version 6 trusts GitHub's own bots
// and, where the account opts in, everyone on an Enterprise instance; version 7
-// re-checks commenter trust on legacy commented threads (#13213). A thread
+// re-checks commenter trust on legacy commented threads (#13213); version 9
+// records a PR's draft and merge state for the inbox row. A thread
// handed off keeps its hand-off; one whose hand-off was refused (a Private
// account without agents) is re-decided like any other. One an Assist model sorted is not
// read again, except your own PR: the rule table decides those, so a verdict
@@ -50,7 +51,7 @@ const WAITING_RUNS_JQ = '[.workflow_runs[] | {id, name, displayTitle: .display_t
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}$/;
-const SUBJECT_JQ = '{author: .user.login, authorType: .user.type, association: .author_association, state: .state, merged: (.merged // false)}';
+const SUBJECT_JQ = '{author: .user.login, authorType: .user.type, association: .author_association, state: .state, merged: (.merged // false), draft: (.draft // false), mergeableState: .mergeable_state}';
const COMMENT_JQ = '{author: .user.login, authorType: .user.type, association: .author_association, mentions: ([(.body // "") | scan("@[A-Za-z0-9][A-Za-z0-9-]*")] | length)}';
const isBotLogin = (login) => /\[bot\]$/i.test(login);
@@ -262,6 +263,8 @@ async function triageThread(row, ctx) {
repoOwned,
repoManaged,
subjectState: subject ? (subject.merged === true ? 'merged' : subject.state || null) : null,
+ subjectDraft: subject?.draft === true,
+ mergeState: typeof subject?.mergeableState === 'string' ? subject.mergeableState : null,
ciBranch,
metadataMissing: Boolean(subjectPath && !subject) || (isDeployment && waitingRun === undefined),
...(waitingRun ? { workflowRun: workflowRunEvidence(waitingRun) } : {}),
diff --git a/server/services/githubNotifications.js b/server/services/githubNotifications.js
index 18adcb3af5..431f2a6513 100644
--- a/server/services/githubNotifications.js
+++ b/server/services/githubNotifications.js
@@ -337,6 +337,15 @@ const deploymentView = (account, row) => {
return htmlUrl ? { runId: run.id, name: run.name, displayTitle: run.displayTitle, headBranch: run.headBranch, htmlUrl } : null;
};
+// The thread's own state, so a row says what it is now: open, draft, merged,
+// closed, and for an open PR GitHub's merge readiness (clean, blocked, ...).
+// Null mergeState: GitHub had not computed it yet, or the thread is no PR.
+const subjectStatusView = (row) => {
+ const evidence = row.evidence || {};
+ if (!evidence.subjectState) return null;
+ return { state: evidence.subjectState, draft: evidence.subjectDraft === true, mergeState: evidence.mergeState || null };
+};
+
const toApi = (row, accountsById) => {
const account = accountsById.get(row.account_id);
const login = account?.login?.toLowerCase();
@@ -359,6 +368,7 @@ const toApi = (row, accountsById) => {
trust: row.trust || null,
suspect: row.suspect === true,
rule: row.evidence?.rule || null,
+ subjectStatus: subjectStatusView(row),
signals: Array.isArray(row.evidence?.signals) ? row.evidence.signals : [],
// The automation-rule kind, so a row can prefill Add automation rule (#13192).
ruleKind: threadAgentKind(row),