Skip to content
Merged
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
type: fixed
area: thread
platforms:
- android
- ios
- desktop
pull_request: 5168
rollout: full
---

## zh-CN

进入会话时,最新一条消息的最后一行不再被输入框上方的「N 个 Agent 正在这里工作」提示盖住;这条提示出现或消失时,消息也不再跟着移动。

## en

Entering a conversation no longer leaves the last line of the newest message under the "N agents working here" line above the composer, and that line appearing or disappearing no longer moves the messages.

## ja

会話を開いたとき、最新メッセージの最後の行が入力欄の上の「エージェント N 個がここで作業中」の行に隠れなくなりました。また、この行が表示されたり消えたりしても、メッセージは動きません。

Large diffs are not rendered by default.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,18 @@ private val NoChannelWorkingLineKinds =

internal val LocalThreadAgentTyping = compositionLocalOf<ThreadAgentTypingUi?> { null }

/**
* Whether this conversation can ever show the typing / working line: only where it has a composer
* to sit on (web renders the line with the composer only). Not for a channel previewed without
* joining (the join footer) or an archived one (the archived banner).
*
* The one condition for the line itself ([rememberThreadAgentTyping]) and for its slot at the
* list's end ([ThreadTimelineSlice.agentTypingLineSlot]): a line without its slot would cover the
* newest message. Read from the conversation's own flags only, never from access resolution,
* write authority or agent activity, which change while a conversation is open.
*/
internal fun RaftThreadScreenPayload.agentTypingLineCanShow(): Boolean = showComposer && joined && !channelArchived

/**
* The conversation an `agent:typing` names for this page: a reply thread is its parent channel and
* root message (web ThreadPanel `typingChannelId` + `parentMessageId`); a channel or DM is itself.
Expand Down Expand Up @@ -277,7 +289,7 @@ internal fun rememberThreadAgentTyping(
} else {
null
}
if (server == null || (agentIds.isEmpty() && working.isEmpty()) || !payload.showComposer) return null
if (server == null || (agentIds.isEmpty() && working.isEmpty()) || !payload.agentTypingLineCanShow()) return null
val membersState = serverMembersStore?.state?.collectAsState()?.value
val serverMembers =
remember(membersState, server) { serverMembersStore?.currentServerMembers(ServerId(server)).orEmpty() }
Expand All @@ -295,7 +307,12 @@ internal fun rememberThreadAgentTyping(
/** web `h-6`: the line's row. */
internal val ThreadAgentTypingLineHeight = 24.dp

/** web `AgentTypingListEnd` `h-7.5`: the list's extra end while the line shows. */
/**
* web `AgentTypingListEnd` `h-7.5`: the line's slot at the list's end. Part of the list's end
* ([threadBottomSpacerAndAnchorTrailingHeight]) in every conversation that can show the line
* ([agentTypingLineCanShow]), not only while the line shows, so the line coming or going moves no
* message.
*/
internal val ThreadAgentTypingListEndHeight = 30.dp

