feat(notifications): add Phase 4 Slice 2 — multi-channel notification system

Full notification infrastructure with in-app, email, Slack, and Teams channels:

Backend:
- NotificationConfig, NotificationLog, Notification models + migration
- Notification service with event routing, channel delivery, retry logic
- 9 API endpoints (config CRUD + in-app notifications)
- APScheduler retry job with exponential backoff (30s, 2m, 10m)
- Wired into escalation, proposal approval, and knowledge flywheel
- Pydantic event key validation, cross-tenant protection on recipients

Frontend:
- TypeScript types + API client for all notification endpoints
- NotificationsPanel: bell icon with unread badge, dropdown, mark-read
- NotificationSettings: channel config, event toggles, test, delete confirm
- Notifications tab on IntegrationsPage
- ARIA attributes, Escape handler, settings link on panel

Review fixes (13 issues resolved):
- notify() no longer commits/rolls back caller's transaction (critical)
- retry_failed_notifications returns count instead of None (critical)
- NotificationSettings moved inside dedicated tab (critical)
- target_user_ids scoped by account_id (security)
- Email loop collects all failures before raising
- Slack webhook validates response body
- events_enabled rejects unknown event keys
- link column widened to String(500)
- Dead code removed from _auto_reinforce
- Delete confirmation, ARIA, Escape key support

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-03-19 12:37:54 +00:00
parent a8999adef3
commit 0f750e63e0
22 changed files with 3402 additions and 53 deletions

View File

@@ -27,3 +27,4 @@ export { sessionToFlowApi } from './sessionToFlow'
export { aiSessionsApi } from './aiSessions'
export { flowProposalsApi } from './flowProposals'
export { flowpilotAnalyticsApi } from './flowpilotAnalytics'
export { notificationsApi } from './notifications'

View File

@@ -0,0 +1,57 @@
import apiClient from './client'
import type {
NotificationConfig,
NotificationConfigCreate,
NotificationConfigUpdate,
AppNotification,
UnreadCount,
} from '@/types/notification'
export const notificationsApi = {
async listConfigs(): Promise<NotificationConfig[]> {
const response = await apiClient.get<NotificationConfig[]>('/notifications/configs')
return response.data
},
async createConfig(data: NotificationConfigCreate): Promise<NotificationConfig> {
const response = await apiClient.post<NotificationConfig>('/notifications/configs', data)
return response.data
},
async updateConfig(id: string, data: NotificationConfigUpdate): Promise<NotificationConfig> {
const response = await apiClient.patch<NotificationConfig>(`/notifications/configs/${id}`, data)
return response.data
},
async deleteConfig(id: string): Promise<void> {
await apiClient.delete(`/notifications/configs/${id}`)
},
async testConfig(configId: string): Promise<{ success: boolean; message: string }> {
const response = await apiClient.post<{ success: boolean; message: string }>(
'/notifications/configs/test',
{ config_id: configId }
)
return response.data
},
async list(params?: { skip?: number; limit?: number }): Promise<AppNotification[]> {
const response = await apiClient.get<AppNotification[]>('/notifications', { params })
return response.data
},
async unreadCount(): Promise<number> {
const response = await apiClient.get<UnreadCount>('/notifications/unread-count')
return response.data.count
},
async markRead(id: string): Promise<void> {
await apiClient.patch(`/notifications/${id}/read`)
},
async markAllRead(): Promise<void> {
await apiClient.post('/notifications/mark-all-read')
},
}
export default notificationsApi