Skip to content

PR6: Disconnect clusters without stranding open views - #1130

Merged
Tomasz Naumowicz (tnaum-ms) merged 24 commits into
feature/connection-lifecyclefrom
dev/tnaum/connection-lifecycle-teardown
Nov 25, 2026
Merged

Tomasz Naumowicz (tnaum-ms) merged 24 commits into
feature/connection-lifecyclefrom
dev/tnaum/connection-lifecycle-teardown

Conversation

@tnaum-ms

@tnaum-ms Tomasz Naumowicz (tnaum-ms) commented Nov 24, 2026 •

Copy link
Copy Markdown
Collaborator

Adds explicit Disconnect and uses the same teardown for Remove and folder deletion. Users can close affected views or keep their contents open and disabled. Active transfers and tasks protect the connection from teardown; the tree offers Connect after an explicit disconnect without changing the node ID.

CP-4: teardown order

sequenceDiagram
    actor User
    participant Command
    participant Tasks as Tasks and transfer leases
    participant Client as Connection lifecycle
    participant Views as Views and workers
    participant Tree
    User->>Command: Disconnect or Remove
    Command->>Tasks: Check conflicts before prompting
    Command->>User: Choose what happens to tabs; confirm unsaved changes if closing
    Command->>Tasks: Recheck the whole target set synchronously
    Command->>Client: Latch and advance the epoch before any await
    Command->>Views: Disable or close views; stop affected workers
    Command->>Client: Close client; clear caches as appropriate
    Command->>Tree: Refresh; offer Connect after Disconnect
Loading

A5 leases span client resolution through transfer cleanup. Connect clears only the explicit Disconnect hold; the tree reconnects using the retained identity. Remove drops cached credentials. The approved saved-edit lock (decision 0018) uses the same pre-save fence but always keep old tabs open and copyable, with no tab-choice prompt.

Draft scope and validation

