Select saved remote bindings after local open

This commit is contained in:
Joe Julian
2026-04-06 17:21:17 -07:00
parent 71a0d75886
commit 574e2a2762
2 changed files with 157 additions and 0 deletions
+45
View File
@@ -1035,6 +1035,7 @@ func (u *ui) openVaultAction() error {
u.resetPasswordPeek()
u.currentPath = append([]string(nil), u.state.CurrentPath...)
u.restoreRecentVaultGroup(path)
u.syncSavedRemoteBindingSelection()
u.loadSecuritySettingsFromSession()
u.editingEntry = false
u.filter()
@@ -1072,6 +1073,7 @@ func (u *ui) startOpenVaultAction() {
u.resetPasswordPeek()
u.currentPath = append([]string(nil), u.state.CurrentPath...)
u.restoreRecentVaultGroup(path)
u.syncSavedRemoteBindingSelection()
u.loadSecuritySettingsFromSession()
u.editingEntry = false
u.filter()
@@ -2199,6 +2201,49 @@ func (u *ui) selectedVaultRemoteBinding() (appstate.RemoteBinding, bool) {
}, true
}
func (u *ui) syncSavedRemoteBindingSelection() {
profiles := u.availableRemoteProfiles()
entries := u.availableRemoteCredentialEntries()
profileID := strings.TrimSpace(u.selectedVaultRemoteProfileID)
if profileID != "" {
var found bool
for _, profile := range profiles {
if profile.ID == profileID {
found = true
break
}
}
if !found {
u.selectedVaultRemoteProfileID = ""
}
}
if strings.TrimSpace(u.selectedVaultRemoteProfileID) == "" && len(profiles) == 1 {
u.selectedVaultRemoteProfileID = profiles[0].ID
}
if profile, ok := u.selectedVaultRemoteProfile(); ok {
u.remoteBaseURL.SetText(profile.BaseURL)
u.remotePath.SetText(profile.Path)
}
entryID := strings.TrimSpace(u.selectedVaultRemoteCredentialEntryID)
if entryID != "" {
var found bool
for _, entry := range entries {
if entry.ID == entryID {
found = true
break
}
}
if !found {
u.selectedVaultRemoteCredentialEntryID = ""
}
}
if strings.TrimSpace(u.selectedVaultRemoteCredentialEntryID) == "" && len(entries) == 1 {
u.selectedVaultRemoteCredentialEntryID = entries[0].ID
}
}
func (u *ui) shouldShowSavedRemoteBindingSelectors() bool {
profiles := u.availableRemoteProfiles()
entries := u.availableRemoteCredentialEntries()