private const val ThreadAgentTypingMaxFaces = 3
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -607,10 +607,14 @@ private fun ThreadMessagesListContent(
bottomPaddingItemIndex = latestItemIndex
)
val threadDensity = LocalDensity.current
// Resolved once per composition, for the spacer row's height and for the scroll owners' trailing
// padding below: both read this value, never the conversation's flags themselves.
val bottomSpacerAndAnchorTrailingHeight =
threadBottomSpacerAndAnchorTrailingHeight(typingLineSlot = renderPayload.agentTypingLineSlot)
val initialBottomAnchorTrailingPaddingPx =
if (latestMessageListItemIndex >= 0) {
with(threadDensity) {
ThreadBottomScrollPaddingHeight.roundToPx()
bottomSpacerAndAnchorTrailingHeight.roundToPx()
}
} else {
0
Expand Down Expand Up @@ -4447,10 +4451,12 @@ private fun ThreadMessagesListContent(
modifier = Modifier
.fillMaxWidth()
.height(
ThreadBottomScrollPaddingHeight +
// The line floats over the list's end: give the end its height, so at
// the bottom it never covers the last message (web AgentTypingListEnd).
(if (agentTyping != null) ThreadAgentTypingListEndHeight else 0.dp) +
// The full end, the typing line's slot included where this
// conversation can show the line, whether or not the line shows: the
// row never changes height when the line comes or goes, so nothing
// moves and the reading anchor has nothing to put back. The scroll
// owners read the same value.
bottomSpacerAndAnchorTrailingHeight +
(if (shareSelectionCaptureTailPaddingActive) {
ThreadShareCaptureBottomScrollPaddingHeight
} else {
Expand Down Expand Up @@ -5322,7 +5328,21 @@ private const val ThreadNewerMessagesListItemKey = "thread-page:newer-messages"
private const val ThreadReplyEmptyListItemKey = "thread-page:reply-empty"
private const val ThreadReplyLoadingListItemKey = "thread-page:reply-loading"
private const val ThreadBottomScrollPaddingListItemKey = "thread-page:bottom-scroll-padding"
private val ThreadBottomScrollPaddingHeight = 16.dp
/**
* The blank end of the list under the newest message: the list's own 16dp end and, in a
* conversation that can show the typing / working line ([typingLineSlot],
* [ThreadTimelineSlice.agentTypingLineSlot]), the slot the line floats over
* ([ThreadAgentTypingListEndHeight]). The slot is there whether or not the line shows; it follows
* the conversation, never agent activity.
*
* The one source for both sides of "the newest message at the bottom": the height of the list's
* last (spacer) row, and the trailing padding every scroll owner uses for it
* (`initialBottomAnchorTrailingPaddingPx`: the initial-anchor check, the focused-tail fit, the
* RenderedBottom anchor). They must stay the same number: a spacer taller than the anchors' padding
* parks the newest message under the line (Android 1.27.0, #proj-mobile #227).
*/
internal fun threadBottomSpacerAndAnchorTrailingHeight(typingLineSlot: Boolean): androidx.compose.ui.unit.Dp =
if (typingLineSlot) 16.dp + ThreadAgentTypingListEndHeight else 16.dp
private val ThreadShareCaptureBottomScrollPaddingHeight = 1200.dp
/** The list's top inset for the find bar until the bar is measured (its usual height). */
private val ThreadInlineSearchBarTopInset = 58.dp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,10 +138,11 @@ internal fun BoxWithConstraintsScope.ThreadMessagesListOverlays(
// Kuikly-era rule kept: the native dispatch capture sits on the pills' ancestor path so
// a tap on a pill never also starts a gesture on the message row underneath.
RaftMessageListJumpControls(
// While the typing line shows, the pills sit above it, not over it (web
// `--message-list-bottom-inset`).
// The pills sit above the typing line's slot (web `--message-list-bottom-inset`)
// where the conversation has one, whether or not the line shows: like the list's
// end, they do not move when it comes or goes.
modifier = Modifier.align(Alignment.BottomCenter)
.padding(bottom = if (agentTypingLineShown) ThreadAgentTypingLineHeight else 0.dp)
.padding(bottom = if (renderPayload.agentTypingLineSlot) ThreadAgentTypingLineHeight else 0.dp)
.zIndex(ThreadJumpControlsZIndex).raftNativeDispatchCapture(),
) {
// Web BottomJumpControls: first on the controls' line (nearest the edge when stacked).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,12 @@ internal data class ThreadTimelineSlice(
val originHiddenTarget: build.raft.app.data.MessageContextHiddenTarget? = null,
/** [RaftThreadScreenPayload.historyStartFocusRequest]: a new value scrolls the list to its history start. */
val historyStartFocusRequest: Int = 0,
/**
* [RaftThreadScreenPayload.agentTypingLineCanShow]: the list's end holds the typing / working
* line's slot (`threadBottomSpacerAndAnchorTrailingHeight`). A property of the conversation,
* not of agent activity.
*/
val agentTypingLineSlot: Boolean = true,
) {
/** Derived from [surfaceKind] and [channelKind]; the menu's `reply` capability reads this single source. */
val showReplyActions: Boolean get() = RaftThreadSurfaceKind.allowsReplyInThread(surfaceKind, channelKind)
Expand Down Expand Up @@ -136,7 +142,8 @@ internal fun RaftThreadScreenPayload.toThreadTimelineSlice(): ThreadTimelineSlic
historyChannelId = (streamChannelId ?: sourceThreadId)?.trim()?.takeIf { it.isNotEmpty() },
joined = joined,
originHiddenTarget = threadOriginHiddenTargetOrNull(),
historyStartFocusRequest = historyStartFocusRequest
historyStartFocusRequest = historyStartFocusRequest,
agentTypingLineSlot = agentTypingLineCanShow()
)

internal fun RaftThreadMessageItem.toThreadReplyMetadata(): ThreadReplyMetadata =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,28 @@ class ThreadAgentTypingTest {
)
}

@Test fun theLineAndItsSlotAtTheListEndGoWithTheComposerOnly() {
val channel = RaftThreadScreenPayload(surfaceKind = RaftThreadSurfaceKind.Channel, sourceThreadId = "ch-1")
val cases =
listOf(
channel to true,
// Previewed without joining: the join footer.
channel.copy(joined = false) to false,
// Archived: the archived banner.
channel.copy(channelArchived = true) to false,
channel.copy(showComposer = false) to false,
// A composer that cannot send yet is still a composer.
channel.copy(canSend = false) to true,
)
cases.forEach { (payload, expected) ->
assertEquals(expected, payload.agentTypingLineCanShow(), "$payload")
// The list's end follows the same answer: the slot is there exactly where the line can be.
assertEquals(expected, payload.toThreadTimelineSlice().agentTypingLineSlot, "$payload")
}
assertEquals(46f, threadBottomSpacerAndAnchorTrailingHeight(typingLineSlot = true).value)
assertEquals(16f, threadBottomSpacerAndAnchorTrailingHeight(typingLineSlot = false).value)
}

@Test fun onlyAgentsAreNamedAndUnknownIdsUseTheFallback() {
val serverMembers =
listOf(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,11 @@ import kotlin.test.assertTrue
* Hands e0a5248d ("进channel 好闪烁,它弹来弹去的", Huawei CMU-AL10, 1.15.0): opening a channel or DM
* cold showed the content, then moved it up and down by the offline stand-in's 40dp top inset
* several times before it settled. The numbers below are the ones the feedback log recorded
* (density 3.375): a reversed list 1941px tall with a 135px top inset, the 54px bottom padding row
* and a 2118px newest message.
* (density 3.375): a reversed list 1941px tall with a 135px top inset, the bottom padding row
* and a 2118px newest message. The padding row was 54px (16dp) then; it is the production
* [threadBottomSpacerAndAnchorTrailingHeight] here, the one height the list's last row and the
* scroll owners' trailing padding share (it holds the typing line's slot whether or not the line
* shows, so a line already showing at open changes none of this).
*
* The page's scroll owners are modelled frame by frame under virtual time against a fake reversed
* raw list read through the production [ReversedThreadLayoutInfo]; the targets and the "anchored"
Expand Down Expand Up @@ -133,7 +136,7 @@ class ThreadChannelOpenSettleTest {
fun aDisplacedListIsAnchoredInOneCommandUnderTheInset() {
// The feedback log's displaced state: raw scrolled 135px, newest row 135px below the composer.
val list = FakeReversedList(topInsetPx = TopInsetPx, layoutPx = LayoutWithComposerPx)
list.scrollToItem(NewestForwardIndex, scrollOffset = 366 - TopInsetPx)
list.scrollToItem(NewestForwardIndex, scrollOffset = NewestRowPx + PaddingRowPx - LayoutWithComposerPx)
assertEquals(TopInsetPx, list.info().newestRowGapToRenderedBottom())
assertFalse(threadItemAtRenderedBottom(list.info(), NewestForwardIndex, PaddingRowPx))

Expand Down Expand Up @@ -284,7 +287,10 @@ class ThreadChannelOpenSettleTest {
private companion object {
const val TopInsetPx = 135
const val LayoutWithComposerPx = 1941
const val PaddingRowPx = 54
const val Density = 3.375f

/** The list's last row, and the trailing padding the owners anchor the newest message with. */
val PaddingRowPx = (threadBottomSpacerAndAnchorTrailingHeight(typingLineSlot = true).value * Density).toInt()
const val NewestRowPx = 2118
const val OlderRowPx = 525

Expand Down
Loading