π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
fix position of rive
Prateek Sunal822138a5c999
diff --git a/mobile/native/android/apps/ensu/app-ui/src/main/java/io/ente/ensu/chat/ChatMessages.kt b/mobile/native/android/apps/ensu/app-ui/src/main/java/io/ente/ensu/chat/ChatMessages.ktindex c80eb9837f..ea39625ad6 100644--- a/mobile/native/android/apps/ensu/app-ui/src/main/java/io/ente/ensu/chat/ChatMessages.kt+++ b/mobile/native/android/apps/ensu/app-ui/src/main/java/io/ente/ensu/chat/ChatMessages.kt@@ -24,6 +24,7 @@ import androidx.compose.foundation.layout.fillMaxSizeimport androidx.compose.foundation.layout.fillMaxWidthimport androidx.compose.foundation.layout.heightimport androidx.compose.foundation.layout.padding+import androidx.compose.foundation.layout.offsetimport androidx.compose.foundation.layout.sizeimport androidx.compose.foundation.layout.widthimport androidx.compose.foundation.layout.wrapContentSize@@ -48,6 +49,7 @@ import androidx.compose.runtime.snapshotFlowimport androidx.compose.ui.Alignmentimport androidx.compose.ui.Modifierimport androidx.compose.ui.draw.clipToBounds+import androidx.compose.ui.geometry.Offsetimport androidx.compose.ui.graphics.Colorimport androidx.compose.ui.hapticfeedback.HapticFeedbackType@@ -60,6 +62,7 @@ import androidx.compose.ui.unit.dpimport androidx.compose.ui.window.Popupimport androidx.compose.ui.window.PopupPropertiesimport io.ente.ensu.components.BranchSwitcher+import app.rive.runtime.kotlin.core.Alignment as RiveAlignmentimport io.ente.ensu.components.ensuRiveAnimationimport io.ente.ensu.designsystem.EnsuColorimport io.ente.ensu.designsystem.EnsuCornerRadius@@ -130,7 +133,6 @@ internal fun MessageList(var lastViewportHeight by remember { mutableStateOf(0) }var lastUserMessageId by remember { mutableStateOf<String?>(null) }var keepStreamingVisible by remember { mutableStateOf(false) }- var lastStreamingParentForOutro by remember { mutableStateOf<String?>(null) }val isAtBottom by remember {derivedStateOf {!listState.canScrollForward@@ -138,7 +140,10 @@ internal fun MessageList(}val streamingOutroDurationMs = 520L- val streamingCollapseDurationMs = 300+ val outroAssistantId = if (!isGenerating && keepStreamingVisible) {+ messages.lastOrNull { it.author == MessageAuthor.Assistant }?.id+ } else null+ val streamingAnchorId = if (isGenerating) streamingParentId else nullval lastMessage = messages.lastOrNull()LaunchedEffect(isGenerating, lastMessage?.id) {@@ -155,11 +160,9 @@ internal fun MessageList(LaunchedEffect(isGenerating, streamingParentId) {if (isGenerating) {keepStreamingVisible = true- lastStreamingParentForOutro = streamingParentId} else if (keepStreamingVisible) {delay(streamingOutroDurationMs)keepStreamingVisible = false- lastStreamingParentForOutro = null}}@@ -242,11 +245,8 @@ internal fun MessageList(),verticalArrangement = Arrangement.spacedBy(EnsuSpacing.lg.dp)) {- items(messages, key = { it.id }) { message ->- Column(- modifier = Modifier- .fillMaxWidth()- ) {+ messages.forEach { message ->+ item(key = message.id) {when (message.author) {MessageAuthor.User -> {UserMessageBubble(@@ -262,44 +262,29 @@ internal fun MessageList(message = message,branchSelections = branchSelections,onRetry = { onRetryMessage(message) },- onBranchChange = onBranchChange+ onBranchChange = onBranchChange,+ showsMetadata = outroAssistantId != message.id,+ showOutroRive = outroAssistantId == message.id)}}+ }- AnimatedVisibility(- visible =- (isGenerating && streamingParentId == message.id) ||- (!isGenerating && keepStreamingVisible && lastStreamingParentForOutro == message.id),- enter = fadeIn(animationSpec = tween(durationMillis = 140)) +- scaleIn(initialScale = 0.94f, animationSpec = tween(durationMillis = 180)),- exit = fadeOut(animationSpec = tween(durationMillis = streamingCollapseDurationMs)) +- shrinkVertically(animationSpec = tween(durationMillis = streamingCollapseDurationMs))- ) {- Column {- Spacer(modifier = Modifier.height(EnsuSpacing.sm.dp))- StreamingMessageBubble(- text = streamingResponse,- isGenerating = isGenerating- )- }+ if (isGenerating && streamingAnchorId == message.id) {+ item(key = "streaming") {+ StreamingMessageBubble(+ text = streamingResponse,+ isGenerating = true+ )}}}- item(key = "streaming") {- AnimatedVisibility(- visible =- (isGenerating && streamingParentId == null) ||- (!isGenerating && keepStreamingVisible && lastStreamingParentForOutro == null),- enter = fadeIn(animationSpec = tween(durationMillis = 140)) +- scaleIn(initialScale = 0.94f, animationSpec = tween(durationMillis = 180)),- exit = fadeOut(animationSpec = tween(durationMillis = streamingCollapseDurationMs)) +- shrinkVertically(animationSpec = tween(durationMillis = streamingCollapseDurationMs))- ) {+ if (isGenerating && streamingAnchorId == null) {+ item(key = "streaming") {StreamingMessageBubble(text = streamingResponse,- isGenerating = isGenerating+ isGenerating = true)}}@@ -533,7 +518,9 @@ private fun AssistantMessageBubble(message: ChatMessage,branchSelections: Map<String, Int>,onRetry: () -> Unit,- onBranchChange: (String, Int) -> Unit+ onBranchChange: (String, Int) -> Unit,+ showsMetadata: Boolean,+ showOutroRive: Boolean) {val clipboard = LocalClipboardManager.currentval haptic = rememberEnsuHaptics()@@ -546,6 +533,7 @@ private fun AssistantMessageBubble(Box {Column(modifier = Modifier+ .fillMaxWidth().pointerInput(Unit) {detectTapGestures(onLongPress = { offset ->@@ -586,23 +574,50 @@ private fun AssistantMessageBubble()}- Spacer(modifier = Modifier.height(EnsuSpacing.sm.dp))+ if (showOutroRive) {+ Box(+ modifier = Modifier+ .padding(horizontal = EnsuSpacing.sm.dp)+ .width(115.dp)+ .height(52.5.dp),+ contentAlignment = Alignment.TopStart+ ) {+ ensuRiveAnimation(+ modifier = Modifier+ .fillMaxSize()+ .offset(y = (-4).dp),+ alignment = RiveAlignment.TOP_LEFT,+ outroTrigger = true,+ outroInputName = "outro",+ clipContent = false+ )+ }+ }- Row(horizontalArrangement = Arrangement.spacedBy(EnsuSpacing.sm.dp), verticalAlignment = Alignment.CenterVertically) {- TimestampText(message.timestampMillis)- if (message.branchCount > 1) {- BranchSwitcher(- currentIndex = branchSelections[message.id] ?: 1,- totalCount = message.branchCount,- onPrevious = {- val current = branchSelections[message.id] ?: 1- onBranchChange(message.id, (current - 1).coerceAtLeast(1))- },- onNext = {- val current = branchSelections[message.id] ?: 1- onBranchChange(message.id, (current + 1).coerceAtMost(message.branchCount))+ AnimatedVisibility(+ visible = showsMetadata,+ enter = fadeIn(animationSpec = tween(durationMillis = 300)),+ exit = fadeOut(animationSpec = tween(durationMillis = 150))+ ) {+ Column {+ Spacer(modifier = Modifier.height(EnsuSpacing.sm.dp))+ Row(horizontalArrangement = Arrangement.spacedBy(EnsuSpacing.sm.dp), verticalAlignment = Alignment.CenterVertically) {+ TimestampText(message.timestampMillis)+ if (message.branchCount > 1) {+ BranchSwitcher(+ currentIndex = branchSelections[message.id] ?: 1,+ totalCount = message.branchCount,+ onPrevious = {+ val current = branchSelections[message.id] ?: 1+ onBranchChange(message.id, (current - 1).coerceAtLeast(1))+ },+ onNext = {+ val current = branchSelections[message.id] ?: 1+ onBranchChange(message.id, (current + 1).coerceAtMost(message.branchCount))+ }+ )}- )+ }}}}@@ -675,8 +690,9 @@ private fun StreamingMessageBubble(text: String,isGenerating: Boolean) {+ var renderedText by remember { mutableStateOf(text) }var showCursor by remember { mutableStateOf(true) }- val shouldBlink = text.isNotBlank()+ val shouldBlink = isGenerating && renderedText.isNotBlank()LaunchedEffect(shouldBlink) {if (!shouldBlink) {@@ -689,11 +705,13 @@ private fun StreamingMessageBubble(}}- var renderedText by remember { mutableStateOf(text) }-- LaunchedEffect(text) {+ LaunchedEffect(text, isGenerating) {+ if (!isGenerating) {+ renderedText = ""+ return@LaunchedEffect+ }if (text.isBlank()) {- renderedText = text+ renderedText = ""return@LaunchedEffect}// Throttle markdown re-rendering while streaming to reduce dropped frames.@@ -705,9 +723,17 @@ private fun StreamingMessageBubble(val riveHeight = 52.5.dpColumn(- modifier = Modifier.fillMaxWidth(),+ modifier = Modifier+ .fillMaxWidth()+ .padding(horizontal = EnsuSpacing.sm.dp)+ .padding(vertical = EnsuSpacing.md.dp),horizontalAlignment = Alignment.Start) {+ if (isGenerating && renderedText.isNotBlank()) {+ MarkdownView(markdown = renderedText, enableSelection = false, trailingCursor = showCursor)+ Spacer(modifier = Modifier.height(EnsuSpacing.xs.dp))+ }+Box(modifier = Modifier.width(riveWidth)@@ -715,16 +741,17 @@ private fun StreamingMessageBubble(.clipToBounds(),contentAlignment = Alignment.CenterStart) {- ensuRiveAnimation(- modifier = Modifier.fillMaxSize(),- outroTrigger = !isGenerating,- outroInputName = "outro"- )- }-- if (renderedText.isNotBlank()) {- Spacer(modifier = Modifier.height(EnsuSpacing.xs.dp))- MarkdownView(markdown = renderedText, enableSelection = false, trailingCursor = showCursor)+ Box(+ modifier = Modifier+ .fillMaxSize()+ .clipToBounds()+ ) {+ ensuRiveAnimation(+ modifier = Modifier.fillMaxSize(),+ outroTrigger = !isGenerating,+ outroInputName = "outro"+ )+ }}}}diff --git a/mobile/native/android/apps/ensu/app-ui/src/main/java/io/ente/ensu/components/EnsuRiveAnimation.kt b/mobile/native/android/apps/ensu/app-ui/src/main/java/io/ente/ensu/components/EnsuRiveAnimation.ktindex ac0e1c99e9..d17c9195e6 100644--- a/mobile/native/android/apps/ensu/app-ui/src/main/java/io/ente/ensu/components/EnsuRiveAnimation.kt+++ b/mobile/native/android/apps/ensu/app-ui/src/main/java/io/ente/ensu/components/EnsuRiveAnimation.kt@@ -2,12 +2,15 @@package io.ente.ensu.components+import android.graphics.Rect+import android.view.ViewGroupimport androidx.compose.runtime.Composableimport androidx.compose.runtime.getValueimport androidx.compose.runtime.mutableStateOfimport androidx.compose.runtime.rememberimport androidx.compose.runtime.setValueimport androidx.compose.ui.Modifier+import androidx.compose.ui.draw.clipToBoundsimport androidx.compose.ui.platform.LocalContextimport androidx.compose.ui.viewinterop.AndroidViewimport app.rive.runtime.kotlin.RiveAnimationView@@ -26,13 +29,18 @@ fun ensuRiveAnimation(autoplay: Boolean = true,outroTrigger: Boolean = false,outroInputName: String = "outro",- outroStateMachineName: String? = null+ outroStateMachineName: String? = null,+ clipContent: Boolean = true) {val context = LocalContext.currentval appContext = context.applicationContext- val riveView = remember(context, fit, alignment, loop, autoplay) {+ val riveView = remember(context, fit, alignment, loop, autoplay, clipContent) {Rive.init(appContext)RiveAnimationView(context).apply {+ layoutParams = ViewGroup.LayoutParams(+ ViewGroup.LayoutParams.MATCH_PARENT,+ ViewGroup.LayoutParams.MATCH_PARENT+ )setRiveResource(resId = R.raw.ensu,autoplay = autoplay,@@ -40,14 +48,32 @@ fun ensuRiveAnimation(alignment = alignment,loop = loop)+ addOnLayoutChangeListener { view, left, top, right, bottom, _, _, _, _ ->+ if (clipContent) {+ val width = (right - left).coerceAtLeast(0)+ val height = (bottom - top).coerceAtLeast(0)+ view.clipBounds = Rect(0, 0, width, height)+ } else {+ view.clipBounds = null+ }+ }}}var lastOutroTrigger by remember { mutableStateOf(false) }AndroidView(- modifier = modifier,+ modifier = if (clipContent) modifier.clipToBounds() else modifier,factory = { riveView },update = { view ->+ view.layoutParams = ViewGroup.LayoutParams(+ ViewGroup.LayoutParams.MATCH_PARENT,+ ViewGroup.LayoutParams.MATCH_PARENT+ )+ if (clipContent && view.width > 0 && view.height > 0) {+ view.clipBounds = Rect(0, 0, view.width, view.height)+ } else if (!clipContent) {+ view.clipBounds = null+ }if (outroTrigger && !lastOutroTrigger) {val stateMachineName = outroStateMachineName ?: view.stateMachines.firstOrNull()?.nameif (stateMachineName != null) {diff --git a/mobile/native/android/apps/ensu/domain/src/main/kotlin/io/ente/ensu/domain/store/ChatStoreActions.kt b/mobile/native/android/apps/ensu/domain/src/main/kotlin/io/ente/ensu/domain/store/ChatStoreActions.ktindex d362b6b71f..5405e6490e 100644--- a/mobile/native/android/apps/ensu/domain/src/main/kotlin/io/ente/ensu/domain/store/ChatStoreActions.kt+++ b/mobile/native/android/apps/ensu/domain/src/main/kotlin/io/ente/ensu/domain/store/ChatStoreActions.kt@@ -632,6 +632,7 @@ internal class ChatStoreActions(if (shouldUpdateUi) {streamingParentId = null+ val (displayMessages, branchSelectionIndices) = buildDisplayMessagesAndSelections(sessionId)state.update { appState ->appState.copy(chat = appState.chat.copy(@@ -640,11 +641,12 @@ internal class ChatStoreActions(streamingResponse = "",streamingParentId = null,downloadPercent = null,- downloadStatus = null+ downloadStatus = null,+ messages = displayMessages,+ branchSelections = branchSelectionIndices))}- rebuildChatState(sessionId)syncActions.syncAfterGeneration()}scheduleSessionSummary(sessionId)@@ -851,12 +853,22 @@ internal class ChatStoreActions(}private fun rebuildChatState(sessionId: String?) {+ val (displayMessages, branchSelectionIndices) = buildDisplayMessagesAndSelections(sessionId)+ state.update { appState ->+ appState.copy(+ chat = appState.chat.copy(+ messages = displayMessages,+ branchSelections = branchSelectionIndices+ )+ )+ }+ }++ private fun buildDisplayMessagesAndSelections(sessionId: String?): Pair<List<ChatMessage>, Map<String, Int>> {if (sessionId == null) {- state.update { appState ->- appState.copy(chat = appState.chat.copy(messages = emptyList(), branchSelections = emptyMap()))- }- return+ return emptyList<ChatMessage>() to emptyMap()}+val messages = messageStore[sessionId].orEmpty()val path = buildSelectedPath(sessionId)val childrenMap = buildChildrenMap(messages)@@ -875,14 +887,7 @@ internal class ChatStoreActions(message.copy(branchCount = max(1, siblings.size))}- state.update { appState ->- appState.copy(- chat = appState.chat.copy(- messages = displayMessages,- branchSelections = branchSelectionIndices- )- )- }+ return displayMessages to branchSelectionIndices}private fun buildSelectedPath(sessionId: String): List<ChatMessage> {diff --git a/mobile/native/darwin/Apps/ensu/ensu/Chat/MessageList/MessageListComponents.swift b/mobile/native/darwin/Apps/ensu/ensu/Chat/MessageList/MessageListComponents.swiftindex 6b6a1e653c..5d4005c6ff 100644--- a/mobile/native/darwin/Apps/ensu/ensu/Chat/MessageList/MessageListComponents.swift+++ b/mobile/native/darwin/Apps/ensu/ensu/Chat/MessageList/MessageListComponents.swift@@ -165,10 +165,12 @@ struct AssistantMessageBubbleView: View {let onRetry: () -> Voidlet onBranchChange: (Int) -> Voidlet onOpenAttachment: (ChatAttachment) -> Void+ let showsMetadata: Bool+ let showOutroRive: Boolvar body: some View {HStack(alignment: .bottom) {- VStack(alignment: .leading, spacing: EnsuSpacing.sm) {+ VStack(alignment: .leading, spacing: 0) {VStack(alignment: .leading, spacing: EnsuSpacing.sm) {AssistantMessageRenderer(text: message.text, isStreaming: false, storageId: message.id.uuidString)@@ -194,20 +196,37 @@ struct AssistantMessageBubbleView: View {}#endif- HStack(spacing: EnsuSpacing.sm) {- TimestampView(date: message.timestamp)- if message.branchCount > 1 {- BranchSwitcherView(- currentIndex: message.branchIndex,- totalCount: message.branchCount,- onPrevious: { onBranchChange(-1) },- onNext: { onBranchChange(1) }- )+ if showOutroRive {+ EnsuBrandIllustration(+ width: 115,+ height: 52.5,+ outroTrigger: true,+ outroInputName: "outro",+ clipsContent: false+ )+ .padding(.horizontal, EnsuSpacing.sm)+ .offset(y: -4)+ .frame(width: 115, height: 52.5, alignment: .topLeading)+ }++ if showsMetadata {+ HStack(spacing: EnsuSpacing.sm) {+ TimestampView(date: message.timestamp)+ if message.branchCount > 1 {+ BranchSwitcherView(+ currentIndex: message.branchIndex,+ totalCount: message.branchCount,+ onPrevious: { onBranchChange(-1) },+ onNext: { onBranchChange(1) }+ )+ }}+ .frame(maxWidth: .infinity, alignment: .leading)+ .padding(.horizontal, EnsuSpacing.sm)+ .transition(.opacity)}- .frame(maxWidth: .infinity, alignment: .leading)- .padding(.horizontal, EnsuSpacing.sm)}+ .animation(.easeInOut(duration: 0.22), value: showsMetadata).frame(maxWidth: .infinity, alignment: .leading)}}@@ -223,39 +242,70 @@ struct StreamingBubbleView: View {let isOutroPhase: Bool@State private var storageId = UUID().uuidString+ @State private var renderedText = ""+ private let riveWidth: CGFloat = 115+ private let riveHeight: CGFloat = 52.5var body: some View {- let hasText = !text.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty+ let hasText = isGenerating && !renderedText.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty+ let bubbleVerticalPadding = hasText ? EnsuSpacing.md : 0+ let contentSpacing = hasText ? EnsuSpacing.sm : 0HStack(alignment: .bottom) {- VStack(alignment: .leading, spacing: EnsuSpacing.sm) {- EnsuBrandIllustration(- width: 115,- height: 52.5,- outroTrigger: isOutroPhase,- outroInputName: "outro"- )- .frame(width: 115, height: 52.5, alignment: .leading)- .clipped()-+ VStack(alignment: .leading, spacing: contentSpacing) {if hasText {TimelineView(.periodic(from: .now, by: 0.55)) { context inlet phase = Int(context.date.timeIntervalSinceReferenceDate * 2) % 2let showCursor = phase == 0AssistantMessageRenderer(- text: text,+ text: renderedText,isStreaming: true,storageId: storageId,showsCursor: showCursor)}}++ EnsuBrandIllustration(+ width: riveWidth,+ height: riveHeight,+ outroTrigger: isOutroPhase,+ outroInputName: "outro",+ clipsContent: false+ )+ .offset(y: -4)+ .frame(width: riveWidth, height: riveHeight, alignment: .topLeading)}- .padding(.vertical, EnsuSpacing.md)+ .padding(.vertical, bubbleVerticalPadding).padding(.horizontal, EnsuSpacing.sm).frame(maxWidth: .infinity, alignment: .leading)}.foregroundStyle(EnsuColor.textPrimary)+ .onAppear {+ let trimmed = text.trimmingCharacters(in: .whitespacesAndNewlines)+ if !trimmed.isEmpty {+ renderedText = text+ } else if isGenerating {+ renderedText = ""+ }+ }+ .onChange(of: text) { newValue in+ let trimmed = newValue.trimmingCharacters(in: .whitespacesAndNewlines)+ if !trimmed.isEmpty {+ renderedText = newValue+ return+ }+ if isGenerating {+ renderedText = ""+ }+ }+ .onChange(of: isGenerating) { generating in+ if !generating {+ renderedText = ""+ } else if text.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty {+ renderedText = ""+ }+ }}}diff --git a/mobile/native/darwin/Apps/ensu/ensu/Chat/MessageListView.swift b/mobile/native/darwin/Apps/ensu/ensu/Chat/MessageListView.swiftindex 4c99f69767..67852a6d86 100644--- a/mobile/native/darwin/Apps/ensu/ensu/Chat/MessageListView.swift+++ b/mobile/native/darwin/Apps/ensu/ensu/Chat/MessageListView.swift@@ -29,8 +29,8 @@ struct MessageListView: View {@State private var showStreamingBubble = false@State private var streamingWasGenerating = false@State private var streamingAnchorParentId: UUID?- @State private var streamingAnchorIndex: Int?@State private var streamingHideWorkItem: DispatchWorkItem?+ private let streamingOutroDuration: TimeInterval = 0.52var body: some View {GeometryReader { proxy in@@ -87,9 +87,6 @@ struct MessageListView: View {showStreamingBubble = isGeneratingstreamingWasGenerating = isGeneratingstreamingAnchorParentId = streamingParentId- streamingAnchorIndex = streamingParentId.flatMap { parentId in- messages.firstIndex(where: { $0.id == parentId })- }scheduleInitialScroll(scrollProxy)}.onChange(of: isGenerating) { generating in@@ -97,39 +94,28 @@ struct MessageListView: View {streamingHideWorkItem?.cancel()streamingHideWorkItem = nilshowStreamingBubble = true- streamingAnchorParentId = streamingParentId- streamingAnchorIndex = streamingParentId.flatMap { parentId in- messages.firstIndex(where: { $0.id == parentId })+ if let parentId = streamingParentId {+ streamingAnchorParentId = parentId}suppressAutoScrollAfterGeneration = false} else {suppressAutoScrollAfterGeneration = trueif streamingWasGenerating {let workItem = DispatchWorkItem {- withAnimation(.easeInOut(duration: 0.30)) {- showStreamingBubble = false- }+ showStreamingBubble = falsesuppressAutoScrollAfterGeneration = falsestreamingHideWorkItem = nil}streamingHideWorkItem?.cancel()streamingHideWorkItem = workItem- DispatchQueue.main.asyncAfter(deadline: .now() + 3.52, execute: workItem)+ DispatchQueue.main.asyncAfter(deadline: .now() + streamingOutroDuration, execute: workItem)}}streamingWasGenerating = generating}.onChange(of: streamingParentId) { parentId in- if isGenerating {+ if let parentId {streamingAnchorParentId = parentId- streamingAnchorIndex = parentId.flatMap { anchorId in- messages.firstIndex(where: { $0.id == anchorId })- }- }- }- .onChange(of: messages.count) { _ in- if isGenerating, let anchorId = streamingAnchorParentId {- streamingAnchorIndex = messages.firstIndex(where: { $0.id == anchorId })}}.onChange(of: sessionId) { _ in@@ -137,9 +123,10 @@ struct MessageListView: View {streamingHideWorkItem = nilshowStreamingBubble = isGeneratingstreamingWasGenerating = isGenerating- streamingAnchorParentId = streamingParentId- streamingAnchorIndex = streamingParentId.flatMap { parentId in- messages.firstIndex(where: { $0.id == parentId })+ if isGenerating {+ streamingAnchorParentId = streamingParentId+ } else {+ streamingAnchorParentId = nil}}}@@ -237,13 +224,11 @@ struct MessageListView: View {.frame(minHeight: emptyStateMinHeight)}- let shouldShowStreaming = isGenerating || showStreamingBubble- let activeStreamingParentId = isGenerating ? streamingParentId : streamingAnchorParentId- let activeStreamingIndex = isGenerating- ? streamingParentId.flatMap { parentId in messages.firstIndex(where: { $0.id == parentId }) }- : streamingAnchorIndex+ let shouldShowStreaming = isGenerating+ let streamingDisplayText = streamingResponse+ let outroAssistantId = (!isGenerating && showStreamingBubble) ? resolvedStreamingAssistantReplyId() : nil- ForEach(Array(messages.enumerated()), id: \.element.id) { index, message in+ ForEach(messages) { message inif message.role == .user {UserMessageBubbleView(message: message,@@ -260,32 +245,22 @@ struct MessageListView: View {onCopy: { onCopy(message) },onRetry: { onRetry(message) },onBranchChange: { delta in onBranchChange(message, delta) },- onOpenAttachment: openAttachment+ onOpenAttachment: openAttachment,+ showsMetadata: outroAssistantId != message.id,+ showOutroRive: (!isGenerating && showStreamingBubble) && outroAssistantId == message.id).id(message.id).transition(messageTransition)}-- let isAnchoredById = activeStreamingParentId == message.id- let isAnchoredByIndex = activeStreamingIndex == index- if shouldShowStreaming && (isAnchoredById || isAnchoredByIndex) {- StreamingBubbleView(- text: streamingResponse,- isGenerating: isGenerating,- isOutroPhase: !isGenerating && showStreamingBubble- )- .id("streaming-\(message.id.uuidString)")- .transition(streamingTransition)- }}- if shouldShowStreaming && activeStreamingParentId == nil && activeStreamingIndex == nil {+ if shouldShowStreaming {StreamingBubbleView(- text: streamingResponse,- isGenerating: isGenerating,- isOutroPhase: !isGenerating && showStreamingBubble+ text: streamingDisplayText,+ isGenerating: true,+ isOutroPhase: false)- .id("streaming-root")+ .id("streaming").transition(streamingTransition)}}@@ -293,7 +268,6 @@ struct MessageListView: View {.padding(.top, EnsuSpacing.lg).padding(.bottom, EnsuSpacing.lg).animation(isGenerating ? .spring(response: 0.35, dampingFraction: 0.86) : nil, value: messages.count)- .animation(.easeInOut(duration: 0.30), value: showStreamingBubble)Color.clear.frame(height: contentBottomPadding)@@ -320,10 +294,38 @@ struct MessageListView: View {private var streamingTransition: AnyTransition {.asymmetric(insertion: .opacity.combined(with: .scale(scale: 0.96, anchor: .topLeading)),- removal: .opacity.combined(with: .scale(scale: 0.92, anchor: .topLeading))+ removal: .opacity)}+ private func resolvedStreamingAnchorId() -> UUID? {+ if isGenerating {+ return streamingParentId ?? streamingAnchorParentId+ }++ return nil+ }++ private func resolvedStreamingAssistantReplyId() -> UUID? {+ guard let parentId = streamingAnchorParentId ?? streamingParentId else { return nil }+ return resolvedAssistantReplyId(forParentId: parentId)+ }++ private func resolvedAssistantReplyId(forParentId parentId: UUID) -> UUID? {+ guard let parentIndex = messages.firstIndex(where: { $0.id == parentId }) else { return nil }+ guard parentIndex < messages.index(before: messages.endIndex) else { return nil }+ for index in messages.index(after: parentIndex)..<messages.endIndex {+ let candidate = messages[index]+ if candidate.role == .assistant {+ return candidate.id+ }+ if candidate.role == .user {+ break+ }+ }+ return nil+ }+private var contentBottomPadding: CGFloat {let fallbackPadding = EnsuSpacing.xxxl + EnsuSpacing.xxl + 60let measuredPadding = inputBarHeight > 0 ? inputBarHeight + EnsuSpacing.md : fallbackPadding@@ -380,4 +382,3 @@ struct MessageListView: View {}}#endif-diff --git a/mobile/native/darwin/Apps/ensu/ensu/Components/EnsuBrandIllustration.swift b/mobile/native/darwin/Apps/ensu/ensu/Components/EnsuBrandIllustration.swiftindex e1ed213cb3..1873736970 100644--- a/mobile/native/darwin/Apps/ensu/ensu/Components/EnsuBrandIllustration.swift+++ b/mobile/native/darwin/Apps/ensu/ensu/Components/EnsuBrandIllustration.swift@@ -9,6 +9,7 @@ struct EnsuBrandIllustration: View {var animated: Bool = truevar outroTrigger: Bool = falsevar outroInputName: String = "outro"+ var clipsContent: Bool = true@StateObject private var riveViewModel = RiveViewModel(fileName: "ensu",@@ -20,13 +21,27 @@ struct EnsuBrandIllustration: View {@State private var resolvedOutroInputName: String?@State private var primaryStateMachineName: String?@State private var primaryAnimationName: String?- @State private var outroStateMachineName: String?- @State private var outroAnimationName: String?++ @ViewBuilder+ private var riveContent: some View {+ if clipsContent {+ riveViewModel+ .view()+ .frame(width: width, height: height, alignment: .topLeading)+ .clipped()+ .mask(+ Rectangle()+ .frame(width: width, height: height, alignment: .topLeading)+ )+ } else {+ riveViewModel+ .view()+ .frame(width: width, height: height, alignment: .topLeading)+ }+ }var body: some View {- riveViewModel- .view()- .frame(width: width, height: height, alignment: .leading)+ riveContent.onAppear {discoverPlaybackTargets()@@ -80,13 +95,6 @@ struct EnsuBrandIllustration: View {primaryAnimationName = riveViewModel.riveModel?.animation?.name() ?? animations.first}- if outroStateMachineName == nil {- outroStateMachineName = stateMachines.first(where: { $0.lowercased().contains("outro") })- }- if outroAnimationName == nil {- outroAnimationName = animations.first(where: { $0.lowercased().contains("outro") })- }-if let discoveredOutro = riveViewModel.riveModel?.stateMachine?.inputNames().first(where: {$0.lowercased().contains("outro")}) {@@ -111,7 +119,20 @@ struct EnsuBrandIllustration: View {private func fireOutro() {discoverPlaybackTargets()- let inputName = resolvedOutroInputName ?? outroInputName+ let inputName: String = {+ let availableInputs = riveViewModel.riveModel?.stateMachine?.inputNames() ?? []+ if let resolvedOutroInputName,+ availableInputs.contains(resolvedOutroInputName) {+ return resolvedOutroInputName+ }+ if let match = availableInputs.first(where: { $0.lowercased() == outroInputName.lowercased() }) {+ return match+ }+ if let match = availableInputs.first(where: { $0.lowercased().contains("outro") }) {+ return match+ }+ return resolvedOutroInputName ?? outroInputName+ }()if let boolInput = riveViewModel.boolInput(named: inputName) {boolInput.setValue(true)@@ -125,19 +146,8 @@ struct EnsuBrandIllustration: View {return}- if let outroStateMachineName {- try? riveViewModel.configureModel(stateMachineName: outroStateMachineName)- riveViewModel.play()- return- }-- if let outroAnimationName {- try? riveViewModel.configureModel(animationName: outroAnimationName)- riveViewModel.play(loop: .oneShot)- return- }-riveViewModel.triggerInput(inputName)+ riveViewModel.play()}private func resetOutroInputValue() {@@ -160,6 +170,7 @@ struct EnsuBrandIllustration: View {var animated: Bool = truevar outroTrigger: Bool = falsevar outroInputName: String = "outro"+ var clipsContent: Bool = true@State private var isAnimating = false