diff --git a/apps/ios/Shared/Views/Call/ActiveCallView.swift b/apps/ios/Shared/Views/Call/ActiveCallView.swift index c74ee673d2..b591a4d1e9 100644 --- a/apps/ios/Shared/Views/Call/ActiveCallView.swift +++ b/apps/ios/Shared/Views/Call/ActiveCallView.swift @@ -326,7 +326,7 @@ struct ActiveCallOverlay: View { .foregroundColor(.white.opacity(0.8)) } VStack { - ProfileImage(imageStr: call.contact.profile.image, size: 192) + ProfileImage(imageStr: call.contact.profile.image, icon: call.contact.chatIcon, size: 192) audioCallInfoView(call) } .foregroundColor(.white) diff --git a/apps/ios/Shared/Views/Chat/ChatItem/CIChatLinkHeader.swift b/apps/ios/Shared/Views/Chat/ChatItem/CIChatLinkHeader.swift index a5e87c3eb2..5eade836cc 100644 --- a/apps/ios/Shared/Views/Chat/ChatItem/CIChatLinkHeader.swift +++ b/apps/ios/Shared/Views/Chat/ChatItem/CIChatLinkHeader.swift @@ -51,7 +51,7 @@ struct CIChatLinkHeader: View { HStack(alignment: .top) { ProfileImage( imageStr: chatLink.image, - icon: Image(systemName: chatLink.iconName), + icon: chatLink.icon, size: 44, color: Color(uiColor: .tertiaryLabel) ) diff --git a/apps/ios/Shared/Views/Chat/ChatItem/FramedItemView.swift b/apps/ios/Shared/Views/Chat/ChatItem/FramedItemView.swift index 752cefb743..54e14c3313 100644 --- a/apps/ios/Shared/Views/Chat/ChatItem/FramedItemView.swift +++ b/apps/ios/Shared/Views/Chat/ChatItem/FramedItemView.swift @@ -321,16 +321,16 @@ struct FramedItemView: View { case .file: ciQuotedMsgView(qi) .padding(.trailing, 20).frame(minWidth: quoteMinWidth, alignment: .leading) - ciQuoteIconView("doc.fill") + ciQuoteIconView(Image(systemName: "doc.fill")) case .voice: ciQuotedMsgView(qi) .padding(.trailing, 20).frame(minWidth: quoteMinWidth, alignment: .leading) - ciQuoteIconView("mic.fill") + ciQuoteIconView(Image(systemName: "mic.fill")) case let .chat(text, chatLink, _): let prefix = NSAttributedString(string: chatLink.displayName + (text != chatLink.connLinkStr ? " - " : "")) ciQuotedMsgView(qi, stripLink: chatLink.connLinkStr, prefix: prefix) .padding(.trailing, 20).frame(minWidth: quoteMinWidth, alignment: .leading) - ciQuoteIconView(chatLink.smallIconName) + ciQuoteIconView(chatLink.smallIcon()) default: ciQuotedMsgView(qi) } @@ -383,8 +383,8 @@ struct FramedItemView: View { .padding(.bottom, terminal ? 0 : 6) } - private func ciQuoteIconView(_ image: String) -> some View { - Image(systemName: image) + private func ciQuoteIconView(_ image: Image) -> some View { + image .resizable() .aspectRatio(contentMode: .fit) .foregroundColor(Color(uiColor: .tertiaryLabel)) diff --git a/apps/ios/Shared/Views/Chat/ChatView.swift b/apps/ios/Shared/Views/Chat/ChatView.swift index 293282fb26..b65bc6dd3d 100644 --- a/apps/ios/Shared/Views/Chat/ChatView.swift +++ b/apps/ios/Shared/Views/Chat/ChatView.swift @@ -2981,7 +2981,7 @@ struct ChatView: View { @ViewBuilder private func contactReactionMenu(_ contact: Contact, _ r: CIReactionCount) -> some View { if !r.userReacted || r.totalReacted > 1 { Button { showChatInfoSheet = true } label: { - profileMenuItem(Text(contact.displayName), contact.image, radius: profileRadius) + profileMenuItem(Text(contact.displayName), contact.image, peerType: contact.profile.peerType, radius: profileRadius) } } if r.userReacted { @@ -3275,7 +3275,7 @@ struct ReactionContextMenu: View { selectedMember = member } } label: { - profileMenuItem(Text(mem.displayName), mem.image, radius: profileRadius) + profileMenuItem(Text(mem.displayName), mem.image, peerType: mem.memberProfile.peerType, radius: profileRadius) } .disabled(userMember) } @@ -3298,13 +3298,13 @@ struct ReactionContextMenu: View { } } -func profileMenuItem(_ nameText: Text, _ image: String?, radius: CGFloat) -> some View { +func profileMenuItem(_ nameText: Text, _ image: String?, peerType: ChatPeerType? = nil, radius: CGFloat) -> some View { HStack { nameText if let image, let img = imageFromBase64(image) { Image(uiImage: maskToCustomShape(img, size: 30, radius: radius)) } else { - Image(systemName: "person.crop.circle") + peerTypeIcon(peerType, person: Image(systemName: "person.crop.circle")) } } } diff --git a/apps/ios/Shared/Views/Chat/ComposeMessage/ComposeChatLinkView.swift b/apps/ios/Shared/Views/Chat/ComposeMessage/ComposeChatLinkView.swift index 78f29c3b60..ce7a029270 100644 --- a/apps/ios/Shared/Views/Chat/ComposeMessage/ComposeChatLinkView.swift +++ b/apps/ios/Shared/Views/Chat/ComposeMessage/ComposeChatLinkView.swift @@ -11,7 +11,7 @@ struct ComposeChatLinkView: View { HStack(alignment: .center, spacing: 8) { ProfileImage( imageStr: chatLink.image, - icon: Image(systemName: chatLink.iconName), + icon: chatLink.icon, size: 44 ) .padding(.leading, 12) diff --git a/apps/ios/Shared/Views/Chat/ComposeMessage/ContextItemView.swift b/apps/ios/Shared/Views/Chat/ComposeMessage/ContextItemView.swift index f7f8d2982e..fc08a39196 100644 --- a/apps/ios/Shared/Views/Chat/ComposeMessage/ContextItemView.swift +++ b/apps/ios/Shared/Views/Chat/ComposeMessage/ContextItemView.swift @@ -80,18 +80,25 @@ struct ContextItemView: View { FileManager.default.fileExists(atPath: getAppFilePath(fileSource.filePath).path) } else { false } switch contextItem.content.msgContent { - case .file: return isFileLoaded ? image("doc.fill") : Text("") - case .image: return image("photo") - case .voice: return isFileLoaded ? image("play.fill") : Text("") + case .file: return isFileLoaded ? image(Image(systemName: "doc.fill")) : Text("") + case .image: return image(Image(systemName: "photo")) + case .voice: return isFileLoaded ? image(Image(systemName: "play.fill")) : Text("") case let .chat(_, chatLink, _): let hasText = contextItem.text != chatLink.connLinkStr - return image(chatLink.smallIconName) + Text(chatLink.displayName) + Text(verbatim: hasText ? " - " : "") + return image(chatLink.smallIcon(agent: textAgentIcon())) + Text(chatLink.displayName) + Text(verbatim: hasText ? " - " : "") default: return Text("") } } - func image(_ s: String) -> Text { - Text(Image(systemName: s)).foregroundColor(Color(uiColor: .tertiaryLabel)) + textSpace + func image(_ i: Image) -> Text { + Text(i).foregroundColor(Color(uiColor: .tertiaryLabel)) + textSpace + } + + func textAgentIcon() -> Image { + guard let person = UIImage(systemName: "person", withConfiguration: UIImage.SymbolConfiguration(textStyle: .body)), + let agent = UIImage(named: "agent") else { return Image("agent") } + let size = CGSize(width: person.size.height * agent.size.width / agent.size.height, height: person.size.height) + return Image(uiImage: UIGraphicsImageRenderer(size: size).image { _ in agent.draw(in: CGRect(origin: .zero, size: size)) }.withRenderingMode(.alwaysTemplate)) } } } diff --git a/apps/ios/Shared/Views/Chat/Group/AddGroupMembersView.swift b/apps/ios/Shared/Views/Chat/Group/AddGroupMembersView.swift index 108f4d4306..5a48922230 100644 --- a/apps/ios/Shared/Views/Chat/Group/AddGroupMembersView.swift +++ b/apps/ios/Shared/Views/Chat/Group/AddGroupMembersView.swift @@ -219,7 +219,7 @@ struct AddGroupMembersViewCommon: View { } } label: { HStack{ - ProfileImage(imageStr: contact.image, size: 30) + ProfileImage(imageStr: contact.image, icon: contact.chatIcon, size: 30) .padding(.trailing, 2) NameWithBadge( Text(ChatInfo.direct(contact: contact).chatViewName) diff --git a/apps/ios/Shared/Views/Chat/Group/GroupMemberInfoView.swift b/apps/ios/Shared/Views/Chat/Group/GroupMemberInfoView.swift index 53a1ca180b..86e95b016b 100644 --- a/apps/ios/Shared/Views/Chat/Group/GroupMemberInfoView.swift +++ b/apps/ios/Shared/Views/Chat/Group/GroupMemberInfoView.swift @@ -831,6 +831,7 @@ func MemberProfileImage( ) -> some View { ProfileImage( imageStr: mem.image, + icon: peerTypeIcon(mem.memberProfile.peerType), size: size, color: color, backgroundColor: backgroundColor, diff --git a/apps/ios/Shared/Views/ChatList/ChatPreviewView.swift b/apps/ios/Shared/Views/ChatList/ChatPreviewView.swift index cfb88c773b..3690d0d155 100644 --- a/apps/ios/Shared/Views/ChatList/ChatPreviewView.swift +++ b/apps/ios/Shared/Views/ChatList/ChatPreviewView.swift @@ -444,7 +444,7 @@ struct ChatPreviewView: View { smallContentPreview(size: dynamicMediaSize, borderColor: chatLink.image != nil ? .secondary : .clear) { ProfileImage( imageStr: chatLink.image, - icon: Image(systemName: chatLink.iconName), + icon: chatLink.icon, size: dynamicMediaSize, color: Color(uiColor: .tertiaryLabel) ) diff --git a/apps/ios/Shared/Views/Contacts/ContactListNavLink.swift b/apps/ios/Shared/Views/Contacts/ContactListNavLink.swift index 9214e3ecde..21022d52ec 100644 --- a/apps/ios/Shared/Views/Contacts/ContactListNavLink.swift +++ b/apps/ios/Shared/Views/Contacts/ContactListNavLink.swift @@ -167,7 +167,7 @@ struct ContactListNavLink: View { func contactPreview(_ contact: Contact, titleColor: Color) -> some View { HStack{ - ProfileImage(imageStr: contact.image, size: 30) + ProfileImage(imageStr: contact.image, icon: contact.chatIcon, size: 30) previewTitle(contact, titleColor: titleColor) @@ -262,7 +262,7 @@ struct ContactListNavLink: View { func contactCardPreview(_ contact: Contact) -> some View { HStack{ - ProfileImage(imageStr: contact.image, size: 30) + ProfileImage(imageStr: contact.image, icon: contact.chatIcon, size: 30) Text(chat.chatInfo.chatViewName) .foregroundColor(.accentColor) @@ -315,7 +315,7 @@ struct ContactListNavLink: View { func contactRequestPreview(color: Color) -> some View { HStack{ - ProfileImage(imageStr: chat.chatInfo.image, size: 30) + ProfileImage(imageStr: chat.chatInfo.image, icon: chatIcon(chat.chatInfo), size: 30) NameWithBadge(Text(chat.chatInfo.chatViewName).foregroundColor(color), chat.chatInfo.nameBadge) .lineLimit(1) diff --git a/apps/ios/Shared/Views/Helpers/ProfileImage.swift b/apps/ios/Shared/Views/Helpers/ProfileImage.swift index 05b4a06967..b3ff520acf 100644 --- a/apps/ios/Shared/Views/Helpers/ProfileImage.swift +++ b/apps/ios/Shared/Views/Helpers/ProfileImage.swift @@ -67,3 +67,47 @@ struct ProfileImage_Previews: PreviewProvider { .background(.black) } } + +struct PeerTypePlaceholders_Previews: PreviewProvider { + static let peerTypes: [ChatPeerType?] = [nil, .human, .agent, .bot] + + static var previews: some View { + VStack(alignment: .leading) { + row { MemberProfileImage(member($0), size: 38) } + row { ChatInfoImage(chat: Chat(chatInfo: .contactRequest(contactRequest: contactRequest($0))), size: 38) } + row { ProfileImage(icon: contactLink($0).icon, size: 38) } + row { contactLink($0).smallIcon().resizable().scaledToFit().frame(width: 38, height: 18) } + row { profileMenuItem(Text("alice"), nil, peerType: $0, radius: 50) } + ForEach(peerTypes.indices, id: \.self) { i in + ContextItemView(chat: Chat.sampleData, contextItems: [linkItem(peerTypes[i])], contextIcon: "arrowshape.turn.up.left", cancelContextItem: {}) + } + } + } + + static func row(@ViewBuilder _ placeholder: @escaping (ChatPeerType?) -> V) -> some View { + HStack { + ForEach(peerTypes.indices, id: \.self) { placeholder(peerTypes[$0]) } + } + } + + static func member(_ peerType: ChatPeerType?) -> GroupMember { + var m = GroupMember.sampleData + m.memberProfile.peerType = peerType + return m + } + + static func contactRequest(_ peerType: ChatPeerType?) -> UserContactRequest { + var r = UserContactRequest.sampleData + r.profile.peerType = peerType + return r + } + + static func contactLink(_ peerType: ChatPeerType?) -> MsgChatLink { + .contact(connLink: "https://simplex.chat/a#alice", profile: Profile(displayName: "alice", fullName: "", peerType: peerType), business: false) + } + + static func linkItem(_ peerType: ChatPeerType?) -> ChatItem { + let link = contactLink(peerType) + return ChatItem(chatDir: .directRcv, meta: CIMeta.getSample(1, previewDate, link.connLinkStr), content: .rcvMsgContent(msgContent: .chat(text: link.connLinkStr, chatLink: link, ownerSig: nil))) + } +} diff --git a/apps/ios/SimpleX Snapshots/References/PeerTypePlaceholders-dark-large.png b/apps/ios/SimpleX Snapshots/References/PeerTypePlaceholders-dark-large.png new file mode 100644 index 0000000000..7acd5ff054 Binary files /dev/null and b/apps/ios/SimpleX Snapshots/References/PeerTypePlaceholders-dark-large.png differ diff --git a/apps/ios/SimpleX Snapshots/References/PeerTypePlaceholders-light-large.png b/apps/ios/SimpleX Snapshots/References/PeerTypePlaceholders-light-large.png new file mode 100644 index 0000000000..a96d937e90 Binary files /dev/null and b/apps/ios/SimpleX Snapshots/References/PeerTypePlaceholders-light-large.png differ diff --git a/apps/ios/SimpleX Snapshots/SnapshotTests.swift b/apps/ios/SimpleX Snapshots/SnapshotTests.swift index d039168254..9bae8b625c 100644 --- a/apps/ios/SimpleX Snapshots/SnapshotTests.swift +++ b/apps/ios/SimpleX Snapshots/SnapshotTests.swift @@ -302,6 +302,7 @@ private func previewScenes() -> [SnapshotScene] { SnapshotScene(OperatorView_Previews.self), SnapshotScene(PasscodeEntry_Previews.self), SnapshotScene(PasscodeViewView_Previews.self), + SnapshotScene(PeerTypePlaceholders_Previews.self), SnapshotScene(PreferencesView_Previews.self), SnapshotScene(PrivacySettings_Previews.self), SnapshotScene(ProfileImage_Previews.self), diff --git a/apps/ios/SimpleXChat/ChatTypes.swift b/apps/ios/SimpleXChat/ChatTypes.swift index fc5e3bad94..668b45019f 100644 --- a/apps/ios/SimpleXChat/ChatTypes.swift +++ b/apps/ios/SimpleXChat/ChatTypes.swift @@ -310,11 +310,11 @@ extension ChatLayout: Codable { } } -public func peerTypeIcon(_ peerType: ChatPeerType?) -> Image { +public func peerTypeIcon(_ peerType: ChatPeerType?, person: Image = Image(systemName: "person.crop.circle.fill"), agent: Image = Image("agent")) -> Image { switch peerType { case .bot: Image(systemName: "cube.fill") - case .agent: Image("agent") - default: Image(systemName: "person.crop.circle.fill") + case .agent: agent + default: person } } @@ -5716,25 +5716,25 @@ public enum MsgChatLink: Equatable, Hashable { } } - public var iconName: String { + public var icon: Image { switch self { case let .group(_, groupProfile): - groupProfile.isChannel ? "antenna.radiowaves.left.and.right.circle.fill" : "person.2.circle.fill" - case let .contact(_, _, business): - business ? "briefcase.circle.fill" : "person.crop.circle.fill" - case .invitation: - "person.crop.circle.fill" + Image(systemName: groupProfile.isChannel ? "antenna.radiowaves.left.and.right.circle.fill" : "person.2.circle.fill") + case let .contact(_, profile, business): + business ? Image(systemName: "briefcase.circle.fill") : peerTypeIcon(profile.peerType) + case let .invitation(_, profile): + peerTypeIcon(profile.peerType) } } - public var smallIconName: String { + public func smallIcon(agent: Image = Image("agent")) -> Image { switch self { case let .group(_, groupProfile): - groupProfile.isChannel ? "antenna.radiowaves.left.and.right" : "person.2" - case let .contact(_, _, business): - business ? "briefcase" : "person" - case .invitation: - "person" + Image(systemName: groupProfile.isChannel ? "antenna.radiowaves.left.and.right" : "person.2") + case let .contact(_, profile, business): + business ? Image(systemName: "briefcase") : peerTypeIcon(profile.peerType, person: Image(systemName: "person"), agent: agent) + case let .invitation(_, profile): + peerTypeIcon(profile.peerType, person: Image(systemName: "person"), agent: agent) } } diff --git a/apps/ios/SimpleXChat/ChatUtils.swift b/apps/ios/SimpleXChat/ChatUtils.swift index ab9cad9de6..68ef812054 100644 --- a/apps/ios/SimpleXChat/ChatUtils.swift +++ b/apps/ios/SimpleXChat/ChatUtils.swift @@ -97,7 +97,7 @@ public func chatIcon(_ cInfo: ChatInfo) -> Image { case let .direct(contact): contact.chatIcon case let .group(groupInfo, _): Image(systemName: groupInfo.chatIconName) case .local: Image(systemName: "folder.circle.fill") - case .contactRequest: Image(systemName: "person.crop.circle.fill") + case let .contactRequest(contactRequest): peerTypeIcon(contactRequest.profile.peerType) default: Image(systemName: "circle.fill") } } diff --git a/apps/ios/spec/client/chat-view.md b/apps/ios/spec/client/chat-view.md index 78299504fd..453b89f475 100644 --- a/apps/ios/spec/client/chat-view.md +++ b/apps/ios/spec/client/chat-view.md @@ -561,7 +561,7 @@ Navigates to a dedicated members view with two sections: - **Owners**: current user (if owner) + members with `memberRole >= .owner` - **Subscribers** (admin+ only): members with `memberRole < .owner` -Member rows show profile image, display name (with verified shield), connection status, and role badge. Non-user rows link to `GroupMemberInfoView`. +Member rows show profile image, display name (with verified shield), connection status, and role badge. Non-user rows link to `GroupMemberInfoView`. `MemberProfileImage` draws a member's avatar: the member's image, otherwise the placeholder of its peer type (`peerTypeIcon`: person, agent or cube). ### Channel Link diff --git a/apps/multiplatform/android/src/main/java/chat/simplex/app/views/call/CallActivity.kt b/apps/multiplatform/android/src/main/java/chat/simplex/app/views/call/CallActivity.kt index e1edc5ebe3..1953054306 100644 --- a/apps/multiplatform/android/src/main/java/chat/simplex/app/views/call/CallActivity.kt +++ b/apps/multiplatform/android/src/main/java/chat/simplex/app/views/call/CallActivity.kt @@ -383,7 +383,7 @@ fun IncomingCallLockScreenAlertLayout( if (chatModel.controller.appPrefs.notificationPreviewMode.get() == NotificationPreviewMode.HIDDEN.name) { ProfileImage(size = 192.dp) } else { - ProfileImage(size = 192.dp, image = invitation.contact.profile.image) + ProfileImage(size = 192.dp, image = invitation.contact.profile.image, icon = invitation.contact.chatIconName) Text(invitation.contact.chatViewName, style = MaterialTheme.typography.h2) } Spacer(Modifier.fillMaxHeight().weight(1f)) diff --git a/apps/multiplatform/common/src/androidMain/kotlin/chat/simplex/common/views/call/CallView.android.kt b/apps/multiplatform/common/src/androidMain/kotlin/chat/simplex/common/views/call/CallView.android.kt index d4c533fd4e..610bf94b0f 100644 --- a/apps/multiplatform/common/src/androidMain/kotlin/chat/simplex/common/views/call/CallView.android.kt +++ b/apps/multiplatform/common/src/androidMain/kotlin/chat/simplex/common/views/call/CallView.android.kt @@ -395,7 +395,7 @@ private fun ActiveCallOverlayLayout( horizontalAlignment = Alignment.CenterHorizontally, verticalArrangement = Arrangement.Center ) { - ProfileImage(size = 192.dp, image = call.contact.profile.image) + ProfileImage(size = 192.dp, image = call.contact.profile.image, icon = call.contact.chatIconName) AudioCallInfoView(call) } } diff --git a/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/model/ChatModel.kt b/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/model/ChatModel.kt index 0d5e97caaf..18d0a566a5 100644 --- a/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/model/ChatModel.kt +++ b/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/model/ChatModel.kt @@ -2257,11 +2257,11 @@ private val ChatLayoutMode?.known: ChatLayoutMode? get() = if (this is ChatLayou fun profileChatLayout(user: User?): ChatLayoutMode = user?.uiThemes?.chatLayout.known ?: ChatController.appPrefs.chatLayout.state.value.known ?: ChatLayoutMode.Classic -fun peerTypeIcon(peerType: ChatPeerType?): ImageResource = +fun peerTypeIcon(peerType: ChatPeerType?, person: ImageResource = MR.images.ic_account_circle_filled): ImageResource = when (peerType) { ChatPeerType.Bot -> MR.images.ic_cube ChatPeerType.Agent -> MR.images.ic_agent - else -> MR.images.ic_account_circle_filled + else -> person } // Supporter badge. The credential/proof bytes stay core-side; the UI only sees the disclosed type + status. @@ -5269,15 +5269,15 @@ sealed class MsgChatLink { val iconRes: ImageResource get() = when (this) { is Group -> if (groupProfile.isChannel) MR.images.ic_bigtop_updates_circle_filled else MR.images.ic_supervised_user_circle_filled - is Contact -> if (business) MR.images.ic_work_filled_padded else MR.images.ic_account_circle_filled - is Invitation -> MR.images.ic_account_circle_filled + is Contact -> if (business) MR.images.ic_work_filled_padded else peerTypeIcon(profile.peerType) + is Invitation -> peerTypeIcon(profile.peerType) } val smallIconRes: ImageResource get() = when (this) { is Group -> if (groupProfile.isChannel) MR.images.ic_bigtop_updates else MR.images.ic_group - is Contact -> if (business) MR.images.ic_work else MR.images.ic_person - is Invitation -> MR.images.ic_person + is Contact -> if (business) MR.images.ic_work else peerTypeIcon(profile.peerType, MR.images.ic_person) + is Invitation -> peerTypeIcon(profile.peerType, MR.images.ic_person) } fun infoLine(signed: Boolean): String { diff --git a/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/chat/group/AddGroupMembersView.kt b/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/chat/group/AddGroupMembersView.kt index 731b125955..f94b357cc2 100644 --- a/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/chat/group/AddGroupMembersView.kt +++ b/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/chat/group/AddGroupMembersView.kt @@ -351,7 +351,7 @@ fun ContactCheckRow( } } else null ) { - ProfileImage(size = 36.dp, contact.image) + ProfileImage(size = 36.dp, contact.image, contact.chatIconName) Spacer(Modifier.width(DEFAULT_SPACE_AFTER_ICON)) NameWithBadge( contact.chatViewName, diff --git a/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/chat/group/GroupMemberInfoView.kt b/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/chat/group/GroupMemberInfoView.kt index dc06d15ea6..296241a5b3 100644 --- a/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/chat/group/GroupMemberInfoView.kt +++ b/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/chat/group/GroupMemberInfoView.kt @@ -939,6 +939,7 @@ fun MemberProfileImage( ProfileImage( size = size, image = mem.image, + icon = peerTypeIcon(mem.memberProfile.peerType), color = color, backgroundColor = backgroundColor, blurred = mem.blocked, @@ -946,6 +947,22 @@ fun MemberProfileImage( ) } +@Preview +@Composable +fun PreviewPeerTypePlaceholders() { + SimpleXTheme { + val peerTypes = listOf(null, ChatPeerType.Human, ChatPeerType.Agent, ChatPeerType.Bot) + fun contactLink(peerType: ChatPeerType?) = MsgChatLink.Contact("", Profile.sampleData.copy(peerType = peerType), false) + Column(Modifier.background(MaterialTheme.colors.background)) { + Row { peerTypes.forEach { MemberImage(GroupMember.sampleData.copy(memberProfile = LocalProfile.sampleData.copy(peerType = it))) } } + Row { peerTypes.forEach { ChatInfoImage(ChatInfo.ContactRequest(UserContactRequest(1, VersionRange(1, 1), "alice", LocalProfile.sampleData.copy(peerType = it), Clock.System.now(), Clock.System.now())), MEMBER_IMAGE_SIZE) } } + Row { peerTypes.forEach { ProfileImage(MEMBER_IMAGE_SIZE, null, contactLink(it).iconRes) } } + Row { peerTypes.forEach { Icon(painterResource(contactLink(it).smallIconRes), null, Modifier.size(MEMBER_IMAGE_SIZE), MaterialTheme.colors.secondary) } } + Row { peerTypes.forEach { ProfileImageForActiveCall(MEMBER_IMAGE_SIZE, icon = peerTypeIcon(it)) } } + } + } +} + fun updateMembersRole(newRole: GroupMemberRole, rhId: Long?, groupInfo: GroupInfo, memberIds: List, onFailure: () -> Unit = {}, onSuccess: () -> Unit = {}) { withBGApi { kotlin.runCatching { diff --git a/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/chat/item/ChatItemView.kt b/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/chat/item/ChatItemView.kt index e39560a773..5c12a3f77d 100644 --- a/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/chat/item/ChatItemView.kt +++ b/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/chat/item/ChatItemView.kt @@ -61,7 +61,8 @@ fun chatEventText(eventText: String, ts: AnnotatedString): AnnotatedString = data class ChatItemReactionMenuItem ( val name: String, val image: String?, - val onClick: (() -> Unit)? + val onClick: (() -> Unit)?, + val icon: ImageResource = MR.images.ic_account_circle_filled ) private val REACTION_SPACING = 5.dp @@ -172,7 +173,7 @@ fun ChatItemView( reactionMenuItems.value = members.map { val enabled = cInfo.groupInfo.membership.groupMemberId != it.groupMember.groupMemberId val click = if (enabled) ({ showMemberInfo(cInfo.groupInfo, it.groupMember) }) else null - ChatItemReactionMenuItem(it.groupMember.displayName, it.groupMember.image, click) + ChatItemReactionMenuItem(it.groupMember.displayName, it.groupMember.image, click, peerTypeIcon(it.groupMember.memberProfile.peerType)) } } } catch (e: Exception) { @@ -186,7 +187,7 @@ fun ChatItemView( if (!r.userReacted || r.totalReacted > 1) { val contact = cInfo.contact - reactions.add(ChatItemReactionMenuItem(contact.displayName, contact.image, showChatInfo)) + reactions.add(ChatItemReactionMenuItem(contact.displayName, contact.image, showChatInfo, contact.chatIconName)) } if (r.userReacted) { @@ -218,7 +219,7 @@ fun ChatItemView( reactionMenuItems.value.forEach { m -> ItemAction( text = m.name, - composable = { ProfileImage(44.dp, m.image) }, + composable = { ProfileImage(44.dp, m.image, m.icon) }, onClick = { val click = m.onClick if (click != null) { diff --git a/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/chatlist/ShareListNavLinkView.kt b/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/chatlist/ShareListNavLinkView.kt index b1fe42cdfc..498a06e59d 100644 --- a/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/chatlist/ShareListNavLinkView.kt +++ b/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/chatlist/ShareListNavLinkView.kt @@ -102,7 +102,7 @@ private fun SharePreviewView(chat: Chat, disabled: Boolean) { } else if (chat.chatInfo is ChatInfo.Group) { ProfileImage(size = 42.dp, chat.chatInfo.image, icon = MR.images.ic_supervised_user_circle_filled) } else { - ProfileImage(size = 42.dp, chat.chatInfo.image) + ChatInfoImage(chat.chatInfo, 42.dp) } NameWithBadge( chat.chatInfo.chatViewName, chat.chatInfo.nameBadge, maxLines = 1, overflow = TextOverflow.Ellipsis, diff --git a/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/helpers/ChatInfoImage.kt b/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/helpers/ChatInfoImage.kt index b09efe7d1d..42d9df0807 100644 --- a/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/helpers/ChatInfoImage.kt +++ b/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/helpers/ChatInfoImage.kt @@ -34,6 +34,7 @@ import chat.simplex.common.model.BadgeType import chat.simplex.common.model.ChatInfo import chat.simplex.common.model.LocalBadge import chat.simplex.common.model.localDate +import chat.simplex.common.model.peerTypeIcon import chat.simplex.common.platform.* import chat.simplex.common.ui.theme.* import chat.simplex.common.views.badges.openBadgesView @@ -50,6 +51,7 @@ fun ChatInfoImage(chatInfo: ChatInfo, size: Dp, iconColor: Color = MaterialTheme is ChatInfo.Group -> chatInfo.groupInfo.chatIconName is ChatInfo.Local -> MR.images.ic_folder_filled is ChatInfo.Direct -> chatInfo.contact.chatIconName + is ChatInfo.ContactRequest -> peerTypeIcon(chatInfo.contactRequest.profile.peerType) else -> MR.images.ic_account_circle_filled } ProfileImage(size, chatInfo.image, icon, if (chatInfo is ChatInfo.Local) NoteFolderIconColor else iconColor) @@ -309,17 +311,27 @@ fun ProfileIconModifier(size: Dp, padding: Boolean = true, blurred: Boolean = fa fun ProfileImageForActiveCall( size: Dp, image: String? = null, + icon: ImageResource = MR.images.ic_account_circle_filled, color: Color = MaterialTheme.colors.secondaryVariant, backgroundColor: Color? = null, ) { if (image == null) { Box(Modifier.requiredSize(size).clip(CircleShape).then(if (backgroundColor != null) Modifier.background(backgroundColor) else Modifier)) { - Icon( - AccountCircleFilled, - contentDescription = stringResource(MR.strings.icon_descr_profile_image_placeholder), - tint = color, - modifier = Modifier.requiredSize(size + 14.dp) - ) + if (icon == MR.images.ic_account_circle_filled) { + Icon( + AccountCircleFilled, + contentDescription = stringResource(MR.strings.icon_descr_profile_image_placeholder), + tint = color, + modifier = Modifier.requiredSize(size + 14.dp) + ) + } else { + Icon( + painterResource(icon), + contentDescription = stringResource(MR.strings.icon_descr_profile_image_placeholder), + tint = color, + modifier = Modifier.requiredSize(size) + ) + } } } else { val imageBitmap = base64ToBitmap(image) diff --git a/apps/multiplatform/common/src/desktopMain/kotlin/chat/simplex/common/views/chatlist/ChatListView.desktop.kt b/apps/multiplatform/common/src/desktopMain/kotlin/chat/simplex/common/views/chatlist/ChatListView.desktop.kt index 250d7ed3d9..fae72c7c1f 100644 --- a/apps/multiplatform/common/src/desktopMain/kotlin/chat/simplex/common/views/chatlist/ChatListView.desktop.kt +++ b/apps/multiplatform/common/src/desktopMain/kotlin/chat/simplex/common/views/chatlist/ChatListView.desktop.kt @@ -65,6 +65,7 @@ private fun ActiveCallInteractiveAreaOneHand(call: Call, showMenu: MutableState< ) { ProfileImage( image = call.contact.profile.image, + icon = call.contact.chatIconName, size = 37.dp * fontSizeSqrtMultiplier, color = MaterialTheme.colors.secondaryVariant.mixWith(MaterialTheme.colors.onBackground, 0.97f) ) @@ -125,7 +126,7 @@ private fun ActiveCallInteractiveAreaNonOneHand(call: Call, showMenu: MutableSta contentAlignment = Alignment.Center ) { Box(Modifier.background(MaterialTheme.colors.background, CircleShape)) { - ProfileImageForActiveCall(size = 56.dp, image = call.contact.profile.image) + ProfileImageForActiveCall(size = 56.dp, image = call.contact.profile.image, icon = call.contact.chatIconName) } Box( Modifier.padding().background(SimplexGreen, CircleShape).padding(4.dp) diff --git a/apps/multiplatform/common/src/desktopTest/kotlin/chat/simplex/app/PeerTypeIconTest.kt b/apps/multiplatform/common/src/desktopTest/kotlin/chat/simplex/app/PeerTypeIconTest.kt new file mode 100644 index 0000000000..728fad1546 --- /dev/null +++ b/apps/multiplatform/common/src/desktopTest/kotlin/chat/simplex/app/PeerTypeIconTest.kt @@ -0,0 +1,36 @@ +package chat.simplex.app + +import chat.simplex.common.model.ChatPeerType +import chat.simplex.common.model.MsgChatLink +import chat.simplex.common.model.Profile +import chat.simplex.common.model.peerTypeIcon +import kotlin.test.Test +import kotlin.test.assertEquals +import kotlin.test.assertNotEquals + +class PeerTypeIconTest { + private fun contact(peerType: ChatPeerType?, business: Boolean = false) = MsgChatLink.Contact("", Profile.sampleData.copy(peerType = peerType), business) + + private fun invitation(peerType: ChatPeerType?) = MsgChatLink.Invitation("", Profile.sampleData.copy(peerType = peerType)) + + @Test + fun linkCardsShowThePeerType() { + assertEquals(peerTypeIcon(ChatPeerType.Agent), contact(ChatPeerType.Agent).iconRes) + assertEquals(peerTypeIcon(ChatPeerType.Bot), contact(ChatPeerType.Bot).iconRes) + assertEquals(peerTypeIcon(null), contact(ChatPeerType.Human).iconRes) + assertEquals(peerTypeIcon(null), contact(null).iconRes) + assertEquals(peerTypeIcon(ChatPeerType.Agent), invitation(ChatPeerType.Agent).iconRes) + assertEquals(contact(null, business = true).iconRes, contact(ChatPeerType.Agent, business = true).iconRes) + assertNotEquals(peerTypeIcon(ChatPeerType.Agent), contact(ChatPeerType.Agent, business = true).iconRes) + } + + @Test + fun smallLinkIconsShowThePeerType() { + assertEquals(peerTypeIcon(ChatPeerType.Agent), contact(ChatPeerType.Agent).smallIconRes) + assertEquals(peerTypeIcon(ChatPeerType.Bot), contact(ChatPeerType.Bot).smallIconRes) + assertEquals(contact(null).smallIconRes, contact(ChatPeerType.Human).smallIconRes) + assertNotEquals(peerTypeIcon(null), contact(null).smallIconRes) + assertEquals(peerTypeIcon(ChatPeerType.Bot), invitation(ChatPeerType.Bot).smallIconRes) + assertEquals(contact(null, business = true).smallIconRes, contact(ChatPeerType.Agent, business = true).smallIconRes) + } +} diff --git a/apps/multiplatform/common/src/desktopTest/kotlin/chat/simplex/app/SnapshotTest.kt b/apps/multiplatform/common/src/desktopTest/kotlin/chat/simplex/app/SnapshotTest.kt index d9d29237bb..61e909ba2c 100644 --- a/apps/multiplatform/common/src/desktopTest/kotlin/chat/simplex/app/SnapshotTest.kt +++ b/apps/multiplatform/common/src/desktopTest/kotlin/chat/simplex/app/SnapshotTest.kt @@ -72,6 +72,7 @@ private val previewScenes = listOf( SnapshotScene("AddGroupMembersView.PreviewAddGroupMembersLayout") { PreviewAddGroupMembersLayout() }, SnapshotScene("GroupChatInfoView.PreviewGroupChatInfoLayout") { PreviewGroupChatInfoLayout() }, SnapshotScene("GroupMemberInfoView.PreviewGroupMemberInfoLayout") { PreviewGroupMemberInfoLayout() }, + SnapshotScene("GroupMemberInfoView.PreviewPeerTypePlaceholders") { PreviewPeerTypePlaceholders() }, SnapshotScene("CIEventView.CIEventViewPreview", chatItemFontScales) { CIEventViewPreview() }, SnapshotScene("CIGroupInvitationView.PendingCIGroupInvitationViewPreview", chatItemFontScales) { PendingCIGroupInvitationViewPreview() }, SnapshotScene("CIGroupInvitationView.CIGroupInvitationViewAcceptedPreview", chatItemFontScales) { CIGroupInvitationViewAcceptedPreview() }, diff --git a/apps/multiplatform/common/src/desktopTest/snapshots/GroupMemberInfoView.PreviewPeerTypePlaceholders-dark-font-100.png b/apps/multiplatform/common/src/desktopTest/snapshots/GroupMemberInfoView.PreviewPeerTypePlaceholders-dark-font-100.png new file mode 100644 index 0000000000..80e41827d2 Binary files /dev/null and b/apps/multiplatform/common/src/desktopTest/snapshots/GroupMemberInfoView.PreviewPeerTypePlaceholders-dark-font-100.png differ diff --git a/apps/multiplatform/common/src/desktopTest/snapshots/GroupMemberInfoView.PreviewPeerTypePlaceholders-light-font-100.png b/apps/multiplatform/common/src/desktopTest/snapshots/GroupMemberInfoView.PreviewPeerTypePlaceholders-light-font-100.png new file mode 100644 index 0000000000..4b88867db9 Binary files /dev/null and b/apps/multiplatform/common/src/desktopTest/snapshots/GroupMemberInfoView.PreviewPeerTypePlaceholders-light-font-100.png differ diff --git a/apps/multiplatform/spec/client/chat-view.md b/apps/multiplatform/spec/client/chat-view.md index 60087e632a..eaa15e5717 100644 --- a/apps/multiplatform/spec/client/chat-view.md +++ b/apps/multiplatform/spec/client/chat-view.md @@ -372,7 +372,7 @@ Key sections: group profile, group link, member list with roles, group preferenc | `AddGroupMembersView.kt` | Add members to group | | `GroupChatInfoView.kt` | Group info and management | | `GroupLinkView.kt` | Group link display and management | -| `GroupMemberInfoView.kt` | Individual member info | +| `GroupMemberInfoView.kt` | Individual member info; `MemberProfileImage`, the member's avatar: its image, otherwise the placeholder of its peer type (`peerTypeIcon`: person, agent or cube) | | `GroupMembersToolbar.kt` | Members toolbar in group info | | `GroupMentions.kt` | @mention autocomplete | | `GroupPreferences.kt` | Group feature preferences | diff --git a/packages/simplex-chat-mcp/REFERENCE.md b/packages/simplex-chat-mcp/REFERENCE.md index 460d7b8940..e69f1e8605 100644 --- a/packages/simplex-chat-mcp/REFERENCE.md +++ b/packages/simplex-chat-mcp/REFERENCE.md @@ -608,6 +608,7 @@ VERSION is the plugin's version, as in `npx -y @simplex-chat/mcp@0.3.0 link`. Th - Each session has a number, starting at 1, which is kept across service restarts. Its group is named `N · NAME`. NAME is the session's name from `claude -n NAME` or `/rename`, otherwise the project folder's name, otherwise `Claude Code`. A new name shows from the next session start. - The group is created at the session start, and the Main group's owners are invited to it as owners. An owner who joins the Main group later is invited to the groups of the open sessions. - The group's members are Claude, the Main group's owners, members who joined with `/join`, people whom members added directly, and `User`. People added directly get the role that the adding member set. `User` is a second profile of the service that posts your terminal prompts. +- Claude's profile has the peer type `agent`, so the app shows Claude with the agent placeholder. `User`'s profile has the peer type `human`, which the service sets at each start. In a session group that you joined while `User` had the peer type `agent`, as in 0.3.0, the new peer type reaches your app with `User`'s next post there, and the app shows `updated profile` from `User` once. - Rights follow the member's role in the group, however they joined: | Role | Rights | diff --git a/packages/simplex-chat-mcp/ROADMAP.md b/packages/simplex-chat-mcp/ROADMAP.md index 5a5c92a586..a050d66c11 100644 --- a/packages/simplex-chat-mcp/ROADMAP.md +++ b/packages/simplex-chat-mcp/ROADMAP.md @@ -5,7 +5,7 @@ What comes next for Claude Code in SimpleX Chat. ## In the app - Sessions open in a flat layout by default, with the avatar raised and the text using the full width. -- Claude appears as an agent, with the agent avatar. +- ✅ Claude appears as an agent, with the agent avatar. - Code in messages is highlighted. - "Read more" folds long messages, at a length you set. - Long answers arrive as one message. diff --git a/packages/simplex-chat-mcp/TESTING.md b/packages/simplex-chat-mcp/TESTING.md index f387d32c8a..fa7dfabfa4 100644 --- a/packages/simplex-chat-mcp/TESTING.md +++ b/packages/simplex-chat-mcp/TESTING.md @@ -187,6 +187,7 @@ The MCP server and the SessionStart, UserPromptSubmit, Stop, PostModelSwitch, Po - `reset-owners` replaces the Main group at once while the owner is in it, without the owner's approval. Run without a terminal, it says to run `link` in a terminal. Run in a terminal, it prints the new link with its QR code. - Both members from the Main group keep their roles in the session's group, and they still prompt and approve there. - An admin from the Main group approves all messages to a chat, and Bash for the rest of the session. After the owner's `/observer` of that admin, `/list` shows the chat without the approval and no approved tool, and the session's stream gets an empty list of approved tools. Claude replies `No member ID in this group.` to `/observer` of a member who has sent `/join 1` but has not joined yet. The member then joins as an admin. + - A data folder of 0.3.0, whose `User` has the peer type `agent`, starts with `User` as `human`, and the hub's contact of `User` gets `human` too. An owner who then joins a session's group sees Claude with `agent` and `User` with `human`. - A new session has no chats. - A stdio session starts the service. It recovers after the service is killed during a call. It starts the service again and attaches without a call. - A SessionStart hook is ended with its descendants while its service starts, as Claude Code ends its hooks when it exits. The service keeps starting, and the next session start shows the link of that service. @@ -198,7 +199,7 @@ In a session started as in step 2 above: 1. At the session start, Claude Code shows `SimpleX MCP: scan this QR code with the SimpleX app and tap Join to supervise your agents in "Claude Control":`, a QR code and the link. Ask Claude which link was shown at the session start. Claude doesn't know it. If Claude Code refuses `plugin:simplex@inline` with the development flag, checks 3, 5, 6, 7 and 8 wait for the published plugin and `plugin:simplex@simplex-chat`. 2. Scan the QR code in the SimpleX app and tap Join. In "Claude Control", tap the invitation to "1 · " and join it. -3. Send `Reply with the word ready.` in "1 · ". The answer comes from Claude, as a reply to your message. +3. Send `Reply with the word ready.` in "1 · ". The answer comes from Claude, as a reply to your message. In an app that shows peer types in groups, Claude has the agent placeholder, three dots, and `User` the person placeholder. 4. Type a prompt in the terminal. It appears in the group from `User`, and the answer appears from Claude. Record whether a prompt from the group also appears from `User`, because Claude Code's documentation does not say whether a channel prompt runs the UserPromptSubmit hook. Ask Claude to run `sleep 5` with Bash in the background. When the task ends, its notification does not appear from `User`; Claude posts a line that starts with ✅ instead. Ask Claude to start a background agent that replies with one word, and to schedule a one-time prompt with CronCreate two minutes ahead. Each appears as one line from Claude. While Claude runs a foreground command, type a prompt in the terminal: it appears from `User`. Ask Claude to read a file and run `sleep 12` with Bash. A line from Claude appears for each step when it starts, `📖 Read PATH` and `💻 ...`, shown as live while the step runs, and each is completed with ✅ and its duration, `12 s` for the sleep, without an edited mark. With an app that supports silent messages, the lines and the notes do not alert, and the last part of each answer does. 5. Send `Count from 1 to 300, one number per line.` in the group, and at once send `Reply with the word two.` The second prompt waits in Claude Code's queue. Claude quotes the first message in the answer with the numbers, and the second message in the answer `two`. Neither prompt appears from `User`. The hub chooses the quote of each answer by the start times of the Stop and UserPromptSubmit hooks, and this check confirms that. Then reply to Claude's answer of check 3 with `Say it again in capitals.` Claude answers in capitals with the word of check 3, as a reply to your message. Send a photo, and reply to it with `What is in this photo?` In the transcript, the tag of the first reply contains `reply_to_from="Claude"`, and its content starts with `> ` and that answer; the content of the second starts with `> image: ` and the photo's file name. 6. React 👍 to Claude's answer of check 3. Claude answers as a reply to that answer, and `User` posts nothing. In the transcript, the tag has `reply_to` equal to `item`, and its content is `> ` and that answer, with 👍 on the next line. Remove the reaction, and nothing happens. Send `Count from 1 to 300, one number per line.`, and react ❤ to that message while Claude counts. Claude answers the reaction in the next turn, as a reply to that message. diff --git a/packages/simplex-chat-mcp/spec/api.md b/packages/simplex-chat-mcp/spec/api.md index 32ec76a23c..846fa9e4b7 100644 --- a/packages/simplex-chat-mcp/spec/api.md +++ b/packages/simplex-chat-mcp/spec/api.md @@ -766,7 +766,7 @@ The session groups stay as they are when the membership or a role in the Main gr Claude updates only the display name and the command menu, starting each time from the group's current profile in the chat database. So the short description, the description and the preferences that owners set stay ([`MainGroup.load`](../src/main-group.ts), [`updateGroupProfile`, `changeGroupProfile`](../src/control.ts)). -The hub's profile `Claude` posts in the group, with peer type `agent` ([`profileName`](../src/hub.ts), [`openCore`](../src/core.ts)). +The hub's profile `Claude` posts in the group, with peer type `agent` ([`profileName`, `Hub.open`](../src/hub.ts), [`openCore`](../src/core.ts)). ### 4.3 Session groups @@ -903,6 +903,7 @@ at = performance.timeOrigin of the hook process; absent: Infinity for an answer' | direct messages | off | | command menu | as in [2.5](#25-group-profile) | | members | `Claude`, the members invited through the Main group, the members others added directly, `User` | +| peer types | `Claude` `agent`; `User` `human`, set at each service start ([`User.open`](../src/user.ts), [`updatedUser`](../src/core.ts)). A member who joined while `User` had `agent`, as in 0.3.0, gets `human` with `User`'s next post in the group, with the event `updated profile`: the core sends a member's profile to a group before the next message after a change of its name, full name, short description, description, image or peer type | Claude makes the profile updates one at a time. It starts each from the group's current profile in the chat database and changes only the display name, the short description or the command menu. So a rename and a model change that overlap both stay. diff --git a/packages/simplex-chat-mcp/spec/architecture.md b/packages/simplex-chat-mcp/spec/architecture.md index 442da5b7cf..91ec372834 100644 --- a/packages/simplex-chat-mcp/spec/architecture.md +++ b/packages/simplex-chat-mcp/spec/architecture.md @@ -123,7 +123,7 @@ These symbols of [`core.ts`](../src/core.ts) and [`version.ts`](../src/version.t | Symbol | Contents | |---|---| | [`prepareCore`](../src/core.ts) | network config, `DATA/tmp` as the core's temp folder, mode 0700, and `DATA/files/sent` deleted | -| [`updatedUser`](../src/core.ts) | display name and peer type `agent` of the profile | +| [`updatedUser`](../src/core.ts) | display name and the given peer type of the profile: `agent` for `serve` and `Claude`, `human` for `User` | | [`bufferEvents`](../src/core.ts) | events received before the handler is installed are queued and replayed in order | | [`version`](../src/version.ts) | the package version | @@ -915,7 +915,7 @@ Data flow of a prompt from the session group: | Symbol | Contents | |---|---| -| `openCore` | folder, `ChatApi.init` with prefix `FOLDER/simplex`, active user or a new one with peer type `agent`, `prepareCore`, event buffer, `startChat`, preset contact deleted for a new user, profile update | +| `openCore` | folder, `ChatApi.init` with prefix `FOLDER/simplex`, active user or a new one with the given peer type, `prepareCore`, event buffer, `startChat`, preset contact deleted for a new user, profile update with the display name and the peer type | | `deletePresetContacts` | the contact `Ask SimpleX Team`, deleted when it has no connection | #### [`hook.ts`](../src/hook.ts), [`owner.ts`](../src/owner.ts), [`qr.ts`](../src/qr.ts) diff --git a/packages/simplex-chat-mcp/spec/flows.md b/packages/simplex-chat-mcp/spec/flows.md index 035b21d630..ae19a5aa43 100644 --- a/packages/simplex-chat-mcp/spec/flows.md +++ b/packages/simplex-chat-mcp/spec/flows.md @@ -793,10 +793,10 @@ sequenceDiagram HK->>D: GET /status: not running HK->>D: spawn simplex-mcp service through a launcher, which exits at once D->>D: lock, stored sessions, socket listens - D->>C: openCore ROOT/_hub "Claude" + D->>C: openCore ROOT/_hub "Claude" agent D->>C: apiNewGroup "Claude Control", short description and welcome of trust, {simplexMcpMain: true} M->>C: apiGetGroupLinkStr #35;M: none, apiCreateGroupLink #35;M member - D->>U: openCore ROOT/_user "User" + D->>U: openCore ROOT/_user "User" human U->>C: joins the hub's one-time link#59; the contact of its connection marked simplexMcpUser D-->>HK: ready HK->>D: POST /title {id, pid, at, name, project, model, config} @@ -826,6 +826,7 @@ Notes: - The service is spawned by a launcher, `node -e LAUNCHER COMMAND ARGS`, which exits at once, so the service is no descendant of the hook. When Claude Code exits during the hook, it ends the hook and the hook's descendants, and the service keeps starting. The service drops its ready line when the hook is gone, and the next session start shows the link ([`launcher`, `spawnService`](../src/client.ts), [`writeReady`](../src/service.ts)). - The Main group's name is `main_group`, `Claude Control` by default, followed by ` - MACHINE` when `SIMPLEX_MCP_MACHINE` is set ([`readConfig`, `withMachine`](../src/config.ts)). - The service deletes the preset contact of a new profile, in `_hub` and in `_user` ([`openCore`, `deletePresetContacts`](../src/core.ts)). +- At each start, `openCore` sets the peer type of each profile: `agent` for Claude and `human` for `User`. In a data folder of 0.3.0, `User` is changed from `agent` to `human` at the first start, and the core sends the change to the hub's contact of `User` at once. Members who join a session group later get `human`; members already in a session group get it with `User`'s next post there, as the event `updated profile` ([`openCore`, `updatedUser`](../src/core.ts), [`Hub.open`](../src/hub.ts), [`User.open`](../src/user.ts)). - `User` connects only at the first start. At later starts, the service finds the hub's contact marked `simplexMcpUser`, the contact whose connection belongs to the invitation that the hub created. When `User` does not connect within 60 s, the service runs without it, and terminal prompts are not posted ([`User.open`, `connect`, `userContact`](../src/user.ts), [`Hub.open`](../src/hub.ts)). - At a later start without owners, the service keeps the Main group's link ([`MainGroup.start`](../src/main-group.ts)). - Owners are invited to the groups of the open sessions when they join the Main group. The groups of closed sessions are joined with `/join N` ([`Hub.inviteOwner`, `join`](../src/hub.ts)). diff --git a/packages/simplex-chat-mcp/src/core.ts b/packages/simplex-chat-mcp/src/core.ts index 55ae51b064..653ac0232e 100644 --- a/packages/simplex-chat-mcp/src/core.ts +++ b/packages/simplex-chat-mcp/src/core.ts @@ -17,17 +17,17 @@ export interface Core { } // spec: spec/architecture.md#core-opencore -export async function openCore(folder: string, displayName: string): Promise { +export async function openCore(folder: string, displayName: string, peerType: T.ChatPeerType): Promise { createDataFolder(folder) const chat = await api.ChatApi.init({type: "sqlite", filePrefix: join(folder, "simplex")}) try { const existing = await chat.apiGetActiveUser() - const created = existing ?? (await chat.apiCreateActiveUser({displayName, fullName: "", peerType: T.ChatPeerType.Agent})) + const created = existing ?? (await chat.apiCreateActiveUser({displayName, fullName: "", peerType})) await prepareCore(chat, folder) const events = bufferEvents(chat) await chat.startChat() if (existing === undefined) await deletePresetContacts(chat, created.userId) - const user = await updatedUser(chat, created, displayName) + const user = await updatedUser(chat, created, displayName, peerType) return {chat, user, events} } catch (error) { await chat.close().catch(() => undefined) @@ -55,10 +55,10 @@ export async function deletePresetContacts(chat: api.ChatApi, userId: number): P } // spec: spec/architecture.md#core-updateduser -export async function updatedUser(chat: api.ChatApi, user: T.User, displayName: string): Promise { +export async function updatedUser(chat: api.ChatApi, user: T.User, displayName: string, peerType: T.ChatPeerType): Promise { const {profile} = user - if (displayName === profile.displayName && profile.peerType === T.ChatPeerType.Agent) return user - await chat.apiUpdateProfile(user.userId, {...util.fromLocalProfile(profile), displayName, peerType: T.ChatPeerType.Agent}) + if (displayName === profile.displayName && profile.peerType === peerType) return user + await chat.apiUpdateProfile(user.userId, {...util.fromLocalProfile(profile), displayName, peerType}) return (await chat.apiGetActiveUser())! } diff --git a/packages/simplex-chat-mcp/src/hub.ts b/packages/simplex-chat-mcp/src/hub.ts index 28cb787f53..f0ec761f27 100644 --- a/packages/simplex-chat-mcp/src/hub.ts +++ b/packages/simplex-chat-mcp/src/hub.ts @@ -610,7 +610,7 @@ export class Hub implements SessionGroups { // spec: spec/architecture.md#hub-hub-open static async open(root: string, config: Config, stored: StoredSession[]): Promise { - const core = await openCore(hubFolder(root), profileName) + const core = await openCore(hubFolder(root), profileName, T.ChatPeerType.Agent) try { const {chat, user} = core const group = (await findMainGroup(chat, user.userId)) ?? (await createMainGroup(chat, user.userId, config.mainGroup)) diff --git a/packages/simplex-chat-mcp/src/serve.ts b/packages/simplex-chat-mcp/src/serve.ts index 12a84c49b6..153e17a080 100644 --- a/packages/simplex-chat-mcp/src/serve.ts +++ b/packages/simplex-chat-mcp/src/serve.ts @@ -96,7 +96,7 @@ async function startAgent(chat: api.ChatApi, options: ServeOptions, token: strin await prepareCore(chat, data) const events = bufferEvents(chat) await chat.startChat() - const user = await updatedUser(chat, created, options.displayName ?? created.profile.displayName) + const user = await updatedUser(chat, created, options.displayName ?? created.profile.displayName, T.ChatPeerType.Agent) const displayName = user.profile.displayName const group = await controlGroup(chat, user.userId, displayName, options.resetOwners) const actions: Actions = new Actions(approve, expireHours, controlDataOf(group.customData)?.nextAction ?? 1, { diff --git a/packages/simplex-chat-mcp/src/user.ts b/packages/simplex-chat-mcp/src/user.ts index 8782af217d..81ec3fea07 100644 --- a/packages/simplex-chat-mcp/src/user.ts +++ b/packages/simplex-chat-mcp/src/user.ts @@ -15,7 +15,7 @@ export class User { // spec: spec/architecture.md#user-user-open static async open(root: string, hub: api.ChatApi, hubUser: T.User): Promise { - const core = await openCore(join(root, "_user"), userName) + const core = await openCore(join(root, "_user"), userName, T.ChatPeerType.Human) try { const user = new User(core.chat, core.user) await core.events(event => user.onEvent(event)) diff --git a/packages/simplex-chat-mcp/test/e2e/service.test.ts b/packages/simplex-chat-mcp/test/e2e/service.test.ts index df94b16936..2689a1e8c9 100644 --- a/packages/simplex-chat-mcp/test/e2e/service.test.ts +++ b/packages/simplex-chat-mcp/test/e2e/service.test.ts @@ -14,6 +14,7 @@ import {resetOwners} from "../../src/owner" import {AttachLine, OwnerState, SessionReply, StatusReply, TitleReply} from "../../src/protocol" import {qrCodeText} from "../../src/qr" import {Service, productionDeps} from "../../src/service" +import {userContact} from "../../src/user" import {version} from "../../src/version" import {descendants} from "../unit/fixtures" import {Bot, ItemCheck, callTool, captureLog, cardNumber, isActive, joinByLink, lines, person, prepareRoot, received, startBot, textStarts, until, updated} from "./helpers" @@ -780,6 +781,15 @@ test("/observer ends the standing approvals of the member it makes an observer, await daveRights }, 600_000) +test("a data folder of 0.3.0 starts with User as a person, and an owner sees Claude as an agent and User as a person", async () => { + const {alice, hub, groupOne} = await linkSession("peers") + expect(hub.user!["user"].profile.peerType).toBe(T.ChatPeerType.Human) + await until(async () => (await userContact(hub.chat, hub.profile.userId))?.profile.peerType === T.ChatPeerType.Human) + const members = await alice.chat.apiListMembers(groupOne) + expect(members.find(({memberProfile}) => memberProfile.displayName === "Claude")?.memberProfile.peerType).toBe(T.ChatPeerType.Agent) + expect(members.find(({memberProfile}) => memberProfile.displayName === "User")?.memberProfile.peerType).toBe(T.ChatPeerType.Human) +}, 600_000) + test("a new session has no chats", async () => { const root = join(dir, "fresh", "root") await prepareRoot(smpServer.address, root) diff --git a/packages/simplex-chat-mcp/test/unit/core.test.ts b/packages/simplex-chat-mcp/test/unit/core.test.ts index 959e7e09e0..9f07665542 100644 --- a/packages/simplex-chat-mcp/test/unit/core.test.ts +++ b/packages/simplex-chat-mcp/test/unit/core.test.ts @@ -1,5 +1,6 @@ import {T} from "@simplex-chat/types" -import {deletePresetContacts} from "../../src/core" +import {api} from "simplex-chat" +import {deletePresetContacts, updatedUser} from "../../src/core" import {FakeChat, contact, direct, user} from "./fixtures" beforeEach(() => { @@ -43,3 +44,33 @@ describe("preset contact of a new profile", () => { expect(errors).toEqual(["preset contact 1: db locked"]) }) }) + +describe("display name and peer type of the profile at each start", () => { + const stored = {...user, profile: {...user.profile, displayName: "User", fullName: "", peerType: T.ChatPeerType.Agent}} as T.User + + function profileChat(): {chat: api.ChatApi; updates: T.Profile[]} { + const updates: T.Profile[] = [] + let current = stored + const chat = { + apiUpdateProfile: async (_userId: number, profile: T.Profile) => { + updates.push(profile) + current = {...current, profile: {...current.profile, ...profile}} + }, + apiGetActiveUser: async () => current, + } + return {chat: chat as unknown as api.ChatApi, updates} + } + + it("updates a profile whose peer type differs", async () => { + const {chat, updates} = profileChat() + const updated = await updatedUser(chat, stored, "User", T.ChatPeerType.Human) + expect(updates).toEqual([expect.objectContaining({displayName: "User", peerType: T.ChatPeerType.Human})]) + expect(updated.profile.peerType).toBe(T.ChatPeerType.Human) + }) + + it("keeps a profile with its name and peer type", async () => { + const {chat, updates} = profileChat() + expect(await updatedUser(chat, stored, "User", T.ChatPeerType.Agent)).toBe(stored) + expect(updates).toEqual([]) + }) +}) diff --git a/plans/2026-11-12-mcp-agent-profile.md b/plans/2026-11-12-mcp-agent-profile.md new file mode 100644 index 0000000000..5b09476e45 --- /dev/null +++ b/plans/2026-11-12-mcp-agent-profile.md @@ -0,0 +1,466 @@ +# Claude as an agent, User as a person + +Status: approved by the user on 2026-11-13 at `7c0da7fef`, with the answers Q1 (b) and Q2 (b); implemented on `ep/mcp-agent-profile` after the merge of master `97bbbd9ac`. On 2026-11-13 the user changed the answer to Q1 to (a), as Q3 A of the plans page: the core sends a change of the peer type alone to groups. Code references: master `9d3241b06`. + +Outcome: +- The apps choose the placeholder of another person's profile by its peer type: in groups, in contact lists, in reactions, in calls, for contact requests and on link cards. Claude gets the agent placeholder in its session groups and in the Main group. +- `User`, the profile that posts the prompts typed in the terminal, is given the peer type `human` and keeps the person placeholder. +- In a data folder of 0.3.0, `User` is changed at the service start, without user action. +- The core sends a change of the peer type alone to groups, before the next message there (Q1 (a)). Owners who joined a session group before the upgrade see `User` as a person after its next post there, once the plugin bundles a core with this change. + +## 1. Goal + +Roadmap line, `packages/simplex-chat-mcp/ROADMAP.md:8`: "Claude appears as an agent, with the agent avatar." + +The user's words, 2026-11-11: "correct default avatar placeholders for claude (we have agent) and correct peer type for claude user". + +"we have agent" names the agent placeholder, which the apps show for contacts with peer type `agent` since #7738. "claude user" is read as the plugin's profile `User`. Claude's profile has the peer type `agent` already, and so does `User` (decision 6). For a profile that posts only prompts a person typed, `agent` is wrong (decision 11). The other reading, Claude's profile, needs no change. + +Done when: +``` +# criterion checked by +1 a member without an image and with peer type agent has the agent placeholder in snapshot tests of the desktop and iOS apps + every place of decision 8 +2 every other placeholder of another profile, in the places of decision 20, is chosen the same snapshot tests for link cards and contact + by its peer type requests; review of the diff for the other places +3 a profile with peer type bot has the cube placeholder; a profile of another peer the same snapshot tests + type, or of none, keeps the person placeholder of its place +4 the plugin's User has peer type human; Claude and the agents of serve keep agent unit tests of core.ts; e2e test of the service +5 after a service start on a data folder of 0.3.0, User has peer type human the same e2e test: prepareRoot makes User agent +6 an owner who joins a session group sees Claude as agent and User as human the same e2e test +7 docs state the peer types; the roadmap line is marked delivered review +8 a change of the peer type alone is sent to each group before the next message there, core test, fails on master + and members see `updated profile` once +``` + +## 2. What users see + +The placeholder of another person's profile without an image, after the change: +``` +profile before after +Claude, in its session groups and the Main group person agent +an agent of serve, in its agent control chat person agent +User, in session groups created or joined after person person + the upgrade +User, in session groups joined before the upgrade person agent until User's next post there, then person (Q1 (a)) +a profile with peer type agent person agent, in every place below +a profile with peer type bot person cube, in every place below +a profile of another peer type, or of none person person +a profile with an image the image the image +``` + +Places that change, in both apps unless one is named: +``` +place drawn by +member avatars (decision 8): + message rows of groups, classic and flat layout, received MemberProfileImage + and own; member list; member info; message info: read + receipts and delivery; member support chats and their + toolbar; channel members and channel relays; mention list + (iOS; the Android and desktop mention list has no avatars) +lists of reactions, of members and of contacts the reaction menu +contact list and contact cards (iOS; Android and desktop ContactListNavLink + choose by peer type already) +contact requests: chat list, chat info, contact list (iOS) ChatInfoImage, chatIcon, ContactListNavLink +contacts to add to a group AddGroupMembersView +share and forward list (Android and desktop; iOS chooses by ShareListNavLinkView + peer type already) +call screen; on desktop, the call button and the active call CallView, ActiveCallView, ChatListView.desktop + card in the chat list +contact and invitation link cards: in messages, in the compose MsgChatLink icons + bar, in the chat list preview; their small icons in quotes + and in the compose context +``` + +Places that stay as they are: +``` +place shows +chat list and chat info of a contact agent, cube or person by peer type, as now +chat list and chat info of a group the group placeholder; a group has no peer type +a business chat seen by the business the person placeholder of the customer: a group profile has no + peer type (src/Simplex/Chat/Types.hs:915) +the user's own profiles: user picker, settings, own rows the person, as now +notifications the app icon when the profile has no image, as now +apps without this change person in every place above +``` + +Agent placeholder: `ic_agent.svg` on Android and desktop, `agent` of `SharedAssets.xcassets` on iOS, three dots. Cube: `ic_cube` and `cube.fill`. The person keeps its form in each place: the filled circle for avatars, `person.crop.circle` in iOS reaction menus, `ic_person` and `person` for small link icons. The placeholder keeps its description `profile image placeholder` on Android and desktop. + +The only text is a group event of the core, `updated profile` (`src/Simplex/Chat/Messages/CIContent.hs:374`). Owners who joined a session group before the upgrade see it from `User` once, above `User`'s next post there (Q1 (a)). + +```mermaid +sequenceDiagram + participant D as service + participant C as core _hub, Claude + participant U as core _user, User + participant O as owner's app + D->>C: openCore _hub "Claude" agent: no change + D->>U: openCore _user "User" human + U->>U: apiUpdateProfile, peer type human + U->>C: x.info to its contact Claude, no chat item + Note over O: a session group created after the upgrade + C->>O: invitation, the owner joins + U->>O: User's profile, human + O->>O: Claude with the agent placeholder, User with the person placeholder + Note over O: a session group the owner joined before the upgrade + D->>U: a prompt typed in the terminal + U->>O: x.info with human, then the prompt (Q1 (a)) + O->>O: event "updated profile" from User, then the prompt, with the person placeholder +``` + +## 3. Questions for the user + +Q1. A peer type change in existing groups. Answered on 2026-11-12: (b); changed on 2026-11-13 to (a), as Q3 A of the plans page. +- (a), the answer: the core counts a peer type change as a change of the member profile, 3 changed lines at `src/Simplex/Chat/Store/Profiles.hs:374-376`, with the test of [Acceptance](#7-acceptance-and-tests). The profile is sent to each group before the next message there, as after a name change. Owners see `updated profile` from `User` once, above `User`'s next terminal prompt, and then the person placeholder. Every client gets the change: a bot or an agent that changes its peer type sends it to its groups. The plugin gets it with the core release that follows, when `release.ts` pins it and the plugin's lock is updated (decision 16). +- (b), the first answer: no core change. In session groups joined before the upgrade, updated apps show `User` with the agent placeholder. New groups and later joiners see a person. +- The user's note: "I don't understand why core has to change - if our plugin correctly updates profile, the update will be sent on the next message." +- The answer. The plugin updates the profile correctly: at each start, `updatedUser` calls `apiUpdateProfile` with the peer type `human` (decision 14). The core then sends the profile by three routes: + ``` + route User's new profile reaches code + x.info to each contact, at once the hub's contact of User Commands.hs:4134-4169 + introductions by the host and the profiles every member who joins a session group after Internal.hs:1355-1365; + sent at each new member connection the update Subscriber.hs:519 + x.info to a group before the next message no group: the core sends it only after a Internal.hs:2717-2739; + there change of the name, full name, short Store/Profiles.hs:369-376 + description, description or image + ``` + So on master the update is not sent with the next message: before a message, the core sends the profile to a group only when `user_member_profile_updated_at` is later than the group's last send, and a change of the peer type alone leaves that time as it is. With (a), that time is updated for the peer type too, so the update is sent with the next message, as the user expected. + +Q2. Placeholders of contacts on other screens. Answered on 2026-11-12: (b). +- (b), the answer: every placeholder of another person's profile is chosen by its peer type: the 18 sites of the first draft and 6 more found in the search for every site (decision 20). +- (a), the first recommendation: only `MemberProfileImage`. +- The user's note: "you mean in app UI we don't show bot or agent? why is that I wonder? can you understand?" +- The answer. The apps show the peer type only where it was added for direct chats with bots. #5360, `4811d663e`, 2025-08-07, added the peer type to identify bots: the cube of a bot contact in the chat list and chat info, and the bot's commands menu (`Contact.chatIconName`, `isBot`). #7738, `77f9f4a46`, 2026-10-17, added `agent` at the same places through `peerTypeIcon`, and in the alerts of links. Neither pull request changed `MemberProfileImage`, which draws every member avatar and dates from 2024 (`b04f15997`, `7a418918d`, blurred images of blocked members), nor the other screens of decision 20. So members, contact lists, reactions, calls, contact requests and link cards kept the person placeholder for every peer type. + +## 4. Decisions + +Core: +1. A profile's peer type is `ChatPeerType`: `human`, `bot`, `business`, `agent`, or another text kept as received (`src/Simplex/Chat/Types.hs:753-779`). It is stored in `contact_profiles.chat_peer_type` (`src/Simplex/Chat/Store/Profiles.hs:391`, `src/Simplex/Chat/Store/Direct.hs:741`). +2. The peer type of a user's own profile is set at creation by `CreateActiveUser` and later by `APIUpdateProfile`, `/_profile USER_ID JSON` (`src/Simplex/Chat/Library/Commands.hs:1626`, `:6807`). The plugin calls `apiCreateActiveUser` and `apiUpdateProfile` (`packages/simplex-chat-nodejs/src/api.ts:1047`, `:1087`). +3. A change is sent to contacts at once: `sendUpdateToContacts` sends `x.info` to each contact whose profile as sent changes, and that profile includes the peer type (`src/Simplex/Chat/Library/Commands.hs:4134-4169`, `:4158`, `src/Simplex/Chat/Types.hs:809-813`). The contact's core stores it and creates no chat item for a peer type change (`src/Simplex/Chat/Library/Subscriber.hs:2770-2787`, `:2806-2814`). +4. A change is sent to a group only before the user's next message there, and only when `user_member_profile_updated_at` is later than the group's last send (`src/Simplex/Chat/Library/Internal.hs:2706-2739`). That time is updated for a change of the name, full name, short description, description or image, and not for a peer type change (`src/Simplex/Chat/Store/Profiles.hs:369-376`). So a peer type change is never sent to the members of existing groups. Peer type `bot` is set by this path by `/set bot commands` and by the directory service (`src/Simplex/Chat/Library/Commands.hs:3666-3670`, `apps/simplex-directory-service/src/Directory/Service.hs:223-228`). +5. The core of a member that receives `x.info` in a group stores the profile with its peer type (`redactedMemberProfile` keeps it, `src/Simplex/Chat/Library/Internal.hs:1367-1369`). It creates the event `updated profile` for any change of content, the peer type included (`src/Simplex/Chat/Library/Subscriber.hs:2911-2944`, `:2953-2966`, `src/Simplex/Chat/Types.hs:794-796`). + +Plugin today: + +6. Claude, `User` and the agents of `serve` have peer type `agent`. `openCore` creates each profile with `agent` and `updatedUser` sets `agent` at each start (`packages/simplex-chat-mcp/src/core.ts:24`, `:29`, `:54-59`). `serve` does the same (`src/serve.ts:89`, `:93`). A data folder of 0.3.0, read on 2026-11-12: `_hub` Claude `agent`, `_user` User `agent`, two agents of `serve` `agent`. In the hub's session group 1, the member Claude is `agent`, User `agent`, and the owner has no peer type. + +Apps today: + +7. Both apps choose a contact's placeholder by its peer type with `peerTypeIcon`: bot the cube, agent the agent placeholder, any other the person (`apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/model/ChatModel.kt:1989-1990`, `:2260-2265`; `apps/ios/SimpleXChat/ChatTypes.swift:313-319`, `:2685-2687`). The chat list and chat info use it for contacts (`.../views/helpers/ChatInfoImage.kt:47-56`; `apps/ios/SimpleXChat/ChatUtils.swift:95-103`). A group gets the group placeholder from `GroupInfo.chatIconName` (`ChatModel.kt:2704-2711`; `ChatTypes.swift:3077-3087`). +8. Both apps draw a member's avatar with `MemberProfileImage`, which passes no icon, so a member without an image gets the person placeholder (`.../views/chat/group/GroupMemberInfoView.kt:931-947` with the default of `ChatInfoImage.kt:73`; `apps/ios/Shared/Views/Chat/Group/GroupMemberInfoView.swift:826-839` with the default of `apps/ios/Shared/Views/Helpers/ProfileImage.swift:15`). The callers of `MemberProfileImage`: + ``` + Android and desktop iOS + ChatView.kt:2882 MemberImage, used by ChatView.swift:2088 classic rows + ChatView.kt:2126 classic rows ChatView.swift:2205, :2225 flat rows, own rows + TerminalItemView.kt:344, :351 flat rows GroupChatInfoView.swift:515 member list + GroupChatInfoView.kt:1138 member list GroupMemberInfoView.swift:519 member info + GroupMemberInfoView.kt:756 member info ChatItemInfoView.swift:503 message info + ChatItemInfoView.kt:380 message info GroupMentions.swift:240 mention list + MemberSupportView.kt:230 MemberSupportView.swift:171 + MemberSupportChatView.kt:135 MemberSupportChatToolbar.swift:20 + ChannelMembersView.kt:136 ChannelMembersView.swift:81 + ChannelRelaysView.kt:149 ChannelRelaysView.swift:131 + ``` +9. Peer type `agent` exists from app 7.1.0-beta.7 (#7738, `77f9f4a46`); that pull request changed only the placeholders of contacts. Joining a session group needs app 7.1.0 or later (plan `2026-11-07-mcp-claude-code-channel.md`, section Groups). Every owner's app therefore decodes `agent`. + +Changes: + +10. `MemberProfileImage` passes `peerTypeIcon` of the member's peer type in both apps. So every place of decision 8 shows the placeholder of the member's peer type, and a bot member gets the cube, as a bot contact does. +11. `User` is given the peer type `human`. `User` posts only prompts a person typed (`packages/simplex-chat-mcp/src/hub.ts:195`, decision 121 of the 0.3.0 plan). No consumer distinguishes `human` from an absent peer type: `peerTypeIcon` returns the person for both, and the core's views test only `bot` (`src/Simplex/Chat/View.hs:671-673`, `:1589`, `:1599`). With `human`, the role is stated in the profile. +12. Claude and the agents of `serve` keep `agent`. +13. `openCore` and `updatedUser` take the peer type. The hub and `serve` pass `agent`; `User.open` passes `human`. +14. A data folder is upgraded by `updatedUser` at each start: it compares the display name and the peer type with the stored profile and updates them when either differs (`src/core.ts:56-57`). In a data folder of 0.3.0, `User` is changed at the first start of the new version. No marker file is written. +15. Q1 (a): `userMemberProfileChanged` also compares the peer type (`src/Simplex/Chat/Store/Profiles.hs:374-376`). Contacts get a peer type change at once already (decision 3). A business chat gets the profile of its business or customer member by the same group path; a change of that member's peer type updates no field of the chat's group profile, which has no peer type (`src/Simplex/Chat/Store/Groups.hs:2823-2829`). +16. The plugin bundles `simplex-chat` 7.1.3 (`packages/simplex-chat-mcp/package-lock.json:4321-4322`), which loads the libraries of `core-7.1.3.0` (`packages/simplex-chat-nodejs/src/release.ts:3`). A core change would reach the plugin only through a core release, its pin in `release.ts` and an update of the plugin's lock. +17. Nothing is posted in any group for the update of `User`. The hub's contact of `User` gets no chat item (decision 3), and the plugin's event handlers ignore `contactUpdated` and `groupMemberUpdated` (`src/tools.ts:665-691`, `src/control.ts:656-670`, `src/user.ts:50-57`). +18. Session groups are never listed by Claude's tools, so the `from_type` of `User`'s messages appears in no tool result (`src/tools.ts:578`, `:1523`). +19. The apps' evidence is a snapshot of each new preview, compared with a committed reference: desktop by `SnapshotTest` (`apps/multiplatform/common/src/desktopTest/kotlin/chat/simplex/app/SnapshotTest.kt:59`, `:137`), iOS by `snapshots.sh` with `previewScenes` (`apps/ios/SimpleX Snapshots/SnapshotTests.swift:205`) and `check-previews.py`. +20. Q2 (b): the other places of another person's profile, found by a search of every `ProfileImage`, `ProfileImageForActiveCall`, profile menu item, person icon and chat link icon in both apps. The first draft listed 18 sites; the search found 6 more, the invitation link cards and the small link icons: + ``` + place Android and desktop iOS + reaction lists ChatItemView.kt:175 members, :189 contacts, ChatView.swift:2984 contacts, :3278 members, + drawn at :221 drawn by profileMenuItem, :3301 + contact list, contact cards (chooses by peer type already) ContactListNavLink.swift:170, :265 + contact requests ChatInfoImage.kt:53 ChatUtils.swift:100; ContactListNavLink.swift:318 + contacts to add to a group AddGroupMembersView.kt:354 AddGroupMembersView.swift:222 + share and forward list ShareListNavLinkView.kt:105 (chooses by peer type already) + call screen CallView.android.kt:398 ActiveCallView.swift:329 + call on the lock screen CallActivity.kt:386 (android module), found - + by the review + call in the chat list ChatListView.desktop.kt:66, :128 - + link cards, contact ChatModel.kt:5272 ChatTypes.swift:5724 + link cards, invitation ChatModel.kt:5273 ChatTypes.swift:5726 + small link icons, contact ChatModel.kt:5279 ChatTypes.swift:5735 + small link icons, invitation ChatModel.kt:5280 ChatTypes.swift:5737 + ``` + The link icons are used by `ComposeChatLinkView.kt:32`, `CIChatLinkHeader.kt:34`, `ChatPreviewView.kt:365`, `ContextItemView.kt:84`, `:95` and `FramedItemView.kt:227`; on iOS by `ComposeChatLinkView.swift:14`, `CIChatLinkHeader.swift:54`, `ChatPreviewView.swift:447`, `ContextItemView.swift:88` and `FramedItemView.swift:333`. +21. Excluded, with their reasons: the user's own profiles; notifications, which show the app icon without an image (`apps/multiplatform/android/src/main/java/chat/simplex/app/model/NtfManager.android.kt:111-115`, `.../desktopMain/.../NtfManager.desktop.kt:105-109`); the customer of a business chat seen by the business, because a group profile has no peer type (`ChatModel.kt:2710`, `ChatTypes.swift:3084`). +22. `peerTypeIcon` takes the person icon of its place, by default the filled circle. The iOS reaction menus pass `person.crop.circle`; the small link icons pass `ic_person` on Android and desktop and `person` on iOS. So people keep the icon of each place, and one function chooses by peer type. +23. Kotlin `ChatItemReactionMenuItem` gets an `icon`, the person by default; members and contacts pass the icon of their peer type. iOS `profileMenuItem` takes the peer type. +24. Kotlin `ProfileImageForActiveCall` takes an `icon`, the person by default. The person keeps its drawing, enlarged by 14 dp to hide the circle's inner padding (`ChatInfoImage.kt:305-333`); another icon is drawn at the image size, as `ProfileImage` draws it. +25. In the Kotlin share list, a chat other than a note folder or a group is drawn with `ChatInfoImage(chat.chatInfo, 42.dp)`. Its size and color equal those of `ShareListNavLinkView.kt:105` (`ChatInfoImage.kt:47-56`). +26. iOS `MsgChatLink.iconName` and `smallIconName` become `icon` and `smallIcon(agent:)` of type `Image`, because the agent placeholder is an image asset, not a system symbol. Their 5 callers pass the image. The helpers `image` of `ContextItemView.swift:93` and `ciQuoteIconView` of `FramedItemView.swift:386` take an `Image`; their other callers pass `Image(systemName:)`. +27. In text, a system symbol scales with the font and an image asset keeps its own size, 21.41 × 24 points for `agent`. So the compose context line draws the agent placeholder at the height of the symbol `person` of the body font, which `peerTypeIcon` and `smallIcon` take as `agent` (found by the review). The quote of a link sizes its icon to 18 points, as before. +28. The lock-screen call of a contact without a name preview, `NotificationPreviewMode.HIDDEN`, keeps the person placeholder, so the lock screen shows nothing of the caller's profile. + +## 5. Design + +Options for the placeholders: +``` +option producer each consumer older apps wire +A1 each place passes the icon of the none one argument at each place; Contact person, as now none + profile's peer type, with peerTypeIcon .chatIconName and .chatIcon where a + and the existing contact helpers contact exists +A2 ProfileImage takes a peer type in none every caller of ProfileImage gains a person, as now none + place of an icon second way to choose its icon, groups, + notes and links included +A3 the plugin sets an image in Claude's an image only Claude changes; contacts, bots and the image the image in every + profile other agents keep the person profile message +``` +A1 is chosen. With A2, the icon of a group or a note folder and the peer type of a profile are passed through one function in two ways. With A3, the placeholder that the user asked for is replaced by a fixed image, and only for Claude. + +Options for the form of the person: +``` +option consumers +P1 peerTypeIcon takes the person of its one function chooses by peer type; each place keeps its person + place, by default the filled circle +P2 a function for each form of the person the choice by peer type repeated in each function +P3 the filled circle everywhere the person changes in iOS reaction menus and small link icons +``` +P1 is chosen. + +Options for `User`: +``` +option what the apps show consumers +U1 human person no consumer distinguishes it from U2 (decision 11) +U2 none person the same +U3 agent agent, after A1 wrong for prompts a person typed +``` +U1 is chosen: the role is stated in the profile. + +Options for groups that owners joined before the upgrade: +``` +option producer members older apps wire +G1 the core counts a peer type change 3 changed lines in updateUserProfile one event `updated profile` the same one x.info per group, + as a member profile change before the next message +G2 the plugin changes a visible field two profile updates at each such two events per group the same two x.info per group + and restores it start, a workaround +G3 nothing none User stays agent the same none +``` +G1 is Q1 (a), the answer; G3 is Q1 (b). G2 is a workaround with two visible changes for a field that the core skips. + +Options for the upgrade: +``` +option cost +D1 updatedUser at each start 2 changed lines; runs at every start, as for the display name now +D2 a one-time migration with a marker a marker file, its read, and its write +``` +D1 is chosen. + +Changes per file, the core (Q1 (a)): +``` +file change +src/Simplex/Chat/Store/Profiles.hs updateUserProfile: userMemberProfileChanged also compares peerType +tests/ChatTests/Groups.hs "change of peer type alone is sent on next message", in "membership profile updates" +``` + +Changes per file, Android and desktop (`apps/multiplatform/common/src`): +``` +file change +commonMain/.../model/ChatModel.kt peerTypeIcon(peerType, person = ic_account_circle_filled); + MsgChatLink.iconRes and smallIconRes of Contact and Invitation by peerTypeIcon, + smallIconRes with person = ic_person; business keeps ic_work_filled_padded and ic_work +commonMain/.../views/chat/group/GroupMemberInfoView.kt MemberProfileImage: icon = peerTypeIcon(mem.memberProfile.peerType); + preview PreviewPeerTypePlaceholders +commonMain/.../views/helpers/ChatInfoImage.kt ChatInfoImage: ContactRequest by peerTypeIcon of the request's profile; + ProfileImageForActiveCall: icon (decision 24) +commonMain/.../views/chat/item/ChatItemView.kt ChatItemReactionMenuItem.icon; members and contacts pass theirs; drawn at 221 +commonMain/.../views/chat/group/AddGroupMembersView.kt ProfileImage(36.dp, contact.image, contact.chatIconName) +commonMain/.../views/chatlist/ShareListNavLinkView.kt ChatInfoImage(chat.chatInfo, 42.dp) for a chat that is neither a note folder nor a group +androidMain/.../views/call/CallView.android.kt icon = call.contact.chatIconName +desktopMain/.../views/chatlist/ChatListView.desktop.kt icon = call.contact.chatIconName at 66 and at 128 +desktopTest/.../SnapshotTest.kt scene GroupMemberInfoView.PreviewPeerTypePlaceholders +desktopTest/.../PeerTypeIconTest.kt link card icons and small link icons by peer type +desktopTest/snapshots/ 2 references, light and dark +``` + +Changes per file, iOS (`apps/ios`): +``` +file change +SimpleXChat/ChatTypes.swift peerTypeIcon(_ peerType, person: Image = the filled circle); + MsgChatLink.icon and smallIcon in place of iconName and smallIconName +SimpleXChat/ChatUtils.swift chatIcon: contactRequest by peerTypeIcon of the request's profile +Shared/Views/Chat/Group/GroupMemberInfoView.swift MemberProfileImage: icon: peerTypeIcon(mem.memberProfile.peerType) +Shared/Views/Chat/ChatView.swift profileMenuItem takes the peer type: peerTypeIcon(peerType, person: + person.crop.circle); its 3 callers pass it +Shared/Views/Contacts/ContactListNavLink.swift icon: contact.chatIcon at 170 and 265; icon: chatIcon(chat.chatInfo) at 318 +Shared/Views/Chat/Group/AddGroupMembersView.swift icon: contact.chatIcon +Shared/Views/Call/ActiveCallView.swift icon: call.contact.chatIcon +Shared/Views/ChatList/ChatPreviewView.swift, icon: chatLink.icon + Chat/ComposeMessage/ComposeChatLinkView.swift, + Chat/ChatItem/CIChatLinkHeader.swift +Shared/Views/Chat/ComposeMessage/ContextItemView.swift image takes an Image; chatLink.smallIcon +Shared/Views/Chat/ChatItem/FramedItemView.swift ciQuoteIconView takes an Image; chatLink.smallIcon +Shared/Views/Helpers/ProfileImage.swift PeerTypePlaceholders_Previews +SimpleX Snapshots/SnapshotTests.swift scene PeerTypePlaceholders_Previews, in the sorted list +SimpleX Snapshots/References/ 2 references, light and dark +``` + +Changes per file, the plugin (`packages/simplex-chat-mcp`): +``` +file change +src/core.ts openCore(folder, displayName, peerType); updatedUser(chat, user, displayName, peerType) +src/hub.ts Hub.open: openCore(hubFolder(root), profileName, T.ChatPeerType.Agent) (368) +src/user.ts User.open: openCore(join(root, "_user"), userName, T.ChatPeerType.Human) (17) +src/serve.ts startAgent: updatedUser(..., T.ChatPeerType.Agent) (93) +test/unit/core.test.ts tests of updatedUser, with a fake of their own +test/e2e/service.test.ts test of decisions 11 and 14 +``` + +`peerTypeIcon`, after the change: +``` +peerTypeIcon(peerType, person = the filled circle): + bot: the cube + agent: the agent placeholder + else: person +``` + +`updatedUser`, after the change: +``` +updatedUser(chat, user, displayName, peerType): + displayName and peerType equal to the stored profile's: user + else: apiUpdateProfile(the stored profile with displayName and peerType); the active user read again +``` + +```mermaid +flowchart LR + S[service start] --> H[openCore _hub Claude agent] + S --> UO[openCore _user User human] + UO --> UU[updatedUser: peer type differs, apiUpdateProfile] + UU --> XC[x.info to the contact Claude] + UO --> J[User joins new session groups with peer type human] + H --> M[owners' cores: members Claude agent and User human] + J --> M + M --> P[peerTypeIcon: member avatars, reactions, contacts, requests, calls, link cards] + P --> A[apps: agent, cube or person] +``` + +## 6. Compatibility + +``` +case result +apps without this change the person placeholder in every place of decisions 8 and 20, as now +apps with this change every place by peer type; people keep the icon of each place +older plugin data folders (0.3.0) User is changed from agent to human at the first start; Claude unchanged +session groups joined before the upgrade User's profile is sent with User's next post there, shown as `updated profile` once, when the + plugin bundles a core with Q1 (a); with core-7.1.3.0, User stays agent there +a later downgrade of the plugin 0.3.0's updatedUser sets User back to agent at its start (core.ts:56-57 of 0.3.0) +agents of serve unchanged: agent at creation and at each start +older Claude Code versions unaffected: the change touches no hook, tool or channel +other clients a peer type change of a user is sent to its groups before its next message there; members + see `updated profile` once; the protocol is unchanged +``` + +## 7. Acceptance and tests + +The criteria are those of [Goal](#1-goal). Tests: +``` +test kind fails on master +tests/ChatTests/Groups.hs, "membership profile updates", core yes: the member record keeps no peer type + "change of peer type alone is sent on next message" +packages/simplex-chat-mcp/test/unit/core.test.ts: unit does not compile on master: updatedUser takes 3 arguments + "updates a profile whose peer type differs" + "keeps a profile with its name and peer type" +packages/simplex-chat-mcp/test/e2e/service.test.ts: e2e yes: User stays agent + "a data folder of 0.3.0 starts with User as a person, and an owner sees Claude as an agent and User as a person" +apps/multiplatform/.../desktopTest/.../PeerTypeIconTest.kt: unit yes: master returns the person for every peer type + "linkCardsShowThePeerType" + "smallLinkIconsShowThePeerType" +GroupMemberInfoView.PreviewPeerTypePlaceholders, desktop snapshot uses the new icon of ProfileImageForActiveCall +PeerTypePlaceholders_Previews, iOS snapshot uses the new icon and smallIcon of MsgChatLink +``` + +The e2e test runs `linkSession`, whose `prepareRoot` creates `User` with `agent` as 0.3.0 does (`test/e2e/helpers.ts:30-35`), and checks: +``` +User's own profile, hub.user["user"] peerType human +the hub's contact of User, userContact peerType human, within the test timeout +Alice's member Claude in the session group peerType agent +Alice's member User in the session group peerType human +``` + +In each preview, one column is drawn for each of no peer type, `human`, `agent` and `bot`, and one row for each kind of place: +``` +row Android and desktop iOS +member avatar MemberImage MemberProfileImage at 38 points +contact request ChatInfoImage of a ContactRequest ChatInfoImage of a contactRequest +contact link card ProfileImage with MsgChatLink.Contact.iconRes ProfileImage with MsgChatLink.contact icon +small link icon Icon of MsgChatLink.Contact.smallIconRes MsgChatLink.contact smallIcon +reaction menu item - profileMenuItem +active call card ProfileImageForActiveCall - +compose context line - ContextItemView with a contact link, one line for each + peer type +``` +The references are recorded from a run with the change. Both previews use parameters that the change adds, so they compile only after it; the failure on master is shown by the unit tests of the plugin and of the Kotlin link icons. At each other place of decision 20, one argument is added, checked in the diff. + +CI: +- The reduced build runs the changed scopes: kotlin (`:common:desktopTest`, which fails for a preview without a scene), ios (build and `check-previews.py`), mcp (unit and e2e tests). +- The app test workflows once each, with the app uploaded: `desktop-linux` (the snapshot comparison), `ios-sim` (the snapshot comparison), `android-emu` (the smoke test of the APK with the changed common code). + +Not covered by tests: the creation of `User` with `human` in a new data folder, because every e2e test prepares the root with the test servers. The code of that path is one argument of `apiCreateActiveUser`. + +The core test is "change of peer type alone is sent on next message" in "membership profile updates" (`tests/ChatTests/Groups.hs`). After `createGroup2 "team" alice bob` and the deletion of their contact, as in `testMembershipProfileUpdateContactDeletedPeerType`, alice sends `/_profile 1 {"displayName": "alice", "fullName": "", "shortDescr": "Alice", "peerType": "agent"}`, `#team hello` and `#team hello again`. Then `memberAddressPeerType bob "alice"` is `[(Nothing, Just CPTAgent)]`, `[(Nothing, Nothing)]` on master, and bob's group has one `updated profile (signed)` item. The plugin's e2e tests load the pinned `core-7.1.3.0`, so the members already in a group are covered by the core test only. + +## 8. Docs to change + +``` +file change +packages/simplex-chat-mcp/ROADMAP.md:8 the line kept and marked as delivered, "- ✅ TEXT", as in the main README +packages/simplex-chat-mcp/REFERENCE.md:581 after "User is a second profile ...": Claude's profile has the peer type agent, and the + app shows it with the agent placeholder; User's profile has the peer type human +packages/simplex-chat-mcp/spec/api.md:723, :826 the members Claude, peer type agent, and User, peer type human +packages/simplex-chat-mcp/spec/architecture.md:126 updatedUser: the display name and the given peer type +packages/simplex-chat-mcp/spec/architecture.md:904 openCore: a new profile with the given peer type +packages/simplex-chat-mcp/spec/flows.md:790, :793 openCore with agent and with human; a note on the upgrade of User at each start +packages/simplex-chat-mcp/TESTING.md:188 the e2e test above +packages/simplex-chat-mcp/TESTING.md, real session a check: in the app, Claude's posts show the agent placeholder and User's the person one +apps/multiplatform/spec/client/chat-view.md:375 MemberProfileImage: the member's image, otherwise the placeholder of its peer type +apps/ios/spec/client/chat-view.md:564 the same, in the section of the member list; both lines are outside the flat layout's + sections, which flat-sessions changes +``` +README.md is unchanged: it names no peer type. + +## 9. Conflict areas with the other items + +``` +file or function items +packages/simplex-chat-mcp/ROADMAP.md:7-8 line 7 is marked by flat-sessions and line 8 by this item: adjacent lines +packages/simplex-chat-mcp/src/hub.ts Hub.open (369) other functions of hub.ts are changed by reactions and replies +packages/simplex-chat-mcp/test/e2e/service.test.ts this item's test is added before "a new session has no chats"; tests of other + items are added at the end of the file +packages/simplex-chat-mcp/TESTING.md, the list of e2e tests an entry of every item is added there +packages/simplex-chat-mcp/REFERENCE.md:578-596, sessions flat-sessions (layout of session groups), replies, reactions +packages/simplex-chat-mcp/spec/flows.md flow 17, :790-827 flat-sessions (group profile at creation) +GroupMemberInfoView.kt, GroupMemberInfoView.swift MemberProfileImage, also changed by flat-sessions for the flat rows: one added + MemberProfileImage argument here, icon = peerTypeIcon(mem.memberProfile.peerType) +apps .../SnapshotTest.kt previewScenes, iOS previewScenes flat-sessions, if it adds previews: adjacent lines of sorted lists +apps/ios/Shared/Views/Chat/ChatView.swift flat-sessions changes the rows (2000-2240); this item changes profileMenuItem + and the reaction menus (2984, 3278, 3301) +apps/ios/Shared/Views/Chat/ChatItem/FramedItemView.swift flat-sessions, if it changes quotes of the flat layout: ciQuoteIconView (386) +apps/multiplatform/.../views/chat/item/ChatItemView.kt flat-sessions, if it changes items: the reaction menu (61, 175-221) +TerminalItemView.kt, ChatView.swift rows changed by flat-sessions only; the previews of this item do not depend on the + layout +``` + +## 10. Estimate + +``` +part lines of code lines of tests other +apps, Android and desktop about 15 about 25 in previews 1 scene line, 2 references +apps, iOS about 25 about 25 in previews 1 scene line, 2 references +plugin about 8 about 40 +docs about 15 +``` +Agent time: about 3 hours of work. CI: the reduced build, about 1 hour. The first run of each app workflow on the branch builds its core: `desktop-linux` about 35 minutes, `android-emu` about 40 minutes, `ios-sim` about 60 minutes plus the wait for a macOS runner (`scripts/ci/README.md`, "How long a run takes"). Later runs reuse that core. One run of each app records the references. + +Commits: `ui: show the peer type placeholder of members and contacts`, `mcp: User has the peer type of a person`. diff --git a/src/Simplex/Chat/Store/Profiles.hs b/src/Simplex/Chat/Store/Profiles.hs index e607d04fb7..0f4f431a8c 100644 --- a/src/Simplex/Chat/Store/Profiles.hs +++ b/src/Simplex/Chat/Store/Profiles.hs @@ -371,9 +371,9 @@ updateUserProfile db user p' DB.execute db "UPDATE users SET user_member_profile_updated_at = ? WHERE user_id = ?" (currentTs, userId) pure $ Just currentTs | otherwise = pure userMemberProfileUpdatedAt - userMemberProfileChanged = newName /= displayName || fn' /= fullName || d' /= shortDescr || desc' /= description || img' /= image - User {userId, userContactId, localDisplayName, profile = LocalProfile {profileId, displayName, fullName, shortDescr, description, image}, userMemberProfileUpdatedAt} = user - Profile {displayName = newName, fullName = fn', shortDescr = d', description = desc', image = img', preferences} = p' + userMemberProfileChanged = newName /= displayName || fn' /= fullName || d' /= shortDescr || desc' /= description || img' /= image || pt' /= peerType + User {userId, userContactId, localDisplayName, profile = LocalProfile {profileId, displayName, fullName, shortDescr, description, image, peerType}, userMemberProfileUpdatedAt} = user + Profile {displayName = newName, fullName = fn', shortDescr = d', description = desc', image = img', peerType = pt', preferences} = p' fullPreferences = fullPreferences' preferences updatedUserProfile :: User -> Profile -> UTCTime -> LocalProfile diff --git a/tests/ChatTests/Groups.hs b/tests/ChatTests/Groups.hs index a8192ef77a..3fbcda8051 100644 --- a/tests/ChatTests/Groups.hs +++ b/tests/ChatTests/Groups.hs @@ -236,6 +236,7 @@ chatGroupTests = do it "member contact is active" testMembershipProfileUpdateContactActive it "member contact is deleted" testMembershipProfileUpdateContactDeleted it "member contact is deleted, peer type is updated" testMembershipProfileUpdateContactDeletedPeerType + it "change of peer type alone is sent on next message" testMembershipProfileUpdatePeerTypeOnly it "member contact is deleted silently, then considered disabled" testMembershipProfileUpdateContactDisabled it "profile update without change is ignored" testMembershipProfileUpdateNoChangeIgnored it "change of profile contact link is ignored" testMembershipProfileUpdateContactLinkIgnored @@ -7581,6 +7582,30 @@ testMembershipProfileUpdateContactDeletedPeerType = memberAddressPeerType bob "alisa" `shouldReturn` [(Nothing, Just CPTBot)] +testMembershipProfileUpdatePeerTypeOnly :: HasCallStack => TestParams -> IO () +testMembershipProfileUpdatePeerTypeOnly = + testChat2 aliceProfile bobProfile $ + \alice bob -> do + createGroup2 "team" alice bob + + alice ##> "/d bob" + alice <## "bob: contact is deleted" + bob <## "alice (Alice) deleted contact with you" + + alice ##> "/_profile 1 {\"displayName\": \"alice\", \"fullName\": \"\", \"shortDescr\": \"Alice\", \"peerType\": \"agent\"}" + + alice #> "#team hello" + bob <# "#team alice> hello" + + memberAddressPeerType bob "alice" `shouldReturn` [(Nothing, Just CPTAgent)] + + alice #> "#team hello again" + bob <# "#team alice> hello again" + + bob ##> "/_get chat #1 count=100" + r <- chat <$> getTermLine bob + filter (== (0, "updated profile (signed)")) r `shouldBe` [(0, "updated profile (signed)")] + testMembershipProfileUpdateContactDisabled :: HasCallStack => TestParams -> IO () testMembershipProfileUpdateContactDisabled = testChat2 aliceProfile bobProfile $