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
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
fix: mark a GitHub notification done once its PR merge is confirmed (#13336)
[._.]/268a92b80103
diff --git a/server/services/githubNotificationPullRequest.js b/server/services/githubNotificationPullRequest.jsindex 4bc1490aac..f08326e176 100644--- a/server/services/githubNotificationPullRequest.js+++ b/server/services/githubNotificationPullRequest.js@@ -8,7 +8,7 @@ import { PULL_REQUEST_ACTIONS } from '../../lib/pullRequestActions.js';import { readGithubPullRequest } from './appPullRequests.js';import { mergeGithubPullRequest, pullRequestMergeReadiness } from './appPullRequestMerge.js';import { managedAppsByRepoKey } from './githubNotificationTriage.js';-import { requireAccountEnv } from './githubNotifications.js';+import { applyNotificationAction, requireAccountEnv } from './githubNotifications.js';import { githubNotificationEvents } from './githubNotificationEvents.js';import { githubReviewAccountSelector } from './githubAccounts.js';import { ON_DEMAND_ORIGINS } from './taskScheduleConstants.js';@@ -95,6 +95,13 @@ export async function actOnNotificationPullRequest(account, threadId, options, {}}await recordAction(account, row, action, { ...result, appId: app?.id || null, number: target.number, automatic });+ // A merged PR leaves nothing to do on its thread. The merge already happened, so+ // a failed mark-done must not fail the action: the row keeps `suggest-mark-read`+ // and the operator's Mark done button still works.+ if (result.merged) {+ await applyNotificationAction(account.id, row.thread_id, 'done', { actor: automatic ? 'automation' : 'operator', learn: false })+ .catch(err => console.warn(`⚠️ Merged PR #${target.number} but could not mark its notification done: ${err.message}`));+ }return result;});}diff --git a/server/services/githubNotifications.db.test.js b/server/services/githubNotifications.db.test.jsindex 000645c67b..20e957d717 100644--- a/server/services/githubNotifications.db.test.js+++ b/server/services/githubNotifications.db.test.js@@ -193,8 +193,8 @@ describe.skipIf(!runDb)('GitHub notifications inbox against Postgres', () => {await syncAccountNotifications(account.id);expect(merges).toEqual([['pr', 'merge', '2011', '--repo', `github.com/${repo}`, '--squash', '--match-head-commit', head]]);const result = await getNotification(account.id, '2011');- expect(result).toMatchObject({ decision: 'suggest-mark-read', pullRequest: null, pullRequestAction: { merged: true, headSha: head } });- expect(result.events.some(event => event.kind === 'merged')).toBe(true);+ expect(result).toMatchObject({ state: 'done', pullRequest: null, pullRequestAction: { merged: true, headSha: head } });+ expect(result.events.map(event => event.kind)).toEqual(expect.arrayContaining(['merged', 'done']));await syncAccountNotifications(account.id);expect(merges).toHaveLength(1);expect(runUntrustedContentAnalysis).not.toHaveBeenCalled();@@ -213,6 +213,7 @@ describe.skipIf(!runDb)('GitHub notifications inbox against Postgres', () => {reviewDecision: 'APPROVED', statusCheckRollup: [{ name: 'CI', conclusion: 'SUCCESS' }] };let current = ready;let refuseMerge = false;+ let landMerge = false;const merges = [];const fallback = vi.mocked(execGh).getMockImplementation();vi.mocked(execGh).mockImplementation(async (args, ...rest) => {@@ -220,6 +221,7 @@ describe.skipIf(!runDb)('GitHub notifications inbox against Postgres', () => {if (args[1] === 'merge') {merges.push(args);if (refuseMerge) throw new Error('Head commit changed');+ if (landMerge) current = { ...ready, state: 'MERGED' };return '';}return JSON.stringify(current);@@ -237,6 +239,11 @@ describe.skipIf(!runDb)('GitHub notifications inbox against Postgres', () => {await expect(actOnPullRequest(account.id, '2012', { action: 'merge' })).rejects.toMatchObject({ code: 'GITHUB_PR_MERGE_UNCONFIRMED' });expect(await getNotification(account.id, '2012')).toMatchObject({ state: 'open', decision: 'needs-you', pullRequestAction: null });expect(merges.every(args => args.includes(head))).toBe(true);+ // A confirmed merge finishes the thread: it comes back done, with no further click.+ landMerge = true;+ const done = await actOnPullRequest(account.id, '2012', { action: 'merge' });+ expect(done).toMatchObject({ merged: true, notification: { state: 'done', unread: false } });+ expect((await getNotification(account.id, '2012')).events.map(event => event.kind)).toEqual(expect.arrayContaining(['merged', 'done']));});it('reaches an older ready PR after a full batch of newer PRs remains pending', async () => {