From be010cfa5219aa3e297050ff79080d58b211c1f9 Mon Sep 17 00:00:00 2001 From: Reef Date: Fri, 20 Nov 2026 06:55:12 +0000 Subject: [PATCH 1/2] fix(tasks): resolve joint-channel task assignee from other server's actor (slock #14517) --- .../joint-task-assignee-actor-avatar.md | 22 ++++++ .../raft/app/tasks/TaskConversationHead.kt | 27 ++++++- .../build/raft/app/tasks/TaskOpenSurfaces.kt | 8 +- .../app/thread/ThreadLinkedTaskProjection.kt | 4 + .../app/thread/ThreadMessageSourceTaskList.kt | 46 +++++++++++- .../build/raft/app/thread/ThreadPage.kt | 21 +++++- .../build/raft/app/thread/ThreadRouteGates.kt | 12 ++- .../build/raft/app/JointBillingNoticeTest.kt | 29 ++++++++ .../raft/app/ThreadMessageSourceTasksTest.kt | 73 ++++++++++++++++++- 9 files changed, 227 insertions(+), 15 deletions(-) create mode 100644 change-logs/1.28.0/changesets/joint-task-assignee-actor-avatar.md diff --git a/change-logs/1.28.0/changesets/joint-task-assignee-actor-avatar.md b/change-logs/1.28.0/changesets/joint-task-assignee-actor-avatar.md new file mode 100644 index 0000000000..a74a5f8244 --- /dev/null +++ b/change-logs/1.28.0/changesets/joint-task-assignee-actor-avatar.md @@ -0,0 +1,22 @@ +--- +type: fixed +area: tasks +platforms: + - android + - ios + - desktop +pull_request: null +rollout: full +--- + +## zh-CN + +跨服务器联合频道中的任务负责人为对方服务器成员或智能体时,现在会正确显示对方实际的头像和名称,不再退回到默认占位头像。 + +## en + +In joint channels, tasks assigned to a person or agent from another server now display their actual avatar and display name instead of falling back to the default placeholder. + +## ja + +ジョイントチャンネルで別サーバーのメンバーやエージェントがタスク担当者になっている場合、デフォルトのプレースホルダーではなく実際のアイコンと表示名が表示されるようになりました。 diff --git a/compose/shared/src/commonMain/kotlin/build/raft/app/tasks/TaskConversationHead.kt b/compose/shared/src/commonMain/kotlin/build/raft/app/tasks/TaskConversationHead.kt index 78f308081b..6308a840e7 100644 --- a/compose/shared/src/commonMain/kotlin/build/raft/app/tasks/TaskConversationHead.kt +++ b/compose/shared/src/commonMain/kotlin/build/raft/app/tasks/TaskConversationHead.kt @@ -102,6 +102,7 @@ import build.raft.app.data.earlierDiscussionVisible import build.raft.app.data.taskHeadSourceMessageId import build.raft.app.data.toTaskHistoryRows import build.raft.app.data.valueOrNull +import build.raft.app.model.ConversationKind import build.raft.app.model.MemberKind import build.raft.app.model.MemberProfile import build.raft.app.model.RaftTimeContext @@ -1239,6 +1240,8 @@ internal data class TaskConversationHeaderChrome( val assigneeId: String? = null, /** The task's server: the assignee's face reads its member directory. */ val avatarServerId: String? = null, + /** Task lives in a joint channel (`task.channelType == "joint"`): remote assignees fall back to actors/resolve. */ + val isJointChannel: Boolean = false, val summarized: Boolean, val headFloatOpen: Boolean = false, /** Null: not known yet (no Follow row). */ @@ -1270,6 +1273,7 @@ internal fun TaskSummary.taskConversationHeaderChrome( assigneeAvatarWireValue = assignee?.avatarWireValueForRenderedAvatar(), assigneeId = assignee?.id?.value, avatarServerId = serverId?.trim()?.takeIf { it.isNotEmpty() }, + isJointChannel = parseConversationKindOrNull(channelType) == ConversationKind.Joint, summarized = summarized, headFloatOpen = headFloatOpen && summarized, followed = followed, @@ -1349,12 +1353,31 @@ internal fun TaskConversationBarTitle(chrome: TaskConversationHeaderChrome, modi RaftTaskStatusBadge(chrome.status.raftTaskStatus(), chrome.status.localizedLabel(), size = RaftTaskStatusBadgeSize.Sm) // The face only (Kirby: a cut name says less than the face), named for screen readers. chrome.assigneeName?.let { name -> + val jointSurface = chrome.isJointChannel || LocalRaftJointActorSurface.current + val avatarResolver = rememberRaftMemberAvatarResolver(chrome.avatarServerId) + val jointAvatarResolver = + remember(avatarResolver, jointSurface) { avatarResolver.forJointSurface(jointSurface) } + val jointActor = + rememberRaftJointActor( + memberAvatarResolver = jointAvatarResolver, + kind = chrome.assigneeKind, + memberId = chrome.assigneeId, + enabled = jointSurface, + ) + val assigneeLabel = + threadMessageSourceTaskAssigneeName( + assigneeIsViewer = false, + viewerLabel = "", + assigneeName = name, + jointActor = jointActor, + ) RaftMemberAvatar( identity = RaftMemberAvatarIdentity(chrome.assigneeKind, chrome.assigneeId, chrome.avatarServerId), - label = name, - modifier = Modifier.semantics { contentDescription = name }, + label = assigneeLabel, + modifier = Modifier.semantics { contentDescription = assigneeLabel }, avatarSize = RaftAvatarSize.Xs.edge, carriedAvatarWireValue = chrome.assigneeAvatarWireValue, + resolver = jointAvatarResolver, ) } TaskBarChevron(open = chrome.headFloatOpen) diff --git a/compose/shared/src/commonMain/kotlin/build/raft/app/tasks/TaskOpenSurfaces.kt b/compose/shared/src/commonMain/kotlin/build/raft/app/tasks/TaskOpenSurfaces.kt index 4db33fcd9e..cebec5add4 100644 --- a/compose/shared/src/commonMain/kotlin/build/raft/app/tasks/TaskOpenSurfaces.kt +++ b/compose/shared/src/commonMain/kotlin/build/raft/app/tasks/TaskOpenSurfaces.kt @@ -49,6 +49,7 @@ import androidx.compose.foundation.layout.width import androidx.compose.foundation.rememberScrollState import androidx.compose.foundation.verticalScroll import androidx.compose.runtime.Composable +import androidx.compose.runtime.CompositionLocalProvider import androidx.compose.runtime.mutableStateMapOf import androidx.compose.runtime.setValue import androidx.compose.runtime.mutableStateOf @@ -64,6 +65,7 @@ import build.raft.app.data.TaskConversationDetailsRepository import build.raft.app.data.ThreadApiResult import build.raft.app.data.toThreadAttachmentCommentsFailureProjection import build.raft.app.model.ChannelId +import build.raft.app.model.ConversationKind import build.raft.app.model.MemberProfile import build.raft.app.model.RaftTimeContext import build.raft.app.model.ServerId @@ -632,11 +634,14 @@ internal fun TaskPendingConversationPage( serverId = serverId, ) val keyboardUp = WindowInsets.ime.getBottom(LocalDensity.current) > 0 + val jointSurface = + parseConversationKindOrNull(task.channelType) == ConversationKind.Joint || LocalRaftJointActorSurface.current // Back puts the pulled-down head back up before it leaves the page. RaftBackHandler(enabled = headScrollState.floatOpen, label = "task_pending_head_float") { headScrollState.closeFloat() } // The conversation page's canvas, so its composer dock sits on the same ground as there. // A press anywhere on the page outside the pulled-down head puts it back up, the composer included. - Column(modifier.fillMaxSize().background(colors.layerCanvas).taskHeadFloatOutsidePress(headScrollState)) { + CompositionLocalProvider(LocalRaftJointActorSurface provides jointSurface) { + Column(modifier.fillMaxSize().background(colors.layerCanvas).taskHeadFloatOutsidePress(headScrollState)) { // The conversation page's top bar (ThreadPage's header for a task conversation). RaftTopPageHeader( title = task.taskRefTitle(), @@ -757,6 +762,7 @@ internal fun TaskPendingConversationPage( ) } } + } } } diff --git a/compose/shared/src/commonMain/kotlin/build/raft/app/thread/ThreadLinkedTaskProjection.kt b/compose/shared/src/commonMain/kotlin/build/raft/app/thread/ThreadLinkedTaskProjection.kt index a9cb230a6b..61a36d39aa 100644 --- a/compose/shared/src/commonMain/kotlin/build/raft/app/thread/ThreadLinkedTaskProjection.kt +++ b/compose/shared/src/commonMain/kotlin/build/raft/app/thread/ThreadLinkedTaskProjection.kt @@ -5,6 +5,7 @@ import build.raft.app.data.SharedTasksDataStoreStatus import build.raft.app.data.SharedTasksProjectionSlice import build.raft.app.data.SharedTasksRouteIntent import build.raft.app.data.TasksUiState +import build.raft.app.model.ConversationKind import build.raft.app.model.MemberKind import build.raft.app.model.MemberProfile import build.raft.app.model.TaskStatus @@ -86,6 +87,8 @@ internal data class ThreadMessageSourceTaskItem( val assigneeName: String?, /** The reader is the assignee (shown as "You"). */ val assigneeIsViewer: Boolean, + /** Task lives in a joint channel (`task.channelType == "joint"`): remote assignees fall back to actors/resolve. */ + val isJointChannel: Boolean = false, ) internal fun TaskSummary.toThreadMessageSourceTaskItem(viewerUserId: String?): ThreadMessageSourceTaskItem { @@ -103,6 +106,7 @@ internal fun TaskSummary.toThreadMessageSourceTaskItem(viewerUserId: String?): T person?.let { threadLinkedTaskAssigneeDisplayName() ?: it.displayName.trim().removePrefix("@").ifBlank { null } }, assigneeIsViewer = person?.kind == MemberKind.Human && assigneeId != null && assigneeId == viewerUserId?.trim(), + isJointChannel = parseConversationKindOrNull(channelType) == ConversationKind.Joint, ) } diff --git a/compose/shared/src/commonMain/kotlin/build/raft/app/thread/ThreadMessageSourceTaskList.kt b/compose/shared/src/commonMain/kotlin/build/raft/app/thread/ThreadMessageSourceTaskList.kt index 55a8e78a76..46d131892c 100644 --- a/compose/shared/src/commonMain/kotlin/build/raft/app/thread/ThreadMessageSourceTaskList.kt +++ b/compose/shared/src/commonMain/kotlin/build/raft/app/thread/ThreadMessageSourceTaskList.kt @@ -2,7 +2,9 @@ package build.raft.app import androidx.compose.runtime.Composable import androidx.compose.runtime.key +import androidx.compose.runtime.remember import androidx.compose.ui.Modifier +import build.raft.app.data.ResolvedActor import build.raft.app.model.MemberKind import build.raft.app.resources.* import build.raft.designsystem.components.RaftAvatarSize @@ -68,7 +70,27 @@ private fun ThreadMessageSourceTaskAssignee( memberAvatarResolver: RaftMemberAvatarResolver, agentStatusResolver: RaftAgentStatusResolver, ) { - val name = if (task.assigneeIsViewer) stringResource(Res.string.thread_author_you) else task.assigneeName.orEmpty() + // Web TaskAssignee.tsx (slock #14517): on a joint channel (by the task's own channelType or the + // channel surface), an assignee absent from this server's rosters falls back to actors/resolve. + val onJointChannel = task.isJointChannel || memberAvatarResolver.jointSurface || LocalRaftJointActorSurface.current + val assigneeResolver = + remember(memberAvatarResolver, onJointChannel) { + memberAvatarResolver.forJointSurface(onJointChannel) + } + val jointActor = + rememberRaftJointActor( + memberAvatarResolver = assigneeResolver, + kind = task.assigneeKind, + memberId = task.assigneeId, + enabled = onJointChannel && !task.assigneeIsViewer, + ) + val name = + threadMessageSourceTaskAssigneeName( + assigneeIsViewer = task.assigneeIsViewer, + viewerLabel = stringResource(Res.string.thread_author_you), + assigneeName = task.assigneeName, + jointActor = jointActor, + ) val agentStatus = if (task.assigneeKind == MemberKind.Agent) { rememberRaftAgentStatusIndicatorState(agentStatusResolver, task.assigneeId) @@ -87,11 +109,29 @@ private fun ThreadMessageSourceTaskAssignee( ) { RaftMemberAvatar( identity = RaftMemberAvatarIdentity(task.assigneeKind, task.assigneeId, serverId = null), - label = task.assigneeName.orEmpty(), + label = name, avatarSize = avatarSize, - resolver = memberAvatarResolver, + resolver = assigneeResolver, ) } }, ) } + +/** + * Web `TaskAssignee.tsx` (`slock #14517`): viewer reads "You"; in a joint channel an assignee + * absent from this server's rosters takes the display name `POST /api/actors/resolve` returned + * (falling back to handle, then the task's `claimedByName`). + */ +internal fun threadMessageSourceTaskAssigneeName( + assigneeIsViewer: Boolean, + viewerLabel: String, + assigneeName: String?, + jointActor: ResolvedActor?, +): String { + if (assigneeIsViewer) return viewerLabel + val actorName = + jointActor?.displayName?.trim()?.takeIf { it.isNotEmpty() } + ?: jointActor?.name?.trim()?.takeIf { it.isNotEmpty() } + return actorName ?: assigneeName.orEmpty() +} diff --git a/compose/shared/src/commonMain/kotlin/build/raft/app/thread/ThreadPage.kt b/compose/shared/src/commonMain/kotlin/build/raft/app/thread/ThreadPage.kt index f59b492a7c..985ca97bd1 100644 --- a/compose/shared/src/commonMain/kotlin/build/raft/app/thread/ThreadPage.kt +++ b/compose/shared/src/commonMain/kotlin/build/raft/app/thread/ThreadPage.kt @@ -7345,6 +7345,18 @@ private fun SharedThreadRouteContentContent( remember(currentSession?.servers) { raftViewerServerLogos(currentSession?.servers.orEmpty().map { it.id to it.avatarUrl }) } + val taskConversationJointSurface = + jointMessageSurface || + parseConversationKindOrNull(taskConversationTask?.channelType) == ConversationKind.Joint || + (taskConversationParentChannelId?.value?.let { id -> + currentServerId?.let(::ServerId)?.let { server -> + conversationIdentityProvider?.resolveProjection(server, id)?.conversationKind == ConversationKind.Joint + } + } == true) + val effectiveMessageAvatarResolver = + remember(messageAvatarResolver, taskConversationJointSurface) { + messageAvatarResolver.forJointSurface(taskConversationJointSurface) + } val threadProvidedValues = raftMarkdownProvidedValuesWith( arrayOf( LocalRaftViewerServerLogos provides viewerServerLogos, @@ -7401,9 +7413,10 @@ private fun SharedThreadRouteContentContent( LocalThreadReverseLayout provides threadReverseLayoutEnabled, LocalThreadFeedbackCardEntryEnabled provides feedbackCardEntryEnabled, LocalThreadViewerServerId provides currentServerId, - // A joint channel's conversation: every person's face (hand-off card, task head, typing, - // followers, composer chips) reads the other server's people as its message rows do. - LocalRaftJointActorSurface provides jointMessageSurface, + // A joint channel's conversation (including a task conversation in one, slock #14517): + // every person's face (hand-off card, task head, typing, followers, composer chips) + // reads the other server's people as its message rows do. + LocalRaftJointActorSurface provides taskConversationJointSurface, // The Add Reaction picker keeps its skin tone and frequently used emoji per account. LocalRaftEmojiPickerOwnerKey provides messageBodyOwnerKey, LocalThreadActionCardNames provides actionCardNames, @@ -7907,7 +7920,7 @@ private fun SharedThreadRouteContentContent( onExternalAuthor = onExternalAuthorHint, highlightedMentions = highlightedMentions, agentStatusResolver = agentStatusResolver, - memberAvatarResolver = messageAvatarResolver, + memberAvatarResolver = effectiveMessageAvatarResolver, memberModelLabelResolver = memberModelLabelResolver, diagnosticsLogger = { bridge.log(it) }, onLayoutGeneration = { width, height -> diff --git a/compose/shared/src/commonMain/kotlin/build/raft/app/thread/ThreadRouteGates.kt b/compose/shared/src/commonMain/kotlin/build/raft/app/thread/ThreadRouteGates.kt index 908af0e590..124996d60a 100644 --- a/compose/shared/src/commonMain/kotlin/build/raft/app/thread/ThreadRouteGates.kt +++ b/compose/shared/src/commonMain/kotlin/build/raft/app/thread/ThreadRouteGates.kt @@ -263,23 +263,27 @@ internal fun threadComposerEventRequiresWriteAccess(action: String): Boolean = internal enum class JointBillingNotice { None, Grace, Locked } /** - * The rendered surface is a joint channel, or a reply thread in one: the route's own kinds first, - * then the conversation directory projection of the parent or any lookup id. + * The rendered surface is a joint channel, or a reply thread / task conversation in one: the + * route's own kinds and task channel type first, then the conversation directory projection of + * the parent or any lookup id. */ internal fun threadMessageSurfaceIsJoint( payload: RaftThreadScreenPayload, lookupIds: List, - projections: Map + projections: Map, + taskChannelType: String? = null, + taskParentChannelId: String? = null, ): Boolean { if (payload.surfaceKind == RaftThreadSurfaceKind.DirectMessage) return false if (parseConversationKindOrNull(payload.channelKind) == ConversationKind.Joint) return true + if (parseConversationKindOrNull(taskChannelType) == ConversationKind.Joint) return true if ( payload.surfaceKind == RaftThreadSurfaceKind.ReplyThread && typedReplyParentConversationKindOrNull(payload.parentSurfaceKind, payload.parentChannelKind) == ConversationKind.Joint ) { return true } - return (listOfNotNull(payload.parentChannelId) + lookupIds).any { id -> + return (listOfNotNull(payload.parentChannelId, taskParentChannelId) + lookupIds).any { id -> projections[id]?.conversationKind == ConversationKind.Joint } } diff --git a/compose/shared/src/commonTest/kotlin/build/raft/app/JointBillingNoticeTest.kt b/compose/shared/src/commonTest/kotlin/build/raft/app/JointBillingNoticeTest.kt index 123aaf0e16..78f5feb07c 100644 --- a/compose/shared/src/commonTest/kotlin/build/raft/app/JointBillingNoticeTest.kt +++ b/compose/shared/src/commonTest/kotlin/build/raft/app/JointBillingNoticeTest.kt @@ -189,5 +189,34 @@ class JointBillingNoticeTest { ) assertEquals(false, joint(RaftThreadScreenPayload(surfaceKind = RaftThreadSurfaceKind.Channel), listOf("chan-1"))) assertEquals(false, joint(RaftThreadScreenPayload(surfaceKind = RaftThreadSurfaceKind.DirectMessage), listOf("joint-1"))) + // Task conversation whose parent channel is a joint channel (by task channelType or parent projection). + assertEquals( + true, + threadMessageSurfaceIsJoint( + RaftThreadScreenPayload(surfaceKind = RaftThreadSurfaceKind.Channel, channelKind = "task"), + emptyList(), + emptyMap(), + taskChannelType = "joint", + ), + ) + assertEquals( + true, + threadMessageSurfaceIsJoint( + RaftThreadScreenPayload(surfaceKind = RaftThreadSurfaceKind.Channel, channelKind = "task"), + emptyList(), + projections, + taskParentChannelId = "joint-1", + ), + ) + assertEquals( + false, + threadMessageSurfaceIsJoint( + RaftThreadScreenPayload(surfaceKind = RaftThreadSurfaceKind.Channel, channelKind = "task"), + emptyList(), + projections, + taskChannelType = "channel", + taskParentChannelId = "chan-1", + ), + ) } } diff --git a/compose/shared/src/commonTest/kotlin/build/raft/app/ThreadMessageSourceTasksTest.kt b/compose/shared/src/commonTest/kotlin/build/raft/app/ThreadMessageSourceTasksTest.kt index fe8cb5d834..56c0954372 100644 --- a/compose/shared/src/commonTest/kotlin/build/raft/app/ThreadMessageSourceTasksTest.kt +++ b/compose/shared/src/commonTest/kotlin/build/raft/app/ThreadMessageSourceTasksTest.kt @@ -1,6 +1,7 @@ package build.raft.app import build.raft.app.data.DataResult +import build.raft.app.data.ResolvedActor import build.raft.app.data.SharedTaskFactFoldOutcome import build.raft.app.data.SharedTasksDataStore import build.raft.app.data.SharedTasksScope @@ -135,6 +136,75 @@ class ThreadMessageSourceTasksTest { ) } + @Test + fun jointChannelTaskCarriesJointFlagAndPrefersResolvedActorDisplayName() { + val jointRow = + parsed( + taskJson( + id = "t-joint", + number = 15, + source = "msg-a", + channelType = "joint", + claimedType = "agent", + claimedId = "00000000-0000-4000-8000-0000000000a1", + claimedName = "remote-agent", + ) + ).toThreadMessageSourceTaskItem(viewerUserId = "user-1") + assertTrue(jointRow.isJointChannel) + + val plainRow = + parsed( + taskJson( + id = "t-plain", + number = 16, + source = "msg-a", + channelType = "channel", + claimedType = "agent", + claimedId = "00000000-0000-4000-8000-0000000000a2", + claimedName = "remote-agent", + ) + ).toThreadMessageSourceTaskItem(viewerUserId = "user-1") + assertEquals(false, plainRow.isJointChannel) + + val actor = + ResolvedActor( + kind = MemberKind.Agent, + id = "00000000-0000-4000-8000-0000000000a1", + homeServerId = "server-2", + name = "remote-agent", + displayName = "Remote Agent", + avatarUrl = "https://example.test/remote-agent.png", + gravatarHash = null, + ) + assertEquals( + "Remote Agent", + threadMessageSourceTaskAssigneeName( + assigneeIsViewer = false, + viewerLabel = "You", + assigneeName = "remote-agent", + jointActor = actor, + ), + ) + assertEquals( + "remote-agent", + threadMessageSourceTaskAssigneeName( + assigneeIsViewer = false, + viewerLabel = "You", + assigneeName = "remote-agent", + jointActor = null, + ), + ) + assertEquals( + "You", + threadMessageSourceTaskAssigneeName( + assigneeIsViewer = true, + viewerLabel = "You", + assigneeName = "me", + jointActor = actor, + ), + ) + } + private fun parsed(json: String): TaskSummary = parseSharedServerTasksPayload("""{"tasks":[$json]}""")?.tasks?.single() ?: error("task dropped: $json") @@ -153,11 +223,12 @@ class ThreadMessageSourceTasksTest { revision: Long = 3, legacy: Boolean = false, reportSource: Boolean = true, + channelType: String = "channel", ): String = """ {"id":"$id","messageId":"${host ?: id}","hostMessageId":${host.json()},${if (reportSource) "\"sourceMessageId\":${source.json()}," else ""} "conversationReplyCount":$replies,"conversationChannelId":${conversation.json()},"conversationAnchored":$anchored, - "channelId":"channel-1","channelName":"general","channelType":"channel","taskNumber":$number, + "channelId":"channel-1","channelName":"general","channelType":"$channelType","taskNumber":$number, "title":"Task $number","description":null,"status":"$status", "createdByType":"user","createdById":"user-1","createdByName":"artin","createdByHandle":"artin", "createdByMembershipStatus":"active","claimedByType":${claimedType.json()},"claimedById":${claimedId.json()}, From c0229586b0761d791e5d8917341dc891d923ca36 Mon Sep 17 00:00:00 2001 From: Reef Date: Fri, 20 Nov 2026 06:56:18 +0000 Subject: [PATCH 2/2] chore(changelog): set pull_request 5132 in joint-task-assignee changeset --- .../1.28.0/changesets/joint-task-assignee-actor-avatar.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/change-logs/1.28.0/changesets/joint-task-assignee-actor-avatar.md b/change-logs/1.28.0/changesets/joint-task-assignee-actor-avatar.md index a74a5f8244..5bf2e9263d 100644 --- a/change-logs/1.28.0/changesets/joint-task-assignee-actor-avatar.md +++ b/change-logs/1.28.0/changesets/joint-task-assignee-actor-avatar.md @@ -5,7 +5,7 @@ platforms: - android - ios - desktop -pull_request: null +pull_request: 5132 rollout: full ---