Repository navigation
Conversation
Serve /api/notifications, its stream, read, clear and settings on the local interface. Notices are heard from site.notices and followed off each reached SSH daemon's /api/notices/stream, tagged with the daemon, filtered by the notifications kinds in settings.yaml, and the last 200 kept. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Member
Author
|
Landed together in #385. |
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.
Unit 5 of the multi-daemon + notifications plan: contract C7 on the local server.
What
src/hmz/web/notifications.py:GET /api/notificationsreturns{items, unread}, newest first. Each item is a C4 notice plus its ownid,daemon(localor the entry name) andread. The last 200 are kept in memory.GET /api/notifications/streamsends SSEnotificationevents and resumes byLast-Event-IDor?last=. A page whose last id came from an earlier server starts over.POST /api/notifications/readtakes{ids}or{all: true}.POST /api/notifications/clearempties the feed.GETandPOST /api/notifications/settingsread and write C2 undernotificationsinsettings.yaml, throughcoganchor.settings.readand.changes. All kinds default to true. Anything else gets a 400 and nothing is written.site.notices(C4.heard).settings.yamldaemons(C1) whosesite.remotes.state(name)isup. It is followed throughreached(name): sign in with/?key=the way a browser does, which yields the remote's ownhmz-<port>cookie. Then read/api/noticesforlast, then follow/api/notices/stream.getattrevery 2 s, so this is green on its own and picks up the sibling units once they land.docs/reference/web.md(Notifications API) anddocs/reference/settings.md(notificationskey).Tests
tests/unit/web/test_notifications.py: public names, with fake notices.tests/integration/test_web_notifications.py: the served site with a fakesite.notices, a fakesite.remotes, and a stand-in remote interface on a local port. Covers the cross-daemon feed, filtering, settings written tosettings.yaml, refusals, read, clear, and the SSE stream with resume.hmz web --port 0, then curl every endpoint and checksettings.yaml.🤖 Generated with Claude Code