diff --git a/clients/macos/vellum-assistant/Features/Contacts/ContactDetailView.swift b/clients/macos/vellum-assistant/Features/Contacts/ContactDetailView.swift index a7a6adafe20..83c90138d23 100644 --- a/clients/macos/vellum-assistant/Features/Contacts/ContactDetailView.swift +++ b/clients/macos/vellum-assistant/Features/Contacts/ContactDetailView.swift @@ -180,7 +180,7 @@ struct ContactDetailView: View { } private var contactTypeBadge: some View { - ContactTypeBadge(role: displayContact.role) + ContactTypeBadge(kind: ContactTypeBadge.Kind(role: displayContact.role, contactType: displayContact.contactType)) } // MARK: - Actions diff --git a/clients/macos/vellum-assistant/Features/Contacts/ContactTypeBadge.swift b/clients/macos/vellum-assistant/Features/Contacts/ContactTypeBadge.swift index bedfbeb16e4..fcb962468a5 100644 --- a/clients/macos/vellum-assistant/Features/Contacts/ContactTypeBadge.swift +++ b/clients/macos/vellum-assistant/Features/Contacts/ContactTypeBadge.swift @@ -4,25 +4,49 @@ import VellumAssistantShared /// A tag showing a contact's classification (Guardian, Assistant, Human) /// with a distinguishing icon. Thin wrapper around VTag. struct ContactTypeBadge: View { - let role: String? + /// Closed set of display variants the badge can render. + enum Kind { + case guardian + case assistant + case human + + /// Derives the badge kind from a contact's `role` and `contactType` fields. + /// `role == "guardian"` takes precedence; otherwise `contactType == "assistant"` + /// selects the assistant variant, and anything else falls back to human. + init(role: String?, contactType: String?) { + if role == "guardian" { + self = .guardian + } else if contactType == "assistant" { + self = .assistant + } else { + self = .human + } + } + } + + let kind: Kind + + init(kind: Kind) { + self.kind = kind + } var body: some View { VTag(label, color: VColor.primaryBase, icon: icon) } private var label: String { - switch role { - case "guardian": return "Guardian" - case "assistant": return "Assistant" - default: return "Human" + switch kind { + case .guardian: return "Guardian" + case .assistant: return "Assistant" + case .human: return "Human" } } private var icon: VIcon { - switch role { - case "guardian": return .shieldCheck - case "assistant": return .sparkles - default: return .user + switch kind { + case .guardian: return .shieldCheck + case .assistant: return .sparkles + case .human: return .user } } } diff --git a/clients/macos/vellum-assistant/Features/Contacts/ContactsContainerView.swift b/clients/macos/vellum-assistant/Features/Contacts/ContactsContainerView.swift index 157e2199d41..d5f3b91327d 100644 --- a/clients/macos/vellum-assistant/Features/Contacts/ContactsContainerView.swift +++ b/clients/macos/vellum-assistant/Features/Contacts/ContactsContainerView.swift @@ -182,7 +182,7 @@ struct ContactsContainerView: View { Text(contact.displayName.hasPrefix("vellum-principal-") ? "You" : "\(contact.displayName) (You)") .font(VFont.titleSmall) .foregroundStyle(VColor.contentDefault) - ContactTypeBadge(role: "guardian") + ContactTypeBadge(kind: .guardian) } Text("\(contact.interactionCount) interaction\(contact.interactionCount == 1 ? "" : "s")") .font(VFont.labelDefault) @@ -312,7 +312,7 @@ struct ContactsContainerView: View { Text("\(cachedAssistantName) (Your Assistant)") .font(VFont.titleSmall) .foregroundStyle(VColor.contentDefault) - ContactTypeBadge(role: "assistant") + ContactTypeBadge(kind: .assistant) } .padding(.horizontal, VSpacing.lg) diff --git a/clients/macos/vellum-assistant/Features/Contacts/ContactsListView.swift b/clients/macos/vellum-assistant/Features/Contacts/ContactsListView.swift index 5ff9d822f56..7e239f20570 100644 --- a/clients/macos/vellum-assistant/Features/Contacts/ContactsListView.swift +++ b/clients/macos/vellum-assistant/Features/Contacts/ContactsListView.swift @@ -44,7 +44,7 @@ struct ContactsListView: View { VStack(alignment: .leading, spacing: VSpacing.sm) { contactListRow( name: "Your Assistant", - role: "assistant", + badgeKind: .assistant, isSelected: selection == .assistant, isHovered: isAssistantHovered, onTap: { selection = .assistant }, @@ -54,7 +54,7 @@ struct ContactsListView: View { if let guardian = viewModel.guardianContact { contactListRow( name: "You", - role: guardian.role, + badgeKind: ContactTypeBadge.Kind(role: guardian.role, contactType: guardian.contactType), isSelected: selection == .contact(guardian.id), isHovered: hoveredContactId == guardian.id, onTap: { selection = .contact(guardian.id) }, @@ -83,7 +83,7 @@ struct ContactsListView: View { ForEach(viewModel.filteredRegularContacts, id: \.id) { contact in contactListRow( name: contact.displayName, - role: contact.role, + badgeKind: ContactTypeBadge.Kind(role: contact.role, contactType: contact.contactType), isSelected: selection == .contact(contact.id), isHovered: hoveredContactId == contact.id, onTap: { selection = .contact(contact.id) }, @@ -151,7 +151,7 @@ struct ContactsListView: View { private func contactListRow( name: String, - role: String?, + badgeKind: ContactTypeBadge.Kind, isSelected: Bool, isHovered: Bool, onTap: @escaping () -> Void, @@ -166,7 +166,7 @@ struct ContactsListView: View { Spacer() - ContactTypeBadge(role: role) + ContactTypeBadge(kind: badgeKind) } .padding(.horizontal, VSpacing.sm) .padding(.vertical, VSpacing.md)