IKHSAN
EN Read in EnglishID

homeio

Publik

Fork dari doctor-io/homeio

Branch
main
Commit terakhir
958d74616 Oktober 2026

notifications.md

Buka raw
Notifications

Purpose

Notifications persist user-visible events in PostgreSQL and stream real-time updates to the UI with SSE. App operations, scheduled task failures, disk warnings, and other system events can create notifications.

Locations

  • Server-side: lib/server/modules/notifications/
  • Client-side: modules/system/components/notifications-panel.tsx, status-bar notification components, modules/system/hooks/useNotifications.ts
  • Routes: app/api/v1/notifications/

Key Files

FileRole
lib/server/modules/notifications/service.tsList/create/read/clear notifications
lib/server/modules/notifications/emitter.tsIn-memory SSE pub/sub
app/api/v1/notifications/stream/route.tsNotification SSE endpoint
modules/system/hooks/useNotifications.tsClient fetching and actions
modules/system/components/notifications-panel.tsxNotifications UI

Public API

  • listNotifications()
  • createNotification()
  • markAllNotificationsRead()
  • clearAllNotifications()
  • subscribeToNotifications()
  • emitNotification(), emitNotificationReadAll(), emitNotificationCleared()

Contracts

  • lib/shared/contracts/notifications.ts

Database Tables

  • notifications

API Routes Owned

  • GET /api/v1/notifications
  • DELETE /api/v1/notifications
  • POST /api/v1/notifications/read-all
  • GET /api/v1/notifications/stream

Known Issues

  • SSE pub/sub is in-memory and does not replay events after restart.
  • The notification list has a hard cap in service code.
  • Notification routes and stream are protected by requireApiSession().
  • toRecord() in service.ts casts DB kind values without runtime validation, per the audit.

How To Extend

To add a new notification producer:

  1. Import createNotification() in server-side code only.
  2. Use an existing NotificationKind from lib/shared/contracts/notifications.ts or add one there.
  3. Add tests for the producer path.
  4. If the UI needs filtering/preferences, update modules/settings/components/panel/sections/notifications-section.tsx and related settings contracts.
byte
2.133
baris
62
Jenis
md
Commit terakhir
16 Oktober 2026