Skip to content

[Repo Assist] fix: reset node/gateway state on settings save; clear _isPendingApproval on disconnect#115

Merged
shanselman merged 1 commit intomasterfrom
repo-assist/fix-issue-114-node-mode-stale-status-a399dc5e3cb112be
Apr 1, 2026
Merged

[Repo Assist] fix: reset node/gateway state on settings save; clear _isPendingApproval on disconnect#115
shanselman merged 1 commit intomasterfrom
repo-assist/fix-issue-114-node-mode-stale-status-a399dc5e3cb112be

Conversation

@github-actions
Copy link
Copy Markdown
Contributor

🤖 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 _currentStatus and non-null _gatewayClient after settings save

OnSettingsSaved disposed the old gateway client but did not:

  • call UnsubscribeGatewayEvents() before disposing
  • null out _gatewayClient
  • reset _currentStatus

Result: 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 != null remaining true caused code paths like ShowTrayMenuPopup's health-check fetch and ShowStatusDetail to proceed with a disposed client.

2. _isPendingApproval not reset on connection drop

WindowsNodeClient.OnDisconnected and OnError reset _isConnected but 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.csOnSettingsSaved

  • Call UnsubscribeGatewayEvents() before Dispose()
  • Set _gatewayClient = null after disposal
  • Reset _currentStatus = ConnectionStatus.Disconnected and call UpdateTrayIcon() so the tray reflects the transition immediately

WindowsNodeClient.csOnDisconnected / OnError

  • Also reset _isPendingApproval = false alongside _isConnected = false

Test Status

✅ 503 shared tests pass, 18 skipped
✅ 93 Tray tests pass

Closes #114

Generated by Repo Assist ·

To install this agentic workflow, run

gh aw add githubnext/agentics/workflows/repo-assist.md@cbb46ab386962aa371045839fc9998ee4e97ca64

…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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Node mode not work

1 participant