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: offer every notification type in Telegram forwarding settings (#6655)
[._.]/ Adam Eivy431bc7ff60ec
diff --git a/client/src/components/settings/TelegramTab.jsx b/client/src/components/settings/TelegramTab.jsxindex 8738b61739..589a9941b3 100644--- a/client/src/components/settings/TelegramTab.jsx+++ b/client/src/components/settings/TelegramTab.jsx@@ -7,17 +7,6 @@ import {deleteTelegramConfig, testTelegram, updateTelegramForwardTypes, updateTelegramMethod} from '../../services/api';-const NOTIFICATION_TYPES = [- { key: 'memory_approval', label: 'Memory Approvals' },- { key: 'task_approval', label: 'Task Approvals' },- { key: 'code_review', label: 'Code Reviews' },- { key: 'health_issue', label: 'Health Issues' },- { key: 'briefing_ready', label: 'Briefings' },- { key: 'autobiography_prompt', label: 'Autobiography Prompts' },- { key: 'plan_question', label: 'Plan Questions' },- { key: 'daily_post_reminder', label: 'POST Reminders' }-];-export function TelegramTab() {const botTokenId = useId();const chatIdId = useId();@@ -32,17 +21,19 @@ export function TelegramTab() {const [tgTesting, setTgTesting] = useState(false);const [tgDisconnecting, setTgDisconnecting] = useState(false);const [tgForwardTypes, setTgForwardTypes] = useState([]);+ const [availableForwardTypes, setAvailableForwardTypes] = useState(null);useEffect(() => {Promise.all([getSettings({ silent: true }),- getTelegramStatus().catch(() => null)+ getTelegramStatus({ silent: true }).catch(() => null)]).then(([settings, status]) => {+ setTgForwardTypes(status?.forwardTypes || settings?.telegram?.forwardTypes || []);if (status) {setTgStatus(status);setMethod(status.method || 'manual');setTgChatId(settings?.telegram?.chatId || '');- setTgForwardTypes(status.forwardTypes || []);+ setAvailableForwardTypes(Array.isArray(status.availableForwardTypes) ? status.availableForwardTypes : null);}}).catch(() => toast.error('Failed to load Telegram settings')).finally(() => setLoading(false));@@ -303,12 +294,16 @@ export function TelegramTab() {)}{/* Forward types (shared between both methods) */}- {tgStatus?.connected && (+ {(tgStatus?.connected || availableForwardTypes === null) && (<div className="bg-port-card border border-port-border rounded-xl p-4 sm:p-6 space-y-2"><p className="block text-sm text-gray-400">Forward Notification Types</p>- <p className="text-xs text-gray-500">When all are unchecked, all types are forwarded</p>+ {availableForwardTypes === null ? (+ <p role="status" className="text-sm text-gray-400">Notification choices unavailable. Saved forwarding selections are unchanged. Reload to try again.</p>+ ) : (+ <p className="text-xs text-gray-500">When all are unchecked, all types are forwarded</p>+ )}<div className="grid grid-cols-2 sm:grid-cols-3 gap-2">- {NOTIFICATION_TYPES.map(({ key, label }) => (+ {(availableForwardTypes || []).map(({ key, label }) => (<label key={key} className="flex items-center gap-2 text-sm text-gray-300 cursor-pointer"><inputtype="checkbox"diff --git a/client/src/components/settings/TelegramTab.test.jsx b/client/src/components/settings/TelegramTab.test.jsxnew file mode 100644index 0000000000..43d542dd36--- /dev/null+++ b/client/src/components/settings/TelegramTab.test.jsx@@ -0,0 +1,61 @@+import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';+import { render, screen, fireEvent, cleanup, waitFor } from '@testing-library/react';+import TelegramTab from './TelegramTab';+import * as api from '../../services/api';++vi.mock('../../services/api', () => ({+ getSettings: vi.fn(), getTelegramStatus: vi.fn(), updateTelegramConfig: vi.fn(),+ deleteTelegramConfig: vi.fn(), testTelegram: vi.fn(),+ updateTelegramForwardTypes: vi.fn(), updateTelegramMethod: vi.fn()+}));+vi.mock('../ui/Toast', () => ({ default: { success: vi.fn(), error: vi.fn() } }));++const choices = [+ { key: 'health_issue', label: 'Health Issues' },+ { key: 'autopilot_paused', label: 'Autopilot Paused' }+];+beforeEach(() => {+ vi.resetAllMocks();+ api.getSettings.mockResolvedValue({ telegram: { forwardTypes: ['unknown_saved_type'] } });+ api.updateTelegramForwardTypes.mockResolvedValue({ success: true });+});+afterEach(cleanup);++describe('Telegram forwarding settings', () => {+ it('selects returned choices while retaining unknown saved keys across method switches', async () => {+ api.getTelegramStatus.mockResolvedValue({+ connected: true, forwardTypes: ['unknown_saved_type'], availableForwardTypes: choices+ });+ api.updateTelegramMethod.mockResolvedValue({ connected: true, method: 'mcp-bridge' });+ render(<TelegramTab />);+ fireEvent.click(await screen.findByRole('checkbox', { name: 'Health Issues' }));+ fireEvent.click(screen.getByRole('checkbox', { name: 'Autopilot Paused' }));+ expect(api.updateTelegramForwardTypes).toHaveBeenLastCalledWith(+ ['unknown_saved_type', 'health_issue', 'autopilot_paused'], { silent: true }+ );+ fireEvent.click(screen.getByRole('button', { name: /Claude MCP Bridge/ }));+ await waitFor(() => expect(api.updateTelegramMethod).toHaveBeenCalledWith('mcp-bridge', { silent: true }));+ expect(screen.getByRole('checkbox', { name: 'Autopilot Paused' })).toBeChecked();+ fireEvent.click(screen.getByRole('checkbox', { name: 'Health Issues' }));+ expect(api.updateTelegramForwardTypes).toHaveBeenLastCalledWith(+ ['unknown_saved_type', 'autopilot_paused'], { silent: true }+ );+ });++ it.each(['missing', 'failed'])('shows unavailable choices without saving when status is %s', async mode => {+ if (mode === 'failed') api.getTelegramStatus.mockRejectedValue(new Error('Unavailable'));+ else api.getTelegramStatus.mockResolvedValue({ connected: true, forwardTypes: ['unknown_saved_type'] });+ render(<TelegramTab />);+ expect(await screen.findByText(/Notification choices unavailable/)).toBeInTheDocument();+ expect(screen.queryByRole('checkbox')).not.toBeInTheDocument();+ expect(api.updateTelegramForwardTypes).not.toHaveBeenCalled();+ });++ it('distinguishes an empty catalog from unavailable choices', async () => {+ api.getTelegramStatus.mockResolvedValue({ connected: true, availableForwardTypes: [] });+ render(<TelegramTab />);+ expect(await screen.findByText('When all are unchecked, all types are forwarded')).toBeInTheDocument();+ expect(screen.queryByText(/Notification choices unavailable/)).not.toBeInTheDocument();+ expect(api.updateTelegramForwardTypes).not.toHaveBeenCalled();+ });+});diff --git a/client/src/services/apiSystem.js b/client/src/services/apiSystem.jsindex 00152bf09a..9a1bf664c1 100644--- a/client/src/services/apiSystem.js+++ b/client/src/services/apiSystem.js@@ -286,7 +286,7 @@ export const deleteNotification = (id) => request(`/notifications/${id}`, { methexport const clearNotifications = () => request('/notifications', { method: 'DELETE' });// Telegram-export const getTelegramStatus = () => request('/telegram/status');+export const getTelegramStatus = (options) => request('/telegram/status', options);export const updateTelegramConfig = (data, options) => request('/telegram/config', {method: 'PUT',body: JSON.stringify(data),diff --git a/server/lib/README.md b/server/lib/README.mdindex 57d997805a..04404c8a2b 100644--- a/server/lib/README.md+++ b/server/lib/README.md@@ -621,3 +621,5 @@ pm` default, `NPM_CONFIG_PREFIX`, nvm/Volta) installed `codex` successfully and| `creativeDirectorVideoCompiler.js` | `compileVideoArtifact` and `validateVideoShot` — pure timed-shot/source-reference compilation and pinned-backend compatibility shared by Creative Director project mutations and Video execution preflight. Storage, history and approval remain with their existing owners. || `providerTypes.js` | Pure shared `isCliProvider`, `isTuiProvider`, `isApiProvider`, `isProcessProvider`, and type-gated `isClaudeHarnessProvider` predicates. |++| `notificationTypes.js` | Notification vocabulary and human labels: `NOTIFICATION_CATALOG`, compatible `NOTIFICATION_TYPES`, and `AVAILABLE_FORWARD_TYPES` for Telegram settings. |diff --git a/server/lib/index.js b/server/lib/index.jsindex 3938716be4..ca736a8e56 100644--- a/server/lib/index.js+++ b/server/lib/index.js@@ -602,3 +602,4 @@ export * from './cosFederationPolicy.js';export * from './creativeDirectorVideoReview.js';export * from './creativeDirectorVideoCompiler.js';export * from './providerTypes.js';+export * from './notificationTypes.js';diff --git a/server/lib/notificationTypes.js b/server/lib/notificationTypes.jsnew file mode 100644index 0000000000..ae5c16adc3--- /dev/null+++ b/server/lib/notificationTypes.js@@ -0,0 +1,20 @@+/** Notification vocabulary and labels shared by producers and forwarding settings. */+export const NOTIFICATION_CATALOG = {+ MEMORY_APPROVAL: { key: 'memory_approval', label: 'Memory Approvals' },+ TASK_APPROVAL: { key: 'task_approval', label: 'Task Approvals' },+ CODE_REVIEW: { key: 'code_review', label: 'Code Reviews' },+ HEALTH_ISSUE: { key: 'health_issue', label: 'Health Issues' },+ BRIEFING_READY: { key: 'briefing_ready', label: 'Briefings' },+ AUTOBIOGRAPHY_PROMPT: { key: 'autobiography_prompt', label: 'Autobiography Prompts' },+ PLAN_QUESTION: { key: 'plan_question', label: 'Plan Questions' },+ AGENT_WARNING: { key: 'agent_warning', label: 'Agent Warnings' },+ AUTOPILOT_PAUSED: { key: 'autopilot_paused', label: 'Autopilot Paused' },+ DAILY_POST_REMINDER: { key: 'daily_post_reminder', label: 'POST Reminders' },+ CREATIVE_COMMISSION: { key: 'creative_commission', label: 'Creative Commissions' }+};++export const NOTIFICATION_TYPES = Object.fromEntries(+ Object.entries(NOTIFICATION_CATALOG).map(([name, { key }]) => [name, key])+);++export const AVAILABLE_FORWARD_TYPES = Object.values(NOTIFICATION_CATALOG);diff --git a/server/routes/telegram.js b/server/routes/telegram.jsindex c0871d2225..f9e9df9e58 100644--- a/server/routes/telegram.js+++ b/server/routes/telegram.js@@ -6,6 +6,8 @@ import { getSettings, updateSettingsWith } from '../services/settings.js';import * as telegram from '../services/telegram.js';import * as telegramBridge from '../services/telegramBridge.js';+import { AVAILABLE_FORWARD_TYPES } from '../lib/notificationTypes.js';+const router = Router();/**@@ -28,7 +30,8 @@ router.get('/status', asyncHandler(async (req, res) => {...status,hasToken: status.hasBotToken,hasChatId: status.hasChatId,- forwardTypes: settings.telegram?.forwardTypes || []+ forwardTypes: settings.telegram?.forwardTypes || [],+ availableForwardTypes: AVAILABLE_FORWARD_TYPES});} else {const status = telegram.getStatus();@@ -37,7 +40,8 @@ router.get('/status', asyncHandler(async (req, res) => {...status,hasToken: !!settings.secrets?.telegram?.token,hasChatId: !!settings.telegram?.chatId,- forwardTypes: settings.telegram?.forwardTypes || []+ forwardTypes: settings.telegram?.forwardTypes || [],+ availableForwardTypes: AVAILABLE_FORWARD_TYPES});}}));diff --git a/server/routes/telegram.test.js b/server/routes/telegram.test.jsnew file mode 100644index 0000000000..a4eca5965d--- /dev/null+++ b/server/routes/telegram.test.js@@ -0,0 +1,50 @@+import { describe, it, expect, vi } from 'vitest';+import express from 'express';+import { request } from '../lib/testHelper.js';+import { errorMiddleware } from '../lib/errorHandler.js';+import { AVAILABLE_FORWARD_TYPES, NOTIFICATION_TYPES } from '../lib/notificationTypes.js';++vi.mock('../services/settings.js', () => ({+ getSettings: vi.fn(),+ updateSettingsWith: vi.fn()+}));+vi.mock('../services/telegram.js', () => ({+ getStatus: vi.fn(() => ({ connected: true })),+ updateCachedForwardTypes: vi.fn()+}));+vi.mock('../services/telegramBridge.js', () => ({+ getStatus: vi.fn(() => ({ connected: true, hasBotToken: true, hasChatId: true })),+ updateCachedForwardTypes: vi.fn()+}));++const { getSettings, updateSettingsWith } = await import('../services/settings.js');+const { default: router } = await import('./telegram.js');+const app = express();+app.use(express.json());+app.use('/api/telegram', router);+app.use(errorMiddleware);++describe('Telegram forwarding catalog contract', () => {+ it.each(['manual', 'mcp-bridge'])('advertises the complete vocabulary and preserves selections for %s', async method => {+ let settings = { telegram: { method, forwardTypes: ['health_issue', 'unknown_saved_type'] } };+ getSettings.mockImplementation(async () => settings);+ updateSettingsWith.mockImplementation(async update => { settings = update(settings); return settings; });+ const status = await request(app).get('/api/telegram/status');+ expect(status.status).toBe(200);+ expect(status.body.availableForwardTypes).toEqual(AVAILABLE_FORWARD_TYPES);+ expect(status.body.availableForwardTypes.map(({ key }) => key).sort()).toEqual(Object.values(NOTIFICATION_TYPES).sort());+ expect(status.body.availableForwardTypes).toEqual(expect.arrayContaining([+ { key: 'agent_warning', label: 'Agent Warnings' },+ { key: 'autopilot_paused', label: 'Autopilot Paused' },+ { key: 'creative_commission', label: 'Creative Commissions' }+ ]));+ expect(status.body.forwardTypes).toEqual(settings.telegram.forwardTypes);+ const forwardTypes = [...status.body.forwardTypes, 'autopilot_paused'];+ const saved = await request(app).put('/api/telegram/forward-types').send({ forwardTypes });+ expect(saved.status).toBe(200);+ expect(settings.telegram).toEqual({ method, forwardTypes });+ const cleared = await request(app).put('/api/telegram/forward-types').send({ forwardTypes: [] });+ expect(cleared.status).toBe(200);+ expect(settings.telegram.forwardTypes).toEqual([]);+ });+});diff --git a/server/services/notifications.js b/server/services/notifications.jsindex 85874a1642..789f7188c5 100644--- a/server/services/notifications.js+++ b/server/services/notifications.js@@ -25,20 +25,7 @@ export const notificationEvents = new EventEmitter();// In-memory cachelet notificationsCache = null;-// Notification types-export const NOTIFICATION_TYPES = {- MEMORY_APPROVAL: 'memory_approval',- TASK_APPROVAL: 'task_approval',- CODE_REVIEW: 'code_review',- HEALTH_ISSUE: 'health_issue',- BRIEFING_READY: 'briefing_ready',- AUTOBIOGRAPHY_PROMPT: 'autobiography_prompt',- PLAN_QUESTION: 'plan_question',- AGENT_WARNING: 'agent_warning',- AUTOPILOT_PAUSED: 'autopilot_paused',- DAILY_POST_REMINDER: 'daily_post_reminder',- CREATIVE_COMMISSION: 'creative_commission'-};+export { NOTIFICATION_TYPES } from '../lib/notificationTypes.js';// Priority levelsexport const PRIORITY_LEVELS = {