Skip to content

armgit / ente

Public Imported from GitHub
0

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

copy change

laurenspriem4f346ac6ef50
diff --git a/mobile/native/android/apps/ensu/app-ui/src/main/java/io/ente/ensu/chat/ChatOverlays.kt b/mobile/native/android/apps/ensu/app-ui/src/main/java/io/ente/ensu/chat/ChatOverlays.kt
index 4a2dbc0033..a535767005 100644
--- a/mobile/native/android/apps/ensu/app-ui/src/main/java/io/ente/ensu/chat/ChatOverlays.kt
+++ b/mobile/native/android/apps/ensu/app-ui/src/main/java/io/ente/ensu/chat/ChatOverlays.kt
@@ -29,7 +29,6 @@ import io.ente.ensu.designsystem.EnsuCornerRadius
import io.ente.ensu.designsystem.EnsuSpacing
import io.ente.ensu.designsystem.EnsuTypography
import io.ente.ensu.designsystem.HugeIcons
-import io.ente.ensu.domain.device.ChatDeviceCapability
import io.ente.ensu.domain.state.OverflowDialogState
import io.ente.ensu.domain.util.formatBytes
import io.ente.ensu.utils.rememberEnsuHaptics
@@ -67,9 +66,12 @@ internal fun OverflowDialog(
)
}
+private const val UNSUPPORTED_DEVICE_MESSAGE =
+ "This device doesn't have enough memory to run Ensu's AI model. " +
+ "You can view existing chats, but can't send new messages."
+
@Composable
internal fun UnsupportedDeviceDialog(
- capability: ChatDeviceCapability.UnsupportedLowMemory,
onDismiss: () -> Unit
) {
AlertDialog(
@@ -77,7 +79,7 @@ internal fun UnsupportedDeviceDialog(
title = { Text(text = "Chat unavailable on this device", style = EnsuTypography.h3) },
text = {
Text(
- text = unsupportedDeviceMessage(capability),
+ text = UNSUPPORTED_DEVICE_MESSAGE,
style = EnsuTypography.body,
color = EnsuColor.textPrimary()
)
@@ -93,7 +95,6 @@ internal fun UnsupportedDeviceDialog(
@Composable
internal fun UnsupportedChatInputNotice(
- capability: ChatDeviceCapability.UnsupportedLowMemory,
modifier: Modifier = Modifier
) {
Column(
@@ -108,7 +109,7 @@ internal fun UnsupportedChatInputNotice(
color = EnsuColor.textPrimary()
)
Text(
- text = unsupportedDeviceMessage(capability),
+ text = UNSUPPORTED_DEVICE_MESSAGE,
style = EnsuTypography.body,
color = EnsuColor.textMuted(),
modifier = Modifier.padding(top = EnsuSpacing.xs.dp)
@@ -116,12 +117,6 @@ internal fun UnsupportedChatInputNotice(
}
}
-private fun unsupportedDeviceMessage(capability: ChatDeviceCapability.UnsupportedLowMemory): String =
- "Ensu runs the AI model locally and needs at least 4 GB of RAM. " +
- "This device does not have enough memory for chat. " +
- "You can still view existing chats, but sending new messages is disabled. " +
- "Reported memory: ${formatBytes(capability.totalMemoryBytes)}."
-
@Composable
internal fun DownloadToastOverlay(
status: String,
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 3e3f791691..42780232e2 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
@@ -240,7 +240,6 @@ fun ChatView(
if (unsupportedCapability != null) {
UnsupportedChatInputNotice(
- capability = unsupportedCapability,
modifier = Modifier
.fillMaxWidth()
.navigationBarsPadding()
@@ -303,7 +302,6 @@ fun ChatView(
if (chatState.showUnsupportedDeviceDialog && unsupportedCapability != null) {
UnsupportedDeviceDialog(
- capability = unsupportedCapability,
onDismiss = onDismissUnsupportedDeviceDialog
)
}
diff --git a/mobile/native/darwin/Apps/Ensu/Ensu/Chat/ChatViewModel.swift b/mobile/native/darwin/Apps/Ensu/Ensu/Chat/ChatViewModel.swift
index 50ca581962..294480fe80 100644
--- a/mobile/native/darwin/Apps/Ensu/Ensu/Chat/ChatViewModel.swift
+++ b/mobile/native/darwin/Apps/Ensu/Ensu/Chat/ChatViewModel.swift
@@ -614,7 +614,7 @@ final class ChatViewModel: ObservableObject {
}
var unsupportedDeviceMessage: String {
- Self.unsupportedDeviceMessage(for: deviceCapability)
+ Self.unsupportedDeviceMessage
}
func refreshDeviceCapability() {
@@ -641,13 +641,9 @@ final class ChatViewModel: ObservableObject {
showUnsupportedDeviceDialog = false
}
- static func unsupportedDeviceMessage(for capability: ChatDeviceCapability) -> String {
- var message = "Ensu runs the AI model locally and needs at least 4 GB of RAM. This device does not have enough memory for chat. You can still view existing chats, but sending new messages is disabled."
- if let totalMemoryBytes = capability.totalMemoryBytes {
- message += " Reported memory: \(Int64(totalMemoryBytes).formattedFileSize)."
- }
- return message
- }
+ static let unsupportedDeviceMessage =
+ "This device doesn't have enough memory to run Ensu's AI model. " +
+ "You can view existing chats, but can't send new messages."
private func reopenSyncStoresIfNeeded(force: Bool = false) {
let hasSyncDb = FileManager.default.fileExists(atPath: syncDbPath)
@@ -2749,8 +2745,8 @@ final class ChatViewModel: ObservableObject {
}
private func userFacingModelReadyError(_ error: Error, wasDownloaded: Bool) -> String {
- if let error = error as? UnsupportedDeviceMemoryError {
- return Self.unsupportedDeviceMessage(for: error.capability)
+ if error is UnsupportedDeviceMemoryError {
+ return Self.unsupportedDeviceMessage
}
if isOutOfStorageError(error) {
return "Not enough storage space to download the model. Please free up space and try again."