Skip to content

armgit / ente

Public Imported from GitHub
0

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

ensu: swap updated rive file and trigger outro on generation end

Prateek Sunal525bdc582a3c
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 d3eb17d16a..5c9c88983c 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
@@ -259,7 +259,10 @@ internal fun MessageList(
) {
Column {
Spacer(modifier = Modifier.height(EnsuSpacing.sm.dp))
- StreamingMessageBubble(text = streamingResponse)
+ StreamingMessageBubble(
+ text = streamingResponse,
+ isGenerating = isGenerating
+ )
}
}
}
@@ -273,7 +276,10 @@ internal fun MessageList(
exit = fadeOut(animationSpec = tween(durationMillis = 180)) +
scaleOut(targetScale = 0.86f, animationSpec = tween(durationMillis = 180))
) {
- StreamingMessageBubble(text = streamingResponse)
+ StreamingMessageBubble(
+ text = streamingResponse,
+ isGenerating = isGenerating
+ )
}
}
@@ -644,7 +650,10 @@ private fun MessageActionsMenu(
}
@Composable
-private fun StreamingMessageBubble(text: String) {
+private fun StreamingMessageBubble(
+ text: String,
+ isGenerating: Boolean
+) {
var showCursor by remember { mutableStateOf(true) }
val shouldBlink = text.isNotBlank()
@@ -679,7 +688,9 @@ private fun StreamingMessageBubble(text: String) {
modifier = Modifier
.wrapContentSize(align = Alignment.TopStart)
.width(115.dp)
- .height(52.5.dp)
+ .height(52.5.dp),
+ outroTrigger = !isGenerating,
+ outroInputName = "outro"
)
if (renderedText.isNotBlank()) {
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
index 32fb2b7c27..ac0e1c99e9 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
@@ -3,7 +3,10 @@
package io.ente.ensu.components
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.platform.LocalContext
import androidx.compose.ui.viewinterop.AndroidView
@@ -20,7 +23,10 @@ fun ensuRiveAnimation(
fit: Fit = Fit.CONTAIN,
alignment: RiveAlignment = RiveAlignment.CENTER_LEFT,
loop: Loop = Loop.LOOP,
- autoplay: Boolean = true
+ autoplay: Boolean = true,
+ outroTrigger: Boolean = false,
+ outroInputName: String = "outro",
+ outroStateMachineName: String? = null
) {
val context = LocalContext.current
val appContext = context.applicationContext
@@ -36,10 +42,21 @@ fun ensuRiveAnimation(
)
}
}
+ var lastOutroTrigger by remember { mutableStateOf(false) }
AndroidView(
modifier = modifier,
factory = { riveView },
- update = { }
+ update = { view ->
+ 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/res/raw/ensu.riv b/mobile/native/android/apps/ensu/app-ui/src/main/res/raw/ensu.riv
index 35f4f64d35..3e687cc42a 100644
Binary files a/mobile/native/android/apps/ensu/app-ui/src/main/res/raw/ensu.riv and b/mobile/native/android/apps/ensu/app-ui/src/main/res/raw/ensu.riv differ
diff --git a/mobile/native/darwin/Apps/ensu/ensu/ensu.riv b/mobile/native/darwin/Apps/ensu/ensu/ensu.riv
index 35f4f64d35..3e687cc42a 100644
Binary files a/mobile/native/darwin/Apps/ensu/ensu/ensu.riv and b/mobile/native/darwin/Apps/ensu/ensu/ensu.riv differ