Connection Flow

Overview

The connection flow is responsible for establishing and managing a persistent WebSocket connection to a discovered chat server. Once authentication completes and an access token has been obtained, the application constructs a ClientManager, which coordinates connection initiation, message routing, and model setup.

This flow is triggered automatically by each chat window (or tab) that is opened by the user. Each chat window maintains its own ClientManager instance, which encapsulates the connection and user-specific state for that context.

Flow Summary

  • After authentication, the application creates a ClientManager for the active chat window
  • The ClientManager is passed a DiscoveryPayload and access token
  • The application calls connectToServer() to initiate the WebSocket handshake
  • Internally, the WebsocketManager connects using the chat endpoint and token
  • Upon successful connection, the connected signal is emitted
  • Channel metadata is received from the server
  • Proxies are populated and the UI is notified via activeChannelsReady

Components Involved

Design Note

Each active chat window in the application owns a dedicated instance of ClientManager. This allows isolated connection handling per window or tab and ensures that each session can maintain its own filtered views, JWT identity, and connection lifecycle independently.

See also authenticationflow.html, discoveryflow.html, and ClientManager.