From 60172d8c6d1758bfbee6eb9c2cfde80b49befc89 Mon Sep 17 00:00:00 2001 From: Joe Julian Date: Mon, 6 Apr 2026 20:55:46 -0700 Subject: [PATCH] Show sync mode in saved remote summary --- main.go | 20 +++++++++++++++----- main_test.go | 34 +++++++++++++++++++++++++++++++++- 2 files changed, 48 insertions(+), 6 deletions(-) diff --git a/main.go b/main.go index ef447a6..b0b2351 100644 --- a/main.go +++ b/main.go @@ -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) + }), ) }) }) diff --git a/main_test.go b/main_test.go index 77a19ea..29ff5dc 100644 --- a/main_test.go +++ b/main_test.go @@ -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) {