PR6 targets feature/connection-lifecycle and includes merged PR4 (#1117) and PR5 (#1121).

OP-5 cleared: on the CI-built 1.1.1-alpha.4 VSIX at 71c646b67, the operator validated Keep open, Close all, Remove, and the saved-edit lock. Disconnect during import/export was verified by automated tests against the teardown preflight, not in a live transfer.

Follow-up at 762f49e6f: the tree says Reconnect; the auto-opened Dashboard resumes after a same-identity reconnect without replaying work. The recovery dialog uses the default Fluent layout and an unanimated full-webview backdrop.

Local Case 2 passed: localization generation and check, formatting, lint, build, strict workspace test type-check, full Vitest (9,901 passed, one skipped), and VSIX packaging. Browser checks also passed for the dialog layout and Dashboard reconnect. AI pre-review remains before handoff for operator review.

Part of #1102. Related: #1059, #566. See the WI-7 plan.

Post-merge description review

The 1.2.0 behavior supersedes the Dashboard-resume and saved-edit notes above. Disconnect, Delete Connection, and Disconnect and update for a live connection use the guarded teardown: active transfers keep running and block teardown; otherwise, open tabs can be closed or kept for inspection and copying. Reconnect starts a new session and cannot revive an old tab, including Cluster Dashboard. A blocked or canceled disconnect does not open the credential or connection-string editor.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Check the connection latch before admitting new work and include import/export leases in the existing task-conflict queries.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Check task and dirty-view conflicts, fence work before closing resources, and offer Connect without changing tree identity.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Fence the confirmed targets before deleting, and let a surviving connection reconnect if its storage deletion fails.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Retire only older view generations after storage changes, including password-only and partial writes. Keep the edit fence retryable until a change is confirmed.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…(WI-8)

Treat closed clients and terminal auth as unavailable, keep partial samples for unsupported commands, and resume one poll loop only after Retry.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Base automatically changed from dev/tnaum/connection-lifecycle-bound-surfaces to feature/connection-lifecycle November 24, 2026 17:23
Keep the import lease through cleanup and the bound import interruption handling from PR5.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Regenerate localization, apply repository formatting, keep Disconnect type narrowing explicit, and update the Atlas fixture for connected-state detection.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@tnaum-ms Tomasz Naumowicz (tnaum-ms) added the ci:full-requested Requests a full run of CI checks. label Nov 24, 2026
@github-actions github-actions Bot removed the ci:full-requested Requests a full run of CI checks. label Nov 24, 2026
@github-actions

github-actions Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

✅ CI passed: standard tier (ready PR)

Commit efd3cf2, workflow run.

Layer Result Ran or skipped because
Static checks ✅ passed every push
Unit tests ✅ passed every push
npm packages: verify tarballs ✅ passed packages/**, package-lock.json or the CI workflow changed
VSIX: inspect contents ✅ passed ready PR
VSIX: self-test of the checks ✅ passed build/verification/**, build/vite/**, the Vite configs, package-lock.json or the CI workflow changed
VSIX: activate in VS Code ✅ passed ready PR
VSIX: self-test of the activation check ✅ passed build/verification/**, build/vite/**, the Vite configs, package-lock.json or the CI workflow changed
Webview host in unbundled extensions ✅ passed packages/vscode-ext-webview/**, package-lock.json or the CI workflow changed
E2E ⏭️ not available yet arrives with the E2E iteration (full tier)

Full run: add the ci:full-requested label to run every layer once on the current commit.
Last full run: ✅ passed on 71c646b, requested by Tomasz Naumowicz (@tnaum-ms), run.

Code quality

Check Status How to fix
Localization (l10n) ✅ Passed Nothing to fix
ESLint ✅ Passed Nothing to fix
Prettier formatting ✅ Passed Nothing to fix

Build size

No size data for feature/connection-lifecycle yet; sizes only. VSIX: 8.8 MiB.

Artifacts: VSIX | Bundle-reports-45613596633 | L1-manifest-report-45613596633

All graphs (exact bytes)
Graph PR bytes
Collection View page (collectionView) 6,058,236
Document View page (documentView) 4,826,019
Local Quick Start page (localQuickStart) 1,592,278
Atlas Credentials page (atlasCredentials) 1,520,944
Cluster Dashboard page (clusterDashboard) 1,570,044
Diagnose Connection page (connectionDiagnostics) 1,543,859
Activation (mainStartup) 3,211,798
Extension host (main) 9,788,390
Playground worker (playgroundWorker) 5,415,042
VSIX (vsix) 9,259,313
playgroundTsPlugin 6,175
viewsEntry 1,468,371
viewsAssets 80,340
editorWorker 259,570
jsonWorker 389,427

Packaged bytes. Shared chunks count in every graph that loads them, so rows do not add up.

Updated in place on every run.

Use Reconnect for an explicit disconnect, keep Fluent layout defaults, and verify teardown rejects active import and export leases.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Reuse Retry for the auto-opened panel only after a same-identity reconnect. Record OP-5 evidence without claiming a live transfer test.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Unresolved critical issues can execute queued shell commands under newly saved credentials and discard document edits without confirmation during multi-connection teardown.

10 open issues
What changed in this PR

Adds explicit Disconnect to the DocumentDB extension and shares teardown with connection removal and folder deletion, addressing stale sessions and stranded views.

Changes:

  • Protects active tasks and transfers, with choices to close tabs or retain their contents disabled.
  • Locks old views after saved connection edits and supports same-identity Dashboard recovery after reconnect.
  • Adds commands, settings, localization, and focused lifecycle coverage.
File Description
src/​webviews/​documentdb/​documentView/​documentView.tsx Reports dirty-state transitions to the host.
src/​webviews/​documentdb/​documentView/​documentView.test.tsx Tests dirty-state reporting.
src/​webviews/​documentdb/​documentView/​documentsViewRouter.ts Adds the dirty-state reporting procedure.
src/​webviews/​documentdb/​documentView/​documentsViewRouter.test.ts Tests panel dirty-state updates.
src/​webviews/​documentdb/​documentView/​documentsViewController.ts Tracks each panel’s unsaved changes.
src/​webviews/​documentdb/​documentView/​documentsViewController.test.ts Tests per-panel dirty tracking.
src/​webviews/​documentdb/​clusterDashboard/​clusterDashboardRouter.test.ts Covers health-poll failure classification.
src/​webviews/​documentdb/​clusterDashboard/​clusterDashboardController.ts Requests recovery after same-identity reconnect.
src/​webviews/​documentdb/​clusterDashboard/​clusterDashboardController.test.ts Tests Dashboard reconnect eligibility.
src/​webviews/​documentdb/​clusterDashboard/​ClusterDashboard.tsx Pauses unavailable polling and handles reconnect.
src/​webviews/​documentdb/​boundViewOperations.ts Rejects retired bindings and maps closed clients.
src/​webviews/​components/​DisconnectedOverlay.tsx Uses standard dialog layout and instant backdrop.
src/​webviews/​components/​DisconnectedOverlay.test.tsx Updates dialog action selectors.
src/​webviews/​components/​DisconnectedOverlay.scss Removes custom dialog layout overrides.
src/​webviews/​_integration/​describeUnavailableConnection.ts Adds reconnect and settings-update guidance.
src/​webviews/​_integration/​connectionUnavailable.ts Adds the update-in-progress reason.
src/​tree/​documentdb/​ClusterItemBase.ts Adds Reconnect children and connected context.
src/​tree/​documentdb/​ClusterItemBase.test.ts Tests disconnected expansion and stable identity.
src/​tree/​connections-view/​LocalQuickStart/​LocalQuickStartItem.ts Honors disconnect before Quick Start preparation.
src/​tree/​connections-view/​DocumentDBClusterItem.ts Uses connection-aware tree context.
src/​settingsKeys.ts Defines the open-tabs teardown setting.
src/​services/​taskService/​taskService.ts Adds resource leases and admission guards.
src/​services/​taskService/​taskService.test.ts Tests lease conflicts and blocked admission.
src/​plugins/​service-atlas-mongodb/​discovery-tree/​AtlasClusterItem.ts Uses connection-aware Atlas tree context.
src/​plugins/​service-atlas-mongodb/​discovery-tree/​AtlasClusterItem.test.ts Updates client-state mocks.
src/​documentdb/​shell/​ShellTerminalLinkProvider.ts Registers shell disconnect callbacks.
src/​documentdb/​shell/​ShellSessionManager.ts Blocks worker use while connections are latched.
src/​documentdb/​shell/​ShellSessionManager.test.ts Tests disconnected worker admission.
src/​documentdb/​shell/​DocumentDBShellPty.ts Stops workers while retaining terminal contents.
src/​documentdb/​ConnectionUnavailableError.ts Adds the update-in-progress reason.
src/​documentdb/​connectionTeardown.ts Centralizes confirmation, fencing, and cleanup.
src/​documentdb/​connectionTeardown.test.ts Covers teardown choices, conflicts, and failures.
src/​documentdb/​connectionBindingRetirement.ts Tracks permanently retired view generations.
src/​documentdb/​ClustersExtension.ts Registers Disconnect and Reconnect commands.
src/​documentdb/​ClusterSession.ts Prevents retired sessions from operating.
src/​documentdb/​ClustersClient.ts Enforces retirement and supports fenced cleanup.
src/​documentdb/​ClustersClient.test.ts Tests retirement and identity-preserving teardown.
src/​commands/​updateCredentials/​updateCredentials.ts Routes credential saves through the edit fence.
src/​commands/​updateCredentials/​updateCredentials.test.ts Covers saved-edit retirement and shell choices.
src/​commands/​updateConnectionString/​updateConnectionString.ts Retires old views after connection-string edits.
src/​commands/​updateConnectionString/​updateConnectionString.test.ts Tests the revised saved-edit lifecycle.
src/​commands/​saveConnectionEdit.ts Fences persistence and retires changed settings.
src/​commands/​removeConnection/​removeConnection.ts Reuses shared teardown before storage deletion.
src/​commands/​playground/​executePlaygroundCode.ts Adds teardown-aware evaluator stopping and guards.
src/​commands/​openInteractiveShell/​openInteractiveShell.ts Wires terminal disconnect callbacks.
src/​commands/​openClusterDashboard/​openClusterDashboard.ts Passes automatic-open reconnect context.
src/​commands/​importDocuments/​importDocuments.ts Holds a lease throughout database import work.
src/​commands/​importDocuments/​importDocuments.test.ts Tests transfer lease lifetime and teardown blocking.
src/​commands/​exportDocuments/​exportDocuments.ts Holds a lease through export completion.
src/​commands/​disconnect/​disconnect.ts Implements explicit Disconnect and Reconnect.
src/​commands/​dashboardBoundCommands.test.ts Updates connection-latch mocks.
src/​commands/​connections-view/​deleteFolder/​ExecuteStep.ts Tears down descendants before deleting storage.
src/​commands/​connections-view/​deleteFolder/​deleteFolder.test.ts Adapts tests to shared removal.
package.nls.json Adds the localized Disconnect command title.
package.json Contributes Disconnect, tab settings, and version update.
package-lock.json Synchronizes the prerelease version.
l10n/​bundle.l10n.json Updates lifecycle messages.
docs/​ai-and-plans/​features/​connection-lifecycle/​README.md Documents retained Dashboard reconnect behavior.
docs/​ai-and-plans/​features/​connection-lifecycle/​iterations/​01-implementation-plan.md Updates disconnect acceptance scenarios.
docs/​ai-and-plans/​features/​connection-lifecycle/​iterations/​01-dev-plan.md Records teardown design and validation progress.
build/​verification/​browser/​scenarios.ts Exercises stale polling and Dashboard recovery.

Review effort: Max

Comment thread src/documentdb/connectionTeardown.ts Resolved
Comment thread package.json Resolved
Comment thread src/commands/disconnect/disconnect.ts Resolved
Comment thread src/commands/saveConnectionEdit.ts Resolved
Comment thread src/documentdb/connectionTeardown.ts Resolved
Comment thread src/documentdb/connectionTeardown.ts Resolved
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

2 participants