Refine remote open lifecycle flow

This commit is contained in:
Joe Julian
2026-04-01 17:10:23 -07:00
parent b7e37820b8
commit e364630b77
3 changed files with 248 additions and 43 deletions
+52
View File
@@ -1339,6 +1339,28 @@ func (u *ui) latestRecentRemote() (recentRemoteRecord, bool, time.Time) {
return recentRemoteRecord{}, false, time.Time{}
}
func (u *ui) currentRemoteRecord() recentRemoteRecord {
return recentRemoteRecord{
BaseURL: strings.TrimSpace(u.remoteBaseURL.Text()),
Path: strings.TrimSpace(u.remotePath.Text()),
Username: strings.TrimSpace(u.remoteUsername.Text()),
Password: u.remotePassword.Text(),
}
}
func (u *ui) selectedRecentRemoteRecord() (recentRemoteRecord, bool) {
record := u.currentRemoteRecord()
if record.BaseURL == "" || record.Path == "" {
return recentRemoteRecord{}, false
}
for _, existing := range u.recentRemotes {
if existing.BaseURL == record.BaseURL && existing.Path == record.Path {
return existing, true
}
}
return recentRemoteRecord{}, false
}
func (u *ui) applyRecentRemoteRecord(record recentRemoteRecord) {
u.remoteBaseURL.SetText(record.BaseURL)
u.remotePath.SetText(record.Path)
@@ -1348,6 +1370,20 @@ func (u *ui) applyRecentRemoteRecord(record recentRemoteRecord) {
u.rememberRemoteAuth.Value = strings.TrimSpace(record.Username) != "" || record.Password != ""
}
func (u *ui) remoteAuthStatusMessage() string {
selected, hasSelected := u.selectedRecentRemoteRecord()
switch {
case !u.rememberRemoteAuth.Value:
return "Only the location will be saved in Recent Connections."
case hasSelected && (strings.TrimSpace(selected.Username) != "" || selected.Password != ""):
return "Saved sign-in will be updated for this connection."
case strings.TrimSpace(u.remoteUsername.Text()) != "" || u.remotePassword.Text() != "":
return "This sign-in will be saved in Recent Connections after a successful open."
default:
return "Enter a username or password to save sign-in details for this connection."
}
}
func (u *ui) noteCurrentRemotePath() {
status, ok := u.state.Session.(sessionStatus)
if !ok || !status.IsRemote() || status.IsLocked() {
@@ -1715,6 +1751,21 @@ func (u *ui) describeActionError(label string, err error) string {
return err.Error()
}
func (u *ui) remoteOpenRetryAvailable() bool {
return u.lifecycleMode == "remote" && strings.HasPrefix(strings.TrimSpace(u.state.ErrorMessage), "open remote vault failed:")
}
func (u *ui) remoteOpenButtonLabel() string {
switch {
case u.lifecycleBusy():
return "Opening Remote Vault..."
case u.remoteOpenRetryAvailable():
return "Retry Remote Vault"
default:
return "Open Remote Vault"
}
}
func (u *ui) bannerSurface() uiBanner {
switch {
case strings.TrimSpace(u.loadingMessage) != "":
@@ -2197,6 +2248,7 @@ func (u *ui) layout(gtx layout.Context) layout.Dimensions {
u.remotePath.SetText("")
u.remoteUsername.SetText("")
u.remotePassword.SetText("")
u.rememberRemoteAuth.Value = false
u.state.ErrorMessage = ""
u.state.StatusMessage = ""
}