[Repo Assist] fix: reset node/gateway state on settings save; clear _isPendingApproval on disconnect#115
Merged
shanselman merged 1 commit intomasterfrom Apr 1, 2026
Conversation
…val on disconnect When settings are saved and the connection mode changes (e.g. operator → node or node → operator), the previous code left _gatewayClient non-null after disposal and did not reset _currentStatus. This caused the tray to show a stale 'Status: Connected' from the old operator connection while the new node mode service was still establishing, making it appear that Node Mode was Disconnected even though the operator was still connected. Fixes: - OnSettingsSaved: call UnsubscribeGatewayEvents() before Dispose(), null out _gatewayClient, reset _currentStatus to Disconnected and call UpdateTrayIcon() so the UI reflects the transition immediately. - WindowsNodeClient.OnDisconnected / OnError: also reset _isPendingApproval so the menu correctly shows 'Disconnected' rather than 'Waiting for Approval' during the reconnect window before hello-ok arrives. Closes #114 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This was referenced Mar 29, 2026
Closed
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.
🤖 This is an automated draft PR from Repo Assist.
Summary
Two related bugs caused the tray to misreport connection state in node mode, contributing to the symptoms described in #114 ("Status: Connected, Node Mode: Disconnected").
Root causes
1. Stale
_currentStatusand non-null_gatewayClientafter settings saveOnSettingsSaveddisposed the old gateway client but did not:UnsubscribeGatewayEvents()before disposing_gatewayClient_currentStatusResult: if the user was previously in operator mode (Status: Connected), switching to node mode via Settings left the tray showing "Status: Connected" while the node connection was still establishing — showing "Node Mode: Disconnected". The two contradictory indicators come directly from this stale state.
Additionally,
_gatewayClient != nullremaining true caused code paths likeShowTrayMenuPopup's health-check fetch andShowStatusDetailto proceed with a disposed client.2.
_isPendingApprovalnot reset on connection dropWindowsNodeClient.OnDisconnectedandOnErrorreset_isConnectedbut not_isPendingApproval. After a connection drop + reconnect, the tray would show "Waiting for Approval" until hello-ok was received again, even though the pairing state is unknown during the reconnect gap. Now both flags are reset together.Changes
App.xaml.cs—OnSettingsSavedUnsubscribeGatewayEvents()beforeDispose()_gatewayClient = nullafter disposal_currentStatus = ConnectionStatus.Disconnectedand callUpdateTrayIcon()so the tray reflects the transition immediatelyWindowsNodeClient.cs—OnDisconnected/OnError_isPendingApproval = falsealongside_isConnected = falseTest Status
✅ 503 shared tests pass, 18 skipped
✅ 93 Tray tests pass
Closes #114