| 1 | # notification.py DOX |
| 2 | |
| 3 | ## Purpose |
| 4 | |
| 5 | - Own the `notification.py` helper module. |
| 6 | - This module owns notification data models and notification manager state. |
| 7 | - Keep this file-level DOX profile synchronized with `notification.py` because this directory is intentionally flat. |
| 8 | |
| 9 | ## Ownership |
| 10 | |
| 11 | - `notification.py` owns the runtime implementation. |
| 12 | - `notification.py.dox.md` owns durable notes about responsibilities, contracts, side effects, and verification for that implementation. |
| 13 | - Classes: |
| 14 | - `NotificationType` (`Enum`) |
| 15 | - `NotificationPriority` (`Enum`) |
| 16 | - `NotificationItem` (no explicit base class) |
| 17 | - `mark_read(self)` |
| 18 | - `output(self)` |
| 19 | - `NotificationManager` (no explicit base class) |
| 20 | - `send_notification(type: NotificationType, priority: NotificationPriority, message: str, title: str=..., detail: str=..., display_time: int=..., group: str=..., id: str=...) -> NotificationItem` |
| 21 | - `add_notification(self, type: NotificationType, priority: NotificationPriority, message: str, title: str=..., detail: str=..., display_time: int=..., group: str=..., id: str=...) -> NotificationItem` |
| 22 | - `get_recent_notifications(self, seconds: int=...) -> list[NotificationItem]` |
| 23 | - `output(self, start: int | None=..., end: int | None=...) -> list[dict]` |
| 24 | - `output_with_state(self, start: int | None=..., end: int | None=...) -> tuple[list[dict], str, int]` |
| 25 | - `output_all(self) -> list[dict]` |
| 26 | - `mark_read_by_ids(self, notification_ids: list[str]) -> int` |
| 27 | - `update_item(self, no: int, **kwargs) -> None` |
| 28 | - `mark_all_read(self)` |
| 29 | |
| 30 | ## Runtime Contracts |
| 31 | |
| 32 | - Helper modules own reusable framework APIs and must preserve public callers unless all callers, tests, and docs are updated together. |
| 33 | - Update this file whenever public functions, classes, persistence behavior, path/security assumptions, side effects, or cross-module contracts change. |
| 34 | - Notification payloads, GUIDs, and update cursors are captured under one lock so WebUI snapshots cannot skip notifications created during snapshot assembly. |
| 35 | - Observed side-effect areas: filesystem deletion, settings/state persistence. |
| 36 | - Imported dependency areas include: `dataclasses`, `datetime`, `enum`, `helpers.localization`, `threading`, `uuid`. |
| 37 | |
| 38 | ## Key Concepts |
| 39 | |
| 40 | - Important called helpers/classes observed in the source: `self.manager.update_item`, `threading.RLock`, `AgentContext.get_notification_manager.add_notification`, `mark_dirty_all`, `self._update_item`, `NotificationType`, `Localization.get.serialize_datetime`, `uuid.uuid4`, `Localization.get.now`, `timedelta`, `n.output`, `AgentContext.get_notification_manager`, `next`, `NotificationPriority`, `NotificationItem`, `self._enforce_limit`, `seen.add`, `notifications.output`, `nid.strip`. |
| 41 | - Keep request/response, tool, or helper semantics documented here at the same time as source changes. |
| 42 | |
| 43 | ## Work Guidance |
| 44 | |
| 45 | - Preserve public helper APIs used by core code and plugins unless every caller is updated. |
| 46 | - Keep path, auth, secret, persistence, network, and subprocess behavior explicit and bounded. |
| 47 | - Prefer adding cohesive helper functions here only when behavior is reused across modules. |
| 48 | |
| 49 | ## Verification |
| 50 | |
| 51 | - Run targeted tests for changed helper behavior; run security regressions for auth, filesystem, WebSocket, tunnel, upload, or secret-handling helpers. |
| 52 | - Related tests observed by source search: |
| 53 | - `tests/test_download_toast_regressions.py` |
| 54 | - `tests/test_multi_tab_isolation.py` |
| 55 | - `tests/test_self_update_tag_filter.py` |
| 56 | - `tests/test_snapshot_parity.py` |
| 57 | - `tests/test_snapshot_schema_v1.py` |
| 58 | - `tests/test_state_monitor.py` |
| 59 | - `tests/test_state_sync_handler.py` |
| 60 | - `tests/test_state_sync_welcome_screen.py` |
| 61 | |
| 62 | ## Child DOX Index |
| 63 | |
| 64 | No child DOX files. |