Skip to content

Conversation

@hunmar
Copy link

@hunmar hunmar commented Jan 4, 2026

Implement a decentralized chat system that leverages the existing Hyperswarm gossip network. Messages are ephemeral (not persisted) and propagate through the swarm like heartbeats.

Features:

  • Terminal-style chat UI with retro aesthetic
  • Optional ephemeral nicknames (stored in localStorage)
  • Rate limiting: 2s cooldown + 5 messages per 30s burst limit
  • Messages signed with Ed25519 and verified with PoW
  • Gossip relay with configurable hop limit (5 for chat)
  • Visual cooldown indicator in UI

Technical changes:

  • New CHAT message type in protocol
  • ChatRateLimiter class for server-side rate limiting
  • POST /api/chat endpoint for sending messages
  • SSE 'chat' event for real-time message delivery
  • TCP relay server for local testing (WSL2 workaround)
  • AGENTS.md documentation for AI agents
image

lklynet and others added 5 commits January 3, 2026 00:24
- Enhance footer and debug element styling with better visibility
- Increase map modal size and adjust marker appearance
- Persist chat collapse state in localStorage and initialize on load
map updates heatmap without refresh
@DataDalton
Copy link
Contributor

This is a duplicate of #20

Combines upstream's ephemeral chat implementation with additional features:

From upstream:
- Peer map with Leaflet-based world visualization
- Minimizable chat terminal with persistent state
- System messages for peer connect/disconnect
- ENABLE_CHAT environment variable toggle

Added enhancements:
- Nickname system with localStorage persistence
- Advanced rate limiting (2s cooldown + 5/30s burst limit)
- ChatRateLimiter class with proper burst tracking
- TCP relay server for local testing (WSL2/Docker workaround)
- Cryptographic signature verification on chat messages
- AGENTS.md documentation for AI agents

Technical changes:
- CHAT message protocol with id, nick, msg, ts, hops, nonce, sig
- ChatRateLimiter replaces simple Map-based rate limiting
- SwarmManager supports RELAY_PORT for TCP relay connections
- getAllConnections() method for unified connection handling
@hunmar hunmar force-pushed the feature/ephemeral-chat branch from 1953e70 to 8d76154 Compare January 4, 2026 03:15
- Update SSE documentation to reflect simplified broadcast method
- Update ChatRateLimiter documentation (instantiated in routes.js)
- Fix routes.js to use getSwarm().connections.size consistently
- Update frontend notes for nickname storage and chat handling
@hunmar
Copy link
Author

hunmar commented Jan 4, 2026

Gotcha
#35

@hunmar hunmar closed this Jan 4, 2026
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.

4 participants