Show sync mode in saved remote summary

This commit is contained in:
Joe Julian
2026-04-06 20:55:46 -07:00
parent 84512172f3
commit 60172d8c6d
2 changed files with 48 additions and 6 deletions
+15 -5
View File
@@ -2593,20 +2593,24 @@ func (u *ui) shouldShowSavedRemoteBindingSelectors() bool {
return len(profiles) > 1 || len(entries) > 1
}
func (u *ui) savedRemoteBindingSummary() (profileLabel, credentialLabel string, ok bool) {
func (u *ui) savedRemoteBindingSummary() (profileLabel, credentialLabel, syncLabel string, ok bool) {
profile, ok := u.selectedVaultRemoteProfile()
if !ok {
return "", "", false
return "", "", "", false
}
entry, ok := u.selectedVaultRemoteCredentialEntry()
if !ok {
return "", "", false
return "", "", "", false
}
credentialLabel = entry.Title
if strings.TrimSpace(entry.Username) != "" {
credentialLabel += " · " + strings.TrimSpace(entry.Username)
}
return profile.Name, credentialLabel, true
syncLabel = "Sync manually when you choose Use Remote Sync."
if normalizeUISyncMode(u.selectedVaultRemoteSyncMode) == appstate.SyncModeAutomaticOnOpenSave {
syncLabel = "Syncs automatically on open and save."
}
return profile.Name, credentialLabel, syncLabel, true
}
func (u *ui) savedRemoteBindingHeading() string {
@@ -5573,7 +5577,7 @@ func (u *ui) syncMenu(gtx layout.Context) layout.Dimensions {
if !u.shouldShowSavedRemoteBindingSelectors() {
rows = append(rows,
layout.Rigid(func(gtx layout.Context) layout.Dimensions {
profileLabel, credentialLabel, ok := u.savedRemoteBindingSummary()
profileLabel, credentialLabel, syncLabel, ok := u.savedRemoteBindingSummary()
if !ok {
return layout.Dimensions{}
}
@@ -5591,6 +5595,12 @@ func (u *ui) syncMenu(gtx layout.Context) layout.Dimensions {
lbl.Color = mutedColor
return lbl.Layout(gtx)
}),
layout.Rigid(layout.Spacer{Height: unit.Dp(2)}.Layout),
layout.Rigid(func(gtx layout.Context) layout.Dimensions {
lbl := material.Label(u.theme, unit.Sp(12), syncLabel)
lbl.Color = mutedColor
return lbl.Layout(gtx)
}),
)
})
})
+33 -1
View File
@@ -5692,7 +5692,7 @@ func TestUISavedRemoteBindingSummaryUsesImplicitSingleChoice(t *testing.T) {
}},
})
profileLabel, credentialLabel, ok := u.savedRemoteBindingSummary()
profileLabel, credentialLabel, syncLabel, ok := u.savedRemoteBindingSummary()
if !ok {
t.Fatal("savedRemoteBindingSummary() ok = false, want true")
}
@@ -5702,6 +5702,38 @@ func TestUISavedRemoteBindingSummaryUsesImplicitSingleChoice(t *testing.T) {
if credentialLabel != "WebDAV Sign-In · tjulian" {
t.Fatalf("credentialLabel = %q, want WebDAV Sign-In · tjulian", credentialLabel)
}
if syncLabel != "Sync manually when you choose Use Remote Sync." {
t.Fatalf("syncLabel = %q, want manual sync summary", syncLabel)
}
}
func TestUISavedRemoteBindingSummaryMentionsAutomaticSyncMode(t *testing.T) {
t.Parallel()
u := newUIWithModel("desktop", vault.Model{
Entries: []vault.Entry{{
ID: "remote-creds-1",
Title: "WebDAV Sign-In",
Username: "tjulian",
Path: []string{"Crew", "Internet"},
}},
RemoteProfiles: []vault.RemoteProfile{{
ID: "family-webdav",
Name: "Family Vault",
Backend: vault.RemoteBackendWebDAV,
BaseURL: "https://dav.example.invalid/remote.php/dav",
Path: "files/family/keepass.kdbx",
}},
})
u.selectedVaultRemoteSyncMode = appstate.SyncModeAutomaticOnOpenSave
_, _, syncLabel, ok := u.savedRemoteBindingSummary()
if !ok {
t.Fatal("savedRemoteBindingSummary() ok = false, want true")
}
if syncLabel != "Syncs automatically on open and save." {
t.Fatalf("syncLabel = %q, want automatic sync summary", syncLabel)
}
}
func TestUISavedRemoteBindingHeadingUsesSyncLanguageForSingleChoice(t *testing.T) {