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

Bring unsubscribed GitHub threads back on new activity

Claude05edac1261ff
diff --git a/client/src/components/github/GitHubInboxTab.jsx b/client/src/components/github/GitHubInboxTab.jsx
index 1dc2b4c9d8..012d6e1c61 100644
--- a/client/src/components/github/GitHubInboxTab.jsx
+++ b/client/src/components/github/GitHubInboxTab.jsx
@@ -36,6 +36,13 @@ const REASON_LABELS = {
const STATE_LABELS = { done: 'Done', muted: 'Muted', unsubscribed: 'Unsubscribed' };
+// Undoing Done is local; undoing Mute/Unsubscribe re-subscribes on GitHub.
+const UNDO_ACTIONS = {
+ done: { action: 'reopen', label: 'Back to inbox' },
+ muted: { action: 'resubscribe', label: 'Unmute' },
+ unsubscribed: { action: 'resubscribe', label: 'Resubscribe' },
+};
+
const OPEN_ACTIONS = [
{ action: 'done', label: 'Done' },
{ action: 'mute', label: 'Mute' },
@@ -75,7 +82,7 @@ function NotificationCard({ notification, accountLabel, busy, onAction }) {
<ExternalLink size={12} aria-hidden="true" /> Open
</a>
)}
- {(handled ? [{ action: 'resubscribe', label: 'Back to inbox' }] : OPEN_ACTIONS).map(({ action, label }) => (
+ {(handled ? [UNDO_ACTIONS[notification.state]].filter(Boolean) : OPEN_ACTIONS).map(({ action, label }) => (
<button
key={action}
type="button"
diff --git a/client/src/pages/GitHub.test.jsx b/client/src/pages/GitHub.test.jsx
index c2751eabfb..d6d47c2251 100644
--- a/client/src/pages/GitHub.test.jsx
+++ b/client/src/pages/GitHub.test.jsx
@@ -1,5 +1,5 @@
import { beforeEach, describe, expect, it, vi } from 'vitest';
-import { fireEvent, render, screen } from '@testing-library/react';
+import { act, fireEvent, render, screen, waitFor } from '@testing-library/react';
import { MemoryRouter, Route, Routes } from 'react-router';
const mock = vi.hoisted(() => ({
@@ -350,6 +350,22 @@ describe('GitHub inbox tab', () => {
expect(await screen.findByText('Nothing needs you right now.')).toBeTruthy();
});
+ it('undoes Done locally and a mute by re-subscribing', async () => {
+ mock.getGitHubNotifications.mockResolvedValue({
+ notifications: [{ ...NOTIFICATION, state: 'done' }, { ...NOTIFICATION, threadId: '102', title: 'Muted change', state: 'muted' }],
+ sync: {},
+ });
+ mock.applyGitHubNotificationAction.mockImplementation(async (_account, threadId) => ({ ...NOTIFICATION, threadId, state: 'open' }));
+ renderTab('inbox');
+ fireEvent.click(await screen.findByRole('button', { name: 'Handled' }));
+ fireEvent.click(await screen.findByRole('button', { name: 'Back to inbox' }));
+ fireEvent.click(screen.getByRole('button', { name: 'Unmute' }));
+ await waitFor(() => expect(mock.applyGitHubNotificationAction).toHaveBeenCalledTimes(2));
+ expect(mock.applyGitHubNotificationAction).toHaveBeenCalledWith('github-com', '101', 'reopen');
+ expect(mock.applyGitHubNotificationAction).toHaveBeenCalledWith('github-com', '102', 'resubscribe');
+ await act(async () => {});
+ });
+
it('shows a failed sync for the account instead of an empty inbox', async () => {
mock.getGitHubNotifications.mockResolvedValue({
notifications: [], sync: { 'github-com': { lastSyncAt: null, lastError: 'gh cannot act as github.com (not-authenticated).' } },
diff --git a/server/lib/db/schema/schema.test.js b/server/lib/db/schema/schema.test.js
index c71496457c..eaca470e07 100644
--- a/server/lib/db/schema/schema.test.js
+++ b/server/lib/db/schema/schema.test.js
@@ -28,7 +28,7 @@ const DOMAIN_ARRAYS = [
'coreDdl', 'tribeDdl', 'humanActivityDdl', 'postDdl', 'commissionsDdl', 'userActionsDdl', 'reviewQueueTriageDdl', 'cosAgentFeedbackDdl', 'cosTasksDdl', 'cosAgentsDdl', 'aiGraphDdl', 'peerExecutionDdl',
'catalogDdl', 'catalogIdentityDdl', 'catalogUserTypesDdl', 'mediaDdl', 'universesDdl',
'libraryDdl', 'pipelineDdl', 'writersRoomDdl', 'loraDdl', 'privacyDdl', 'stackerNewsDdl', 'xDdl',
- 'beeperDdl', 'mindToolRecipesDdl',
+ 'beeperDdl', 'githubNotificationsDdl', 'mindToolRecipesDdl',
'auditDdl', 'syncFeedDdl',
];
@@ -75,6 +75,7 @@ describe('db/schema barrel + composer (#2832)', () => {
...schema.stackerNewsDdl,
...schema.xDdl,
...schema.beeperDdl,
+ ...schema.githubNotificationsDdl,
...schema.mindToolRecipesDdl,
...schema.decksDdl,
...schema.auditDdl,
diff --git a/server/lib/validation.js b/server/lib/validation.js
index 7180a9a9ef..ae9abe18c0 100644
--- a/server/lib/validation.js
+++ b/server/lib/validation.js
@@ -977,7 +977,7 @@ export const githubNotificationsSyncSchema = z.object({
}).strict();
export const githubNotificationActionSchema = z.object({
- action: z.enum(['read', 'done', 'mute', 'unsubscribe', 'resubscribe']),
+ action: z.enum(['read', 'done', 'reopen', 'mute', 'unsubscribe', 'resubscribe']),
}).strict();
export const GITHUB_NOTIFICATION_THREAD_ID_RE = /^\d{1,20}$/;
diff --git a/server/routes/github.js b/server/routes/github.js
index b428890fc7..86e32bafdf 100644
--- a/server/routes/github.js
+++ b/server/routes/github.js
@@ -146,7 +146,7 @@ router.post('/notifications/sync', asyncHandler(async (req, res) => {
}));
/**
- * POST /api/github/notifications/:accountId/:threadId — done / read / mute / unsubscribe / resubscribe
+ * POST /api/github/notifications/:accountId/:threadId — read / done / reopen / mute / unsubscribe / resubscribe
*/
router.post('/notifications/:accountId/:threadId', asyncHandler(async (req, res) => {
const { action } = validateRequest(githubNotificationActionSchema, req.body ?? {});
diff --git a/server/services/githubNotifications.db.test.js b/server/services/githubNotifications.db.test.js
index ab4c20d384..6e59d68334 100644
--- a/server/services/githubNotifications.db.test.js
+++ b/server/services/githubNotifications.db.test.js
@@ -142,6 +142,27 @@ describe.skipIf(!runDb)('GitHub notifications inbox against Postgres', () => {
expect(open.map((row) => row.threadId)).toEqual(['301']);
});
+ it('brings an unsubscribed thread back on a new mention but leaves a muted one handled', async () => {
+ let updatedAt = '2026-10-01T10:00:00Z';
+ mockGh(() => listing([thread('401', { updatedAt }), thread('402', { updatedAt })]));
+ await syncAccountNotifications(account.id);
+ await applyNotificationAction(account.id, '401', 'unsubscribe');
+ await applyNotificationAction(account.id, '402', 'mute');
+
+ updatedAt = '2026-10-02T10:00:00Z';
+ await syncAccountNotifications(account.id);
+ const open = (await listNotifications({ accountId: account.id, view: 'needs-you' })).notifications;
+ expect(open.map((row) => row.threadId)).toEqual(['401']);
+ });
+
+ it('reopens a done thread locally without subscribing to it on GitHub', async () => {
+ const actions = mockGh(() => listing([thread('501')]));
+ await syncAccountNotifications(account.id);
+ await applyNotificationAction(account.id, '501', 'done');
+ expect(await applyNotificationAction(account.id, '501', 'reopen')).toMatchObject({ state: 'open' });
+ expect(actions).toEqual([['DELETE', 'notifications/threads/501']]);
+ });
+
it('records the failure on the sync cursor and refuses actions on unknown threads', async () => {
mockGh(() => { throw Object.assign(new Error('HTTP 502'), { ghExitCode: 1, ghStderr: 'HTTP 502' }); });
await expect(syncAccountNotifications(account.id)).rejects.toThrow('HTTP 502');
diff --git a/server/services/githubNotifications.js b/server/services/githubNotifications.js
index b591dedddf..2d636d8be9 100644
--- a/server/services/githubNotifications.js
+++ b/server/services/githubNotifications.js
@@ -27,11 +27,14 @@ const MAX_PAGES = 5;
const LIST_LIMIT = 200;
export const NOTIFICATION_VIEWS = Object.freeze(['needs-you', 'handled', 'all']);
-export const NOTIFICATION_ACTIONS = Object.freeze(['read', 'done', 'mute', 'unsubscribe', 'resubscribe']);
+export const NOTIFICATION_ACTIONS = Object.freeze(['read', 'done', 'reopen', 'mute', 'unsubscribe', 'resubscribe']);
// method + path suffix + fields for each operator action; the state it leaves
// the stored row in. Thread ids are digits-only (validated at the route).
+// `reopen` is local only: re-subscribing a done thread would opt into all of
+// its future activity when the notification was a one-off mention.
const ACTION_SPECS = {
+ reopen: { method: null, path: '', fields: [], state: 'open' },
read: { method: 'PATCH', path: '', fields: [], state: null },
done: { method: 'DELETE', path: '', fields: [], state: 'done' },
mute: { method: 'PUT', path: '/subscription', fields: ['-F', 'ignored=true'], state: 'muted' },
@@ -89,8 +92,9 @@ const UPSERT_SQL = `INSERT INTO github_notifications (
subject_api_url = EXCLUDED.subject_api_url,
html_url = EXCLUDED.html_url,
unread = EXCLUDED.unread,
- -- GitHub brings a thread marked done back when it has new activity.
- state = CASE WHEN github_notifications.state = 'done' AND EXCLUDED.gh_updated_at > github_notifications.gh_updated_at
+ -- New activity brings back a thread marked done, and an unsubscribed one
+ -- (GitHub re-subscribes on a fresh mention or review request). Muted stays.
+ state = CASE WHEN github_notifications.state IN ('done', 'unsubscribed') AND EXCLUDED.gh_updated_at > github_notifications.gh_updated_at
THEN 'open' ELSE github_notifications.state END,
gh_updated_at = EXCLUDED.gh_updated_at,
updated_at = NOW()`;
@@ -225,12 +229,14 @@ export async function applyNotificationAction(accountId, threadId, action) {
if (!existing) {
throw new ServerError('Notification not found', { status: 404, code: 'GITHUB_NOTIFICATION_NOT_FOUND' });
}
- const env = await requireAccountEnv(account);
- await execGh(
- ['api', '--hostname', account.host, '--method', spec.method, `notifications/threads/${threadId}${spec.path}`, ...spec.fields],
- GH_TIMEOUT_MS,
- { env },
- );
+ if (spec.method) {
+ const env = await requireAccountEnv(account);
+ await execGh(
+ ['api', '--hostname', account.host, '--method', spec.method, `notifications/threads/${threadId}${spec.path}`, ...spec.fields],
+ GH_TIMEOUT_MS,
+ { env },
+ );
+ }
const result = await query(
`UPDATE github_notifications SET
unread = CASE WHEN $3::text IN ('read','done') THEN FALSE ELSE unread END,