feat(notifications)!: expose occurrences and queue alerts - #2020
Open
hmans wants to merge 27 commits into
Open
Conversation
…ccurrence-delivery * origin/main: chore(main): release chatto-desktop 0.1.0-alpha.2 (#1900) feat(desktop): stream macOS games through LiveKit (#2024) feat(auth): manage member-authorized OAuth clients (#2014) feat(auth)!: require CIMD clients for remote access (#2013) feat(auth): identify OAuth clients through CIMD (#2012) fix(dockercompose): validate init-env arguments (#2023) # Conflicts: # apps/docs-website/src/content/docs/releases/0-5-0.mdx # cli/internal/connectapi/api_contract_test.go # cli/internal/connectapi/api_test_helpers_test.go # cli/internal/core/core.go # cli/internal/http_server/cors_test.go # cli/internal/pb/chatto/core/v1/event.pb.go # docs/adr/INDEX.md # docs/architecture/interfaces.md # docs/architecture/subjects-and-events.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
AMBIENTorIMPORTANT; reactions are neutral/ambient while current mentions, replies, DMs, and followed activity use Chatto orangeNOTIFICATIONS_QUEUEthroughevents.DurableWorker, with current policy, DND, subscription, target-visibility, and materializer fencesThis PR is stacked on #2011 and should merge after it. Closes #1556.
Architecture
Notifications remain derived
RUNTIME_STATE, not domain facts: this adds no notification-only events toEVT. Source-command OCC retries recompute and reconcile prepared recipients. A single causal materializer consumes existing domain events; interruptive delivery then uses the separate file-backedNOTIFICATIONS_QUEUEwork queue. The queue and consumer are included in backups so accepted pending work survives the backup boundary, while a strict two-minute stream and worker age horizon prevents stale restored pushes.The public API exposes individual occurrences. Presentation grouping belongs to clients and never changes unread counts, read state, deletion identity, jump targets, or attention level. Visual attention is deliberately independent from push delivery intensity (
OFF/BADGE/ALERT), leaving room for future user-configurable attention without changing occurrence identity or delivery policy.Attention is persisted on each occurrence at source-command preparation time. Existing rows that omit the additive field derive a conservative value from their reasons. New clients talking to an older Notifications 2.0 server treat absent Important counts as all unread being Important, preserving the previous all-orange behavior.
Frontend occurrence state has one owner and fences optimistic mutations, projection resets, authorization loss/restoration, pagination, and realtime refreshes. First-page refreshes are coalesced so adjacent invalidations do not create redundant list bursts.
API compatibility
This intentionally breaks the experimental pre-1.0 notification API at the Notifications 2.0 cutover:
ListNotificationGroupsbecomesListNotificationOccurrencesDeleteNotificationGroupbecomes idempotent exact/batch occurrence deletionThe attention additions themselves are additive:
NotificationAttentionLevel, occurrence attention, exact Important unread counts, and per-room Important counts. Legacy Notifications 1.0 records are neither migrated nor read, as agreed for the 0.5.0 reset. Persisted/core protobuf evolution remains additive; the breaking surface is limited to the superseded public API and realtime projection.Verification
mise test-climise test-frontend(129 server files / 1,184 tests; 164 client files / 1,648 tests; 61 Storybook files / 184 tests; 5 performance comparison tests)mise x -- pnpm --dir apps/frontend check(0 errors, 0 warnings)mise codegen-protomise license-checkmise lintThe public Buf breaking check reports only the intentional group-API and realtime-field replacement described above.
Decision records