Add sync mode choice to remote setup

This commit is contained in:
Joe Julian
2026-04-06 20:41:21 -07:00
parent 94ee7fd4c0
commit 554d4f760d
2 changed files with 84 additions and 1 deletions
+23 -1
View File
@@ -380,6 +380,7 @@ type ui struct {
cancelLifecycleProgress widget.Clickable
retryLifecycleOpen widget.Clickable
approvalPermanent widget.Bool
syncSetupAutomatic widget.Bool
apiPolicyAllow widget.Bool
apiPolicyGroupScopeW widget.Bool
apiTokenDisabled widget.Bool
@@ -1387,11 +1388,15 @@ func (u *ui) openRemoteSyncSetupDialog() {
u.syncDialogPurpose = syncDialogPurposeRemoteSetup
u.syncSourceMode = syncSourceRemote
u.syncDirection = syncDirectionPush
u.syncSetupAutomatic.Value = true
if strings.TrimSpace(u.syncLocalPath.Text()) == "" {
u.syncLocalPath.SetText(strings.TrimSpace(u.vaultPath.Text()))
}
u.syncSavedRemoteBindingSelection()
u.prefillAdvancedSyncRemoteFromSavedBinding()
if _, ok := u.selectedVaultRemoteBinding(); ok && u.selectedVaultRemoteSyncMode == appstate.SyncModeManual {
u.syncSetupAutomatic.Value = false
}
}
func (u *ui) clearSyncLocalImport() {
@@ -1576,7 +1581,7 @@ func (u *ui) persistSyncDialogRemoteBinding(baseURL, remotePath string) error {
Username: strings.TrimSpace(u.syncRemoteUsername.Text()),
Password: u.syncRemotePassword.Text(),
CredentialPath: append([]string(nil), u.currentPath...),
SyncMode: u.newRemoteBindingSyncMode(),
SyncMode: u.syncSetupMode(),
}
binding, err := u.state.ConfigureRemoteBinding(input)
if err != nil {
@@ -2380,6 +2385,13 @@ func (u *ui) shouldShowSyncSourceChoices() bool {
return u.syncDialogPurpose != syncDialogPurposeRemoteSetup
}
func (u *ui) syncSetupMode() appstate.SyncMode {
if u.syncSetupAutomatic.Value {
return appstate.SyncModeAutomaticOnOpenSave
}
return appstate.SyncModeManual
}
func (u *ui) selectVaultRemoteProfile(id string) {
id = strings.TrimSpace(id)
u.selectedVaultRemoteProfileID = id
@@ -5079,6 +5091,16 @@ func (u *ui) syncDialogContent(gtx layout.Context) layout.Dimensions {
return u.syncPasswordField(gtx)
}),
}
if u.syncDialogPurpose == syncDialogPurposeRemoteSetup {
children = append(children,
layout.Rigid(layout.Spacer{Height: unit.Dp(8)}.Layout),
layout.Rigid(func(gtx layout.Context) layout.Dimensions {
check := material.CheckBox(u.theme, &u.syncSetupAutomatic, "Sync automatically on open and save")
check.Color = accentColor
return check.Layout(gtx)
}),
)
}
if len(matchingCredentials) > 0 {
children = append(children,
layout.Rigid(layout.Spacer{Height: unit.Dp(8)}.Layout),