Commit 99d1fab
authored
Unify deployment tracking and support multiple deployments (#677)
This change centralizes deployment state management and enables seamless
multi-deployment support. The extension now properly tracks
per-deployment credentials, syncs state across VS Code windows, and
handles login/logout flows in a unified way.
Key changes:
Architecture:
- Add `DeploymentManager` to centralize deployment state (`url`,
`label`, `token`, `user`) and coordinate extension client updates, auth
contexts, and workspace refreshes
- Add `LoginCoordinator` to handle login prompts with cross-window
detection, preventing duplicate login dialogs when multiple windows need
auth
Storage & Auth:
- `SecretsManager` now stores per-deployment credentials using
label-based keys (`coder.session.<label>`) instead of flat
`sessionToken` storage
- Add LRU tracking for deployments with automatic cleanup of old
credentials
- Add migration from legacy flat storage format
- Cross-window sync via `secrets.onDidChange` events
- Debug command (`coder.debug.listDeployments`) for inspecting stored
state
Commands & Remote:
- Commands now use `DeploymentManager` instead of directly manipulating
client
- Remote connection uses `LoginCoordinator` for auth prompts during
workspace connections
- `CliManager.configure()` now called on every remote connection, with
secrets storage as the source of truth for credentials
WebSocket improvements:
- `CoderApi` now implements Disposable to clean up WebSocket connections
- Add `setCredentials()` method to update host+token atomically,
avoiding unnecessary reconnection cycles
- Add `disconnect()` support to `ReconnectingWebSocket` for clean
disconnects
- Simplify WebSocket fallback logic with cleaner SSE fallback handling
Tests:
- Update `secretsManager` tests for new per-deployment API
- Add comprehensive `reconnectingWebSocket` tests for disconnect/reconnect
- Extend `coderApi` tests for credential handling1 parent 5ef523f commit 99d1fab
File tree
30 files changed
+3191
-1046
lines changed- src
- api
- core
- deployment
- login
- remote
- websocket
- test
- mocks
- unit
- api
- core
- deployment
- login
- websocket
30 files changed
+3191
-1046
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
265 | 265 | | |
266 | 266 | | |
267 | 267 | | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
268 | 273 | | |
269 | 274 | | |
270 | 275 | | |
271 | 276 | | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
272 | 281 | | |
273 | 282 | | |
274 | 283 | | |
| |||
0 commit comments