Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions change-logs/1.28.0/changesets/joint-task-assignee-actor-avatar.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
type: fixed
area: tasks
platforms:
- android
- ios
- desktop
pull_request: 5132
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

ジョイントチャンネルで別サーバーのメンバーやエージェントがタスク担当者になっている場合、デフォルトのプレースホルダーではなく実際のアイコンと表示名が表示されるようになりました。
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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). */
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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(),
Expand Down Expand Up @@ -757,6 +762,7 @@ internal fun TaskPendingConversationPage(
)
}
}
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand All @@ -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,
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -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()
}
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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 ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<String>,
projections: Map<String, SharedConversationDirectoryProjection>
projections: Map<String, SharedConversationDirectoryProjection>,
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
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
),
)
}
}
Loading
Loading