Add configurable connection timeout as a VS Code setting for instrument connections - #315
Merged
suribabu-ganti merged 8 commits intoAug 27, 2026
Conversation
Wrap runConnectFlow with runConnectFlowWithTimeout, which reads the tsp.connectionTimeout setting and cancels an in-progress connection attempt if it doesn't complete in time, notifying the user with a warning message. Add Connection.combineCancellationTokens() to merge the existing progress-cancellation token with a timeout-driven token, so a timeout is handled through the same cancellation path already used for user-initiated cancellation (terminates the background process and restores the original status). A timeout of 0 (or an invalid value) disables the timeout entirely.
…tionTokens now returns a disposable that removes its listeners once a connect() attempt finishes, instead of leaving them registered indefinitely - Add a safe process-termination helper (terminateBackgroundProcess) that only clears/kills _background_process if it's still the same process instance, preventing a stale timeout/callback from terminating a newer background process - Ensure proper timeout vs user cancellation handling: both paths now go through the same cancellation flow, reliably terminating the active background process and restoring the prior connection status
Add CancelReason ("user" | "timeout") tracked in runConnectFlowWithTimeout and passed into runConnectFlow, so cancellation logs correctly report "cancelled by user" vs "cancelled due to timeout" instead of a single generic message.
Use a first-cancellation-wins rule: cancelReason is set by whichever source (user cancel or timeout) fires first, with the user-cancellation listener registered before combineCancellationTokens() so it always runs before the forwarding listener that triggers runConnectFlow's handler. This avoids an ambiguous reason when both fire nearly simultaneously.
Forward status updates when an existing connection is merged by address and type, ensuring the instrument explorer icon transitions correctly from Connecting to Connected or Active instead of remaining stuck on the initial status.
…connecting-to-instrument-Part-2
esarver
approved these changes
Aug 26, 2026
suribabu-ganti
deleted the
task/TSP-822-UX-improvements-when-connecting-to-instrument-Part-2
branch
August 27, 2026 05:02
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Users can now set connectionTimeout to bound how long a connection attempt may run. If it doesn't complete in time, the attempt is cancelled and the user is notified with a warning message.
Reads tsp.connectionTimeout from configuration.
If 0/invalid, calls runConnectFlow unchanged (no timeout).
Otherwise starts a setTimeout for that many seconds; if it fires, logs a warning, and shows warning message to notify the user the connection timed out.