diff --git a/docs/vision-20260407.md b/docs/vision-20260407.md index fd93219..e367393 100644 --- a/docs/vision-20260407.md +++ b/docs/vision-20260407.md @@ -345,6 +345,32 @@ A structured logging system where peers report errors, warnings, and debug info **Effort:** 1-2 days. +### 23. Peer session persistence ("welcome back") + +When a peer disconnects, their state is lost (groups, profile, visibility, stats, summary). On reconnect they start blank. Persist peer state so returning peers resume where they left off. + +**What persists (keyed by meshId + memberId):** +- Groups and roles +- Profile (avatar, title, bio, capabilities) +- Visibility setting +- Last summary +- Cumulative stats (messages, tool calls across all sessions) +- Last seen timestamp + +**What resets:** status (always "idle" on connect), WebSocket/presenceId (ephemeral). + +**Reconnect flow:** +1. Peer sends hello with same `memberId` +2. Broker looks up `peer_state` table for (meshId, memberId) +3. If found: restore groups, profile, visibility, stats — hello fields take precedence if explicitly set +4. Enriched `hello_ack` includes `restored: true` and previous summary +5. System notification: `"Welcome back, Alice! Last seen 2h ago. Restored: @frontend:lead, @devops:member"` +6. On disconnect: upsert current state to `peer_state` + +**Why:** AI sessions restart often (context limits, crashes, new tasks). Without persistence, every reconnect requires manual group joins and profile setup. With it, the mesh remembers who you are. + +**Effort:** Half day. + --- ## Suggested build order @@ -374,6 +400,7 @@ A structured logging system where peers report errors, warnings, and debug info | 21 | SDK (@claudemesh/sdk) | 1 day | Non-Claude-Code clients | **DONE** `7e102a2` | | 22 | Telegram connector | 1-2 days | Reach beyond Claude Code | **DONE** `fe92853` | | 23 | Mesh telemetry + debugging | 1-2 days | Self-diagnosing mesh | | +| 24 | Peer session persistence | Half day | "Welcome back" on reconnect | | ---