From 3a17d0381cc28ef29be9ca5b169433d82c9759d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zolt=C3=A1n=20Papp?= Date: Thu, 30 Jul 2026 20:45:14 +0200 Subject: [PATCH] [client] Clear the removed profile's email by its resolved ID MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit RemoveProfile takes a handle — a display name or an ID prefix resolve just as well as a full ID — but the state file holding the account email is named after the ID. Passing the request handle straight through therefore named a different file, or none, leaving the email behind for a recreated profile to inherit. The daemon already echoes back the ID it resolved for exactly this purpose; use it. --- client/ui/services/profile.go | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/client/ui/services/profile.go b/client/ui/services/profile.go index ff29d514d..5a9a0e68d 100644 --- a/client/ui/services/profile.go +++ b/client/ui/services/profile.go @@ -153,10 +153,11 @@ func (s *Profiles) Remove(ctx context.Context, p ProfileRef) error { if err != nil { return err } - if _, err = cli.RemoveProfile(ctx, &proto.RemoveProfileRequest{ + resp, err := cli.RemoveProfile(ctx, &proto.RemoveProfileRequest{ ProfileName: p.ProfileName, Username: p.Username, - }); err != nil { + }) + if err != nil { return err } @@ -165,10 +166,14 @@ func (s *Profiles) Remove(ctx context.Context, p ProfileRef) error { // Connection.Logout). Legacy profiles are keyed by name rather than by a // generated ID, so a recreated profile of the same name would inherit the // deleted one's email and offer it as the login_hint. - if p.ProfileName != "" { - if err := profilemanager.NewProfileManager().RemoveProfileState(p.ProfileName); err != nil { + // + // Keyed on the ID the daemon resolved, not on the request handle: that may + // have been a display name or an ID prefix, which would name a different + // file (or none). + if id := resp.GetId(); id != "" { + if err := profilemanager.NewProfileManager().RemoveProfileState(id); err != nil { // Non-fatal: the profile itself is gone. - log.Warnf("failed to remove profile state for %s: %v", p.ProfileName, err) + log.Warnf("failed to remove profile state for %s: %v", id, err) } }