Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

replace mobile rive with dots

Prateek Sunal77292ed4bf23
diff --git a/mobile/native/android/apps/ensu/app-ui/build.gradle.kts b/mobile/native/android/apps/ensu/app-ui/build.gradle.kts
index 726fb42a2a..95caa4c64e 100644
--- a/mobile/native/android/apps/ensu/app-ui/build.gradle.kts
+++ b/mobile/native/android/apps/ensu/app-ui/build.gradle.kts
@@ -115,10 +115,6 @@ dependencies {
implementation("androidx.lifecycle:lifecycle-viewmodel-compose:2.7.0")
implementation("androidx.navigation:navigation-compose:2.7.7")
implementation("com.google.accompanist:accompanist-navigation-animation:0.34.0")
- implementation("app.rive:rive-android:10.2.1") {
- exclude(group = "androidx.lifecycle", module = "lifecycle-runtime-ktx")
- }
-
implementation(project(":domain"))
implementation(project(":data"))
implementation(project(":crypto-auth-core"))
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.kt
index 7bdd85b51d..e22c0ae722 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
@@ -48,8 +48,6 @@ import androidx.compose.runtime.setValue
import androidx.compose.runtime.snapshotFlow
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
-import androidx.compose.ui.draw.clipToBounds
-
import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.hapticfeedback.HapticFeedbackType
@@ -62,8 +60,7 @@ import androidx.compose.ui.unit.dp
import androidx.compose.ui.window.Popup
import androidx.compose.ui.window.PopupProperties
import io.ente.ensu.components.BranchSwitcher
-import app.rive.runtime.kotlin.core.Alignment as RiveAlignment
-import io.ente.ensu.components.ensuRiveAnimation
+import io.ente.ensu.components.GeneratingDotsIndicator
import io.ente.ensu.designsystem.EnsuColor
import io.ente.ensu.designsystem.EnsuCornerRadius
import io.ente.ensu.designsystem.EnsuSpacing
@@ -273,8 +270,7 @@ internal fun MessageList(
branchSelections = branchSelections,
onRetry = { onRetryMessage(message) },
onBranchChange = onBranchChange,
- showsMetadata = true,
- showOutroRive = false
+ showsMetadata = true
)
}
}
@@ -529,8 +525,7 @@ private fun AssistantMessageBubble(
branchSelections: Map<String, Int>,
onRetry: () -> Unit,
onBranchChange: (String, Int) -> Unit,
- showsMetadata: Boolean,
- showOutroRive: Boolean
+ showsMetadata: Boolean
) {
val clipboard = LocalClipboardManager.current
val haptic = rememberEnsuHaptics()
@@ -584,26 +579,6 @@ private fun AssistantMessageBubble(
)
}
- 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
- )
- }
- }
-
AnimatedVisibility(
visible = showsMetadata,
enter = fadeIn(animationSpec = tween(durationMillis = 300)),
@@ -702,7 +677,8 @@ private fun StreamingMessageBubble(
) {
var renderedText by remember { mutableStateOf(text) }
var showCursor by remember { mutableStateOf(true) }
- val shouldBlink = isGenerating && renderedText.isNotBlank()
+ val hasText = renderedText.isNotBlank()
+ val shouldBlink = isGenerating && hasText
LaunchedEffect(shouldBlink) {
if (!shouldBlink) {
@@ -729,16 +705,21 @@ private fun StreamingMessageBubble(
renderedText = text
}
- if (isGenerating && renderedText.isNotBlank()) {
- Column(
- modifier = Modifier
- .fillMaxWidth()
- .padding(horizontal = EnsuSpacing.sm.dp)
- .padding(vertical = EnsuSpacing.md.dp),
- horizontalAlignment = Alignment.Start
- ) {
+ if (!isGenerating) return
+
+ Column(
+ modifier = Modifier
+ .fillMaxWidth()
+ .padding(horizontal = EnsuSpacing.sm.dp)
+ .padding(vertical = if (hasText) EnsuSpacing.md.dp else 0.dp),
+ horizontalAlignment = Alignment.Start,
+ verticalArrangement = Arrangement.spacedBy(if (hasText) EnsuSpacing.sm.dp else 0.dp)
+ ) {
+ if (hasText) {
MarkdownView(markdown = renderedText, enableSelection = false, trailingCursor = showCursor)
}
+
+ GeneratingDotsIndicator(alignment = Alignment.CenterStart)
}
}
diff --git a/mobile/native/android/apps/ensu/app-ui/src/main/java/io/ente/ensu/chat/ChatView.kt b/mobile/native/android/apps/ensu/app-ui/src/main/java/io/ente/ensu/chat/ChatView.kt
index b1c31a35df..1bff5fa9a0 100644
--- a/mobile/native/android/apps/ensu/app-ui/src/main/java/io/ente/ensu/chat/ChatView.kt
+++ b/mobile/native/android/apps/ensu/app-ui/src/main/java/io/ente/ensu/chat/ChatView.kt
@@ -13,27 +13,20 @@ import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
-import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.imePadding
import androidx.compose.foundation.layout.navigationBarsPadding
-import androidx.compose.foundation.layout.offset
import androidx.compose.foundation.layout.padding
-import androidx.compose.foundation.layout.width
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.derivedStateOf
import androidx.compose.runtime.getValue
-import androidx.compose.runtime.mutableIntStateOf
+import androidx.compose.runtime.key
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
-import androidx.compose.ui.layout.onSizeChanged
-import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.platform.LocalFocusManager
import androidx.compose.ui.unit.dp
-import app.rive.runtime.kotlin.core.Alignment as RiveAlignment
-import io.ente.ensu.components.ensuRiveAnimation
import io.ente.ensu.designsystem.EnsuColor
import io.ente.ensu.designsystem.EnsuSpacing
import io.ente.ensu.domain.model.Attachment
@@ -78,8 +71,6 @@ fun ChatView(
var didAutoFocusInput by remember { mutableStateOf(false) }
var focusRequestId by remember { mutableStateOf(0) }
var wasDrawerOpen by remember { mutableStateOf(false) }
- var inputBarHeightPx by remember { mutableIntStateOf(0) }
- var showFloatingStreamingIndicator by remember { mutableStateOf(chatState.isGenerating) }
val shouldAutoFocusInput = chatState.isModelDownloaded &&
!showDownloadOnboarding &&
@@ -132,15 +123,6 @@ fun ChatView(
}
}
- LaunchedEffect(chatState.isGenerating) {
- if (chatState.isGenerating) {
- showFloatingStreamingIndicator = true
- } else if (showFloatingStreamingIndicator) {
- delay(520)
- showFloatingStreamingIndicator = false
- }
- }
-
val sessionKey = chatState.currentSessionId ?: "new-session"
val editingMessage by remember(chatState.editingMessageId, chatState.messages) {
@@ -151,9 +133,6 @@ fun ChatView(
}
}
- val density = LocalDensity.current
- val floatingIndicatorBottomPadding = with(density) { inputBarHeightPx.toDp() }
-
Box(modifier = Modifier.fillMaxSize()) {
Column(
modifier = Modifier
@@ -176,30 +155,32 @@ fun ChatView(
enter.togetherWith(exit)
},
label = "session-change"
- ) {
- MessageList(
- modifier = Modifier
- .fillMaxSize()
- .padding(
- start = EnsuSpacing.pageHorizontal.dp,
- end = EnsuSpacing.pageHorizontal.dp
- ),
- messages = chatState.messages,
- streamingResponse = chatState.streamingResponse,
- streamingParentId = chatState.streamingParentId,
- isGenerating = chatState.isGenerating,
- isModelDownloaded = chatState.isModelDownloaded,
- isDownloading = chatState.isDownloading,
- downloadPercent = chatState.downloadPercent,
- downloadStatus = chatState.downloadStatus,
- modelDownloadSizeBytes = chatState.modelDownloadSizeBytes,
- branchSelections = chatState.branchSelections,
- onEditMessage = onEditMessage,
- onRetryMessage = onRetryMessage,
- onBranchChange = onBranchChange,
- onOpenAttachment = onOpenAttachment,
- onStartDownload = onStartDownload
- )
+ ) { targetSessionKey ->
+ key(targetSessionKey) {
+ MessageList(
+ modifier = Modifier
+ .fillMaxSize()
+ .padding(
+ start = EnsuSpacing.pageHorizontal.dp,
+ end = EnsuSpacing.pageHorizontal.dp
+ ),
+ messages = chatState.messages,
+ streamingResponse = chatState.streamingResponse,
+ streamingParentId = chatState.streamingParentId,
+ isGenerating = chatState.isGenerating,
+ isModelDownloaded = chatState.isModelDownloaded,
+ isDownloading = chatState.isDownloading,
+ downloadPercent = chatState.downloadPercent,
+ downloadStatus = chatState.downloadStatus,
+ modelDownloadSizeBytes = chatState.modelDownloadSizeBytes,
+ branchSelections = chatState.branchSelections,
+ onEditMessage = onEditMessage,
+ onRetryMessage = onRetryMessage,
+ onBranchChange = onBranchChange,
+ onOpenAttachment = onOpenAttachment,
+ onStartDownload = onStartDownload
+ )
+ }
}
chatState.overflowDialog?.let { overflow ->
@@ -216,8 +197,7 @@ fun ChatView(
modifier = Modifier
.fillMaxWidth()
.navigationBarsPadding()
- .background(EnsuColor.backgroundBase())
- .onSizeChanged { inputBarHeightPx = it.height },
+ .background(EnsuColor.backgroundBase()),
messageText = chatState.messageText,
attachments = chatState.attachments,
editingMessage = editingMessage,
@@ -241,30 +221,6 @@ fun ChatView(
}
}
- if (!showDownloadOnboarding && showFloatingStreamingIndicator) {
- Box(
- modifier = Modifier
- .align(androidx.compose.ui.Alignment.BottomCenter)
- .padding(bottom = floatingIndicatorBottomPadding)
- ) {
- Box(
- modifier = Modifier
- .width(115.dp)
- .height(52.5.dp)
- ) {
- ensuRiveAnimation(
- modifier = Modifier
- .fillMaxSize()
- .offset(y = (-4).dp),
- alignment = RiveAlignment.CENTER,
- outroTrigger = !chatState.isGenerating,
- outroInputName = "outro",
- clipContent = false
- )
- }
- }
- }
-
val status = chatState.downloadStatus
val isLoading = status?.contains("Loading", ignoreCase = true) == true
val showToast by remember(status, chatState.isDownloading, showDownloadOnboarding, isLoading) {
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.kt
deleted file mode 100644
index d17c9195e6..0000000000
--- a/mobile/native/android/apps/ensu/app-ui/src/main/java/io/ente/ensu/components/EnsuRiveAnimation.kt
+++ /dev/null
@@ -1,88 +0,0 @@
-@file:Suppress("PackageDirectoryMismatch")
-
-package io.ente.ensu.components
-
-import android.graphics.Rect
-import android.view.ViewGroup
-import androidx.compose.runtime.Composable
-import androidx.compose.runtime.getValue
-import androidx.compose.runtime.mutableStateOf
-import androidx.compose.runtime.remember
-import androidx.compose.runtime.setValue
-import androidx.compose.ui.Modifier
-import androidx.compose.ui.draw.clipToBounds
-import androidx.compose.ui.platform.LocalContext
-import androidx.compose.ui.viewinterop.AndroidView
-import app.rive.runtime.kotlin.RiveAnimationView
-import app.rive.runtime.kotlin.core.Alignment as RiveAlignment
-import app.rive.runtime.kotlin.core.Fit
-import app.rive.runtime.kotlin.core.Loop
-import app.rive.runtime.kotlin.core.Rive
-import io.ente.ensu.R
-
-@Composable
-fun ensuRiveAnimation(
- modifier: Modifier = Modifier,
- fit: Fit = Fit.CONTAIN,
- alignment: RiveAlignment = RiveAlignment.CENTER_LEFT,
- loop: Loop = Loop.LOOP,
- autoplay: Boolean = true,
- outroTrigger: Boolean = false,
- outroInputName: String = "outro",
- outroStateMachineName: String? = null,
- clipContent: Boolean = true
-) {
- val context = LocalContext.current
- val appContext = context.applicationContext
- 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,
- fit = fit,
- 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 = 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()?.name
- if (stateMachineName != null) {
- runCatching {
- view.fireState(stateMachineName, outroInputName)
- }
- }
- }
- lastOutroTrigger = outroTrigger
- }
- )
-}
diff --git a/mobile/native/android/apps/ensu/app-ui/src/main/java/io/ente/ensu/components/GeneratingDotsIndicator.kt b/mobile/native/android/apps/ensu/app-ui/src/main/java/io/ente/ensu/components/GeneratingDotsIndicator.kt
new file mode 100644
index 0000000000..5a480bcacb
--- /dev/null
+++ b/mobile/native/android/apps/ensu/app-ui/src/main/java/io/ente/ensu/components/GeneratingDotsIndicator.kt
@@ -0,0 +1,55 @@
+@file:Suppress("PackageDirectoryMismatch")
+
+package io.ente.ensu.components
+
+import androidx.compose.foundation.layout.Box
+import androidx.compose.foundation.layout.widthIn
+import androidx.compose.material3.Text
+import androidx.compose.runtime.Composable
+import androidx.compose.runtime.LaunchedEffect
+import androidx.compose.runtime.getValue
+import androidx.compose.runtime.mutableIntStateOf
+import androidx.compose.runtime.remember
+import androidx.compose.runtime.setValue
+import androidx.compose.ui.Alignment
+import androidx.compose.ui.Modifier
+import androidx.compose.ui.graphics.Color
+import androidx.compose.ui.text.TextStyle
+import androidx.compose.ui.text.font.FontFamily
+import androidx.compose.ui.unit.dp
+import io.ente.ensu.designsystem.EnsuColor
+import io.ente.ensu.designsystem.EnsuTypography
+import kotlinx.coroutines.delay
+
+@Composable
+fun GeneratingDotsIndicator(
+ modifier: Modifier = Modifier,
+ isAnimating: Boolean = true,
+ alignment: Alignment = Alignment.Center,
+ textStyle: TextStyle = EnsuTypography.message,
+ color: Color = EnsuColor.textMuted()
+) {
+ var dotCount by remember { mutableIntStateOf(1) }
+
+ LaunchedEffect(isAnimating) {
+ if (!isAnimating) {
+ dotCount = 1
+ return@LaunchedEffect
+ }
+
+ while (true) {
+ delay(420)
+ dotCount = if (dotCount == 3) 1 else dotCount + 1
+ }
+ }
+
+ Box(modifier = modifier, contentAlignment = alignment) {
+ Text(
+ text = ".".repeat(dotCount),
+ style = textStyle,
+ color = color,
+ fontFamily = FontFamily.Monospace,
+ modifier = Modifier.widthIn(min = 24.dp)
+ )
+ }
+}
diff --git a/mobile/native/android/apps/ensu/app-ui/src/main/res/raw/ensu.riv b/mobile/native/android/apps/ensu/app-ui/src/main/res/raw/ensu.riv
deleted file mode 100644
index 9eb57731ca..0000000000
Binary files a/mobile/native/android/apps/ensu/app-ui/src/main/res/raw/ensu.riv and /dev/null differ
diff --git a/mobile/native/darwin/Apps/ensu/ensu/Chat/MessageList/MessageListComponents.swift b/mobile/native/darwin/Apps/ensu/ensu/Chat/MessageList/MessageListComponents.swift
index 5d4005c6ff..ab039ad778 100644
--- a/mobile/native/darwin/Apps/ensu/ensu/Chat/MessageList/MessageListComponents.swift
+++ b/mobile/native/darwin/Apps/ensu/ensu/Chat/MessageList/MessageListComponents.swift
@@ -166,7 +166,6 @@ struct AssistantMessageBubbleView: View {
let onBranchChange: (Int) -> Void
let onOpenAttachment: (ChatAttachment) -> Void
let showsMetadata: Bool
- let showOutroRive: Bool
var body: some View {
HStack(alignment: .bottom) {
@@ -196,19 +195,6 @@ struct AssistantMessageBubbleView: View {
}
#endif
- 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)
@@ -239,12 +225,9 @@ private enum StreamingCursor {
struct StreamingBubbleView: View {
let text: String
let isGenerating: Bool
- let isOutroPhase: Bool
@State private var storageId = UUID().uuidString
@State private var renderedText = ""
- private let riveWidth: CGFloat = 115
- private let riveHeight: CGFloat = 52.5
var body: some View {
let hasText = isGenerating && !renderedText.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty
@@ -266,15 +249,15 @@ struct StreamingBubbleView: View {
}
}
- EnsuBrandIllustration(
- width: riveWidth,
- height: riveHeight,
- outroTrigger: isOutroPhase,
- outroInputName: "outro",
- clipsContent: false
- )
- .offset(y: -4)
- .frame(width: riveWidth, height: riveHeight, alignment: .topLeading)
+ TimelineView(.periodic(from: .now, by: 0.42)) { context in
+ let step = Int(context.date.timeIntervalSinceReferenceDate / 0.42)
+ let count = (step % 3) + 1
+ Text(String(repeating: ".", count: count))
+ .font(EnsuTypography.message)
+ .monospaced()
+ .foregroundStyle(EnsuColor.textMuted)
+ .frame(minWidth: 24, alignment: .leading)
+ }
}
.padding(.vertical, bubbleVerticalPadding)
.padding(.horizontal, EnsuSpacing.sm)
diff --git a/mobile/native/darwin/Apps/ensu/ensu/Chat/MessageListView.swift b/mobile/native/darwin/Apps/ensu/ensu/Chat/MessageListView.swift
index 9c54998ece..e366f7c7a3 100644
--- a/mobile/native/darwin/Apps/ensu/ensu/Chat/MessageListView.swift
+++ b/mobile/native/darwin/Apps/ensu/ensu/Chat/MessageListView.swift
@@ -25,12 +25,7 @@ struct MessageListView: View {
@State private var lastContentHeight: CGFloat = 0
@State private var lastScrollChange = ScrollChange()
@State private var didInitialScroll = false
- @State private var suppressAutoScrollAfterGeneration = false
- @State private var showStreamingBubble = false
- @State private var streamingWasGenerating = false
@State private var streamingTextStorageId = UUID().uuidString
- @State private var streamingHideWorkItem: DispatchWorkItem?
- private let streamingOutroDuration: TimeInterval = 0.52
var body: some View {
GeometryReader { proxy in
@@ -79,53 +74,8 @@ struct MessageListView: View {
.onAppear {
lastScrollChange = currentScrollChange
didInitialScroll = false
- showStreamingBubble = isGenerating
- streamingWasGenerating = isGenerating
scheduleInitialScroll(scrollProxy)
}
- .onChange(of: isGenerating) { generating in
- if generating {
- streamingHideWorkItem?.cancel()
- streamingHideWorkItem = nil
- showStreamingBubble = true
- suppressAutoScrollAfterGeneration = false
- } else {
- suppressAutoScrollAfterGeneration = true
- if streamingWasGenerating {
- let workItem = DispatchWorkItem {
- showStreamingBubble = false
- suppressAutoScrollAfterGeneration = false
- streamingHideWorkItem = nil
- }
- streamingHideWorkItem?.cancel()
- streamingHideWorkItem = workItem
- DispatchQueue.main.asyncAfter(deadline: .now() + streamingOutroDuration, execute: workItem)
- }
- }
- streamingWasGenerating = generating
- }
- .onChange(of: sessionId) { _ in
- streamingHideWorkItem?.cancel()
- streamingHideWorkItem = nil
- showStreamingBubble = isGenerating
- streamingWasGenerating = isGenerating
- }
-
- if showStreamingBubble {
- EnsuBrandIllustration(
- width: 115,
- height: 52.5,
- outroTrigger: !isGenerating,
- outroInputName: "outro",
- clipsContent: false,
- riveAlignment: .center
- )
- .offset(y: -4)
- .frame(width: 115, height: 52.5, alignment: .top)
- .padding(.bottom, floatingStreamingBottomPadding)
- .frame(maxWidth: .infinity, alignment: .center)
- .allowsHitTesting(false)
- }
}
}
}
@@ -246,8 +196,7 @@ struct MessageListView: View {
onRetry: { onRetry(message) },
onBranchChange: { delta in onBranchChange(message, delta) },
onOpenAttachment: openAttachment,
- showsMetadata: true,
- showOutroRive: false
+ showsMetadata: true
)
.id(message.id)
.transition(messageTransition)
@@ -292,17 +241,21 @@ struct MessageListView: View {
let hasText = !trimmed.isEmpty
return HStack(alignment: .bottom) {
- VStack(alignment: .leading, spacing: 0) {
- TimelineView(.periodic(from: .now, by: 0.55)) { context in
- let phase = Int(context.date.timeIntervalSinceReferenceDate * 2) % 2
- let showCursor = phase == 0
- AssistantMessageRenderer(
- text: streamingResponse,
- isStreaming: true,
- storageId: streamingTextStorageId,
- showsCursor: showCursor
- )
+ VStack(alignment: .leading, spacing: hasText ? EnsuSpacing.sm : 0) {
+ if hasText {
+ TimelineView(.periodic(from: .now, by: 0.55)) { context in
+ let phase = Int(context.date.timeIntervalSinceReferenceDate * 2) % 2
+ let showCursor = phase == 0
+ AssistantMessageRenderer(
+ text: streamingResponse,
+ isStreaming: true,
+ storageId: streamingTextStorageId,
+ showsCursor: showCursor
+ )
+ }
}
+
+ StreamingDotsView()
}
.padding(.vertical, hasText ? EnsuSpacing.md : 0)
.padding(.horizontal, EnsuSpacing.sm)
@@ -315,13 +268,6 @@ struct MessageListView: View {
.identity
}
- private var floatingStreamingBottomPadding: CGFloat {
- let floatingGap: CGFloat = 36
- let minPadding = EnsuSpacing.xxxl + floatingGap
- let inputPadding = inputBarHeight > 0 ? inputBarHeight + floatingGap : minPadding
- return max(minPadding, inputPadding)
- }
-
private var contentBottomPadding: CGFloat {
let fallbackPadding = EnsuSpacing.xxxl + EnsuSpacing.xxl + 60
let measuredPadding = inputBarHeight > 0 ? inputBarHeight + EnsuSpacing.md : fallbackPadding
@@ -376,6 +322,20 @@ struct MessageListView: View {
}
}
+private struct StreamingDotsView: View {
+ var body: some View {
+ TimelineView(.periodic(from: .now, by: 0.42)) { context in
+ let step = Int(context.date.timeIntervalSinceReferenceDate / 0.42)
+ let count = (step % 3) + 1
+ Text(String(repeating: ".", count: count))
+ .font(EnsuTypography.message)
+ .monospaced()
+ .foregroundStyle(EnsuColor.textMuted)
+ .frame(minWidth: 24, alignment: .leading)
+ }
+ }
+}
+
#else
import SwiftUI