Skip to content

VSCode extension: no way to manually reconnect when stuck Offline #728

@amrmelsayed

Description

@amrmelsayed

Summary

When the Codev VSCode extension shows Codev: Offline in the status bar, there is no user-facing way to make it retry the connection — even when Tower is running and healthy. The extension stays stuck in disconnected indefinitely.

Repro

  1. Open a Codev workspace in VSCode while Tower is not running.
  2. Extension activates, calls connectionManager.initialize(), the initial connect() fails, state goes to disconnected.
  3. Start Tower (afx tower start).
  4. Status bar still says Codev: Offline. Sidebar views are empty. Terminals can't be opened.
  5. There is no Command Palette entry, status-bar click handler, or context menu action to retry.

Root cause

In packages/vscode/src/connection-manager.ts:

  • initialize() (line 57) calls connect() once. On failure, state is set to disconnected and execution returns. No retry is scheduled.
  • scheduleReconnect() (line 121) — the only retry path — is only invoked from startSSE()'s disconnect callback (line 178). That path requires a previously successful connection whose SSE stream later dropped. The cold-start failure case never reaches it.
  • The reconnectAttempt exponential backoff therefore only protects against mid-session SSE drops, not against "Tower wasn't up at activation time."

In packages/vscode/src/extension.ts:

  • The status bar item (line 38–41) has no command set, so clicking the Offline indicator does nothing.
  • No codev.reconnect command is registered (verified via grep against package.json — only codev.connectTunnel / codev.disconnectTunnel exist, which are unrelated).

Current workarounds (both bad)

  1. Developer: Reload Window — kills every integrated terminal in the window, including non-Codev ones running pnpm dev, tails, SSH, etc. Terminal scrollback persists; running processes do not.
  2. Disable + re-enable the Codev extension in the Extensions view — works, but is several clicks deep and not discoverable.

Proposed fix

  1. Register a codev.reconnect command that calls connectionManager.connect() after resetting reconnectAttempt = 0 (so the user-initiated retry isn't penalised by backoff state from a previous mid-session drop).
  2. Set statusBarItem.command = 'codev.reconnect' in extension.ts so clicking the Offline / Reconnecting... indicator triggers it.
  3. In ConnectionManager.connect(), when the attempt fails from a fresh disconnected state (i.e. cold start, no SSE ever established), call scheduleReconnect() so the extension self-heals once Tower comes up — instead of parking forever.

Acceptance

  • Codev: Reconnect appears in the Command Palette.
  • Clicking the Codev: Offline status bar item triggers a reconnection attempt.
  • After Tower starts post-activation, the extension reconnects automatically within ~30s without any user action.
  • No regression in the existing mid-session SSE-drop reconnect path.

Affected files

  • packages/vscode/src/connection-manager.ts
  • packages/vscode/src/extension.ts
  • packages/vscode/package.json (command + status-bar contribution)

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions