Skip to content

Conversation

@EhabY
Copy link
Collaborator

@EhabY EhabY commented Dec 9, 2025

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
  • Move deployment types to src/deployment/ module with proper type guards

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 suspend/reconnect
  • Extend coderApi tests for credential handling

@EhabY EhabY force-pushed the multi-deployment-squashed branch 2 times, most recently from bc9bce5 to 642fd52 Compare December 10, 2025 13:34
@EhabY EhabY force-pushed the multi-deployment-squashed branch 3 times, most recently from 5e83d93 to 46afe7f Compare December 10, 2025 14:50
@EhabY EhabY force-pushed the multi-deployment-squashed branch from 46afe7f to acf26aa Compare December 10, 2025 14:59
Copy link
Member

@code-asher code-asher left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I ran out of time to test it but will do so tomorrow!

@EhabY
Copy link
Collaborator Author

EhabY commented Dec 11, 2025

@code-asher I've add tests in the last commit BTW, if you wish I can make it a separate PR 🙏

@EhabY EhabY force-pushed the multi-deployment-squashed branch 4 times, most recently from b37031e to 6f307c1 Compare December 11, 2025 22:14
@code-asher
Copy link
Member

Nah same PR for tests I would say!

Copy link
Member

@code-asher code-asher left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow tried it out and the cross-window stuff is quite magical. ✨ Really cool!!

@code-asher
Copy link
Member

I love "final final" lol 🤣

@EhabY
Copy link
Collaborator Author

EhabY commented Dec 15, 2025

I love "final final" lol 🤣

I'm manifesting hahaha

EhabY added 10 commits December 16, 2025 11:24
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 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
- Move deployment types to src/deployment/ module with proper type guards

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
- Remove forceLogout in favor of unified logout through DeploymentManager
- 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 suspend() 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 suspend/reconnect
- Extend coderApi tests for credential handling
@EhabY EhabY force-pushed the multi-deployment-squashed branch from 461eae8 to fae35bd Compare December 16, 2025 08:25
@EhabY EhabY force-pushed the multi-deployment-squashed branch from 2b8f068 to 3e12008 Compare December 16, 2025 08:57
@EhabY EhabY merged commit 99d1fab into coder:main Dec 16, 2025
3 checks passed
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.

2 participants