From 5d435f1f1ff06595c79cde623f459c6519924d5a Mon Sep 17 00:00:00 2001 From: Joe Julian Date: Mon, 6 Apr 2026 22:30:05 -0700 Subject: [PATCH] Move remote sync actions into sync menu --- main.go | 87 ++++++++++++++++++++++++++++++---------------------- main_test.go | 49 +++++++++++++++++++++++++++++ 2 files changed, 99 insertions(+), 37 deletions(-) diff --git a/main.go b/main.go index 827793b..bed5e88 100644 --- a/main.go +++ b/main.go @@ -2764,6 +2764,23 @@ func (u *ui) remoteSyncSetupShortcutLabel() string { return "Set Up Remote Sync" } +func (u *ui) syncMenuActionLabels() []string { + labels := []string{"Open Advanced Sync"} + if u.shouldShowRemoteSyncSetupShortcut() { + labels = append(labels, u.remoteSyncSetupShortcutLabel()) + } + if u.shouldShowDirectRemoteSyncShortcut() { + labels = append(labels, u.directRemoteSyncShortcutLabel()) + } + if u.shouldShowRemoteSyncSettingsShortcut() { + labels = append(labels, u.remoteSyncSettingsShortcutLabel()) + } + if u.shouldShowRemoveRemoteSyncShortcut() { + labels = append(labels, u.removeRemoteSyncShortcutLabel()) + } + return labels +} + func remoteBindingSuffix(baseURL, path, username string) string { sum := sha256.Sum256([]byte(strings.TrimSpace(baseURL) + "\n" + strings.TrimSpace(path) + "\n" + strings.TrimSpace(username))) return hex.EncodeToString(sum[:8]) @@ -5663,6 +5680,38 @@ func (u *ui) syncMenu(gtx layout.Context) layout.Dimensions { return tonedButton(gtx, u.theme, &u.openAdvancedSync, "Open Advanced Sync") }), } + if u.shouldShowRemoteSyncSetupShortcut() { + rows = append(rows, + layout.Rigid(layout.Spacer{Height: unit.Dp(6)}.Layout), + layout.Rigid(func(gtx layout.Context) layout.Dimensions { + return tonedButton(gtx, u.theme, &u.useSavedAdvancedSyncRemote, u.remoteSyncSetupShortcutLabel()) + }), + ) + } + if u.shouldShowDirectRemoteSyncShortcut() { + rows = append(rows, + layout.Rigid(layout.Spacer{Height: unit.Dp(6)}.Layout), + layout.Rigid(func(gtx layout.Context) layout.Dimensions { + return tonedButton(gtx, u.theme, &u.openSelectedVaultRemote, u.directRemoteSyncShortcutLabel()) + }), + ) + } + if u.shouldShowRemoteSyncSettingsShortcut() { + rows = append(rows, + layout.Rigid(layout.Spacer{Height: unit.Dp(6)}.Layout), + layout.Rigid(func(gtx layout.Context) layout.Dimensions { + return tonedButton(gtx, u.theme, &u.useSavedAdvancedSyncRemote, u.remoteSyncSettingsShortcutLabel()) + }), + ) + } + if u.shouldShowRemoveRemoteSyncShortcut() { + rows = append(rows, + layout.Rigid(layout.Spacer{Height: unit.Dp(6)}.Layout), + layout.Rigid(func(gtx layout.Context) layout.Dimensions { + return tonedButton(gtx, u.theme, &u.removeSelectedRemoteBinding, u.removeRemoteSyncShortcutLabel()) + }), + ) + } if u.hasOpenVault() && len(profiles) > 0 && len(credentials) > 0 { rows = append(rows, layout.Rigid(layout.Spacer{Height: unit.Dp(10)}.Layout), @@ -7021,43 +7070,7 @@ func (u *ui) pathBar(gtx layout.Context) layout.Dimensions { return children }()...) } - if !u.shouldShowDirectRemoteSyncShortcut() && !u.shouldShowRemoteSyncSetupShortcut() && !u.shouldShowRemoteSyncSettingsShortcut() && !u.shouldShowRemoveRemoteSyncShortcut() { - return crumbBar(gtx) - } - children := []layout.FlexChild{ - layout.Rigid(crumbBar), - layout.Rigid(layout.Spacer{Height: unit.Dp(6)}.Layout), - } - if u.shouldShowDirectRemoteSyncShortcut() { - children = append(children, layout.Rigid(func(gtx layout.Context) layout.Dimensions { - return tonedButton(gtx, u.theme, &u.openSelectedVaultRemote, u.directRemoteSyncShortcutLabel()) - })) - } - if u.shouldShowRemoteSyncSetupShortcut() { - if u.shouldShowDirectRemoteSyncShortcut() { - children = append(children, layout.Rigid(layout.Spacer{Height: unit.Dp(6)}.Layout)) - } - children = append(children, layout.Rigid(func(gtx layout.Context) layout.Dimensions { - return tonedButton(gtx, u.theme, &u.useSavedAdvancedSyncRemote, u.remoteSyncSetupShortcutLabel()) - })) - } - if u.shouldShowRemoteSyncSettingsShortcut() { - if u.shouldShowDirectRemoteSyncShortcut() || u.shouldShowRemoteSyncSetupShortcut() { - children = append(children, layout.Rigid(layout.Spacer{Height: unit.Dp(6)}.Layout)) - } - children = append(children, layout.Rigid(func(gtx layout.Context) layout.Dimensions { - return tonedButton(gtx, u.theme, &u.useSavedAdvancedSyncRemote, u.remoteSyncSettingsShortcutLabel()) - })) - } - if u.shouldShowRemoveRemoteSyncShortcut() { - if u.shouldShowDirectRemoteSyncShortcut() || u.shouldShowRemoteSyncSetupShortcut() || u.shouldShowRemoteSyncSettingsShortcut() { - children = append(children, layout.Rigid(layout.Spacer{Height: unit.Dp(6)}.Layout)) - } - children = append(children, layout.Rigid(func(gtx layout.Context) layout.Dimensions { - return tonedButton(gtx, u.theme, &u.removeSelectedRemoteBinding, u.removeRemoteSyncShortcutLabel()) - })) - } - return layout.Flex{Axis: layout.Vertical}.Layout(gtx, children...) + return crumbBar(gtx) } func (u *ui) visibleBreadcrumbs(displayPath []string) ([]string, []int) { diff --git a/main_test.go b/main_test.go index 50f7aae..fa09fb6 100644 --- a/main_test.go +++ b/main_test.go @@ -5953,6 +5953,55 @@ func TestUIRemoteSetupShortcutHasParityAcrossModes(t *testing.T) { } } +func TestUISyncMenuActionLabelsIncludeRemoteSetupForUnboundVault(t *testing.T) { + t.Parallel() + + u := newUIWithModel("desktop", vault.Model{ + Entries: []vault.Entry{{ + ID: "entry-1", + Title: "Mint Console", + Path: []string{"Crew", "Signals"}, + }}, + }) + u.state.Section = appstate.SectionEntries + + got := u.syncMenuActionLabels() + if !slices.Contains(got, "Set Up Remote Sync") { + t.Fatalf("syncMenuActionLabels() = %v, want Set Up Remote Sync", got) + } + if slices.Contains(got, "Use Remote Sync") { + t.Fatalf("syncMenuActionLabels() = %v, want no Use Remote Sync without saved binding", got) + } +} + +func TestUISyncMenuActionLabelsIncludeSavedRemoteActionsForBoundVault(t *testing.T) { + t.Parallel() + + u := newUIWithModel("desktop", vault.Model{ + Entries: []vault.Entry{{ + ID: "remote-creds-1", + Title: "Bellagio WebDAV Sign-In", + Username: "linuscaldwell", + Path: []string{"Crew", "Signals"}, + }}, + RemoteProfiles: []vault.RemoteProfile{{ + ID: "bellagio-webdav", + Name: "Bellagio Vault", + Backend: vault.RemoteBackendWebDAV, + BaseURL: "https://dav.example.invalid/remote.php/dav", + Path: "files/bellagio/keepass.kdbx", + }}, + }) + u.state.Section = appstate.SectionEntries + + got := u.syncMenuActionLabels() + for _, want := range []string{"Use Remote Sync", "Remote Sync Settings", "Stop Using Remote Sync"} { + if !slices.Contains(got, want) { + t.Fatalf("syncMenuActionLabels() = %v, want %q", got, want) + } + } +} + func TestUIShouldHideRemoteSyncSetupShortcutWhenSavedBindingExists(t *testing.T) { t.Parallel()