Skip to content

internal/ui: prevent spurious profile switch when opening main window#281

Closed
gitzone83 wants to merge 1 commit intoDeedleFake:masterfrom
gitzone83:fix/profile-dropdown-switch
Closed

internal/ui: prevent spurious profile switch when opening main window#281
gitzone83 wants to merge 1 commit intoDeedleFake:masterfrom
gitzone83:fix/profile-dropdown-switch

Conversation

@gitzone83
Copy link
Copy Markdown
Contributor

Summary

  • When the main window opens or receives a ProfileStatus update, updateProfiles() rebuilds the dropdown model, resetting the selection to index 0. This fires the selected-item notification handler, which calls SwitchProfile for the wrong profile — silently switching tailnets without user action.
  • Added an updatingProfiles flag to skip SwitchProfile calls triggered by programmatic model rebuilds
  • Added an activeProfileID check to skip redundant switches even outside of model rebuilds

Fixes #251

When the main window opens or receives a ProfileStatus update,
updateProfiles() rebuilds the dropdown model, which resets the
selection to index 0. This fires the selected-item notification
handler, which calls SwitchProfile for the wrong profile —
silently switching tailnets without user action.

Two guards added:
- updatingProfiles flag: set during updateProfiles(), causes the
  notification handler to skip SwitchProfile calls triggered by
  programmatic model rebuilds
- activeProfileID check: compares the selected profile against
  the currently active profile and skips the switch if they match,
  preventing redundant SwitchProfile calls even outside of model
  rebuilds

Fixes DeedleFake#277
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Opening the application window toggles multiple tailnet swithing randomly

1 participant