Skip to content

fix(lsp): preserve websocket clients across tab switches - #2764

Merged
bajrangCoder merged 2 commits into
mainfrom
fix/lsp-websocket-tab-switch
Aug 18, 2026
Merged

fix(lsp): preserve websocket clients across tab switches#2764
bajrangCoder merged 2 commits into
mainfrom
fix/lsp-websocket-tab-switch

Conversation

@bajrangCoder

@bajrangCoder bajrangCoder commented Aug 18, 2026

Copy link
Copy Markdown
Member

Closes: #2680

Keep externally managed WebSocket runtimes alive when editor views detach,
retain eager cleanup for owned runtimes
@greptile-apps

greptile-apps Bot commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR replaces indefinite idle-client retention with a configurable grace period, preserving an LSP connection across short tab switches while eventually disposing clients that remain unused.

  • Adds a cancellable 15-second idle timer to each cached LSP client.
  • Cancels pending disposal when a document reattaches.
  • Adds lifecycle coverage for WebSocket and transport-based runtimes.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Important Files Changed

Filename Overview
src/cm/lsp/clientManager.ts Adds a per-client cancellable idle grace timer and retains eventual disposal for clients with no attached files.
src/cm/lsp/types.ts Exposes an optional finite idle grace-period configuration in client-manager options.
tests/unit/lspExternalWebSocketLifecycle.test.js Verifies reuse during the grace period and eventual disposal for WebSocket and generic transport runtimes.

Sequence Diagram

sequenceDiagram
  participant Tab
  participant Manager as LspClientManager
  participant Timer as Idle timer
  participant Client as LSP client
  Tab->>Manager: Detach last document
  Manager->>Timer: Schedule grace period
  alt Document reattaches during grace period
    Tab->>Manager: Attach document
    Manager->>Timer: Cancel
    Manager-->>Tab: Reuse existing client
  else Client remains idle
    Timer->>Manager: Grace period expires
    Manager->>Client: onClientIdle → dispose
  end
Loading

Reviews (2): Last reviewed commit: "fix(lsp): dispose idle clients after gra..." | Re-trigger Greptile

Comment thread src/cm/lsp/clientManager.ts Outdated
@bajrangCoder

This comment was marked as outdated.

@bajrangCoder
bajrangCoder added this pull request to the merge queue Aug 18, 2026
Merged via the queue into main with commit 85106aa Aug 18, 2026
11 checks passed
@github-project-automation github-project-automation Bot moved this from Backlog to Done in The Code Board - Acode Aug 18, 2026
@bajrangCoder
bajrangCoder deleted the fix/lsp-websocket-tab-switch branch August 18, 2026 01:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Custom WS LSP restarting on every file switch

1 participant