Summary
Add WebSocket support to enable real-time updates in the TUI, eliminating delays when resources are created, updated, or deleted.
Current Problem
Currently, the TUI polls for updates every 5 seconds, which causes noticeable delays:
- When a cluster is created, it takes up to 10-30 seconds to appear in the TUI
- Task status changes are not reflected immediately
- Service deployments don't show up right away
This creates a poor user experience where users have to wait or manually refresh to see their changes.
Root Causes of Delays
- TUI polling interval: 5 seconds (in
internal/tui/model.go)
- Batch update delay: 2 seconds (sync controller's
BatchUpdater)
- Initial pod processing delay: 3 seconds (
processExistingPods sleep)
Proposed Solution
Implement WebSocket-based real-time notifications:
Architecture
-
WebSocket Server
- Add WebSocket endpoint to the admin server (port 5374)
- Path:
/ws/events or similar
- Broadcast events for resource changes (clusters, services, tasks, etc.)
-
Event Types
type Event struct {
Type string // "cluster.created", "task.updated", etc.
Resource string // Resource ARN
Data interface{} // Resource data
Timestamp time.Time
}
-
TUI WebSocket Client
- Connect to WebSocket on startup
- Handle reconnection logic
- Update local state immediately when events are received
- Fall back to polling if WebSocket is unavailable
Implementation Areas
Benefits
- Immediate feedback: Resources appear instantly after creation
- Reduced server load: Less frequent polling required
- Better UX: Real-time updates for all resource changes
- Foundation for future features: Live logs, metrics, etc.
Alternative Short-term Solutions
While this is being implemented, we can:
- Reduce TUI polling interval from 5s to 2s
- Add immediate refresh after create/update operations in TUI
- Add manual refresh command (e.g., Ctrl+R)
Related Issues
- Could also benefit from GraphQL subscriptions as an alternative
- Would enable real-time log streaming in the future
Technical Considerations
- Use gorilla/websocket (already in dependencies)
- Consider using a message queue for reliability
- Implement proper connection pooling and cleanup
- Add metrics for WebSocket connections
Acceptance Criteria
Priority
Medium - This is a quality of life improvement that would significantly enhance the user experience, but the current polling mechanism is functional.
Summary
Add WebSocket support to enable real-time updates in the TUI, eliminating delays when resources are created, updated, or deleted.
Current Problem
Currently, the TUI polls for updates every 5 seconds, which causes noticeable delays:
This creates a poor user experience where users have to wait or manually refresh to see their changes.
Root Causes of Delays
internal/tui/model.go)BatchUpdater)processExistingPodssleep)Proposed Solution
Implement WebSocket-based real-time notifications:
Architecture
WebSocket Server
/ws/eventsor similarEvent Types
TUI WebSocket Client
Implementation Areas
internal/controlplane/admin/)internal/tui/)Benefits
Alternative Short-term Solutions
While this is being implemented, we can:
Related Issues
Technical Considerations
Acceptance Criteria
Priority
Medium - This is a quality of life improvement that would significantly enhance the user experience, but the current polling mechanism is functional.