mirror of
https://github.com/coder/coder.git
synced 2026-06-02 20:48:20 +00:00
0c453d7f8e
The Agent function had complex nested control flow and cross-case state sharing via the showStartupLogs flag. This made the code hard to follow and maintain. This change extract an agentWaiter struct with self-contained methods: - wait: main state machine loop - waitForConnection: handles Connecting/Timeout states - handleConnected: handles Connected state and startup scripts - streamLogs: handles log streaming/fetching - waitForReconnection: handles Disconnected state - pollWhile: helper to consolidate polling loops Each handler is now self-contained with no cross-method state sharing and the showStartupLogs flag is replaced by return values and the waitedForConnection tracking variable.