Skip to content

feat(matrix): Matrix messages panel in mesh dashboard - #53

Merged
mdheller merged 2 commits into
mainfrom
feat/matrix-dashboard-panel
Aug 4, 2026
Merged

feat(matrix): Matrix messages panel in mesh dashboard#53
mdheller merged 2 commits into
mainfrom
feat/matrix-dashboard-panel

Conversation

@mdheller

@mdheller mdheller commented Aug 4, 2026

Copy link
Copy Markdown

Summary

  • _matrix_config() — reads MATRIX_HOMESERVER_URL / MATRIX_ACCESS_TOKEN / MATRIX_BOT_ROOM_ID from env, falling back to ~/.config/sourceos/matrix.yaml (same key-set the bridge uses)
  • _matrix_recent_messages(n) — calls GET /_matrix/client/v3/rooms/{room}/messages?dir=b&limit={n} via urllib.request (3 s timeout), filters m.text events, reverses to newest-last; returns [] silently on any error so the dashboard stays healthy when Matrix is unconfigured
  • gather_state() extended with matrix_messages (8 most-recent) and matrix_room_id
  • Dashboard: new Matrix Room card below Runbooks — shows sender, HH:MM timestamp, and up to 120 chars of body per message; empty state prompts to configure MATRIX_BOT_ROOM_ID
  • GET /api/matrix/rooms — proxies /_matrix/client/v3/joined_rooms with the configured bearer token (5 s timeout); returns {"rooms": [], "error": "..."} on failure
  • GET /api/matrix/messages — returns {"messages": [...]} for last 20 messages, used by future Lua/WezTerm pane consumers

Test plan

  • python3 -m py_compile assets/sourceos/bin/turtle-mesh-serve passes (verified before commit)
  • With Matrix unconfigured: dashboard loads, Matrix card shows "No messages — configure MATRIX_BOT_ROOM_ID", /api/matrix/rooms returns {"rooms":[],"error":"Matrix not configured"}
  • With valid env vars set: card shows recent messages; /api/matrix/rooms returns joined room list; /api/matrix/messages returns up to 20 messages

… endpoints

- Add _matrix_config() reads homeserver/token/room_id from env or ~/.config/sourceos/matrix.yaml
- Add _matrix_recent_messages(n) fetches CS API dir=b, filters m.text, reverses newest-last
- Inject matrix_messages + matrix_room_id into gather_state()
- Dashboard: Matrix Room card after Runbooks — shows sender, timestamp, body (120 chars)
- GET /api/matrix/rooms proxies joined_rooms CS API (5s timeout, graceful error envelope)
- GET /api/matrix/messages returns last 20 messages for Lua/WezTerm consumers
…le-pipe, ctx

turtle-matrix-bridge:
  - `send` reads stdin when piped (cmd | mx now works)
  - `pipe` — stdin → formatted code block, --lang flag for syntax hint
  - `reply <event_id> <text>` — threaded Matrix reply
  - `react <event_id> <emoji>` — emoji reaction on any event
  - `edit <event_id> <new_text>` — in-place message edit
  - `rooms` — list joined rooms with display names
  - `messages [n]` — fetch last n messages with sender + timestamp
  - `wormhole-pipe` — stdin → temp file → wormhole send → posts code to room
  - `ctx` — post active.json + mesh tail as a context snapshot
  - `-r <room>` flag on all commands (no positional-only room arg)
  - Smart lang detection from file extension + content shebang/prefix
  - `_lang_for(path)` maps 15 extensions to highlight languages

Shell surface:
  - `mx` — reads stdin when piped; `k3s get pods | mx` just works
  - `mxpipe [--lang <l>]` — pipe stdin as code block
  - `mxw` — detects pipe mode: `k3s logs pod | mxw` sends via wormhole
  - `mxreply <eid> <text>` — threaded reply
  - `mxreact <eid> <emoji>` — reaction
  - `mxedit <eid> <text>` — edit message
  - `mxrooms` — list joined rooms
  - `mxlog [n]` — print last n messages from room
  - `mxctx` — post context snapshot to room

Palette: 9 Matrix entries; all new verbs reachable via CMD+P
@mdheller
mdheller merged commit 9c47bad into main Aug 4, 2026
@mdheller
mdheller deleted the feat/matrix-dashboard-panel branch August 4, 2026 15:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant