Add stream package for console event timeline and system publishers#573
Merged
Conversation
New package mu/stream: a typed, append-only event log that powers the
home console. Every building block publishes to it. Users interact
with it. The agent responds in it. Separate from status (profile
feature) and social (threaded forum).
Data model:
- Event{ID, Type, AuthorID, Author, Content, Metadata, CreatedAt}
- Types: user, agent, system, market, news, reminder
- Stored in stream.json, capped at 500, newest first
- DedupeAdjacent collapses consecutive same-user same-text entries
Publishing API:
- stream.Publish(e) — generic
- stream.PostUser(id, content) — human console input
- stream.PostAgent(content) — @micro responses
- stream.PostSystem(content, meta) — system notifications
- stream.Recent(max, viewerID) — filtered by ban status
- stream.Since(t) / stream.CountSince(t) — for polling
- stream.Clear() / stream.ClearByAuthor(id) — admin
HTTP:
- GET /stream — HTML console page or JSON (?format=json&since=ts)
- POST /stream — post a message (middleware gates auth + credits)
- GET /stream/fragment — HTML fragment for polling
Console UI:
- Compose box with @micro hint
- Three visual treatments: user (avatar+name), agent (green M),
system/market/news/reminder (icon + compact one-liner)
- 10s polling via /stream/fragment, scroll-preserving
- Form submits via fetch with CSRF, clears on success
Wiring:
- stream.AIReplyHook wired in main.go → agent.Query → PostAgent
- POST /stream in chargedWriteOp → 1 credit (OpSocialPost)
- /updates endpoint includes stream count
- MCP tools: stream (read) and stream_post (write, 1 credit)
Next: wire system publishers (reminder, markets, headlines) and
add Console/Cards toggle to the home page.
https://claude.ai/code/session_01GRGLA9yj7BpqKiyi6xFwnm
System events now publish into the stream automatically: Reminder: when the daily reminder updates, the verse text is posted as a TypeReminder event. Appears in the console with 🕌 icon. Markets: when BTC, ETH, SOL, GOLD, or OIL moves >2% between refreshes, a TypeMarket event is posted with the ticker, price, and percentage change. e.g. "BTC +3.2% ($68,500)" News: when SurfaceBreaking detects a story covered by 2+ sources, the headline is posted as a TypeNews event with the URL. Home page Console/Cards toggle: The home screen now has two views toggled by Console | Cards tabs at the top. Choice persists in localStorage. Console (default): full-height stream with compose box. Shows user messages, @micro agent responses, and system events (reminders, markets, news) in one chronological timeline. Polling updates every 10 seconds. Form submits via fetch. This is the command-and-control surface. Cards: the existing dashboard layout with weather, blog, markets, news, social, video, reminder cards. Same as before for people who want the overview-at-a-glance. The old status card is still in the cards view but the console is now the primary interaction surface — mobile users see the stream first, which is what they naturally interact with. https://claude.ai/code/session_01GRGLA9yj7BpqKiyi6xFwnm
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.
No description provided.