Skip to content

Fix spurious profile switch when opening main window#279

Merged
DeedleFake merged 1 commit intoDeedleFake:masterfrom
gitzone83:fix/profile-dropdown-switch
Apr 15, 2026
Merged

Fix spurious profile switch when opening main window#279
DeedleFake merged 1 commit intoDeedleFake:masterfrom
gitzone83:fix/profile-dropdown-switch

Conversation

@gitzone83
Copy link
Copy Markdown
Contributor

Summary

Fixes #277

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

Changes

Two guards added to internal/ui/mainwindow.go:

  • updatingProfiles flag — set to true during updateProfiles(), causes the notification handler to return early and skip SwitchProfile calls triggered by programmatic model rebuilds
  • activeProfileID check — the notification handler compares the selected profile ID against the currently active profile (tracked via activeProfileID, updated in updateProfiles()) and skips the switch if they match, preventing redundant SwitchProfile calls even outside of model rebuilds

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
@DeedleFake DeedleFake merged commit b755ad4 into DeedleFake:master Apr 15, 2026
1 of 4 checks passed
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 main window can spuriously switch tailnets when active profile is not the alphabetically-first one

2 participants