Improve ui when other holds the session

This commit is contained in:
Theodor S. Midtlien
2026-09-21 17:35:11 +02:00
parent e5c1b21fd3
commit a785814a3f
18 changed files with 250 additions and 74 deletions
+17 -20
View File
@@ -2585,32 +2585,29 @@ func (s *Server) GetActiveProfile(ctx context.Context, msg *proto.GetActiveProfi
return nil, gstatus.Error(codes.Unauthenticated, "caller identity could not be resolved")
}
// The name is resolved through the caller's own listing, so a profile
// belonging to somebody else is not in it. Leave the name empty rather than
// falling back to the ID: a 32 character hex string tells the user nothing,
// and the owner's chosen name is not the caller's to read. Clients render
// their own wording for an active profile that is not theirs.
//
// A legacy profile is its own name, so the ID stands in for it.
displayName := ""
if activeProfile.ID == profilemanager.DefaultProfileName {
displayName = activeProfile.ID.String()
} else if profiles, lerr := s.profileManager.ListProfiles(userID); lerr == nil {
for _, p := range profiles {
if p.ID == activeProfile.ID {
displayName = p.Name
break
}
}
}
return &proto.GetActiveProfileResponse{
ProfileName: displayName,
ProfileName: s.activeProfileNameFor(userID, activeProfile.ID),
Username: activeProfile.Username,
Id: activeProfile.ID.String(),
}, nil
}
// activeProfileNameFor returns the display name of the active profile as this
// caller may read it, and empty when the profile is not theirs.
func (s *Server) activeProfileNameFor(caller ipcauth.Identity, activeID profilemanager.ID) string {
profiles, err := s.profileManager.ListProfiles(caller)
if err != nil {
log.Debugf("failed to list profiles to name the active one: %v", err)
return ""
}
for _, p := range profiles {
if p.ID == activeID {
return p.Name
}
}
return ""
}
// GetFeatures returns the features supported by the daemon.
func (s *Server) GetFeatures(ctx context.Context, msg *proto.GetFeaturesRequest) (*proto.GetFeaturesResponse, error) {
s.mutex.Lock()