Skip to content

armgit / ente

Public Imported from GitHub
0

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

commit stuff

Prateek Sunal628cb1e0e08e
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 7d2e4022f1..07fe2804e6 100644
--- a/mobile/native/android/apps/ensu/app-ui/build.gradle.kts
+++ b/mobile/native/android/apps/ensu/app-ui/build.gradle.kts
@@ -7,6 +7,15 @@ android {
namespace = "io.ente.ensu"
compileSdk = 34
+ signingConfigs {
+ create("release") {
+ storeFile = file("../debug.keystore")
+ storePassword = "android"
+ keyAlias = "androiddebugkey"
+ keyPassword = "android"
+ }
+ }
+
defaultConfig {
applicationId = "io.ente.ensu"
minSdk = 23
@@ -15,6 +24,12 @@ android {
versionName = "1.0"
}
+ buildTypes {
+ release {
+ signingConfig = signingConfigs.getByName("release")
+ }
+ }
+
buildFeatures {
compose = true
}
diff --git a/mobile/native/android/apps/ensu/app-ui/src/debug/AndroidManifest.xml b/mobile/native/android/apps/ensu/app-ui/src/debug/AndroidManifest.xml
new file mode 100644
index 0000000000..36f3d2cf39
--- /dev/null
+++ b/mobile/native/android/apps/ensu/app-ui/src/debug/AndroidManifest.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns:android="http://schemas.android.com/apk/res/android">
+ <application android:usesCleartextTraffic="true" />
+</manifest>
diff --git a/mobile/native/android/apps/ensu/app-ui/src/main/AndroidManifest.xml b/mobile/native/android/apps/ensu/app-ui/src/main/AndroidManifest.xml
index 94fd896b5c..d8c8bc619b 100644
--- a/mobile/native/android/apps/ensu/app-ui/src/main/AndroidManifest.xml
+++ b/mobile/native/android/apps/ensu/app-ui/src/main/AndroidManifest.xml
@@ -5,9 +5,10 @@
<application
android:label="@string/app_name"
- android:icon="@drawable/ic_launcher_foreground"
- android:roundIcon="@drawable/ic_launcher_foreground"
- android:theme="@style/Theme.Ensu">
+ android:icon="@mipmap/ic_launcher"
+ android:roundIcon="@mipmap/ic_launcher_round"
+ android:theme="@style/Theme.Ensu"
+ android:usesCleartextTraffic="true">
<activity
android:name=".MainActivity"
android:exported="true"
@@ -17,6 +18,16 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
+
+ <provider
+ android:name="androidx.core.content.FileProvider"
+ android:authorities="${applicationId}.fileprovider"
+ android:exported="false"
+ android:grantUriPermissions="true">
+ <meta-data
+ android:name="android.support.FILE_PROVIDER_PATHS"
+ android:resource="@xml/file_paths" />
+ </provider>
</application>
</manifest>
diff --git a/mobile/native/android/apps/ensu/app-ui/src/main/assets/ensu-logo.svg b/mobile/native/android/apps/ensu/app-ui/src/main/assets/ensu-logo.svg
new file mode 100644
index 0000000000..f6d5e5709b
--- /dev/null
+++ b/mobile/native/android/apps/ensu/app-ui/src/main/assets/ensu-logo.svg
@@ -0,0 +1,6 @@
+<svg width="135" height="40" viewBox="0 0 135 40" fill="none" xmlns="http://www.w3.org/2000/svg">
+<path fill-rule="evenodd" clip-rule="evenodd" d="M58.1279 0.714844C59.5808 0.71489 60.8058 1.23858 61.623 2.37598C62.3964 3.45228 62.705 4.94425 62.7051 6.69336L62.6982 7.12109C62.6672 8.1704 62.5277 9.59137 62.29 11.3633L62.2891 11.373L60.2979 25.1289C59.9072 27.8639 59.7178 29.9853 59.7178 31.5137C59.7178 32.0145 59.7818 32.2914 59.834 32.4238C60.2542 32.3861 60.9226 32.0663 61.8555 31.0566C62.8205 30.0121 63.9186 28.3957 65.1436 26.1641L65.6523 25.2363L66.5498 25.7979C67.1673 26.1838 67.8184 26.7714 67.8975 27.6162L67.9053 27.7891L67.8994 27.9912C67.8465 29.0046 67.4017 30.0546 66.709 31.1123C66.0556 32.1098 65.137 33.1812 63.9746 34.3262L63.4619 34.8213C62.0644 36.1433 60.763 37.1667 59.5605 37.8643C58.3656 38.5575 57.2026 38.9677 56.0996 38.9678C54.8677 38.9678 53.8164 38.5052 53.1211 37.5068C52.4715 36.5741 52.2227 35.299 52.2227 33.8369C52.2227 31.7496 52.4891 28.9039 53.0078 25.3223L54.2979 16.3975C54.7131 13.5153 54.915 11.271 54.915 9.64453C54.915 8.75862 54.7549 8.27161 54.5869 8.03027C54.4647 7.85485 54.2894 7.7305 53.8867 7.73047C51.219 7.73047 48.2817 9.55102 45.0947 13.752L45.0938 13.751C41.9726 17.8729 40.1689 22.2784 39.6494 26.9766V26.9785L38.5869 36.4189L30.9912 39.5283L31.5762 34.0986V34.0928L31.8711 31.5127L33.7891 14.4004L34.0098 12.4551C34.1554 10.9485 34.2256 9.75725 34.2256 8.87012C34.2256 8.13471 34.1283 7.73139 34.0361 7.54688C34.0288 7.5322 34.0203 7.52118 34.0146 7.51172C33.4918 7.52323 32.7914 7.82795 31.9043 8.76465C31.0097 9.70928 30.0372 11.1801 29 13.2305L28.4355 14.3467L27.4707 13.5498C27.1484 13.2836 26.863 12.9999 26.6514 12.6963C26.442 12.3959 26.2598 12.0096 26.2598 11.5615C26.2599 10.5368 26.7169 9.46822 27.4336 8.39648C28.1609 7.30894 29.224 6.1167 30.5928 4.82324C31.974 3.51743 33.2402 2.5062 34.3877 1.81641C35.5217 1.13475 36.625 0.714948 37.6592 0.714844C38.9452 0.714844 40.0642 1.1387 40.8262 2.11328C41.5514 3.04098 41.831 4.31647 41.8311 5.77148C41.8311 6.51086 41.7651 7.47261 41.6406 8.64258L41.3467 11.623L41.3457 11.6328L41.3447 11.6416L41.1914 12.9443C43.5116 9.92831 45.9957 7.33834 48.6455 5.18066C52.1588 2.31539 55.3376 0.714844 58.1279 0.714844ZM63.6572 33.2275C63.6763 33.2087 63.6953 33.19 63.7139 33.1709L63.7422 33.1416C63.7142 33.1704 63.6855 33.1986 63.6572 33.2275ZM59.0498 26.9424C59.0333 27.0805 59.0192 27.2171 59.0039 27.3516C59.0235 27.1798 59.0429 27.0049 59.0645 26.8271L59.0498 26.9424ZM32.0732 7.26758C32.1539 7.20702 32.2352 7.14997 32.3154 7.09668C32.3205 7.09333 32.325 7.08926 32.3301 7.08594C32.2447 7.14227 32.1592 7.20299 32.0732 7.26758ZM32.457 7.00488C32.4358 7.01787 32.4148 7.03142 32.3936 7.04492C32.4748 6.99326 32.5559 6.94553 32.6367 6.90137L32.457 7.00488Z" fill="white"/>
+<path fill-rule="evenodd" clip-rule="evenodd" d="M19.9561 0.714844C21.6289 0.714875 23.0624 1.16738 24.0625 2.24121C25.0499 3.30159 25.455 4.79855 25.4551 6.5459C25.4551 10.5148 23.5174 14.2854 19.8809 17.8457C16.4514 21.226 12.3048 23.6248 7.46387 25.0537C7.75489 27.4922 8.39211 29.2302 9.29004 30.3691C10.2461 31.5818 11.5703 32.21 13.3916 32.21C16.9868 32.2098 20.0934 29.9482 22.6377 24.8359L23.1484 23.8096L24.0957 24.4541C24.8884 24.9932 25.4549 25.7586 25.4551 26.7559C25.4551 27.4256 25.1313 28.1422 24.7207 28.8223C24.2877 29.5393 23.6593 30.3724 22.8555 31.3145L22.8516 31.3193C18.5644 36.2833 14.1574 38.9677 9.62988 38.9678C6.98921 38.9678 4.76115 37.968 3.00391 36.0156L2.6582 35.6123C0.861924 33.4077 6.04278e-05 30.6254 0 27.3467C0 21.4755 2.21782 15.6038 6.53906 9.75C10.8478 3.92212 15.312 0.714844 19.9561 0.714844ZM7.05469 19.9844C7.08204 19.9918 7.10957 19.9979 7.13672 20.0049C7.02486 19.9761 6.91111 19.9447 6.7959 19.9092L7.05469 19.9844ZM15.5303 7.50977C13.8793 7.50979 12.2286 8.48039 10.6045 10.8701C9.14101 13.0342 8.14218 15.7641 7.64062 19.0957C7.95096 19.1606 8.23212 19.1914 8.48633 19.1914C11.3125 19.1914 13.7547 18.3318 15.8564 16.6143C17.9564 14.8981 18.9189 12.9772 18.9189 10.8242C18.9189 9.54443 18.5952 8.7669 18.1211 8.30078C17.6439 7.83159 16.8432 7.50977 15.5303 7.50977ZM15.4424 18.1572C15.4992 18.1196 15.5579 18.0846 15.6143 18.0459L15.6416 18.0264C15.5761 18.0716 15.5085 18.1134 15.4424 18.1572ZM19.9189 10.8242L19.915 10.5586C19.9143 10.5363 19.912 10.5142 19.9111 10.4922C19.9156 10.6007 19.9189 10.7113 19.9189 10.8242ZM12.1484 7.71094C11.9119 7.88895 11.6787 8.08713 11.4482 8.30469L11.7969 7.99316C11.9135 7.89441 12.0303 7.79983 12.1484 7.71094Z" fill="white"/>
+<path fill-rule="evenodd" clip-rule="evenodd" d="M85.3828 0.714844C87.2121 0.714844 89.1673 1.01467 91.2422 1.59961L92.1387 1.86816L93.7803 2.38672L87.4785 8.21484L86.8115 7.71484C85.1121 6.44031 83.2439 5.8125 81.1787 5.8125C79.9535 5.81254 79.2205 6.07279 78.8047 6.41992C78.4236 6.73824 78.1592 7.25686 78.1592 8.16895L78.1709 8.375C78.2288 8.88722 78.4994 9.61542 79.1191 10.5938C79.7265 11.5525 80.6188 12.673 81.8125 13.959L82.3428 14.5205L82.3506 14.5283L84.6299 16.9551C86.3564 18.7567 87.6843 20.4155 88.585 21.9297C89.48 23.4344 89.9971 24.8698 89.9971 26.2031L89.9922 26.5273C89.8903 29.8616 88.2131 32.7596 85.1602 35.207L85.1562 35.2109C82.0002 37.7148 78.3497 38.9678 74.2451 38.9678C71.5057 38.9677 68.9196 38.347 66.5 37.1084L66.0186 36.8516L64.7236 36.1387L71.6797 30.4434L72.3193 31.124C74.0404 32.9553 76.1822 33.87 78.8184 33.8701C80.443 33.8701 81.477 33.4776 82.1074 32.8691C82.7313 32.267 83.1289 31.2886 83.1289 29.7432C83.1288 29.0644 82.8305 28.1184 82.0605 26.8643C81.3001 25.6256 80.1348 24.1742 78.5391 22.5059L76.4395 20.333L76.4355 20.3291C74.8684 18.6867 73.6606 17.1683 72.8398 15.7764C72.0243 14.3932 71.5489 13.0642 71.5488 11.8203C71.5488 8.62943 72.9456 5.95433 75.6172 3.84375L75.6211 3.84082C78.3053 1.7413 81.5798 0.71492 85.3828 0.714844ZM73.7314 37.96L74.2451 37.9678C73.9059 37.9678 73.5693 37.9567 73.2354 37.9365C73.4001 37.9465 73.5654 37.9549 73.7314 37.96ZM72.6387 10.5166C72.6302 10.5765 72.6235 10.6369 72.6162 10.6973C72.6338 10.5515 72.6541 10.4069 72.6787 10.2637L72.6387 10.5166ZM73.1572 8.56934C73.1459 8.59744 73.136 8.62608 73.125 8.6543L73.208 8.4502L73.1572 8.56934Z" fill="white"/>
+<path fill-rule="evenodd" clip-rule="evenodd" d="M130.538 1.76562C129.856 4.59298 129.346 7.10548 129.007 9.30566L129.008 9.30664L126.794 24.7217C126.672 25.648 126.576 26.426 126.503 27.0557L126.502 27.0674L126.244 29.085C126.097 30.3392 126.03 31.1726 126.03 31.624C126.03 31.8447 126.046 32.0131 126.068 32.1357C126.073 32.1603 126.079 32.1818 126.084 32.2012C126.703 32.1435 127.455 31.7637 128.342 30.7998C129.306 29.7516 130.328 28.1213 131.39 25.8525L131.857 24.8545L132.806 25.417C133.451 25.7998 134.192 26.3961 134.282 27.2773L134.291 27.457L134.286 27.6084C134.261 27.9616 134.152 28.3164 134.016 28.6475C133.854 29.0383 133.624 29.4671 133.34 29.9277C132.772 30.848 131.939 31.9698 130.858 33.2861L130.859 33.2871C127.944 36.8753 125.017 38.9677 122.08 38.9678C120.936 38.9678 119.934 38.5677 119.259 37.6611C118.625 36.8098 118.388 35.6532 118.388 34.3535C118.388 33.5267 118.481 32.4561 118.655 31.1592V31.1562L119.061 28.2061C119.153 27.5406 119.229 26.9638 119.296 26.4785C117.073 29.4082 114.654 31.9942 112.034 34.2295C108.501 37.2437 105.394 38.9677 102.792 38.9678C101.331 38.9678 100.09 38.4653 99.2539 37.3506C98.4584 36.2899 98.1406 34.8184 98.1406 33.0996C98.1406 31.8319 98.3071 29.8025 98.627 27.0469L99.9541 14.9561L99.9561 14.9404L99.958 14.9238C99.9768 14.7921 100.036 14.1247 100.136 12.8486L100.137 12.835L100.357 10.4375L100.358 10.4268C100.43 9.73938 100.464 9.1348 100.464 8.61133C100.464 7.96088 100.366 7.63408 100.291 7.50195C100.284 7.48925 100.277 7.48012 100.272 7.47363C100.266 7.47309 100.258 7.47266 100.247 7.47266C99.7051 7.4727 98.9782 7.77938 98.0557 8.74121C97.1429 9.69293 96.1493 11.1737 95.0879 13.2363L94.5322 14.3164L93.5791 13.5635C92.9787 13.0894 92.498 12.4367 92.498 11.5986C92.4981 10.5533 92.9551 9.46825 93.6807 8.37988C94.4153 7.27788 95.4885 6.07778 96.8711 4.7832L96.875 4.78027C98.2698 3.48604 99.5527 2.48474 100.72 1.80176C101.875 1.12547 102.996 0.714844 104.046 0.714844C105.322 0.714871 106.417 1.17054 107.15 2.17773C107.841 3.12585 108.106 4.42622 108.106 5.91895C108.106 6.62967 108.054 7.44324 107.953 8.35352L107.952 8.3584L107.621 11.1885L107.29 14.2871L107.289 14.292L106.109 24.8389C105.917 26.5961 105.82 28.3789 105.82 30.1865L105.827 30.4521C105.857 31.0331 105.981 31.3463 106.095 31.5C106.183 31.6191 106.324 31.7305 106.701 31.7305C107.809 31.7305 109.085 31.2746 110.547 30.208C112.009 29.1418 113.598 27.5076 115.311 25.2646L115.312 25.2617C118.752 20.7882 120.74 16.4207 121.349 12.1572L122.689 2.80957L130.965 0L130.538 1.76562ZM129.56 33.2822C129.532 33.3146 129.504 33.3469 129.477 33.3789C129.499 33.3526 129.523 33.3273 129.546 33.3008C129.562 33.2818 129.577 33.2615 129.593 33.2422C129.581 33.2554 129.571 33.2691 129.56 33.2822ZM126.111 33.2031L126.308 33.1836C126.32 33.1819 126.332 33.1784 126.344 33.1758C126.266 33.1875 126.189 33.1978 126.111 33.2031ZM125.311 32.9072C125.318 32.9173 125.326 32.926 125.334 32.9355C125.305 32.8984 125.277 32.8582 125.252 32.8135L125.311 32.9072ZM129.078 31.4766L129.277 31.2539C129.286 31.2445 129.293 31.2345 129.301 31.2246C129.226 31.3112 129.153 31.3957 129.078 31.4766ZM132.583 26.4639C132.565 26.4507 132.548 26.4365 132.529 26.4238C132.518 26.4163 132.506 26.4098 132.495 26.4023C132.526 26.4225 132.554 26.4437 132.583 26.4639Z" fill="white"/>
+</svg>
diff --git a/mobile/native/android/apps/ensu/app-ui/src/main/java/io/ente/ensu/AppViewModel.kt b/mobile/native/android/apps/ensu/app-ui/src/main/java/io/ente/ensu/AppViewModel.kt
index 226aa3fe85..8fef04ae4c 100644
--- a/mobile/native/android/apps/ensu/app-ui/src/main/java/io/ente/ensu/AppViewModel.kt
+++ b/mobile/native/android/apps/ensu/app-ui/src/main/java/io/ente/ensu/AppViewModel.kt
@@ -10,9 +10,12 @@ import io.ente.ensu.data.logging.InMemoryLogRepository
import io.ente.ensu.data.storage.CredentialStore
import io.ente.ensu.data.llm.InferenceRsProvider
import io.ente.ensu.data.chat.RustChatRepository
+import io.ente.ensu.data.chat.RustChatSyncRepository
import io.ente.ensu.domain.store.AppStore
import kotlinx.coroutines.flow.collectLatest
+import kotlinx.coroutines.flow.first
import kotlinx.coroutines.launch
+import kotlinx.coroutines.runBlocking
import java.io.File
class AppViewModel(application: Application) : AndroidViewModel(application) {
@@ -20,15 +23,25 @@ class AppViewModel(application: Application) : AndroidViewModel(application) {
private val endpointPreferences = EndpointPreferencesDataStore(application)
private val credentialStore = CredentialStore(application)
+ private companion object {
+ const val fixedEndpoint = "https://1227635d8108.ngrok-free.app"
+ }
+
val logRepository = InMemoryLogRepository()
private val llmProvider = InferenceRsProvider(
modelDir = File(application.filesDir, "llm")
)
private val chatRepository = RustChatRepository(application, credentialStore)
+ private val chatSyncRepository = RustChatSyncRepository(
+ context = application,
+ credentialStore = credentialStore,
+ endpointPreferences = endpointPreferences
+ )
val store = AppStore(
sessionPreferences = sessionPreferences,
chatRepository = chatRepository,
+ chatSyncRepository = chatSyncRepository,
llmProvider = llmProvider,
logRepository = logRepository
)
@@ -42,6 +55,13 @@ class AppViewModel(application: Application) : AndroidViewModel(application) {
val currentEndpointFlow = authService.currentEndpointFlow
init {
+ runBlocking {
+ val endpoint = endpointPreferences.endpointFlow.first()
+ if (endpoint.isNullOrBlank()) {
+ endpointPreferences.setEndpoint(fixedEndpoint)
+ }
+ }
+
store.bootstrap(viewModelScope)
val email = credentialStore.getEmail()
if (credentialStore.isLoggedIn() && !email.isNullOrBlank()) {
diff --git a/mobile/native/android/apps/ensu/app-ui/src/main/java/io/ente/ensu/HomeView.kt b/mobile/native/android/apps/ensu/app-ui/src/main/java/io/ente/ensu/HomeView.kt
index f9252bcd1a..3e47698c67 100644
--- a/mobile/native/android/apps/ensu/app-ui/src/main/java/io/ente/ensu/HomeView.kt
+++ b/mobile/native/android/apps/ensu/app-ui/src/main/java/io/ente/ensu/HomeView.kt
@@ -7,12 +7,23 @@ import android.net.Uri
import android.provider.OpenableColumns
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
+import androidx.compose.foundation.layout.PaddingValues
+import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.WindowInsets
import androidx.compose.foundation.layout.fillMaxSize
+import androidx.compose.foundation.layout.heightIn
import androidx.compose.foundation.layout.padding
+import androidx.compose.foundation.layout.width
+import android.content.Intent
+import android.webkit.MimeTypeMap
+import android.widget.Toast
+import androidx.compose.foundation.rememberScrollState
+import androidx.compose.foundation.verticalScroll
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.outlined.ArrowBack
+import androidx.compose.material.icons.outlined.Download
import androidx.compose.material.icons.outlined.Menu
+import androidx.compose.material3.AlertDialog
import androidx.compose.material3.DrawerValue
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
@@ -22,21 +33,28 @@ import androidx.compose.material3.Text
import androidx.compose.material3.TextButton
import androidx.compose.material3.TopAppBar
import androidx.compose.material3.TopAppBarDefaults
+import androidx.core.content.FileProvider
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
+import androidx.compose.ui.Alignment
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
+import androidx.compose.ui.unit.dp
import io.ente.ensu.auth.AuthFlowScreen
import io.ente.ensu.chat.ChatView
import io.ente.ensu.chat.SessionDrawer
import io.ente.ensu.components.ChoiceDialog
+import io.ente.ensu.components.EnsuLogo
import io.ente.ensu.data.auth.EnsuAuthService
import io.ente.ensu.designsystem.EnsuColor
+import io.ente.ensu.designsystem.EnsuSpacing
import io.ente.ensu.designsystem.EnsuTypography
import io.ente.ensu.domain.model.Attachment
+import io.ente.ensu.domain.model.AttachmentDownloadItem
+import io.ente.ensu.domain.model.AttachmentDownloadStatus
import io.ente.ensu.domain.model.AttachmentType
import io.ente.ensu.domain.model.LogEntry
import io.ente.ensu.domain.state.AppState
@@ -64,6 +82,8 @@ fun HomeView(
var isShowingAuth by remember { mutableStateOf(false) }
var isShowingSignOutDialog by remember { mutableStateOf(false) }
var destination by remember { mutableStateOf(HomeDestination.Chat) }
+ var showAttachmentDownloads by remember { mutableStateOf(false) }
+ var deleteSessionTarget by remember { mutableStateOf<io.ente.ensu.domain.model.ChatSession?>(null) }
val imagePicker = androidx.activity.compose.rememberLauncherForActivityResult(
contract = androidx.activity.result.contract.ActivityResultContracts.GetContent()
@@ -112,8 +132,8 @@ fun HomeView(
isLoggedIn = appState.auth.isLoggedIn,
userEmail = appState.auth.email,
onNewChat = {
- val sessionId = store.createNewSession()
- store.persistSelectedSession(scope, sessionId)
+ store.startNewSessionDraft()
+ store.persistSelectedSession(scope, null)
destination = HomeDestination.Chat
scope.launch { drawerState.close() }
},
@@ -123,7 +143,14 @@ fun HomeView(
destination = HomeDestination.Chat
scope.launch { drawerState.close() }
},
- onSync = {},
+ onDeleteSession = { session ->
+ deleteSessionTarget = session
+ },
+ onSync = {
+ store.syncNow { message ->
+ Toast.makeText(context, message, Toast.LENGTH_SHORT).show()
+ }
+ },
onOpenLogs = {
destination = HomeDestination.Logs
scope.launch { drawerState.close() }
@@ -152,8 +179,11 @@ fun HomeView(
sessionTitle = currentSession?.title,
showBrand = appState.chat.messages.isEmpty(),
isLoggedIn = appState.auth.isLoggedIn,
+ attachmentDownloads = appState.chat.attachmentDownloads,
+ attachmentDownloadProgress = appState.chat.attachmentDownloadProgress,
onOpenDrawer = { scope.launch { drawerState.open() } },
- onSignIn = { isShowingAuth = true }
+ onSignIn = { isShowingAuth = true },
+ onAttachmentDownloads = { showAttachmentDownloads = true }
)
androidx.compose.material3.HorizontalDivider(color = EnsuColor.border())
}
@@ -197,7 +227,10 @@ fun HomeView(
onEditMessage = { message -> store.beginEditing(message.id) },
onRetryMessage = { message -> store.retryAssistantMessage(message.id) },
onCancelEdit = store::cancelEditing,
- onBranchChange = store::updateBranchSelection
+ onBranchChange = store::updateBranchSelection,
+ onOpenAttachment = { attachment ->
+ openAttachment(context, attachment)
+ }
)
}
HomeDestination.Logs -> {
@@ -233,6 +266,32 @@ fun HomeView(
)
}
+ if (showAttachmentDownloads) {
+ AttachmentDownloadsDialog(
+ downloads = appState.chat.attachmentDownloads,
+ onCancel = { store.cancelAttachmentDownload(it) },
+ onDismiss = { showAttachmentDownloads = false }
+ )
+ }
+
+ if (deleteSessionTarget != null) {
+ ChoiceDialog(
+ title = "Delete Chat",
+ body = "This will delete the chat and sync the change.",
+ firstButtonLabel = "Delete",
+ secondButtonLabel = "Cancel",
+ isCritical = true,
+ onFirst = {
+ deleteSessionTarget?.let { session ->
+ store.deleteSession(session.id)
+ }
+ deleteSessionTarget = null
+ },
+ onSecond = { deleteSessionTarget = null },
+ onDismiss = { deleteSessionTarget = null }
+ )
+ }
+
if (isShowingSignOutDialog) {
ChoiceDialog(
title = "Sign Out",
@@ -256,24 +315,33 @@ private fun EnsuTopBar(
sessionTitle: String?,
showBrand: Boolean,
isLoggedIn: Boolean,
+ attachmentDownloads: List<io.ente.ensu.domain.model.AttachmentDownloadItem>,
+ attachmentDownloadProgress: Int?,
onOpenDrawer: () -> Unit,
- onSignIn: () -> Unit
+ onSignIn: () -> Unit,
+ onAttachmentDownloads: () -> Unit
) {
- val titleText = if (showBrand) "ensu" else sessionTitle?.takeIf { it.isNotBlank() } ?: "New Chat"
- val titleStyle = if (showBrand) EnsuTypography.h3Bold else EnsuTypography.h3Bold
+ val titleText = sessionTitle?.takeIf { it.isNotBlank() } ?: "New Chat"
TopAppBar(
title = {
- Text(
- text = titleText,
- style = titleStyle,
- color = EnsuColor.textPrimary(),
- maxLines = 1
- )
+ if (showBrand) {
+ EnsuLogo(height = 20.dp)
+ } else {
+ Text(
+ text = titleText,
+ style = EnsuTypography.h3Bold,
+ color = EnsuColor.textPrimary(),
+ maxLines = 1
+ )
+ }
},
navigationIcon = {
IconButton(onClick = onOpenDrawer) {
- Icon(imageVector = Icons.Outlined.Menu, contentDescription = "Menu")
+ Icon(
+ imageVector = Icons.Outlined.Menu,
+ contentDescription = "Menu"
+ )
}
},
actions = {
@@ -281,12 +349,108 @@ private fun EnsuTopBar(
TextButton(onClick = onSignIn) {
Text(text = "Sign In", style = EnsuTypography.small, color = EnsuColor.accent())
}
+ } else {
+ val hasPending = attachmentDownloads.any {
+ it.status == AttachmentDownloadStatus.Queued ||
+ it.status == AttachmentDownloadStatus.Downloading ||
+ it.status == AttachmentDownloadStatus.Failed
+ }
+ if (hasPending) {
+ val active = attachmentDownloads.filter { it.status != AttachmentDownloadStatus.Canceled }
+ val completed = active.count { it.status == AttachmentDownloadStatus.Completed }
+ val total = active.size
+ TextButton(
+ onClick = onAttachmentDownloads,
+ contentPadding = PaddingValues(horizontal = 8.dp, vertical = 0.dp)
+ ) {
+ Row(verticalAlignment = Alignment.CenterVertically) {
+ Icon(
+ imageVector = Icons.Outlined.Download,
+ contentDescription = "Attachment downloads",
+ tint = EnsuColor.textPrimary()
+ )
+ Text(
+ text = "$completed/$total",
+ style = EnsuTypography.mini,
+ color = EnsuColor.textMuted(),
+ maxLines = 1,
+ softWrap = false,
+ modifier = Modifier.padding(start = 6.dp)
+ )
+ }
+ }
+ }
}
},
colors = TopAppBarDefaults.topAppBarColors(containerColor = EnsuColor.backgroundBase())
)
}
+@Composable
+private fun AttachmentDownloadsDialog(
+ downloads: List<AttachmentDownloadItem>,
+ onCancel: (String) -> Unit,
+ onDismiss: () -> Unit
+) {
+ AlertDialog(
+ onDismissRequest = onDismiss,
+ title = { Text(text = "Attachment downloads", style = EnsuTypography.h3Bold) },
+ text = {
+ if (downloads.isEmpty()) {
+ Text(text = "No pending downloads", style = EnsuTypography.body, color = EnsuColor.textMuted())
+ } else {
+ Column(
+ modifier = Modifier
+ .heightIn(max = 320.dp)
+ .verticalScroll(rememberScrollState())
+ ) {
+ downloads.forEach { item ->
+ Row(
+ modifier = Modifier.padding(vertical = EnsuSpacing.xs.dp),
+ verticalAlignment = Alignment.CenterVertically
+ ) {
+ Column(modifier = Modifier.weight(1f)) {
+ Text(text = item.name, style = EnsuTypography.body, color = EnsuColor.textPrimary())
+ Text(
+ text = "Session ${item.sessionId.take(6)} β€’ ${item.sizeBytes / 1024} KB",
+ style = EnsuTypography.mini,
+ color = EnsuColor.textMuted()
+ )
+ }
+ Text(
+ text = statusLabel(item.status),
+ style = EnsuTypography.mini,
+ color = EnsuColor.textMuted(),
+ modifier = Modifier.padding(end = EnsuSpacing.xs.dp)
+ )
+ if (item.status == AttachmentDownloadStatus.Queued || item.status == AttachmentDownloadStatus.Downloading) {
+ TextButton(onClick = { onCancel(item.id) }) {
+ Text(text = "Cancel", style = EnsuTypography.mini)
+ }
+ }
+ }
+ }
+ }
+ }
+ },
+ confirmButton = {
+ TextButton(onClick = onDismiss) {
+ Text(text = "Close", style = EnsuTypography.small)
+ }
+ }
+ )
+}
+
+private fun statusLabel(status: AttachmentDownloadStatus): String {
+ return when (status) {
+ AttachmentDownloadStatus.Queued -> "Queued"
+ AttachmentDownloadStatus.Downloading -> "Downloading"
+ AttachmentDownloadStatus.Completed -> "Completed"
+ AttachmentDownloadStatus.Failed -> "Failed"
+ AttachmentDownloadStatus.Canceled -> "Canceled"
+ }
+}
+
@Composable
private fun SimpleTopBar(title: String, onBack: () -> Unit) {
TopAppBar(
@@ -350,6 +514,46 @@ private fun buildAttachmentFromUri(
}.getOrNull()
}
+private fun openAttachment(context: Context, attachment: Attachment) {
+ val path = attachment.localPath
+ if (path.isNullOrBlank()) {
+ Toast.makeText(context, "Attachment not available", Toast.LENGTH_SHORT).show()
+ return
+ }
+ val file = File(path)
+ if (!file.exists()) {
+ Toast.makeText(context, "Attachment not downloaded", Toast.LENGTH_SHORT).show()
+ return
+ }
+
+ val extension = file.extension.lowercase()
+ val mimeFromExtension = if (extension.isNotBlank()) {
+ MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension)
+ } else {
+ null
+ }
+ val mime = when {
+ attachment.type == AttachmentType.Image -> mimeFromExtension ?: "image/*"
+ else -> mimeFromExtension ?: "*/*"
+ }
+
+ val uri = FileProvider.getUriForFile(
+ context,
+ "${context.packageName}.fileprovider",
+ file
+ )
+ val intent = Intent(Intent.ACTION_VIEW)
+ .setDataAndType(uri, mime)
+ .addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)
+ val chooser = Intent.createChooser(intent, "Open attachment")
+ val resolved = intent.resolveActivity(context.packageManager)
+ if (resolved != null) {
+ context.startActivity(chooser)
+ } else {
+ Toast.makeText(context, "No app available to open this file", Toast.LENGTH_SHORT).show()
+ }
+}
+
private fun queryDisplayName(resolver: android.content.ContentResolver, uri: Uri): String? {
resolver.query(uri, arrayOf(OpenableColumns.DISPLAY_NAME), null, null, null)?.use { cursor ->
if (cursor.moveToFirst()) {
diff --git a/mobile/native/android/apps/ensu/app-ui/src/main/java/io/ente/ensu/auth/AuthComponents.kt b/mobile/native/android/apps/ensu/app-ui/src/main/java/io/ente/ensu/auth/AuthComponents.kt
index 86fa643578..06937cc142 100644
--- a/mobile/native/android/apps/ensu/app-ui/src/main/java/io/ente/ensu/auth/AuthComponents.kt
+++ b/mobile/native/android/apps/ensu/app-ui/src/main/java/io/ente/ensu/auth/AuthComponents.kt
@@ -192,6 +192,7 @@ fun CodeTextField(
placeholder = {
Text(
text = "β€’ β€’ β€’ β€’ β€’ β€’",
+ modifier = Modifier.fillMaxWidth(),
style = TextStyle(
fontSize = 28.sp,
lineHeight = 32.sp,
diff --git a/mobile/native/android/apps/ensu/app-ui/src/main/java/io/ente/ensu/auth/AuthFlowScreen.kt b/mobile/native/android/apps/ensu/app-ui/src/main/java/io/ente/ensu/auth/AuthFlowScreen.kt
index b35ae8e34e..510eb749fd 100644
--- a/mobile/native/android/apps/ensu/app-ui/src/main/java/io/ente/ensu/auth/AuthFlowScreen.kt
+++ b/mobile/native/android/apps/ensu/app-ui/src/main/java/io/ente/ensu/auth/AuthFlowScreen.kt
@@ -33,6 +33,7 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.text.input.KeyboardType
import androidx.compose.ui.unit.dp
+import io.ente.ensu.components.EnsuLogo
import io.ente.ensu.data.auth.AuthResponsePayload
import io.ente.ensu.data.auth.EnsuAuthService
import io.ente.ensu.data.auth.KeyAttributes
@@ -96,11 +97,7 @@ fun AuthFlowScreen(
topBar = {
CenterAlignedTopAppBar(
title = {
- Text(
- text = "ensu",
- style = EnsuTypography.h3Bold,
- color = EnsuColor.textPrimary()
- )
+ EnsuLogo(height = 20.dp)
},
navigationIcon = {
IconButton(onClick = {
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 f752c6dd27..87932624a6 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
@@ -39,8 +39,6 @@ import androidx.compose.material.icons.outlined.Refresh
import androidx.compose.material.icons.outlined.Code
import androidx.compose.material.icons.outlined.Close
import androidx.compose.material3.CircularProgressIndicator
-import androidx.compose.material3.DropdownMenu
-import androidx.compose.material3.DropdownMenuItem
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.LinearProgressIndicator
@@ -89,7 +87,8 @@ fun ChatView(
onEditMessage: (ChatMessage) -> Unit,
onRetryMessage: (ChatMessage) -> Unit,
onCancelEdit: () -> Unit,
- onBranchChange: (String, Int) -> Unit
+ onBranchChange: (String, Int) -> Unit,
+ onOpenAttachment: (Attachment) -> Unit
) {
Box(modifier = Modifier.fillMaxSize()) {
Column(modifier = Modifier.fillMaxSize()) {
@@ -108,7 +107,8 @@ fun ChatView(
branchSelections = chatState.branchSelections,
onEditMessage = onEditMessage,
onRetryMessage = onRetryMessage,
- onBranchChange = onBranchChange
+ onBranchChange = onBranchChange,
+ onOpenAttachment = onOpenAttachment
)
val editingMessage = chatState.editingMessageId?.let { editingId ->
@@ -127,6 +127,8 @@ fun ChatView(
isGenerating = chatState.isGenerating,
isDownloading = chatState.isDownloading,
downloadPercent = chatState.downloadPercent,
+ isAttachmentDownloadBlocked = chatState.isAttachmentDownloadBlocked,
+ attachmentDownloadPercent = chatState.attachmentDownloadProgress,
onMessageChange = onMessageChange,
onSend = onSend,
onStop = onStop,
@@ -159,7 +161,8 @@ private fun MessageList(
branchSelections: Map<String, Int>,
onEditMessage: (ChatMessage) -> Unit,
onRetryMessage: (ChatMessage) -> Unit,
- onBranchChange: (String, Int) -> Unit
+ onBranchChange: (String, Int) -> Unit,
+ onOpenAttachment: (Attachment) -> Unit
) {
if (messages.isEmpty() && !isGenerating) {
EmptyState(modifier = modifier)
@@ -215,7 +218,8 @@ private fun MessageList(
message = message,
branchSelections = branchSelections,
onEdit = { onEditMessage(message) },
- onBranchChange = onBranchChange
+ onBranchChange = onBranchChange,
+ onOpenAttachment = onOpenAttachment
)
}
MessageAuthor.Assistant -> {
@@ -263,7 +267,8 @@ private fun UserMessageBubble(
message: ChatMessage,
branchSelections: Map<String, Int>,
onEdit: () -> Unit,
- onBranchChange: (String, Int) -> Unit
+ onBranchChange: (String, Int) -> Unit,
+ onOpenAttachment: (Attachment) -> Unit
) {
Column(
modifier = Modifier
@@ -286,7 +291,8 @@ private fun UserMessageBubble(
name = attachment.name,
size = "${attachment.sizeBytes / 1024} KB",
icon = icon,
- isUploading = attachment.isUploading
+ isUploading = attachment.isUploading,
+ onClick = { onOpenAttachment(attachment) }
)
}
}
@@ -485,7 +491,7 @@ private fun DownloadToastOverlay(
}
Spacer(modifier = Modifier.height(EnsuSpacing.sm.dp))
LinearProgressIndicator(
- progress = clamped / 100f,
+ progress = { clamped / 100f },
color = if (isLoading) EnsuColor.accent() else EnsuColor.accent(),
trackColor = EnsuColor.border(),
modifier = Modifier.fillMaxWidth()
@@ -573,6 +579,8 @@ private fun MessageInput(
isGenerating: Boolean,
isDownloading: Boolean,
downloadPercent: Int?,
+ isAttachmentDownloadBlocked: Boolean,
+ attachmentDownloadPercent: Int?,
onMessageChange: (String) -> Unit,
onSend: () -> Unit,
onStop: () -> Unit,
@@ -580,12 +588,16 @@ private fun MessageInput(
onRemoveAttachment: (Attachment) -> Unit,
onCancelEdit: () -> Unit
) {
- var showMenu by remember { mutableStateOf(false) }
- val placeholder = if (isDownloading) {
- val percent = downloadPercent?.let { " ($it%)" } ?: ""
- "Downloading model...$percent"
- } else {
- "Compose your message..."
+ val placeholder = when {
+ isDownloading -> {
+ val percent = downloadPercent?.let { " ($it%)" } ?: ""
+ "Downloading model...$percent"
+ }
+ isAttachmentDownloadBlocked -> {
+ val percent = attachmentDownloadPercent?.let { " ($it%)" } ?: ""
+ "Downloading attachments...$percent"
+ }
+ else -> "Compose your message..."
}
Column(
@@ -675,33 +687,15 @@ private fun MessageInput(
Spacer(modifier = Modifier.width(EnsuSpacing.sm.dp))
if (editingMessage == null) {
- Box {
- IconButton(
- onClick = { showMenu = true },
- enabled = !isGenerating && !isDownloading,
- modifier = Modifier.size(36.dp)
- ) {
- Icon(
- imageVector = Icons.Outlined.AttachFile,
- contentDescription = "Attach"
- )
- }
- DropdownMenu(expanded = showMenu, onDismissRequest = { showMenu = false }) {
- DropdownMenuItem(
- text = { Text(text = "Image") },
- onClick = {
- showMenu = false
- onAttachmentSelected(AttachmentType.Image)
- }
- )
- DropdownMenuItem(
- text = { Text(text = "Document") },
- onClick = {
- showMenu = false
- onAttachmentSelected(AttachmentType.Document)
- }
- )
- }
+ IconButton(
+ onClick = { onAttachmentSelected(AttachmentType.Image) },
+ enabled = !isGenerating && !isDownloading && !isAttachmentDownloadBlocked,
+ modifier = Modifier.size(36.dp)
+ ) {
+ Icon(
+ imageVector = Icons.Outlined.AttachFile,
+ contentDescription = "Attach"
+ )
}
}
@@ -709,7 +703,7 @@ private fun MessageInput(
IconButton(
onClick = if (isGenerating) onStop else onSend,
- enabled = !isDownloading && (isGenerating || canSend),
+ enabled = isGenerating || (!isDownloading && !isAttachmentDownloadBlocked && canSend),
modifier = Modifier.size(36.dp)
) {
val icon = when {
diff --git a/mobile/native/android/apps/ensu/app-ui/src/main/java/io/ente/ensu/chat/SessionDrawer.kt b/mobile/native/android/apps/ensu/app-ui/src/main/java/io/ente/ensu/chat/SessionDrawer.kt
index 017e3eb772..e60d5941d6 100644
--- a/mobile/native/android/apps/ensu/app-ui/src/main/java/io/ente/ensu/chat/SessionDrawer.kt
+++ b/mobile/native/android/apps/ensu/app-ui/src/main/java/io/ente/ensu/chat/SessionDrawer.kt
@@ -40,6 +40,7 @@ import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
+import io.ente.ensu.components.EnsuLogo
import io.ente.ensu.designsystem.EnsuColor
import io.ente.ensu.designsystem.EnsuCornerRadius
import io.ente.ensu.designsystem.EnsuSpacing
@@ -55,6 +56,7 @@ fun SessionDrawer(
userEmail: String?,
onNewChat: () -> Unit,
onSelectSession: (ChatSession) -> Unit,
+ onDeleteSession: (ChatSession) -> Unit,
onSync: () -> Unit,
onOpenLogs: () -> Unit,
onOpenDeveloperSettings: () -> Unit,
@@ -93,7 +95,8 @@ fun SessionDrawer(
SessionGroups(
sessions = sessions,
selectedSessionId = selectedSessionId,
- onSelectSession = onSelectSession
+ onSelectSession = onSelectSession,
+ onDeleteSession = onDeleteSession
)
}
@@ -124,11 +127,7 @@ private fun DrawerHeader(
.padding(EnsuSpacing.lg.dp),
verticalArrangement = Arrangement.spacedBy(EnsuSpacing.md.dp)
) {
- Text(
- text = "ensu",
- style = EnsuTypography.h2.copy(letterSpacing = 1.sp),
- color = EnsuColor.textPrimary()
- )
+ EnsuLogo(height = 28.dp)
Row(
modifier = Modifier.fillMaxWidth(),
horizontalArrangement = Arrangement.spacedBy(EnsuSpacing.sm.dp),
@@ -219,7 +218,8 @@ private fun DrawerNewChat(onNewChat: () -> Unit) {
private fun SessionGroups(
sessions: List<ChatSession>,
selectedSessionId: String?,
- onSelectSession: (ChatSession) -> Unit
+ onSelectSession: (ChatSession) -> Unit,
+ onDeleteSession: (ChatSession) -> Unit
) {
val grouped = sessions.groupBy { sessionGroupLabel(it.updatedAtMillis) }
val order = listOf("TODAY", "YESTERDAY", "THIS WEEK", "LAST WEEK", "THIS MONTH", "OLDER")
@@ -245,7 +245,8 @@ private fun SessionGroups(
SessionTile(
session = session,
isSelected = session.id == selectedSessionId,
- onSelect = { onSelectSession(session) }
+ onSelect = { onSelectSession(session) },
+ onDelete = { onDeleteSession(session) }
)
}
}
@@ -257,7 +258,8 @@ private fun SessionGroups(
private fun SessionTile(
session: ChatSession,
isSelected: Boolean,
- onSelect: () -> Unit
+ onSelect: () -> Unit,
+ onDelete: () -> Unit
) {
Column(
modifier = Modifier
@@ -292,7 +294,7 @@ private fun SessionTile(
modifier = Modifier
.size(36.dp)
.clip(RoundedCornerShape(4.dp))
- .clickable(onClick = {}),
+ .clickable(onClick = onDelete),
contentAlignment = Alignment.Center
) {
Icon(
diff --git a/mobile/native/android/apps/ensu/app-ui/src/main/java/io/ente/ensu/components/AttachmentChip.kt b/mobile/native/android/apps/ensu/app-ui/src/main/java/io/ente/ensu/components/AttachmentChip.kt
index 187844e5e1..eaef0c827f 100644
--- a/mobile/native/android/apps/ensu/app-ui/src/main/java/io/ente/ensu/components/AttachmentChip.kt
+++ b/mobile/native/android/apps/ensu/app-ui/src/main/java/io/ente/ensu/components/AttachmentChip.kt
@@ -1,6 +1,7 @@
package io.ente.ensu.components
import androidx.compose.foundation.background
+import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
@@ -33,13 +34,21 @@ fun AttachmentChip(
size: String,
icon: ImageVector,
isUploading: Boolean,
- onDelete: (() -> Unit)? = null
+ onDelete: (() -> Unit)? = null,
+ onClick: (() -> Unit)? = null
) {
+ val clickModifier = if (onClick != null) {
+ Modifier.clickable(onClick = onClick)
+ } else {
+ Modifier
+ }
+
Row(
verticalAlignment = Alignment.CenterVertically,
modifier = Modifier
.widthIn(max = 220.dp)
.background(EnsuColor.fillFaint(), RoundedCornerShape(EnsuCornerRadius.input.dp))
+ .then(clickModifier)
.padding(horizontal = 10.dp, vertical = 6.dp)
) {
Icon(
diff --git a/mobile/native/android/apps/ensu/app-ui/src/main/java/io/ente/ensu/components/EnsuLogo.kt b/mobile/native/android/apps/ensu/app-ui/src/main/java/io/ente/ensu/components/EnsuLogo.kt
new file mode 100644
index 0000000000..2c3f673283
--- /dev/null
+++ b/mobile/native/android/apps/ensu/app-ui/src/main/java/io/ente/ensu/components/EnsuLogo.kt
@@ -0,0 +1,45 @@
+package io.ente.ensu.components
+
+import androidx.compose.foundation.Image
+import androidx.compose.foundation.layout.Box
+import androidx.compose.foundation.layout.aspectRatio
+import androidx.compose.foundation.layout.height
+import androidx.compose.foundation.layout.padding
+import androidx.compose.runtime.Composable
+import androidx.compose.ui.Alignment
+import androidx.compose.ui.Modifier
+import androidx.compose.ui.graphics.Color
+import androidx.compose.ui.graphics.ColorFilter
+import androidx.compose.ui.layout.ContentScale
+import androidx.compose.ui.res.painterResource
+import androidx.compose.ui.unit.Dp
+import androidx.compose.ui.unit.dp
+import io.ente.ensu.R
+import io.ente.ensu.designsystem.EnsuColor
+
+@Composable
+fun EnsuLogo(
+ modifier: Modifier = Modifier,
+ height: Dp = 24.dp,
+ horizontalPadding: Dp = 4.dp,
+ verticalPadding: Dp = 2.dp,
+ tint: Color = EnsuColor.textPrimary()
+) {
+ val imageHeight = height - verticalPadding * 2
+ Box(
+ modifier = modifier
+ .height(height)
+ .padding(horizontal = horizontalPadding, vertical = verticalPadding),
+ contentAlignment = Alignment.Center
+ ) {
+ Image(
+ painter = painterResource(R.drawable.ensu_logo),
+ contentDescription = "Ensu",
+ modifier = Modifier
+ .height(imageHeight)
+ .aspectRatio(135f / 40f),
+ contentScale = ContentScale.Fit,
+ colorFilter = ColorFilter.tint(tint)
+ )
+ }
+}
diff --git a/mobile/native/android/apps/ensu/app-ui/src/main/java/io/ente/ensu/designsystem/EnsuIcon.kt b/mobile/native/android/apps/ensu/app-ui/src/main/java/io/ente/ensu/designsystem/EnsuIcon.kt
new file mode 100644
index 0000000000..0b87afd796
--- /dev/null
+++ b/mobile/native/android/apps/ensu/app-ui/src/main/java/io/ente/ensu/designsystem/EnsuIcon.kt
@@ -0,0 +1,14 @@
+package io.ente.ensu.designsystem
+
+import androidx.compose.ui.unit.dp
+
+object EnsuIcon {
+ val tiny = 12.dp
+ val small = 16.dp
+ val medium = 20.dp
+ val large = 24.dp
+ val extraLarge = 28.dp
+ val buttonSmall = 28.dp
+ val buttonMedium = 36.dp
+ val button = 40.dp
+}
diff --git a/mobile/native/android/apps/ensu/app-ui/src/main/java/io/ente/ensu/designsystem/EnsuTheme.kt b/mobile/native/android/apps/ensu/app-ui/src/main/java/io/ente/ensu/designsystem/EnsuTheme.kt
index 01e13fee3c..b1b0031f15 100644
--- a/mobile/native/android/apps/ensu/app-ui/src/main/java/io/ente/ensu/designsystem/EnsuTheme.kt
+++ b/mobile/native/android/apps/ensu/app-ui/src/main/java/io/ente/ensu/designsystem/EnsuTheme.kt
@@ -103,8 +103,8 @@ object EnsuCornerRadius {
object EnsuTypography {
private val serifFamily = FontFamily(
- Font(R.font.cormorant_garamond_variable, FontWeight.Medium),
- Font(R.font.cormorant_garamond_variable, FontWeight.SemiBold)
+ Font(R.font.dm_serif_text_regular, FontWeight.Medium),
+ Font(R.font.dm_serif_text_regular, FontWeight.SemiBold)
)
private val uiFamily = FontFamily(
@@ -114,11 +114,7 @@ object EnsuTypography {
Font(R.font.inter_bold, FontWeight.Bold)
)
- private val messageFamily = FontFamily(
- Font(R.font.sourceserif4_variable, FontWeight.Normal),
- Font(R.font.sourceserif4_variable, FontWeight.SemiBold),
- Font(R.font.sourceserif4_variable, FontWeight.Bold)
- )
+ private val messageFamily = uiFamily
private val codeFamily = FontFamily(
Font(R.font.jetbrainsmono_regular, FontWeight.Normal)
diff --git a/mobile/native/android/apps/ensu/app-ui/src/main/res/drawable/ensu_logo.xml b/mobile/native/android/apps/ensu/app-ui/src/main/res/drawable/ensu_logo.xml
new file mode 100644
index 0000000000..53531d0339
--- /dev/null
+++ b/mobile/native/android/apps/ensu/app-ui/src/main/res/drawable/ensu_logo.xml
@@ -0,0 +1,22 @@
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="135dp"
+ android:height="40dp"
+ android:viewportWidth="135"
+ android:viewportHeight="40">
+ <path
+ android:fillColor="#FFFFFF"
+ android:fillType="evenOdd"
+ android:pathData="M58.1279 0.714844C59.5808 0.71489 60.8058 1.23858 61.623 2.37598C62.3964 3.45228 62.705 4.94425 62.7051 6.69336L62.6982 7.12109C62.6672 8.1704 62.5277 9.59137 62.29 11.3633L62.2891 11.373L60.2979 25.1289C59.9072 27.8639 59.7178 29.9853 59.7178 31.5137C59.7178 32.0145 59.7818 32.2914 59.834 32.4238C60.2542 32.3861 60.9226 32.0663 61.8555 31.0566C62.8205 30.0121 63.9186 28.3957 65.1436 26.1641L65.6523 25.2363L66.5498 25.7979C67.1673 26.1838 67.8184 26.7714 67.8975 27.6162L67.9053 27.7891L67.8994 27.9912C67.8465 29.0046 67.4017 30.0546 66.709 31.1123C66.0556 32.1098 65.137 33.1812 63.9746 34.3262L63.4619 34.8213C62.0644 36.1433 60.763 37.1667 59.5605 37.8643C58.3656 38.5575 57.2026 38.9677 56.0996 38.9678C54.8677 38.9678 53.8164 38.5052 53.1211 37.5068C52.4715 36.5741 52.2227 35.299 52.2227 33.8369C52.2227 31.7496 52.4891 28.9039 53.0078 25.3223L54.2979 16.3975C54.7131 13.5153 54.915 11.271 54.915 9.64453C54.915 8.75862 54.7549 8.27161 54.5869 8.03027C54.4647 7.85485 54.2894 7.7305 53.8867 7.73047C51.219 7.73047 48.2817 9.55102 45.0947 13.752L45.0938 13.751C41.9726 17.8729 40.1689 22.2784 39.6494 26.9766V26.9785L38.5869 36.4189L30.9912 39.5283L31.5762 34.0986V34.0928L31.8711 31.5127L33.7891 14.4004L34.0098 12.4551C34.1554 10.9485 34.2256 9.75725 34.2256 8.87012C34.2256 8.13471 34.1283 7.73139 34.0361 7.54688C34.0288 7.5322 34.0203 7.52118 34.0146 7.51172C33.4918 7.52323 32.7914 7.82795 31.9043 8.76465C31.0097 9.70928 30.0372 11.1801 29 13.2305L28.4355 14.3467L27.4707 13.5498C27.1484 13.2836 26.863 12.9999 26.6514 12.6963C26.442 12.3959 26.2598 12.0096 26.2598 11.5615C26.2599 10.5368 26.7169 9.46822 27.4336 8.39648C28.1609 7.30894 29.224 6.1167 30.5928 4.82324C31.974 3.51743 33.2402 2.5062 34.3877 1.81641C35.5217 1.13475 36.625 0.714948 37.6592 0.714844C38.9452 0.714844 40.0642 1.1387 40.8262 2.11328C41.5514 3.04098 41.831 4.31647 41.8311 5.77148C41.8311 6.51086 41.7651 7.47261 41.6406 8.64258L41.3467 11.623L41.3457 11.6328L41.3447 11.6416L41.1914 12.9443C43.5116 9.92831 45.9957 7.33834 48.6455 5.18066C52.1588 2.31539 55.3376 0.714844 58.1279 0.714844ZM63.6572 33.2275C63.6763 33.2087 63.6953 33.19 63.7139 33.1709L63.7422 33.1416C63.7142 33.1704 63.6855 33.1986 63.6572 33.2275ZM59.0498 26.9424C59.0333 27.0805 59.0192 27.2171 59.0039 27.3516C59.0235 27.1798 59.0429 27.0049 59.0645 26.8271L59.0498 26.9424ZM32.0732 7.26758C32.1539 7.20702 32.2352 7.14997 32.3154 7.09668C32.3205 7.09333 32.325 7.08926 32.3301 7.08594C32.2447 7.14227 32.1592 7.20299 32.0732 7.26758ZM32.457 7.00488C32.4358 7.01787 32.4148 7.03142 32.3936 7.04492C32.4748 6.99326 32.5559 6.94553 32.6367 6.90137L32.457 7.00488Z" />
+ <path
+ android:fillColor="#FFFFFF"
+ android:fillType="evenOdd"
+ android:pathData="M19.9561 0.714844C21.6289 0.714875 23.0624 1.16738 24.0625 2.24121C25.0499 3.30159 25.455 4.79855 25.4551 6.5459C25.4551 10.5148 23.5174 14.2854 19.8809 17.8457C16.4514 21.226 12.3048 23.6248 7.46387 25.0537C7.75489 27.4922 8.39211 29.2302 9.29004 30.3691C10.2461 31.5818 11.5703 32.21 13.3916 32.21C16.9868 32.2098 20.0934 29.9482 22.6377 24.8359L23.1484 23.8096L24.0957 24.4541C24.8884 24.9932 25.4549 25.7586 25.4551 26.7559C25.4551 27.4256 25.1313 28.1422 24.7207 28.8223C24.2877 29.5393 23.6593 30.3724 22.8555 31.3145L22.8516 31.3193C18.5644 36.2833 14.1574 38.9677 9.62988 38.9678C6.98921 38.9678 4.76115 37.968 3.00391 36.0156L2.6582 35.6123C0.861924 33.4077 6.04278e-05 30.6254 0 27.3467C0 21.4755 2.21782 15.6038 6.53906 9.75C10.8478 3.92212 15.312 0.714844 19.9561 0.714844ZM7.05469 19.9844C7.08204 19.9918 7.10957 19.9979 7.13672 20.0049C7.02486 19.9761 6.91111 19.9447 6.7959 19.9092L7.05469 19.9844ZM15.5303 7.50977C13.8793 7.50979 12.2286 8.48039 10.6045 10.8701C9.14101 13.0342 8.14218 15.7641 7.64062 19.0957C7.95096 19.1606 8.23212 19.1914 8.48633 19.1914C11.3125 19.1914 13.7547 18.3318 15.8564 16.6143C17.9564 14.8981 18.9189 12.9772 18.9189 10.8242C18.9189 9.54443 18.5952 8.7669 18.1211 8.30078C17.6439 7.83159 16.8432 7.50977 15.5303 7.50977ZM15.4424 18.1572C15.4992 18.1196 15.5579 18.0846 15.6143 18.0459L15.6416 18.0264C15.5761 18.0716 15.5085 18.1134 15.4424 18.1572ZM19.9189 10.8242L19.915 10.5586C19.9143 10.5363 19.912 10.5142 19.9111 10.4922C19.9156 10.6007 19.9189 10.7113 19.9189 10.8242ZM12.1484 7.71094C11.9119 7.88895 11.6787 8.08713 11.4482 8.30469L11.7969 7.99316C11.9135 7.89441 12.0303 7.79983 12.1484 7.71094Z" />
+ <path
+ android:fillColor="#FFFFFF"
+ android:fillType="evenOdd"
+ android:pathData="M85.3828 0.714844C87.2121 0.714844 89.1673 1.01467 91.2422 1.59961L92.1387 1.86816L93.7803 2.38672L87.4785 8.21484L86.8115 7.71484C85.1121 6.44031 83.2439 5.8125 81.1787 5.8125C79.9535 5.81254 79.2205 6.07279 78.8047 6.41992C78.4236 6.73824 78.1592 7.25686 78.1592 8.16895L78.1709 8.375C78.2288 8.88722 78.4994 9.61542 79.1191 10.5938C79.7265 11.5525 80.6188 12.673 81.8125 13.959L82.3428 14.5205L82.3506 14.5283L84.6299 16.9551C86.3564 18.7567 87.6843 20.4155 88.585 21.9297C89.48 23.4344 89.9971 24.8698 89.9971 26.2031L89.9922 26.5273C89.8903 29.8616 88.2131 32.7596 85.1602 35.207L85.1562 35.2109C82.0002 37.7148 78.3497 38.9678 74.2451 38.9678C71.5057 38.9677 68.9196 38.347 66.5 37.1084L66.0186 36.8516L64.7236 36.1387L71.6797 30.4434L72.3193 31.124C74.0404 32.9553 76.1822 33.87 78.8184 33.8701C80.443 33.8701 81.477 33.4776 82.1074 32.8691C82.7313 32.267 83.1289 31.2886 83.1289 29.7432C83.1288 29.0644 82.8305 28.1184 82.0605 26.8643C81.3001 25.6256 80.1348 24.1742 78.5391 22.5059L76.4395 20.333L76.4355 20.3291C74.8684 18.6867 73.6606 17.1683 72.8398 15.7764C72.0243 14.3932 71.5489 13.0642 71.5488 11.8203C71.5488 8.62943 72.9456 5.95433 75.6172 3.84375L75.6211 3.84082C78.3053 1.7413 81.5798 0.71492 85.3828 0.714844ZM73.7314 37.96L74.2451 37.9678C73.9059 37.9678 73.5693 37.9567 73.2354 37.9365C73.4001 37.9465 73.5654 37.9549 73.7314 37.96ZM72.6387 10.5166C72.6302 10.5765 72.6235 10.6369 72.6162 10.6973C72.6338 10.5515 72.6541 10.4069 72.6787 10.2637L72.6387 10.5166ZM73.1572 8.56934C73.1459 8.59744 73.136 8.62608 73.125 8.6543L73.208 8.4502L73.1572 8.56934Z" />
+ <path
+ android:fillColor="#FFFFFF"
+ android:fillType="evenOdd"
+ android:pathData="M130.538 1.76562C129.856 4.59298 129.346 7.10548 129.007 9.30566L129.008 9.30664L126.794 24.7217C126.672 25.648 126.576 26.426 126.503 27.0557L126.502 27.0674L126.244 29.085C126.097 30.3392 126.03 31.1726 126.03 31.624C126.03 31.8447 126.046 32.0131 126.068 32.1357C126.073 32.1603 126.079 32.1818 126.084 32.2012C126.703 32.1435 127.455 31.7637 128.342 30.7998C129.306 29.7516 130.328 28.1213 131.39 25.8525L131.857 24.8545L132.806 25.417C133.451 25.7998 134.192 26.3961 134.282 27.2773L134.291 27.457L134.286 27.6084C134.261 27.9616 134.152 28.3164 134.016 28.6475C133.854 29.0383 133.624 29.4671 133.34 29.9277C132.772 30.848 131.939 31.9698 130.858 33.2861L130.859 33.2871C127.944 36.8753 125.017 38.9677 122.08 38.9678C120.936 38.9678 119.934 38.5677 119.259 37.6611C118.625 36.8098 118.388 35.6532 118.388 34.3535C118.388 33.5267 118.481 32.4561 118.655 31.1592V31.1562L119.061 28.2061C119.153 27.5406 119.229 26.9638 119.296 26.4785C117.073 29.4082 114.654 31.9942 112.034 34.2295C108.501 37.2437 105.394 38.9677 102.792 38.9678C101.331 38.9678 100.09 38.4653 99.2539 37.3506C98.4584 36.2899 98.1406 34.8184 98.1406 33.0996C98.1406 31.8319 98.3071 29.8025 98.627 27.0469L99.9541 14.9561L99.9561 14.9404L99.958 14.9238C99.9768 14.7921 100.036 14.1247 100.136 12.8486L100.137 12.835L100.357 10.4375L100.358 10.4268C100.43 9.73938 100.464 9.1348 100.464 8.61133C100.464 7.96088 100.366 7.63408 100.291 7.50195C100.284 7.48925 100.277 7.48012 100.272 7.47363C100.266 7.47309 100.258 7.47266 100.247 7.47266C99.7051 7.4727 98.9782 7.77938 98.0557 8.74121C97.1429 9.69293 96.1493 11.1737 95.0879 13.2363L94.5322 14.3164L93.5791 13.5635C92.9787 13.0894 92.498 12.4367 92.498 11.5986C92.4981 10.5533 92.9551 9.46825 93.6807 8.37988C94.4153 7.27788 95.4885 6.07778 96.8711 4.7832L96.875 4.78027C98.2698 3.48604 99.5527 2.48474 100.72 1.80176C101.875 1.12547 102.996 0.714844 104.046 0.714844C105.322 0.714871 106.417 1.17054 107.15 2.17773C107.841 3.12585 108.106 4.42622 108.106 5.91895C108.106 6.62967 108.054 7.44324 107.953 8.35352L107.952 8.3584L107.621 11.1885L107.29 14.2871L107.289 14.292L106.109 24.8389C105.917 26.5961 105.82 28.3789 105.82 30.1865L105.827 30.4521C105.857 31.0331 105.981 31.3463 106.095 31.5C106.183 31.6191 106.324 31.7305 106.701 31.7305C107.809 31.7305 109.085 31.2746 110.547 30.208C112.009 29.1418 113.598 27.5076 115.311 25.2646L115.312 25.2617C118.752 20.7882 120.74 16.4207 121.349 12.1572L122.689 2.80957L130.965 0L130.538 1.76562ZM129.56 33.2822C129.532 33.3146 129.504 33.3469 129.477 33.3789C129.499 33.3526 129.523 33.3273 129.546 33.3008C129.562 33.2818 129.577 33.2615 129.593 33.2422C129.581 33.2554 129.571 33.2691 129.56 33.2822ZM126.111 33.2031L126.308 33.1836C126.32 33.1819 126.332 33.1784 126.344 33.1758C126.266 33.1875 126.189 33.1978 126.111 33.2031ZM125.311 32.9072C125.318 32.9173 125.326 32.926 125.334 32.9355C125.305 32.8984 125.277 32.8582 125.252 32.8135L125.311 32.9072ZM129.078 31.4766L129.277 31.2539C129.286 31.2445 129.293 31.2345 129.301 31.2246C129.226 31.3112 129.153 31.3957 129.078 31.4766ZM132.583 26.4639C132.565 26.4507 132.548 26.4365 132.529 26.4238C132.518 26.4163 132.506 26.4098 132.495 26.4023C132.526 26.4225 132.554 26.4437 132.583 26.4639Z" />
+</vector>
diff --git a/mobile/native/android/apps/ensu/app-ui/src/main/res/drawable/ic_launcher_foreground.png b/mobile/native/android/apps/ensu/app-ui/src/main/res/drawable/ic_launcher_foreground.png
new file mode 100644
index 0000000000..65a2f3dd6d
Binary files /dev/null and b/mobile/native/android/apps/ensu/app-ui/src/main/res/drawable/ic_launcher_foreground.png differ
diff --git a/mobile/native/android/apps/ensu/app-ui/src/main/res/drawable/ic_launcher_foreground.xml b/mobile/native/android/apps/ensu/app-ui/src/main/res/drawable/ic_launcher_foreground.xml
deleted file mode 100644
index bc97717d15..0000000000
--- a/mobile/native/android/apps/ensu/app-ui/src/main/res/drawable/ic_launcher_foreground.xml
+++ /dev/null
@@ -1,12 +0,0 @@
-<vector xmlns:android="http://schemas.android.com/apk/res/android"
- android:width="108dp"
- android:height="108dp"
- android:viewportWidth="108"
- android:viewportHeight="108">
- <path
- android:fillColor="#9A7E0A"
- android:pathData="M54,10a44,44 0 1,0 0,88a44,44 0 1,0 0,-88z" />
- <path
- android:fillColor="#F8F5F0"
- android:pathData="M38,34h32v8h-22v8h20v8h-20v8h22v8h-32z" />
-</vector>
diff --git a/mobile/native/android/apps/ensu/app-ui/src/main/res/font/dm_serif_text_regular.ttf b/mobile/native/android/apps/ensu/app-ui/src/main/res/font/dm_serif_text_regular.ttf
new file mode 100644
index 0000000000..a8adbe2a9b
Binary files /dev/null and b/mobile/native/android/apps/ensu/app-ui/src/main/res/font/dm_serif_text_regular.ttf differ
diff --git a/mobile/native/android/apps/ensu/app-ui/src/main/res/mipmap-anydpi-v26/ic_launcher.xml b/mobile/native/android/apps/ensu/app-ui/src/main/res/mipmap-anydpi-v26/ic_launcher.xml
new file mode 100644
index 0000000000..a8a8fa5518
--- /dev/null
+++ b/mobile/native/android/apps/ensu/app-ui/src/main/res/mipmap-anydpi-v26/ic_launcher.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="utf-8"?>
+<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
+ <background android:drawable="@color/ic_launcher_background" />
+ <foreground android:drawable="@drawable/ic_launcher_foreground" />
+</adaptive-icon>
diff --git a/mobile/native/android/apps/ensu/app-ui/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml b/mobile/native/android/apps/ensu/app-ui/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml
new file mode 100644
index 0000000000..a8a8fa5518
--- /dev/null
+++ b/mobile/native/android/apps/ensu/app-ui/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="utf-8"?>
+<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
+ <background android:drawable="@color/ic_launcher_background" />
+ <foreground android:drawable="@drawable/ic_launcher_foreground" />
+</adaptive-icon>
diff --git a/mobile/native/android/apps/ensu/app-ui/src/main/res/mipmap-hdpi/ic_launcher.png b/mobile/native/android/apps/ensu/app-ui/src/main/res/mipmap-hdpi/ic_launcher.png
new file mode 100644
index 0000000000..1376c79c67
Binary files /dev/null and b/mobile/native/android/apps/ensu/app-ui/src/main/res/mipmap-hdpi/ic_launcher.png differ
diff --git a/mobile/native/android/apps/ensu/app-ui/src/main/res/mipmap-hdpi/ic_launcher_round.png b/mobile/native/android/apps/ensu/app-ui/src/main/res/mipmap-hdpi/ic_launcher_round.png
new file mode 100644
index 0000000000..1376c79c67
Binary files /dev/null and b/mobile/native/android/apps/ensu/app-ui/src/main/res/mipmap-hdpi/ic_launcher_round.png differ
diff --git a/mobile/native/android/apps/ensu/app-ui/src/main/res/mipmap-mdpi/ic_launcher.png b/mobile/native/android/apps/ensu/app-ui/src/main/res/mipmap-mdpi/ic_launcher.png
new file mode 100644
index 0000000000..8c9cd95b35
Binary files /dev/null and b/mobile/native/android/apps/ensu/app-ui/src/main/res/mipmap-mdpi/ic_launcher.png differ
diff --git a/mobile/native/android/apps/ensu/app-ui/src/main/res/mipmap-mdpi/ic_launcher_round.png b/mobile/native/android/apps/ensu/app-ui/src/main/res/mipmap-mdpi/ic_launcher_round.png
new file mode 100644
index 0000000000..5bbd1a3aae
Binary files /dev/null and b/mobile/native/android/apps/ensu/app-ui/src/main/res/mipmap-mdpi/ic_launcher_round.png differ
diff --git a/mobile/native/android/apps/ensu/app-ui/src/main/res/mipmap-xhdpi/ic_launcher.png b/mobile/native/android/apps/ensu/app-ui/src/main/res/mipmap-xhdpi/ic_launcher.png
new file mode 100644
index 0000000000..400b56145d
Binary files /dev/null and b/mobile/native/android/apps/ensu/app-ui/src/main/res/mipmap-xhdpi/ic_launcher.png differ
diff --git a/mobile/native/android/apps/ensu/app-ui/src/main/res/mipmap-xhdpi/ic_launcher_round.png b/mobile/native/android/apps/ensu/app-ui/src/main/res/mipmap-xhdpi/ic_launcher_round.png
new file mode 100644
index 0000000000..400b56145d
Binary files /dev/null and b/mobile/native/android/apps/ensu/app-ui/src/main/res/mipmap-xhdpi/ic_launcher_round.png differ
diff --git a/mobile/native/android/apps/ensu/app-ui/src/main/res/mipmap-xxhdpi/ic_launcher.png b/mobile/native/android/apps/ensu/app-ui/src/main/res/mipmap-xxhdpi/ic_launcher.png
new file mode 100644
index 0000000000..e89de9975c
Binary files /dev/null and b/mobile/native/android/apps/ensu/app-ui/src/main/res/mipmap-xxhdpi/ic_launcher.png differ
diff --git a/mobile/native/android/apps/ensu/app-ui/src/main/res/mipmap-xxhdpi/ic_launcher_round.png b/mobile/native/android/apps/ensu/app-ui/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
new file mode 100644
index 0000000000..e89de9975c
Binary files /dev/null and b/mobile/native/android/apps/ensu/app-ui/src/main/res/mipmap-xxhdpi/ic_launcher_round.png differ
diff --git a/mobile/native/android/apps/ensu/app-ui/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/mobile/native/android/apps/ensu/app-ui/src/main/res/mipmap-xxxhdpi/ic_launcher.png
new file mode 100644
index 0000000000..041b9bc5cb
Binary files /dev/null and b/mobile/native/android/apps/ensu/app-ui/src/main/res/mipmap-xxxhdpi/ic_launcher.png differ
diff --git a/mobile/native/android/apps/ensu/app-ui/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png b/mobile/native/android/apps/ensu/app-ui/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
new file mode 100644
index 0000000000..041b9bc5cb
Binary files /dev/null and b/mobile/native/android/apps/ensu/app-ui/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png differ
diff --git a/mobile/native/android/apps/ensu/app-ui/src/main/res/values/colors.xml b/mobile/native/android/apps/ensu/app-ui/src/main/res/values/colors.xml
index 37a54cf429..ff2283b833 100644
--- a/mobile/native/android/apps/ensu/app-ui/src/main/res/values/colors.xml
+++ b/mobile/native/android/apps/ensu/app-ui/src/main/res/values/colors.xml
@@ -1,3 +1,3 @@
<resources>
- <color name="ic_launcher_background">#F8F5F0</color>
+ <color name="ic_launcher_background">#343434</color>
</resources>
diff --git a/mobile/native/android/apps/ensu/app-ui/src/main/res/xml/file_paths.xml b/mobile/native/android/apps/ensu/app-ui/src/main/res/xml/file_paths.xml
new file mode 100644
index 0000000000..bb5b4fbc11
--- /dev/null
+++ b/mobile/native/android/apps/ensu/app-ui/src/main/res/xml/file_paths.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8"?>
+<paths xmlns:android="http://schemas.android.com/apk/res/android">
+ <files-path
+ name="attachments"
+ path="attachments/" />
+</paths>
diff --git a/mobile/native/android/apps/ensu/data/src/main/java/io/ente/ensu/data/chat/RustChatRepository.kt b/mobile/native/android/apps/ensu/data/src/main/java/io/ente/ensu/data/chat/RustChatRepository.kt
index d50c66530c..e026828b03 100644
--- a/mobile/native/android/apps/ensu/data/src/main/java/io/ente/ensu/data/chat/RustChatRepository.kt
+++ b/mobile/native/android/apps/ensu/data/src/main/java/io/ente/ensu/data/chat/RustChatRepository.kt
@@ -10,6 +10,7 @@ import io.ente.ensu.domain.model.ChatSession
import io.ente.ensu.domain.model.MessageAuthor
import io.ente.labs.llmchat_db.AttachmentKind
import io.ente.labs.llmchat_db.AttachmentMeta
+import io.ente.labs.llmchat_db.DbException
import io.ente.labs.llmchat_db.LlmChatDb
import java.io.File
@@ -19,22 +20,20 @@ class RustChatRepository(
) : ChatRepository {
private val attachmentsDir = File(context.filesDir, "attachments")
- private val db: LlmChatDb
+ private val mainDbFile = File(context.filesDir, "llmchat.db")
+ private val attachmentsDbFile = File(context.filesDir, "llmchat_attachments.db")
+ private val dbKey = credentialStore.getOrCreateChatDbKey()
+ private var db: LlmChatDb = openDb()
init {
if (!attachmentsDir.exists()) {
attachmentsDir.mkdirs()
}
-
- val mainDb = File(context.filesDir, "llmchat.db").absolutePath
- val attachmentsDb = File(context.filesDir, "llmchat_attachments.db").absolutePath
- val key = credentialStore.getOrCreateChatDbKey()
- db = LlmChatDb.open(mainDb, attachmentsDb, key)
}
- override fun listSessions(): List<ChatSession> {
+ override fun listSessions(): List<ChatSession> = withDbRecovery {
val sessions = db.listSessions()
- return sessions.map { session ->
+ sessions.map { session ->
val lastMessage = runCatching { db.getMessages(session.uuid) }.getOrNull()?.lastOrNull()?.text
ChatSession(
id = session.uuid,
@@ -45,9 +44,9 @@ class RustChatRepository(
}
}
- override fun createSession(title: String): ChatSession {
+ override fun createSession(title: String): ChatSession = withDbRecovery {
val session = db.createSession(title)
- return ChatSession(
+ ChatSession(
id = session.uuid,
title = session.title,
lastMessagePreview = null,
@@ -55,12 +54,12 @@ class RustChatRepository(
)
}
- override fun deleteSession(sessionId: String) {
+ override fun deleteSession(sessionId: String) = withDbRecovery {
db.deleteSession(sessionId)
}
- override fun getMessages(sessionId: String): List<ChatMessage> {
- return db.getMessages(sessionId).map { message ->
+ override fun getMessages(sessionId: String): List<ChatMessage> = withDbRecovery {
+ db.getMessages(sessionId).map { message ->
ChatMessage(
id = message.uuid,
sessionId = message.sessionUuid,
@@ -94,7 +93,7 @@ class RustChatRepository(
author: MessageAuthor,
text: String,
attachments: List<Attachment>
- ): ChatMessage {
+ ): ChatMessage = withDbRecovery {
val meta = attachments.map { att ->
AttachmentMeta(
id = att.id,
@@ -115,7 +114,7 @@ class RustChatRepository(
attachments = meta
)
- return ChatMessage(
+ ChatMessage(
id = message.uuid,
sessionId = message.sessionUuid,
parentId = message.parentMessageUuid,
@@ -126,7 +125,44 @@ class RustChatRepository(
)
}
- override fun updateMessageText(messageId: String, text: String) {
+ override fun updateMessageText(messageId: String, text: String) = withDbRecovery {
db.updateMessageText(messageId, text)
}
+
+ private fun openDb(): LlmChatDb {
+ return LlmChatDb.open(
+ mainDbFile.absolutePath,
+ attachmentsDbFile.absolutePath,
+ dbKey
+ )
+ }
+
+ private fun <T> withDbRecovery(block: () -> T): T {
+ return try {
+ block()
+ } catch (error: DbException) {
+ if (shouldResetDb(error)) {
+ resetDb()
+ block()
+ } else {
+ throw error
+ }
+ }
+ }
+
+ private fun shouldResetDb(error: DbException): Boolean {
+ val message = when (error) {
+ is DbException.Message -> error.v1
+ else -> error.message.orEmpty()
+ }.lowercase()
+ return message.contains("stream pull failed") ||
+ message.contains("invalid blob") ||
+ message.contains("invalid encrypted")
+ }
+
+ private fun resetDb() {
+ mainDbFile.delete()
+ attachmentsDbFile.delete()
+ db = openDb()
+ }
}
diff --git a/mobile/native/android/apps/ensu/data/src/main/java/io/ente/ensu/data/chat/RustChatSyncRepository.kt b/mobile/native/android/apps/ensu/data/src/main/java/io/ente/ensu/data/chat/RustChatSyncRepository.kt
new file mode 100644
index 0000000000..6aba135a86
--- /dev/null
+++ b/mobile/native/android/apps/ensu/data/src/main/java/io/ente/ensu/data/chat/RustChatSyncRepository.kt
@@ -0,0 +1,104 @@
+package io.ente.ensu.data.chat
+
+import android.content.Context
+import io.ente.ensu.data.EndpointPreferencesDataStore
+import io.ente.ensu.data.network.NetworkConfiguration
+import io.ente.ensu.data.storage.CredentialStore
+import io.ente.ensu.domain.chat.ChatSyncRepository
+import io.ente.labs.llmchat_sync.LlmChatSync
+import io.ente.labs.llmchat_sync.SyncAuth
+import io.ente.labs.llmchat_sync.SyncException
+import kotlinx.coroutines.Dispatchers
+import kotlinx.coroutines.flow.first
+import kotlinx.coroutines.withContext
+import java.io.File
+
+class RustChatSyncRepository(
+ private val context: Context,
+ private val credentialStore: CredentialStore,
+ private val endpointPreferences: EndpointPreferencesDataStore
+) : ChatSyncRepository {
+
+ private val syncEngine: LlmChatSync by lazy { buildSyncEngine() }
+
+ override suspend fun sync() {
+ withContext(Dispatchers.IO) {
+ try {
+ syncEngine.sync(buildAuth())
+ } catch (err: Throwable) {
+ throw IllegalStateException(syncErrorMessage(err), err)
+ }
+ }
+ }
+
+ override suspend fun downloadAttachment(attachmentId: String, sessionId: String): Boolean {
+ return withContext(Dispatchers.IO) {
+ syncEngine.downloadAttachment(attachmentId, sessionId, buildAuth())
+ }
+ }
+
+ private fun buildSyncEngine(): LlmChatSync {
+ val baseDir = File(context.filesDir, "llmchat")
+ if (!baseDir.exists()) baseDir.mkdirs()
+
+ val encryptedAttachmentsDir = File(baseDir, "chat_attachments_encrypted")
+ if (!encryptedAttachmentsDir.exists()) encryptedAttachmentsDir.mkdirs()
+
+ val metaDir = File(baseDir, "sync_meta")
+ if (!metaDir.exists()) metaDir.mkdirs()
+
+ val mainDb = File(context.filesDir, "llmchat.db").absolutePath
+ val attachmentsDb = File(context.filesDir, "llmchat_attachments.db").absolutePath
+ val dbKey = credentialStore.getOrCreateChatDbKey()
+ val plaintextDir = File(context.filesDir, "attachments")
+ if (!plaintextDir.exists()) plaintextDir.mkdirs()
+
+ return LlmChatSync.open(
+ mainDbPath = mainDb,
+ attachmentsDbPath = attachmentsDb,
+ dbKey = dbKey,
+ attachmentsDir = encryptedAttachmentsDir.absolutePath,
+ metaDir = metaDir.absolutePath,
+ plaintextDir = plaintextDir.absolutePath
+ )
+ }
+
+ private suspend fun buildAuth(): SyncAuth {
+ val endpoint = endpointPreferences.endpointFlow.first()
+ val baseUrl = endpoint ?: NetworkConfiguration.default.apiEndpoint.toString()
+ val token = credentialStore.getToken()?.let(::normalizeToken)
+ ?: throw IllegalStateException("Missing auth token")
+ val masterKey = credentialStore.getMasterKey()
+ ?: throw IllegalStateException("Missing master key")
+
+ val clientVersion = runCatching {
+ context.packageManager.getPackageInfo(context.packageName, 0).versionName
+ }.getOrNull()
+
+ return SyncAuth(
+ baseUrl = baseUrl,
+ authToken = token,
+ masterKey = masterKey,
+ userAgent = "EnteNative-Android",
+ clientPackage = context.packageName,
+ clientVersion = clientVersion
+ )
+ }
+
+ private fun normalizeToken(token: String): String {
+ val remainder = token.length % 4
+ return if (remainder == 0) token else token + "=".repeat(4 - remainder)
+ }
+
+ private fun syncErrorMessage(error: Throwable): String {
+ val syncMessage = generateSequence(error) { it.cause }
+ .filterIsInstance<SyncException.Message>()
+ .firstOrNull()
+ if (syncMessage != null) {
+ return syncMessage.v1
+ }
+
+ val rootCause = generateSequence(error) { it.cause }.lastOrNull() ?: error
+ return rootCause.message ?: error.message ?: rootCause.toString()
+ }
+}
diff --git a/mobile/native/android/apps/ensu/debug.keystore b/mobile/native/android/apps/ensu/debug.keystore
new file mode 100644
index 0000000000..333a582364
Binary files /dev/null and b/mobile/native/android/apps/ensu/debug.keystore differ
diff --git a/mobile/native/android/apps/ensu/domain/src/main/kotlin/io/ente/ensu/domain/chat/ChatSyncRepository.kt b/mobile/native/android/apps/ensu/domain/src/main/kotlin/io/ente/ensu/domain/chat/ChatSyncRepository.kt
new file mode 100644
index 0000000000..374a888750
--- /dev/null
+++ b/mobile/native/android/apps/ensu/domain/src/main/kotlin/io/ente/ensu/domain/chat/ChatSyncRepository.kt
@@ -0,0 +1,6 @@
+package io.ente.ensu.domain.chat
+
+interface ChatSyncRepository {
+ suspend fun sync()
+ suspend fun downloadAttachment(attachmentId: String, sessionId: String): Boolean
+}
diff --git a/mobile/native/android/apps/ensu/domain/src/main/kotlin/io/ente/ensu/domain/model/AttachmentDownload.kt b/mobile/native/android/apps/ensu/domain/src/main/kotlin/io/ente/ensu/domain/model/AttachmentDownload.kt
new file mode 100644
index 0000000000..cc85543358
--- /dev/null
+++ b/mobile/native/android/apps/ensu/domain/src/main/kotlin/io/ente/ensu/domain/model/AttachmentDownload.kt
@@ -0,0 +1,17 @@
+package io.ente.ensu.domain.model
+
+enum class AttachmentDownloadStatus {
+ Queued,
+ Downloading,
+ Completed,
+ Failed,
+ Canceled
+}
+
+data class AttachmentDownloadItem(
+ val id: String,
+ val sessionId: String,
+ val name: String,
+ val sizeBytes: Long,
+ val status: AttachmentDownloadStatus
+)
diff --git a/mobile/native/android/apps/ensu/domain/src/main/kotlin/io/ente/ensu/domain/state/ChatState.kt b/mobile/native/android/apps/ensu/domain/src/main/kotlin/io/ente/ensu/domain/state/ChatState.kt
index a1c7098e65..d1bfdb4f56 100644
--- a/mobile/native/android/apps/ensu/domain/src/main/kotlin/io/ente/ensu/domain/state/ChatState.kt
+++ b/mobile/native/android/apps/ensu/domain/src/main/kotlin/io/ente/ensu/domain/state/ChatState.kt
@@ -19,5 +19,8 @@ data class ChatState(
val attachments: List<Attachment> = emptyList(),
val editingMessageId: String? = null,
val branchSelections: Map<String, Int> = emptyMap(),
- val isProcessingAttachments: Boolean = false
+ val isProcessingAttachments: Boolean = false,
+ val attachmentDownloads: List<io.ente.ensu.domain.model.AttachmentDownloadItem> = emptyList(),
+ val attachmentDownloadProgress: Int? = null,
+ val isAttachmentDownloadBlocked: Boolean = false
)
diff --git a/mobile/native/android/apps/ensu/domain/src/main/kotlin/io/ente/ensu/domain/store/AppStore.kt b/mobile/native/android/apps/ensu/domain/src/main/kotlin/io/ente/ensu/domain/store/AppStore.kt
index 63ef3e44a0..6c76f866a2 100644
--- a/mobile/native/android/apps/ensu/domain/src/main/kotlin/io/ente/ensu/domain/store/AppStore.kt
+++ b/mobile/native/android/apps/ensu/domain/src/main/kotlin/io/ente/ensu/domain/store/AppStore.kt
@@ -1,9 +1,12 @@
package io.ente.ensu.domain.store
+import io.ente.ensu.domain.chat.ChatSyncRepository
import io.ente.ensu.domain.llm.LlmMessage
import io.ente.ensu.domain.llm.LlmModelTarget
import io.ente.ensu.domain.llm.LlmProvider
import io.ente.ensu.domain.model.Attachment
+import io.ente.ensu.domain.model.AttachmentDownloadItem
+import io.ente.ensu.domain.model.AttachmentDownloadStatus
import io.ente.ensu.domain.model.AttachmentType
import io.ente.ensu.domain.model.AuthState
import io.ente.ensu.domain.model.ChatMessage
@@ -16,6 +19,7 @@ import io.ente.ensu.domain.state.ModelSettingsState
import io.ente.ensu.domain.logging.LogRepository
import io.ente.ensu.domain.logging.NoOpLogRepository
import kotlinx.coroutines.CoroutineScope
+import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.Job
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.StateFlow
@@ -25,12 +29,15 @@ import kotlinx.coroutines.flow.first
import kotlinx.coroutines.flow.update
import kotlinx.coroutines.launch
import kotlinx.coroutines.runBlocking
+import kotlinx.coroutines.withContext
+import java.io.File
import kotlin.math.abs
import kotlin.math.max
class AppStore(
private val sessionPreferences: SessionPreferences,
private val chatRepository: io.ente.ensu.domain.chat.ChatRepository,
+ private val chatSyncRepository: ChatSyncRepository? = null,
private val llmProvider: LlmProvider,
private val clock: () -> Long = { System.currentTimeMillis() },
private val logRepository: LogRepository = NoOpLogRepository
@@ -44,6 +51,13 @@ class AppStore(
private var generationJob: Job? = null
private var stopRequested = false
private var streamingParentId: String? = null
+ private var pendingSyncRequested = false
+ private var pendingSyncErrorHandler: ((String) -> Unit)? = null
+
+ private val attachmentDownloads = mutableMapOf<String, AttachmentDownloadItem>()
+ private val attachmentDownloadQueue = ArrayDeque<String>()
+ private val attachmentDownloadActive = mutableMapOf<String, Job>()
+ private val maxAttachmentDownloadConcurrency = 2
fun bootstrap(scope: CoroutineScope) {
this.scope = scope
@@ -105,10 +119,37 @@ class AppStore(
}
// Session is empty, no DB load needed.
rebuildChatState(session.id)
+ updateAttachmentDownloadState()
logRepository.log(LogLevel.Info, "Created new session")
return session.id
}
+ fun startNewSessionDraft() {
+ generationJob?.cancel()
+ llmProvider.stopGeneration()
+ streamingParentId = null
+ _state.update { appState ->
+ appState.copy(
+ chat = appState.chat.copy(
+ currentSessionId = null,
+ messages = emptyList(),
+ branchSelections = emptyMap(),
+ isGenerating = false,
+ isDownloading = false,
+ streamingResponse = "",
+ streamingParentId = null,
+ downloadPercent = null,
+ downloadStatus = null,
+ messageText = "",
+ attachments = emptyList(),
+ editingMessageId = null
+ )
+ )
+ }
+ updateAttachmentDownloadState()
+ logRepository.log(LogLevel.Info, "Started new session draft")
+ }
+
fun selectSession(sessionId: String) {
generationJob?.cancel()
llmProvider.stopGeneration()
@@ -128,9 +169,74 @@ class AppStore(
}
loadMessagesFromDb(sessionId)
rebuildChatState(sessionId)
+ ensureAttachmentsAvailable(sessionId)
logRepository.log(LogLevel.Info, "Selected session", sessionId)
}
+ fun deleteSession(sessionId: String) {
+ val currentState = _state.value
+ val isCurrent = currentState.chat.currentSessionId == sessionId
+
+ if (isCurrent) {
+ generationJob?.cancel()
+ llmProvider.stopGeneration()
+ streamingParentId = null
+ }
+
+ chatRepository.deleteSession(sessionId)
+ messageStore.remove(sessionId)
+ branchSelections.remove(sessionId)
+ purgeAttachmentDownloads(sessionId)
+
+ val remaining = currentState.chat.sessions.filterNot { it.id == sessionId }
+ val sessions = remaining
+
+ sessions.forEach { session ->
+ messageStore.getOrPut(session.id) { mutableListOf() }
+ branchSelections.getOrPut(session.id) { mutableMapOf() }
+ }
+
+ val newCurrent = if (isCurrent) {
+ sessions.firstOrNull()?.id
+ } else {
+ currentState.chat.currentSessionId?.takeIf { id -> sessions.any { it.id == id } }
+ ?: sessions.firstOrNull()?.id
+ }
+
+ _state.update { appState ->
+ val resetCurrent = isCurrent
+ appState.copy(
+ chat = appState.chat.copy(
+ sessions = sessions,
+ currentSessionId = newCurrent,
+ isGenerating = if (resetCurrent) false else appState.chat.isGenerating,
+ isDownloading = if (resetCurrent) false else appState.chat.isDownloading,
+ streamingResponse = if (resetCurrent) "" else appState.chat.streamingResponse,
+ streamingParentId = if (resetCurrent) null else appState.chat.streamingParentId,
+ downloadPercent = if (resetCurrent) null else appState.chat.downloadPercent,
+ downloadStatus = if (resetCurrent) null else appState.chat.downloadStatus,
+ messageText = if (resetCurrent) "" else appState.chat.messageText,
+ attachments = if (resetCurrent) emptyList() else appState.chat.attachments,
+ editingMessageId = if (resetCurrent) null else appState.chat.editingMessageId
+ )
+ )
+ }
+
+ if (newCurrent != null) {
+ loadMessagesFromDb(newCurrent)
+ rebuildChatState(newCurrent)
+ ensureAttachmentsAvailable(newCurrent)
+ } else {
+ _state.update { appState ->
+ appState.copy(chat = appState.chat.copy(messages = emptyList(), branchSelections = emptyMap()))
+ }
+ }
+
+ scope?.launch { sessionPreferences.setSelectedSessionId(newCurrent) }
+ syncNow()
+ logRepository.log(LogLevel.Info, "Deleted session", sessionId)
+ }
+
fun persistSelectedSession(scope: CoroutineScope, sessionId: String?) {
scope.launch {
sessionPreferences.setSelectedSessionId(sessionId)
@@ -192,7 +298,7 @@ class AppStore(
}
fun addAttachment(attachment: Attachment) {
- if (_state.value.chat.isGenerating || _state.value.chat.isDownloading) return
+ if (_state.value.chat.isGenerating || _state.value.chat.isDownloading || _state.value.chat.isAttachmentDownloadBlocked) return
_state.update { appState ->
appState.copy(
@@ -244,8 +350,13 @@ class AppStore(
val parentId = message.parentId ?: return
val parent = messageStore[sessionId]?.firstOrNull { it.id == parentId } ?: return
+ if (missingAttachments(sessionId).isNotEmpty()) {
+ ensureAttachmentsAvailable(sessionId)
+ return
+ }
llmProvider.resetContext()
startGeneration(sessionId, parent)
+ requestSync()
}
fun sendMessage() {
@@ -256,6 +367,10 @@ class AppStore(
if (text.isEmpty() && attachments.isEmpty()) return
val sessionId = currentState.chat.currentSessionId ?: createNewSession()
+ if (missingAttachments(sessionId).isNotEmpty()) {
+ ensureAttachmentsAvailable(sessionId)
+ return
+ }
val timestamp = clock()
val editingMessageId = currentState.chat.editingMessageId
@@ -290,6 +405,7 @@ class AppStore(
updateCurrentSessionPreview(sessionId, text, timestamp)
rebuildChatState(sessionId)
startGeneration(sessionId, userMessage)
+ requestSync()
logRepository.log(LogLevel.Info, "Sent message", text)
}
@@ -310,6 +426,7 @@ class AppStore(
appState.copy(auth = AuthState(isLoggedIn = true, email = email))
}
logRepository.log(LogLevel.Info, "Signed in", email)
+ syncNow()
}
fun signOut() {
@@ -319,6 +436,223 @@ class AppStore(
logRepository.log(LogLevel.Info, "Signed out")
}
+ fun syncNow(onError: ((String) -> Unit)? = null) {
+ requestSync(onError)
+ }
+
+ private fun requestSync(onError: ((String) -> Unit)? = null) {
+ if (_state.value.chat.isGenerating) {
+ pendingSyncRequested = true
+ if (onError != null) {
+ pendingSyncErrorHandler = onError
+ }
+ return
+ }
+
+ val handler = pendingSyncErrorHandler ?: onError
+ pendingSyncRequested = false
+ pendingSyncErrorHandler = null
+ performSync(handler)
+ }
+
+ private fun syncAfterGeneration() {
+ val handler = pendingSyncErrorHandler
+ val shouldAutoSync = _state.value.auth.isLoggedIn
+ if (!pendingSyncRequested && !shouldAutoSync) {
+ pendingSyncErrorHandler = null
+ return
+ }
+ if (!shouldAutoSync && handler == null) {
+ pendingSyncRequested = false
+ pendingSyncErrorHandler = null
+ return
+ }
+ pendingSyncRequested = false
+ pendingSyncErrorHandler = null
+ performSync(handler)
+ }
+
+ private fun performSync(onError: ((String) -> Unit)? = null) {
+ val scope = scope ?: return
+ scope.launch {
+ try {
+ withContext(Dispatchers.IO) {
+ chatSyncRepository?.sync()
+ }
+ loadSessionsFromDb()
+ } catch (err: Throwable) {
+ val message = syncErrorMessage(err)
+ logRepository.log(LogLevel.Error, "Sync failed", message)
+ if (onError != null) {
+ withContext(Dispatchers.Main) {
+ onError("Sync failed: $message")
+ }
+ }
+ }
+ }
+ }
+
+ fun cancelAttachmentDownload(attachmentId: String) {
+ attachmentDownloadActive[attachmentId]?.cancel()
+ attachmentDownloadActive.remove(attachmentId)
+ attachmentDownloadQueue.removeAll { it == attachmentId }
+ attachmentDownloads[attachmentId]?.let { item ->
+ attachmentDownloads[attachmentId] = item.copy(status = AttachmentDownloadStatus.Canceled)
+ }
+ updateAttachmentDownloadState()
+ startNextAttachmentDownloads()
+ }
+
+ private fun syncErrorMessage(error: Throwable): String {
+ var current: Throwable? = error
+ while (current != null) {
+ val message = current.message
+ if (!message.isNullOrBlank()) {
+ return message
+ }
+ current = current.cause
+ }
+ return "Unknown error"
+ }
+
+ private fun purgeAttachmentDownloads(sessionId: String) {
+ val ids = attachmentDownloads.values.filter { it.sessionId == sessionId }.map { it.id }
+ ids.forEach { id ->
+ attachmentDownloadActive[id]?.cancel()
+ attachmentDownloadActive.remove(id)
+ attachmentDownloadQueue.removeAll { it == id }
+ attachmentDownloads.remove(id)
+ }
+ updateAttachmentDownloadState()
+ }
+
+ private fun ensureAttachmentsAvailable(sessionId: String) {
+ val missing = missingAttachments(sessionId)
+ if (missing.isEmpty()) {
+ updateAttachmentDownloadState()
+ return
+ }
+ queueAttachmentDownloads(missing)
+ updateAttachmentDownloadState()
+ }
+
+ private fun missingAttachments(sessionId: String): List<AttachmentDownloadItem> {
+ val messages = messageStore[sessionId].orEmpty()
+ if (messages.isEmpty()) return emptyList()
+ val seen = mutableSetOf<String>()
+ val missing = mutableListOf<AttachmentDownloadItem>()
+
+ for (message in messages) {
+ for (attachment in message.attachments) {
+ if (!seen.add(attachment.id)) continue
+ val path = attachment.localPath
+ if (path != null && File(path).exists()) {
+ attachmentDownloadActive[attachment.id]?.cancel()
+ attachmentDownloadActive.remove(attachment.id)
+ attachmentDownloadQueue.removeAll { it == attachment.id }
+ attachmentDownloads.remove(attachment.id)
+ continue
+ }
+ val existing = attachmentDownloads[attachment.id]
+ val status = existing?.status ?: AttachmentDownloadStatus.Queued
+ missing.add(
+ AttachmentDownloadItem(
+ id = attachment.id,
+ sessionId = sessionId,
+ name = attachment.name,
+ sizeBytes = attachment.sizeBytes,
+ status = status
+ )
+ )
+ }
+ }
+
+ return missing
+ }
+
+ private fun queueAttachmentDownloads(items: List<AttachmentDownloadItem>) {
+ items.forEach { item ->
+ val existing = attachmentDownloads[item.id]
+ val updated = if (existing == null ||
+ existing.status == AttachmentDownloadStatus.Failed ||
+ existing.status == AttachmentDownloadStatus.Canceled
+ ) {
+ item
+ } else {
+ existing
+ }
+ attachmentDownloads[item.id] = updated
+ if (updated.status != AttachmentDownloadStatus.Completed &&
+ updated.status != AttachmentDownloadStatus.Canceled &&
+ attachmentDownloadActive[item.id] == null &&
+ !attachmentDownloadQueue.contains(item.id)
+ ) {
+ attachmentDownloadQueue.addLast(item.id)
+ }
+ }
+ startNextAttachmentDownloads()
+ }
+
+ private fun startNextAttachmentDownloads() {
+ val scope = scope ?: return
+ while (attachmentDownloadActive.size < maxAttachmentDownloadConcurrency && attachmentDownloadQueue.isNotEmpty()) {
+ val id = attachmentDownloadQueue.removeFirst()
+ val item = attachmentDownloads[id] ?: continue
+ if (item.status == AttachmentDownloadStatus.Completed || item.status == AttachmentDownloadStatus.Canceled) {
+ continue
+ }
+ attachmentDownloads[id] = item.copy(status = AttachmentDownloadStatus.Downloading)
+ updateAttachmentDownloadState()
+
+ val job = scope.launch(Dispatchers.IO) {
+ val result = runCatching {
+ chatSyncRepository?.downloadAttachment(id, item.sessionId)
+ ?: throw IllegalStateException("Sync unavailable")
+ }
+ val status = if (result.isSuccess) {
+ AttachmentDownloadStatus.Completed
+ } else {
+ AttachmentDownloadStatus.Failed
+ }
+ withContext(Dispatchers.Main) {
+ attachmentDownloads[id]?.let { current ->
+ if (current.status != AttachmentDownloadStatus.Canceled) {
+ attachmentDownloads[id] = current.copy(status = status)
+ }
+ }
+ attachmentDownloadActive.remove(id)
+ updateAttachmentDownloadState()
+ startNextAttachmentDownloads()
+ }
+ }
+ attachmentDownloadActive[id] = job
+ }
+ }
+
+ private fun updateAttachmentDownloadState() {
+ val currentSessionId = _state.value.chat.currentSessionId
+ val missing = currentSessionId?.let { missingAttachments(it) }.orEmpty()
+ val items = attachmentDownloads.values.sortedBy { it.name }
+ val active = items.filter { it.status != AttachmentDownloadStatus.Canceled }
+ val total = active.size
+ val completed = active.count { it.status == AttachmentDownloadStatus.Completed }
+ val hasPending = active.any {
+ it.status == AttachmentDownloadStatus.Queued ||
+ it.status == AttachmentDownloadStatus.Downloading ||
+ it.status == AttachmentDownloadStatus.Failed
+ }
+ val progress = if (total > 0 && hasPending) (completed * 100 / total) else null
+ _state.update { appState ->
+ appState.copy(
+ chat = appState.chat.copy(
+ attachmentDownloads = items,
+ attachmentDownloadProgress = progress,
+ isAttachmentDownloadBlocked = missing.isNotEmpty()
+ )
+ )
+ }
+ }
+
private fun startGeneration(sessionId: String, userMessage: ChatMessage) {
val scope = scope ?: return
generationJob?.cancel()
@@ -374,6 +708,7 @@ class AppStore(
if (!cancelled) {
logRepository.log(LogLevel.Error, "Model load failed", err.message ?: "")
}
+ syncAfterGeneration()
return@launch
}
@@ -460,6 +795,7 @@ class AppStore(
)
}
rebuildChatState(sessionId)
+ syncAfterGeneration()
}
private fun updateCurrentSessionPreview(sessionId: String, preview: String, timestamp: Long) {
@@ -696,26 +1032,38 @@ class AppStore(
private fun loadSessionsFromDb() {
val sessions = chatRepository.listSessions()
- val initial = if (sessions.isEmpty()) {
- listOf(chatRepository.createSession("New Chat"))
- } else {
- sessions
- }
- initial.forEach { session ->
+ sessions.forEach { session ->
messageStore.getOrPut(session.id) { mutableListOf() }
branchSelections.getOrPut(session.id) { mutableMapOf() }
}
val stored = runBlocking { sessionPreferences.selectedSessionId.first() }
- val current = stored?.takeIf { id -> initial.any { it.id == id } } ?: initial.first().id
+ val resolvedStored = stored?.takeIf { id -> sessions.any { it.id == id } }
+ val shouldKeepDraft = resolvedStored == null &&
+ stored == null &&
+ _state.value.chat.currentSessionId == null &&
+ _state.value.chat.sessions.isNotEmpty()
+ val current = if (shouldKeepDraft) null else resolvedStored ?: sessions.firstOrNull()?.id
_state.update { appState ->
- appState.copy(chat = appState.chat.copy(sessions = initial, currentSessionId = current))
+ appState.copy(
+ chat = appState.chat.copy(
+ sessions = sessions,
+ currentSessionId = current,
+ messages = if (current == null) emptyList() else appState.chat.messages,
+ branchSelections = if (current == null) emptyMap() else appState.chat.branchSelections
+ )
+ )
}
- loadMessagesFromDb(current)
- rebuildChatState(current)
+ if (current != null) {
+ loadMessagesFromDb(current)
+ rebuildChatState(current)
+ ensureAttachmentsAvailable(current)
+ } else {
+ updateAttachmentDownloadState()
+ }
}
private data class PromptResult(
diff --git a/mobile/native/android/packages/rust/tool/build_android.sh b/mobile/native/android/packages/rust/tool/build_android.sh
index 129c7080d7..4a3b4ff913 100755
--- a/mobile/native/android/packages/rust/tool/build_android.sh
+++ b/mobile/native/android/packages/rust/tool/build_android.sh
@@ -5,6 +5,7 @@ ROOT="$(cd "$(dirname "$0")/.." && pwd)"
REPO_ROOT="$(cd "$ROOT/../../../../.." && pwd)"
INFERENCE_UNIFFI_RUST_DIR="$REPO_ROOT/rust/inference_rs_uniffi"
CHATDB_UNIFFI_RUST_DIR="$REPO_ROOT/rust/llmchat_db_uniffi"
+CHAT_SYNC_UNIFFI_RUST_DIR="$REPO_ROOT/rust/llmchat_sync_uniffi"
# Note: Older builds used to patch llama-cpp sources; this repo no longer ships that patch script.
PATCH_SCRIPT=""
OUT_DIR="$ROOT/src/main/jniLibs"
@@ -29,7 +30,7 @@ export CARGO_CFG_TARGET_FEATURE="${CARGO_CFG_TARGET_FEATURE:-}"
mkdir -p "$OUT_DIR"
-for CRATE_DIR in "$INFERENCE_UNIFFI_RUST_DIR" "$CHATDB_UNIFFI_RUST_DIR"; do
+for CRATE_DIR in "$INFERENCE_UNIFFI_RUST_DIR" "$CHATDB_UNIFFI_RUST_DIR" "$CHAT_SYNC_UNIFFI_RUST_DIR"; do
pushd "$CRATE_DIR" >/dev/null
cargo ndk \
--platform 23 \
diff --git a/mobile/native/darwin/Apps/ensu/ensu.xcodeproj/project.pbxproj b/mobile/native/darwin/Apps/ensu/ensu.xcodeproj/project.pbxproj
index d6b31dab67..6e6fe5cf8f 100644
--- a/mobile/native/darwin/Apps/ensu/ensu.xcodeproj/project.pbxproj
+++ b/mobile/native/darwin/Apps/ensu/ensu.xcodeproj/project.pbxproj
@@ -304,6 +304,7 @@
outputPaths = (
"$(TARGET_TEMP_DIR)/ensu_rust/libensu_uniffi.a",
"$(TARGET_TEMP_DIR)/ensu_rust/libllmchat_db_uniffi.a",
+ "$(TARGET_TEMP_DIR)/ensu_rust/libllmchat_sync_uniffi.a",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
@@ -320,6 +321,7 @@
outputPaths = (
"$(TARGET_TEMP_DIR)/ensu_rust/libensu_uniffi.a",
"$(TARGET_TEMP_DIR)/ensu_rust/libllmchat_db_uniffi.a",
+ "$(TARGET_TEMP_DIR)/ensu_rust/libllmchat_sync_uniffi.a",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
@@ -526,6 +528,7 @@
"-force_load",
"$(TARGET_TEMP_DIR)/ensu_rust/libensu_uniffi.a",
"$(TARGET_TEMP_DIR)/ensu_rust/libllmchat_db_uniffi.a",
+ "$(TARGET_TEMP_DIR)/ensu_rust/libllmchat_sync_uniffi.a",
);
OTHER_SWIFT_FLAGS = (
"$(inherited)",
@@ -533,6 +536,8 @@
"-fmodule-map-file=$(SRCROOT)/ensu/Generated/ensu_uniffiFFI.modulemap",
"-Xcc",
"-fmodule-map-file=$(SRCROOT)/ensu/Generated/llmchat_db_uniffiFFI.modulemap",
+ "-Xcc",
+ "-fmodule-map-file=$(SRCROOT)/ensu/Generated/llmchat_sync_uniffiFFI.modulemap",
);
SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_VERSION = 5.0;
@@ -583,6 +588,7 @@
"-force_load",
"$(TARGET_TEMP_DIR)/ensu_rust/libensu_uniffi.a",
"$(TARGET_TEMP_DIR)/ensu_rust/libllmchat_db_uniffi.a",
+ "$(TARGET_TEMP_DIR)/ensu_rust/libllmchat_sync_uniffi.a",
);
OTHER_SWIFT_FLAGS = (
"$(inherited)",
@@ -590,6 +596,8 @@
"-fmodule-map-file=$(SRCROOT)/ensu/Generated/ensu_uniffiFFI.modulemap",
"-Xcc",
"-fmodule-map-file=$(SRCROOT)/ensu/Generated/llmchat_db_uniffiFFI.modulemap",
+ "-Xcc",
+ "-fmodule-map-file=$(SRCROOT)/ensu/Generated/llmchat_sync_uniffiFFI.modulemap",
);
SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_VERSION = 5.0;
@@ -639,6 +647,7 @@
"-force_load",
"$(TARGET_TEMP_DIR)/ensu_rust/libensu_uniffi.a",
"$(TARGET_TEMP_DIR)/ensu_rust/libllmchat_db_uniffi.a",
+ "$(TARGET_TEMP_DIR)/ensu_rust/libllmchat_sync_uniffi.a",
);
OTHER_SWIFT_FLAGS = (
"$(inherited)",
@@ -646,6 +655,8 @@
"-fmodule-map-file=$(SRCROOT)/ensu/Generated/ensu_uniffiFFI.modulemap",
"-Xcc",
"-fmodule-map-file=$(SRCROOT)/ensu/Generated/llmchat_db_uniffiFFI.modulemap",
+ "-Xcc",
+ "-fmodule-map-file=$(SRCROOT)/ensu/Generated/llmchat_sync_uniffiFFI.modulemap",
);
SDKROOT = macosx;
SUPPORTED_PLATFORMS = macosx;
@@ -696,6 +707,7 @@
"-force_load",
"$(TARGET_TEMP_DIR)/ensu_rust/libensu_uniffi.a",
"$(TARGET_TEMP_DIR)/ensu_rust/libllmchat_db_uniffi.a",
+ "$(TARGET_TEMP_DIR)/ensu_rust/libllmchat_sync_uniffi.a",
);
OTHER_SWIFT_FLAGS = (
"$(inherited)",
@@ -703,6 +715,8 @@
"-fmodule-map-file=$(SRCROOT)/ensu/Generated/ensu_uniffiFFI.modulemap",
"-Xcc",
"-fmodule-map-file=$(SRCROOT)/ensu/Generated/llmchat_db_uniffiFFI.modulemap",
+ "-Xcc",
+ "-fmodule-map-file=$(SRCROOT)/ensu/Generated/llmchat_sync_uniffiFFI.modulemap",
);
SDKROOT = macosx;
SUPPORTED_PLATFORMS = macosx;
diff --git a/mobile/native/darwin/Apps/ensu/ensu/Assets.xcassets/AppIcon.appiconset/IconOGAny.png b/mobile/native/darwin/Apps/ensu/ensu/Assets.xcassets/AppIcon.appiconset/IconOGAny.png
index 7a0504b429..18e14a4761 100644
Binary files a/mobile/native/darwin/Apps/ensu/ensu/Assets.xcassets/AppIcon.appiconset/IconOGAny.png and b/mobile/native/darwin/Apps/ensu/ensu/Assets.xcassets/AppIcon.appiconset/IconOGAny.png differ
diff --git a/mobile/native/darwin/Apps/ensu/ensu/Assets.xcassets/AppIcon.appiconset/IconOGDark.png b/mobile/native/darwin/Apps/ensu/ensu/Assets.xcassets/AppIcon.appiconset/IconOGDark.png
index 9bc5fb6721..18e14a4761 100644
Binary files a/mobile/native/darwin/Apps/ensu/ensu/Assets.xcassets/AppIcon.appiconset/IconOGDark.png and b/mobile/native/darwin/Apps/ensu/ensu/Assets.xcassets/AppIcon.appiconset/IconOGDark.png differ
diff --git a/mobile/native/darwin/Apps/ensu/ensu/Assets.xcassets/AppIcon.appiconset/IconOGTinted.png b/mobile/native/darwin/Apps/ensu/ensu/Assets.xcassets/AppIcon.appiconset/IconOGTinted.png
index 9bc5fb6721..18e14a4761 100644
Binary files a/mobile/native/darwin/Apps/ensu/ensu/Assets.xcassets/AppIcon.appiconset/IconOGTinted.png and b/mobile/native/darwin/Apps/ensu/ensu/Assets.xcassets/AppIcon.appiconset/IconOGTinted.png differ
diff --git a/mobile/native/darwin/Apps/ensu/ensu/Assets.xcassets/AppIconMac.appiconset/Contents.json b/mobile/native/darwin/Apps/ensu/ensu/Assets.xcassets/AppIconMac.appiconset/Contents.json
new file mode 100644
index 0000000000..64dc11ee74
--- /dev/null
+++ b/mobile/native/darwin/Apps/ensu/ensu/Assets.xcassets/AppIconMac.appiconset/Contents.json
@@ -0,0 +1,68 @@
+{
+ "images" : [
+ {
+ "filename" : "icon_16x16.png",
+ "idiom" : "mac",
+ "scale" : "1x",
+ "size" : "16x16"
+ },
+ {
+ "filename" : "[email protected]",
+ "idiom" : "mac",
+ "scale" : "2x",
+ "size" : "16x16"
+ },
+ {
+ "filename" : "icon_32x32.png",
+ "idiom" : "mac",
+ "scale" : "1x",
+ "size" : "32x32"
+ },
+ {
+ "filename" : "[email protected]",
+ "idiom" : "mac",
+ "scale" : "2x",
+ "size" : "32x32"
+ },
+ {
+ "filename" : "icon_128x128.png",
+ "idiom" : "mac",
+ "scale" : "1x",
+ "size" : "128x128"
+ },
+ {
+ "filename" : "[email protected]",
+ "idiom" : "mac",
+ "scale" : "2x",
+ "size" : "128x128"
+ },
+ {
+ "filename" : "icon_256x256.png",
+ "idiom" : "mac",
+ "scale" : "1x",
+ "size" : "256x256"
+ },
+ {
+ "filename" : "[email protected]",
+ "idiom" : "mac",
+ "scale" : "2x",
+ "size" : "256x256"
+ },
+ {
+ "filename" : "icon_512x512.png",
+ "idiom" : "mac",
+ "scale" : "1x",
+ "size" : "512x512"
+ },
+ {
+ "filename" : "[email protected]",
+ "idiom" : "mac",
+ "scale" : "2x",
+ "size" : "512x512"
+ }
+ ],
+ "info" : {
+ "author" : "xcode",
+ "version" : 1
+ }
+}
diff --git a/mobile/native/darwin/Apps/ensu/ensu/Assets.xcassets/AppIconMac.appiconset/icon_128x128.png b/mobile/native/darwin/Apps/ensu/ensu/Assets.xcassets/AppIconMac.appiconset/icon_128x128.png
new file mode 100644
index 0000000000..55ae1aac30
Binary files /dev/null and b/mobile/native/darwin/Apps/ensu/ensu/Assets.xcassets/AppIconMac.appiconset/icon_128x128.png differ
diff --git a/mobile/native/darwin/Apps/ensu/ensu/Assets.xcassets/AppIconMac.appiconset/[email protected] b/mobile/native/darwin/Apps/ensu/ensu/Assets.xcassets/AppIconMac.appiconset/[email protected]
new file mode 100644
index 0000000000..f782d9065b
Binary files /dev/null and b/mobile/native/darwin/Apps/ensu/ensu/Assets.xcassets/AppIconMac.appiconset/[email protected] differ
diff --git a/mobile/native/darwin/Apps/ensu/ensu/Assets.xcassets/AppIconMac.appiconset/icon_16x16.png b/mobile/native/darwin/Apps/ensu/ensu/Assets.xcassets/AppIconMac.appiconset/icon_16x16.png
new file mode 100644
index 0000000000..170f89b4e6
Binary files /dev/null and b/mobile/native/darwin/Apps/ensu/ensu/Assets.xcassets/AppIconMac.appiconset/icon_16x16.png differ
diff --git a/mobile/native/darwin/Apps/ensu/ensu/Assets.xcassets/AppIconMac.appiconset/[email protected] b/mobile/native/darwin/Apps/ensu/ensu/Assets.xcassets/AppIconMac.appiconset/[email protected]
new file mode 100644
index 0000000000..2229413530
Binary files /dev/null and b/mobile/native/darwin/Apps/ensu/ensu/Assets.xcassets/AppIconMac.appiconset/[email protected] differ
diff --git a/mobile/native/darwin/Apps/ensu/ensu/Assets.xcassets/AppIconMac.appiconset/icon_256x256.png b/mobile/native/darwin/Apps/ensu/ensu/Assets.xcassets/AppIconMac.appiconset/icon_256x256.png
new file mode 100644
index 0000000000..f782d9065b
Binary files /dev/null and b/mobile/native/darwin/Apps/ensu/ensu/Assets.xcassets/AppIconMac.appiconset/icon_256x256.png differ
diff --git a/mobile/native/darwin/Apps/ensu/ensu/Assets.xcassets/AppIconMac.appiconset/[email protected] b/mobile/native/darwin/Apps/ensu/ensu/Assets.xcassets/AppIconMac.appiconset/[email protected]
new file mode 100644
index 0000000000..2fd6545b39
Binary files /dev/null and b/mobile/native/darwin/Apps/ensu/ensu/Assets.xcassets/AppIconMac.appiconset/[email protected] differ
diff --git a/mobile/native/darwin/Apps/ensu/ensu/Assets.xcassets/AppIconMac.appiconset/icon_32x32.png b/mobile/native/darwin/Apps/ensu/ensu/Assets.xcassets/AppIconMac.appiconset/icon_32x32.png
new file mode 100644
index 0000000000..2229413530
Binary files /dev/null and b/mobile/native/darwin/Apps/ensu/ensu/Assets.xcassets/AppIconMac.appiconset/icon_32x32.png differ
diff --git a/mobile/native/darwin/Apps/ensu/ensu/Assets.xcassets/AppIconMac.appiconset/[email protected] b/mobile/native/darwin/Apps/ensu/ensu/Assets.xcassets/AppIconMac.appiconset/[email protected]
new file mode 100644
index 0000000000..0104eeef52
Binary files /dev/null and b/mobile/native/darwin/Apps/ensu/ensu/Assets.xcassets/AppIconMac.appiconset/[email protected] differ
diff --git a/mobile/native/darwin/Apps/ensu/ensu/Assets.xcassets/AppIconMac.appiconset/icon_512x512.png b/mobile/native/darwin/Apps/ensu/ensu/Assets.xcassets/AppIconMac.appiconset/icon_512x512.png
new file mode 100644
index 0000000000..2fd6545b39
Binary files /dev/null and b/mobile/native/darwin/Apps/ensu/ensu/Assets.xcassets/AppIconMac.appiconset/icon_512x512.png differ
diff --git a/mobile/native/darwin/Apps/ensu/ensu/Assets.xcassets/AppIconMac.appiconset/[email protected] b/mobile/native/darwin/Apps/ensu/ensu/Assets.xcassets/AppIconMac.appiconset/[email protected]
new file mode 100644
index 0000000000..f2a5d81f89
Binary files /dev/null and b/mobile/native/darwin/Apps/ensu/ensu/Assets.xcassets/AppIconMac.appiconset/[email protected] differ
diff --git a/mobile/native/darwin/Apps/ensu/ensu/Assets.xcassets/ArrowDown01Icon.imageset/ArrowDown01Icon.svg b/mobile/native/darwin/Apps/ensu/ensu/Assets.xcassets/ArrowDown01Icon.imageset/ArrowDown01Icon.svg
new file mode 100644
index 0000000000..bd7d9af220
--- /dev/null
+++ b/mobile/native/darwin/Apps/ensu/ensu/Assets.xcassets/ArrowDown01Icon.imageset/ArrowDown01Icon.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
+ <path d="M18 9.00005C18 9.00005 13.5811 15 12 15C10.4188 15 6 9 6 9" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" />
+</svg>
diff --git a/mobile/native/darwin/Apps/ensu/ensu/Assets.xcassets/ArrowDown01Icon.imageset/Contents.json b/mobile/native/darwin/Apps/ensu/ensu/Assets.xcassets/ArrowDown01Icon.imageset/Contents.json
new file mode 100644
index 0000000000..17674c9e1f
--- /dev/null
+++ b/mobile/native/darwin/Apps/ensu/ensu/Assets.xcassets/ArrowDown01Icon.imageset/Contents.json
@@ -0,0 +1,16 @@
+{
+ "images" : [
+ {
+ "filename" : "ArrowDown01Icon.svg",
+ "idiom" : "universal"
+ }
+ ],
+ "info" : {
+ "author" : "xcode",
+ "version" : 1
+ },
+ "properties" : {
+ "preserves-vector-representation" : true,
+ "template-rendering-intent" : "template"
+ }
+}
diff --git a/mobile/native/darwin/Apps/ensu/ensu/Assets.xcassets/ArrowLeft01Icon.imageset/ArrowLeft01Icon.svg b/mobile/native/darwin/Apps/ensu/ensu/Assets.xcassets/ArrowLeft01Icon.imageset/ArrowLeft01Icon.svg
new file mode 100644
index 0000000000..2535aac7f5
--- /dev/null
+++ b/mobile/native/darwin/Apps/ensu/ensu/Assets.xcassets/ArrowLeft01Icon.imageset/ArrowLeft01Icon.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
+ <path d="M15 6C15 6 9.00001 10.4189 9 12C8.99999 13.5812 15 18 15 18" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" />
+</svg>
diff --git a/mobile/native/darwin/Apps/ensu/ensu/Assets.xcassets/ArrowLeft01Icon.imageset/Contents.json b/mobile/native/darwin/Apps/ensu/ensu/Assets.xcassets/ArrowLeft01Icon.imageset/Contents.json
new file mode 100644
index 0000000000..e3d7a57618
--- /dev/null
+++ b/mobile/native/darwin/Apps/ensu/ensu/Assets.xcassets/ArrowLeft01Icon.imageset/Contents.json
@@ -0,0 +1,16 @@
+{
+ "images" : [
+ {
+ "filename" : "ArrowLeft01Icon.svg",
+ "idiom" : "universal"
+ }
+ ],
+ "info" : {
+ "author" : "xcode",
+ "version" : 1
+ },
+ "properties" : {
+ "preserves-vector-representation" : true,
+ "template-rendering-intent" : "template"
+ }
+}
diff --git a/mobile/native/darwin/Apps/ensu/ensu/Assets.xcassets/ArrowRight01Icon.imageset/ArrowRight01Icon.svg b/mobile/native/darwin/Apps/ensu/ensu/Assets.xcassets/ArrowRight01Icon.imageset/ArrowRight01Icon.svg
new file mode 100644
index 0000000000..fb6608293a
--- /dev/null
+++ b/mobile/native/darwin/Apps/ensu/ensu/Assets.xcassets/ArrowRight01Icon.imageset/ArrowRight01Icon.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
+ <path d="M9.00005 6C9.00005 6 15 10.4189 15 12C15 13.5812 9 18 9 18" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" />
+</svg>
diff --git a/mobile/native/darwin/Apps/ensu/ensu/Assets.xcassets/ArrowRight01Icon.imageset/Contents.json b/mobile/native/darwin/Apps/ensu/ensu/Assets.xcassets/ArrowRight01Icon.imageset/Contents.json
new file mode 100644
index 0000000000..c86820f4b6
--- /dev/null
+++ b/mobile/native/darwin/Apps/ensu/ensu/Assets.xcassets/ArrowRight01Icon.imageset/Contents.json
@@ -0,0 +1,16 @@
+{
+ "images" : [
+ {
+ "filename" : "ArrowRight01Icon.svg",
+ "idiom" : "universal"
+ }
+ ],
+ "info" : {
+ "author" : "xcode",
+ "version" : 1
+ },
+ "properties" : {
+ "preserves-vector-representation" : true,
+ "template-rendering-intent" : "template"
+ }
+}
diff --git a/mobile/native/darwin/Apps/ensu/ensu/Assets.xcassets/ArrowRight02Icon.imageset/ArrowRight02Icon.svg b/mobile/native/darwin/Apps/ensu/ensu/Assets.xcassets/ArrowRight02Icon.imageset/ArrowRight02Icon.svg
new file mode 100644
index 0000000000..4495bb3d12
--- /dev/null
+++ b/mobile/native/darwin/Apps/ensu/ensu/Assets.xcassets/ArrowRight02Icon.imageset/ArrowRight02Icon.svg
@@ -0,0 +1,4 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
+ <path d="M18.5 12L4.99997 12" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" />
+ <path d="M13 18C13 18 19 13.5811 19 12C19 10.4188 13 6 13 6" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" />
+</svg>
diff --git a/mobile/native/darwin/Apps/ensu/ensu/Assets.xcassets/ArrowRight02Icon.imageset/Contents.json b/mobile/native/darwin/Apps/ensu/ensu/Assets.xcassets/ArrowRight02Icon.imageset/Contents.json
new file mode 100644
index 0000000000..b36cd373ab
--- /dev/null
+++ b/mobile/native/darwin/Apps/ensu/ensu/Assets.xcassets/ArrowRight02Icon.imageset/Contents.json
@@ -0,0 +1,16 @@
+{
+ "images" : [
+ {
+ "filename" : "ArrowRight02Icon.svg",
+ "idiom" : "universal"
+ }
+ ],
+ "info" : {
+ "author" : "xcode",
+ "version" : 1
+ },
+ "properties" : {
+ "preserves-vector-representation" : true,
+ "template-rendering-intent" : "template"
+ }
+}
diff --git a/mobile/native/darwin/Apps/ensu/ensu/Assets.xcassets/Attachment01Icon.imageset/Attachment01Icon.svg b/mobile/native/darwin/Apps/ensu/ensu/Assets.xcassets/Attachment01Icon.imageset/Attachment01Icon.svg
new file mode 100644
index 0000000000..238519c6a7
--- /dev/null
+++ b/mobile/native/darwin/Apps/ensu/ensu/Assets.xcassets/Attachment01Icon.imageset/Attachment01Icon.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
+ <path d="M5.82338 12L4.27922 10.4558C2.57359 8.75022 2.57359 5.98485 4.27922 4.27922C5.98485 2.57359 8.75022 2.57359 10.4558 4.27922L19.7208 13.5442C21.4264 15.2498 21.4264 18.0152 19.7208 19.7208C18.0152 21.4264 15.2498 21.4264 13.5442 19.7208L10.0698 16.2464C9.00379 15.1804 9.00379 13.4521 10.0698 12.386C11.1358 11.32 12.8642 11.32 13.9302 12.386L15.8604 14.3162" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" />
+</svg>
diff --git a/mobile/native/darwin/Apps/ensu/ensu/Assets.xcassets/Attachment01Icon.imageset/Contents.json b/mobile/native/darwin/Apps/ensu/ensu/Assets.xcassets/Attachment01Icon.imageset/Contents.json
new file mode 100644
index 0000000000..46b4052b3f
--- /dev/null
+++ b/mobile/native/darwin/Apps/ensu/ensu/Assets.xcassets/Attachment01Icon.imageset/Contents.json
@@ -0,0 +1,16 @@
+{
+ "images" : [
+ {
+ "filename" : "Attachment01Icon.svg",
+ "idiom" : "universal"
+ }
+ ],
+ "info" : {
+ "author" : "xcode",
+ "version" : 1
+ },
+ "properties" : {
+ "preserves-vector-representation" : true,
+ "template-rendering-intent" : "template"
+ }
+}
diff --git a/mobile/native/darwin/Apps/ensu/ensu/Assets.xcassets/Bug01Icon.imageset/Bug01Icon.svg b/mobile/native/darwin/Apps/ensu/ensu/Assets.xcassets/Bug01Icon.imageset/Bug01Icon.svg
new file mode 100644
index 0000000000..2bcb99f797
--- /dev/null
+++ b/mobile/native/darwin/Apps/ensu/ensu/Assets.xcassets/Bug01Icon.imageset/Bug01Icon.svg
@@ -0,0 +1,10 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
+ <path d="M3.01309 4.99084C2.89323 6.05084 3.55249 8.42285 6.48923 8.42285" stroke="currentColor" stroke-linecap="round" stroke-width="2" />
+ <path d="M17.5951 8.38081C18.8357 8.57881 21.1132 7.49881 20.9957 5.00281" stroke="currentColor" stroke-linecap="round" stroke-width="2" />
+ <path d="M20.9928 20.9989C21.0528 19.9429 20.1777 17.5549 17.599 17.4229" stroke="currentColor" stroke-linecap="round" stroke-width="2" />
+ <path d="M6.45163 17.4708C5.65013 17.2308 3.01306 18.3348 3.01306 20.9988" stroke="currentColor" stroke-linecap="round" stroke-width="2" />
+ <path d="M9.3299 6.11884C9.35388 5.09884 9.84533 2.99884 12.0029 2.99884C13.9208 2.99884 14.5861 4.61884 14.676 6.11884M6.26131 9.41884C6.38118 8.63884 7.29216 6.81484 9.36586 6.63484C11.4635 6.55564 14.3403 6.58684 14.8797 6.67084C15.5869 6.73377 17.2951 7.43884 17.7506 9.41884C17.9124 10.4388 17.8285 11.8788 17.8524 12.7188C17.8165 13.5588 17.9207 15.2623 17.7565 16.1388C17.6367 17.0988 16.9894 18.4668 16.1024 19.3068C14.7838 20.7228 11.1639 22.2108 8.03534 19.4508C6.41713 17.8908 6.30925 16.3788 6.18939 15.7788C6.15725 15.4571 6.15875 13.8763 6.16541 12.3588C6.14144 11.046 6.17235 9.78063 6.26131 9.41884Z" stroke="currentColor" stroke-width="2" />
+ <path d="M3.01306 12.8988H5.9498" stroke="currentColor" stroke-linecap="round" stroke-width="2" />
+ <path d="M20.9929 12.8988L18.1161 12.8988" stroke="currentColor" stroke-linecap="round" stroke-width="2" />
+ <path d="M12.0033 16.4988L12.0033 20.2788" stroke="currentColor" stroke-linecap="round" stroke-width="2" />
+</svg>
diff --git a/mobile/native/darwin/Apps/ensu/ensu/Assets.xcassets/Bug01Icon.imageset/Contents.json b/mobile/native/darwin/Apps/ensu/ensu/Assets.xcassets/Bug01Icon.imageset/Contents.json
new file mode 100644
index 0000000000..bed4efdabb
--- /dev/null
+++ b/mobile/native/darwin/Apps/ensu/ensu/Assets.xcassets/Bug01Icon.imageset/Contents.json
@@ -0,0 +1,16 @@
+{
+ "images" : [
+ {
+ "filename" : "Bug01Icon.svg",
+ "idiom" : "universal"
+ }
+ ],
+ "info" : {
+ "author" : "xcode",
+ "version" : 1
+ },
+ "properties" : {
+ "preserves-vector-representation" : true,
+ "template-rendering-intent" : "template"
+ }
+}
diff --git a/mobile/native/darwin/Apps/ensu/ensu/Assets.xcassets/Cancel01Icon.imageset/Cancel01Icon.svg b/mobile/native/darwin/Apps/ensu/ensu/Assets.xcassets/Cancel01Icon.imageset/Cancel01Icon.svg
new file mode 100644
index 0000000000..8525887fac
--- /dev/null
+++ b/mobile/native/darwin/Apps/ensu/ensu/Assets.xcassets/Cancel01Icon.imageset/Cancel01Icon.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
+ <path d="M18 6L6.00081 17.9992M17.9992 18L6 6.00085" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" />
+</svg>
diff --git a/mobile/native/darwin/Apps/ensu/ensu/Assets.xcassets/Cancel01Icon.imageset/Contents.json b/mobile/native/darwin/Apps/ensu/ensu/Assets.xcassets/Cancel01Icon.imageset/Contents.json
new file mode 100644
index 0000000000..1a9c530aae
--- /dev/null
+++ b/mobile/native/darwin/Apps/ensu/ensu/Assets.xcassets/Cancel01Icon.imageset/Contents.json
@@ -0,0 +1,16 @@
+{
+ "images" : [
+ {
+ "filename" : "Cancel01Icon.svg",
+ "idiom" : "universal"
+ }
+ ],
+ "info" : {
+ "author" : "xcode",
+ "version" : 1
+ },
+ "properties" : {
+ "preserves-vector-representation" : true,
+ "template-rendering-intent" : "template"
+ }
+}
diff --git a/mobile/native/darwin/Apps/ensu/ensu/Assets.xcassets/Copy01Icon.imageset/Contents.json b/mobile/native/darwin/Apps/ensu/ensu/Assets.xcassets/Copy01Icon.imageset/Contents.json
new file mode 100644
index 0000000000..f16299a34a
--- /dev/null
+++ b/mobile/native/darwin/Apps/ensu/ensu/Assets.xcassets/Copy01Icon.imageset/Contents.json
@@ -0,0 +1,16 @@
+{
+ "images" : [
+ {
+ "filename" : "Copy01Icon.svg",
+ "idiom" : "universal"
+ }
+ ],
+ "info" : {
+ "author" : "xcode",
+ "version" : 1
+ },
+ "properties" : {
+ "preserves-vector-representation" : true,
+ "template-rendering-intent" : "template"
+ }
+}
diff --git a/mobile/native/darwin/Apps/ensu/ensu/Assets.xcassets/Copy01Icon.imageset/Copy01Icon.svg b/mobile/native/darwin/Apps/ensu/ensu/Assets.xcassets/Copy01Icon.imageset/Copy01Icon.svg
new file mode 100644
index 0000000000..907881f51e
--- /dev/null
+++ b/mobile/native/darwin/Apps/ensu/ensu/Assets.xcassets/Copy01Icon.imageset/Copy01Icon.svg
@@ -0,0 +1,4 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
+ <path d="M9 15C9 12.1716 9 10.7574 9.87868 9.87868C10.7574 9 12.1716 9 15 9L16 9C18.8284 9 20.2426 9 21.1213 9.87868C22 10.7574 22 12.1716 22 15V16C22 18.8284 22 20.2426 21.1213 21.1213C20.2426 22 18.8284 22 16 22H15C12.1716 22 10.7574 22 9.87868 21.1213C9 20.2426 9 18.8284 9 16L9 15Z" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" />
+ <path d="M16.9999 9C16.9975 6.04291 16.9528 4.51121 16.092 3.46243C15.9258 3.25989 15.7401 3.07418 15.5376 2.90796C14.4312 2 12.7875 2 9.5 2C6.21252 2 4.56878 2 3.46243 2.90796C3.25989 3.07417 3.07418 3.25989 2.90796 3.46243C2 4.56878 2 6.21252 2 9.5C2 12.7875 2 14.4312 2.90796 15.5376C3.07417 15.7401 3.25989 15.9258 3.46243 16.092C4.51121 16.9528 6.04291 16.9975 9 16.9999" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" />
+</svg>
diff --git a/mobile/native/darwin/Apps/ensu/ensu/Assets.xcassets/Delete01Icon.imageset/Contents.json b/mobile/native/darwin/Apps/ensu/ensu/Assets.xcassets/Delete01Icon.imageset/Contents.json
new file mode 100644
index 0000000000..2a6952d3a0
--- /dev/null
+++ b/mobile/native/darwin/Apps/ensu/ensu/Assets.xcassets/Delete01Icon.imageset/Contents.json
@@ -0,0 +1,16 @@
+{
+ "images" : [
+ {
+ "filename" : "Delete01Icon.svg",
+ "idiom" : "universal"
+ }
+ ],
+ "info" : {
+ "author" : "xcode",
+ "version" : 1
+ },
+ "properties" : {
+ "preserves-vector-representation" : true,
+ "template-rendering-intent" : "template"
+ }
+}
diff --git a/mobile/native/darwin/Apps/ensu/ensu/Assets.xcassets/Delete01Icon.imageset/Delete01Icon.svg b/mobile/native/darwin/Apps/ensu/ensu/Assets.xcassets/Delete01Icon.imageset/Delete01Icon.svg
new file mode 100644
index 0000000000..378a205573
--- /dev/null
+++ b/mobile/native/darwin/Apps/ensu/ensu/Assets.xcassets/Delete01Icon.imageset/Delete01Icon.svg
@@ -0,0 +1,4 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
+ <path d="M19.5 5.5L18.8803 15.5251C18.7219 18.0864 18.6428 19.3671 18.0008 20.2879C17.6833 20.7431 17.2747 21.1273 16.8007 21.416C15.8421 22 14.559 22 11.9927 22C9.42312 22 8.1383 22 7.17905 21.4149C6.7048 21.1257 6.296 20.7408 5.97868 20.2848C5.33688 19.3626 5.25945 18.0801 5.10461 15.5152L4.5 5.5" stroke="currentColor" stroke-linecap="round" stroke-width="2" />
+ <path d="M3 5.5H21M16.0557 5.5L15.3731 4.09173C14.9196 3.15626 14.6928 2.68852 14.3017 2.39681C14.215 2.3321 14.1231 2.27454 14.027 2.2247C13.5939 2 13.0741 2 12.0345 2C10.9688 2 10.436 2 9.99568 2.23412C9.8981 2.28601 9.80498 2.3459 9.71729 2.41317C9.32164 2.7167 9.10063 3.20155 8.65861 4.17126L8.05292 5.5" stroke="currentColor" stroke-linecap="round" stroke-width="2" />
+</svg>
diff --git a/mobile/native/darwin/Apps/ensu/ensu/Assets.xcassets/Edit01Icon.imageset/Contents.json b/mobile/native/darwin/Apps/ensu/ensu/Assets.xcassets/Edit01Icon.imageset/Contents.json
new file mode 100644
index 0000000000..34f66daa21
--- /dev/null
+++ b/mobile/native/darwin/Apps/ensu/ensu/Assets.xcassets/Edit01Icon.imageset/Contents.json
@@ -0,0 +1,16 @@
+{
+ "images" : [
+ {
+ "filename" : "Edit01Icon.svg",
+ "idiom" : "universal"
+ }
+ ],
+ "info" : {
+ "author" : "xcode",
+ "version" : 1
+ },
+ "properties" : {
+ "preserves-vector-representation" : true,
+ "template-rendering-intent" : "template"
+ }
+}
diff --git a/mobile/native/darwin/Apps/ensu/ensu/Assets.xcassets/Edit01Icon.imageset/Edit01Icon.svg b/mobile/native/darwin/Apps/ensu/ensu/Assets.xcassets/Edit01Icon.imageset/Edit01Icon.svg
new file mode 100644
index 0000000000..92f2a42338
--- /dev/null
+++ b/mobile/native/darwin/Apps/ensu/ensu/Assets.xcassets/Edit01Icon.imageset/Edit01Icon.svg
@@ -0,0 +1,4 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
+ <path d="M16.9459 3.17305C17.5332 2.58578 17.8268 2.29215 18.1521 2.15173C18.6208 1.94942 19.1521 1.94942 19.6208 2.15173C19.946 2.29215 20.2397 2.58578 20.8269 3.17305C21.4142 3.76032 21.7079 4.05395 21.8483 4.37925C22.0506 4.8479 22.0506 5.37924 21.8483 5.84789C21.7079 6.17319 21.4142 6.46682 20.8269 7.05409L15.8054 12.0757C14.5682 13.3129 13.9496 13.9315 13.1748 14.298C12.4 14.6645 11.5294 14.7504 9.78823 14.9222L9 15L9.07778 14.2118C9.24958 12.4706 9.33549 11.6 9.70201 10.8252C10.0685 10.0504 10.6871 9.43183 11.9243 8.19464L16.9459 3.17305Z" stroke="currentColor" stroke-linejoin="round" stroke-width="2" />
+ <path d="M6 15H3.75C2.7835 15 2 15.7835 2 16.75C2 17.7165 2.7835 18.5 3.75 18.5H13.25C14.2165 18.5 15 19.2835 15 20.25C15 21.2165 14.2165 22 13.25 22H11" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" />
+</svg>
diff --git a/mobile/native/darwin/Apps/ensu/ensu/Assets.xcassets/EnsuLogo.imageset/Contents.json b/mobile/native/darwin/Apps/ensu/ensu/Assets.xcassets/EnsuLogo.imageset/Contents.json
new file mode 100644
index 0000000000..2066f5492f
--- /dev/null
+++ b/mobile/native/darwin/Apps/ensu/ensu/Assets.xcassets/EnsuLogo.imageset/Contents.json
@@ -0,0 +1,15 @@
+{
+ "images" : [
+ {
+ "filename" : "ensu-logo.svg",
+ "idiom" : "universal"
+ }
+ ],
+ "info" : {
+ "author" : "xcode",
+ "version" : 1
+ },
+ "properties" : {
+ "preserves-vector-representation" : true
+ }
+}
diff --git a/mobile/native/darwin/Apps/ensu/ensu/Assets.xcassets/EnsuLogo.imageset/ensu-logo.svg b/mobile/native/darwin/Apps/ensu/ensu/Assets.xcassets/EnsuLogo.imageset/ensu-logo.svg
new file mode 100644
index 0000000000..f6d5e5709b
--- /dev/null
+++ b/mobile/native/darwin/Apps/ensu/ensu/Assets.xcassets/EnsuLogo.imageset/ensu-logo.svg
@@ -0,0 +1,6 @@
+<svg width="135" height="40" viewBox="0 0 135 40" fill="none" xmlns="http://www.w3.org/2000/svg">
+<path fill-rule="evenodd" clip-rule="evenodd" d="M58.1279 0.714844C59.5808 0.71489 60.8058 1.23858 61.623 2.37598C62.3964 3.45228 62.705 4.94425 62.7051 6.69336L62.6982 7.12109C62.6672 8.1704 62.5277 9.59137 62.29 11.3633L62.2891 11.373L60.2979 25.1289C59.9072 27.8639 59.7178 29.9853 59.7178 31.5137C59.7178 32.0145 59.7818 32.2914 59.834 32.4238C60.2542 32.3861 60.9226 32.0663 61.8555 31.0566C62.8205 30.0121 63.9186 28.3957 65.1436 26.1641L65.6523 25.2363L66.5498 25.7979C67.1673 26.1838 67.8184 26.7714 67.8975 27.6162L67.9053 27.7891L67.8994 27.9912C67.8465 29.0046 67.4017 30.0546 66.709 31.1123C66.0556 32.1098 65.137 33.1812 63.9746 34.3262L63.4619 34.8213C62.0644 36.1433 60.763 37.1667 59.5605 37.8643C58.3656 38.5575 57.2026 38.9677 56.0996 38.9678C54.8677 38.9678 53.8164 38.5052 53.1211 37.5068C52.4715 36.5741 52.2227 35.299 52.2227 33.8369C52.2227 31.7496 52.4891 28.9039 53.0078 25.3223L54.2979 16.3975C54.7131 13.5153 54.915 11.271 54.915 9.64453C54.915 8.75862 54.7549 8.27161 54.5869 8.03027C54.4647 7.85485 54.2894 7.7305 53.8867 7.73047C51.219 7.73047 48.2817 9.55102 45.0947 13.752L45.0938 13.751C41.9726 17.8729 40.1689 22.2784 39.6494 26.9766V26.9785L38.5869 36.4189L30.9912 39.5283L31.5762 34.0986V34.0928L31.8711 31.5127L33.7891 14.4004L34.0098 12.4551C34.1554 10.9485 34.2256 9.75725 34.2256 8.87012C34.2256 8.13471 34.1283 7.73139 34.0361 7.54688C34.0288 7.5322 34.0203 7.52118 34.0146 7.51172C33.4918 7.52323 32.7914 7.82795 31.9043 8.76465C31.0097 9.70928 30.0372 11.1801 29 13.2305L28.4355 14.3467L27.4707 13.5498C27.1484 13.2836 26.863 12.9999 26.6514 12.6963C26.442 12.3959 26.2598 12.0096 26.2598 11.5615C26.2599 10.5368 26.7169 9.46822 27.4336 8.39648C28.1609 7.30894 29.224 6.1167 30.5928 4.82324C31.974 3.51743 33.2402 2.5062 34.3877 1.81641C35.5217 1.13475 36.625 0.714948 37.6592 0.714844C38.9452 0.714844 40.0642 1.1387 40.8262 2.11328C41.5514 3.04098 41.831 4.31647 41.8311 5.77148C41.8311 6.51086 41.7651 7.47261 41.6406 8.64258L41.3467 11.623L41.3457 11.6328L41.3447 11.6416L41.1914 12.9443C43.5116 9.92831 45.9957 7.33834 48.6455 5.18066C52.1588 2.31539 55.3376 0.714844 58.1279 0.714844ZM63.6572 33.2275C63.6763 33.2087 63.6953 33.19 63.7139 33.1709L63.7422 33.1416C63.7142 33.1704 63.6855 33.1986 63.6572 33.2275ZM59.0498 26.9424C59.0333 27.0805 59.0192 27.2171 59.0039 27.3516C59.0235 27.1798 59.0429 27.0049 59.0645 26.8271L59.0498 26.9424ZM32.0732 7.26758C32.1539 7.20702 32.2352 7.14997 32.3154 7.09668C32.3205 7.09333 32.325 7.08926 32.3301 7.08594C32.2447 7.14227 32.1592 7.20299 32.0732 7.26758ZM32.457 7.00488C32.4358 7.01787 32.4148 7.03142 32.3936 7.04492C32.4748 6.99326 32.5559 6.94553 32.6367 6.90137L32.457 7.00488Z" fill="white"/>
+<path fill-rule="evenodd" clip-rule="evenodd" d="M19.9561 0.714844C21.6289 0.714875 23.0624 1.16738 24.0625 2.24121C25.0499 3.30159 25.455 4.79855 25.4551 6.5459C25.4551 10.5148 23.5174 14.2854 19.8809 17.8457C16.4514 21.226 12.3048 23.6248 7.46387 25.0537C7.75489 27.4922 8.39211 29.2302 9.29004 30.3691C10.2461 31.5818 11.5703 32.21 13.3916 32.21C16.9868 32.2098 20.0934 29.9482 22.6377 24.8359L23.1484 23.8096L24.0957 24.4541C24.8884 24.9932 25.4549 25.7586 25.4551 26.7559C25.4551 27.4256 25.1313 28.1422 24.7207 28.8223C24.2877 29.5393 23.6593 30.3724 22.8555 31.3145L22.8516 31.3193C18.5644 36.2833 14.1574 38.9677 9.62988 38.9678C6.98921 38.9678 4.76115 37.968 3.00391 36.0156L2.6582 35.6123C0.861924 33.4077 6.04278e-05 30.6254 0 27.3467C0 21.4755 2.21782 15.6038 6.53906 9.75C10.8478 3.92212 15.312 0.714844 19.9561 0.714844ZM7.05469 19.9844C7.08204 19.9918 7.10957 19.9979 7.13672 20.0049C7.02486 19.9761 6.91111 19.9447 6.7959 19.9092L7.05469 19.9844ZM15.5303 7.50977C13.8793 7.50979 12.2286 8.48039 10.6045 10.8701C9.14101 13.0342 8.14218 15.7641 7.64062 19.0957C7.95096 19.1606 8.23212 19.1914 8.48633 19.1914C11.3125 19.1914 13.7547 18.3318 15.8564 16.6143C17.9564 14.8981 18.9189 12.9772 18.9189 10.8242C18.9189 9.54443 18.5952 8.7669 18.1211 8.30078C17.6439 7.83159 16.8432 7.50977 15.5303 7.50977ZM15.4424 18.1572C15.4992 18.1196 15.5579 18.0846 15.6143 18.0459L15.6416 18.0264C15.5761 18.0716 15.5085 18.1134 15.4424 18.1572ZM19.9189 10.8242L19.915 10.5586C19.9143 10.5363 19.912 10.5142 19.9111 10.4922C19.9156 10.6007 19.9189 10.7113 19.9189 10.8242ZM12.1484 7.71094C11.9119 7.88895 11.6787 8.08713 11.4482 8.30469L11.7969 7.99316C11.9135 7.89441 12.0303 7.79983 12.1484 7.71094Z" fill="white"/>
+<path fill-rule="evenodd" clip-rule="evenodd" d="M85.3828 0.714844C87.2121 0.714844 89.1673 1.01467 91.2422 1.59961L92.1387 1.86816L93.7803 2.38672L87.4785 8.21484L86.8115 7.71484C85.1121 6.44031 83.2439 5.8125 81.1787 5.8125C79.9535 5.81254 79.2205 6.07279 78.8047 6.41992C78.4236 6.73824 78.1592 7.25686 78.1592 8.16895L78.1709 8.375C78.2288 8.88722 78.4994 9.61542 79.1191 10.5938C79.7265 11.5525 80.6188 12.673 81.8125 13.959L82.3428 14.5205L82.3506 14.5283L84.6299 16.9551C86.3564 18.7567 87.6843 20.4155 88.585 21.9297C89.48 23.4344 89.9971 24.8698 89.9971 26.2031L89.9922 26.5273C89.8903 29.8616 88.2131 32.7596 85.1602 35.207L85.1562 35.2109C82.0002 37.7148 78.3497 38.9678 74.2451 38.9678C71.5057 38.9677 68.9196 38.347 66.5 37.1084L66.0186 36.8516L64.7236 36.1387L71.6797 30.4434L72.3193 31.124C74.0404 32.9553 76.1822 33.87 78.8184 33.8701C80.443 33.8701 81.477 33.4776 82.1074 32.8691C82.7313 32.267 83.1289 31.2886 83.1289 29.7432C83.1288 29.0644 82.8305 28.1184 82.0605 26.8643C81.3001 25.6256 80.1348 24.1742 78.5391 22.5059L76.4395 20.333L76.4355 20.3291C74.8684 18.6867 73.6606 17.1683 72.8398 15.7764C72.0243 14.3932 71.5489 13.0642 71.5488 11.8203C71.5488 8.62943 72.9456 5.95433 75.6172 3.84375L75.6211 3.84082C78.3053 1.7413 81.5798 0.71492 85.3828 0.714844ZM73.7314 37.96L74.2451 37.9678C73.9059 37.9678 73.5693 37.9567 73.2354 37.9365C73.4001 37.9465 73.5654 37.9549 73.7314 37.96ZM72.6387 10.5166C72.6302 10.5765 72.6235 10.6369 72.6162 10.6973C72.6338 10.5515 72.6541 10.4069 72.6787 10.2637L72.6387 10.5166ZM73.1572 8.56934C73.1459 8.59744 73.136 8.62608 73.125 8.6543L73.208 8.4502L73.1572 8.56934Z" fill="white"/>
+<path fill-rule="evenodd" clip-rule="evenodd" d="M130.538 1.76562C129.856 4.59298 129.346 7.10548 129.007 9.30566L129.008 9.30664L126.794 24.7217C126.672 25.648 126.576 26.426 126.503 27.0557L126.502 27.0674L126.244 29.085C126.097 30.3392 126.03 31.1726 126.03 31.624C126.03 31.8447 126.046 32.0131 126.068 32.1357C126.073 32.1603 126.079 32.1818 126.084 32.2012C126.703 32.1435 127.455 31.7637 128.342 30.7998C129.306 29.7516 130.328 28.1213 131.39 25.8525L131.857 24.8545L132.806 25.417C133.451 25.7998 134.192 26.3961 134.282 27.2773L134.291 27.457L134.286 27.6084C134.261 27.9616 134.152 28.3164 134.016 28.6475C133.854 29.0383 133.624 29.4671 133.34 29.9277C132.772 30.848 131.939 31.9698 130.858 33.2861L130.859 33.2871C127.944 36.8753 125.017 38.9677 122.08 38.9678C120.936 38.9678 119.934 38.5677 119.259 37.6611C118.625 36.8098 118.388 35.6532 118.388 34.3535C118.388 33.5267 118.481 32.4561 118.655 31.1592V31.1562L119.061 28.2061C119.153 27.5406 119.229 26.9638 119.296 26.4785C117.073 29.4082 114.654 31.9942 112.034 34.2295C108.501 37.2437 105.394 38.9677 102.792 38.9678C101.331 38.9678 100.09 38.4653 99.2539 37.3506C98.4584 36.2899 98.1406 34.8184 98.1406 33.0996C98.1406 31.8319 98.3071 29.8025 98.627 27.0469L99.9541 14.9561L99.9561 14.9404L99.958 14.9238C99.9768 14.7921 100.036 14.1247 100.136 12.8486L100.137 12.835L100.357 10.4375L100.358 10.4268C100.43 9.73938 100.464 9.1348 100.464 8.61133C100.464 7.96088 100.366 7.63408 100.291 7.50195C100.284 7.48925 100.277 7.48012 100.272 7.47363C100.266 7.47309 100.258 7.47266 100.247 7.47266C99.7051 7.4727 98.9782 7.77938 98.0557 8.74121C97.1429 9.69293 96.1493 11.1737 95.0879 13.2363L94.5322 14.3164L93.5791 13.5635C92.9787 13.0894 92.498 12.4367 92.498 11.5986C92.4981 10.5533 92.9551 9.46825 93.6807 8.37988C94.4153 7.27788 95.4885 6.07778 96.8711 4.7832L96.875 4.78027C98.2698 3.48604 99.5527 2.48474 100.72 1.80176C101.875 1.12547 102.996 0.714844 104.046 0.714844C105.322 0.714871 106.417 1.17054 107.15 2.17773C107.841 3.12585 108.106 4.42622 108.106 5.91895C108.106 6.62967 108.054 7.44324 107.953 8.35352L107.952 8.3584L107.621 11.1885L107.29 14.2871L107.289 14.292L106.109 24.8389C105.917 26.5961 105.82 28.3789 105.82 30.1865L105.827 30.4521C105.857 31.0331 105.981 31.3463 106.095 31.5C106.183 31.6191 106.324 31.7305 106.701 31.7305C107.809 31.7305 109.085 31.2746 110.547 30.208C112.009 29.1418 113.598 27.5076 115.311 25.2646L115.312 25.2617C118.752 20.7882 120.74 16.4207 121.349 12.1572L122.689 2.80957L130.965 0L130.538 1.76562ZM129.56 33.2822C129.532 33.3146 129.504 33.3469 129.477 33.3789C129.499 33.3526 129.523 33.3273 129.546 33.3008C129.562 33.2818 129.577 33.2615 129.593 33.2422C129.581 33.2554 129.571 33.2691 129.56 33.2822ZM126.111 33.2031L126.308 33.1836C126.32 33.1819 126.332 33.1784 126.344 33.1758C126.266 33.1875 126.189 33.1978 126.111 33.2031ZM125.311 32.9072C125.318 32.9173 125.326 32.926 125.334 32.9355C125.305 32.8984 125.277 32.8582 125.252 32.8135L125.311 32.9072ZM129.078 31.4766L129.277 31.2539C129.286 31.2445 129.293 31.2345 129.301 31.2246C129.226 31.3112 129.153 31.3957 129.078 31.4766ZM132.583 26.4639C132.565 26.4507 132.548 26.4365 132.529 26.4238C132.518 26.4163 132.506 26.4098 132.495 26.4023C132.526 26.4225 132.554 26.4437 132.583 26.4639Z" fill="white"/>
+</svg>
diff --git a/mobile/native/darwin/Apps/ensu/ensu/Assets.xcassets/Menu01Icon.imageset/Contents.json b/mobile/native/darwin/Apps/ensu/ensu/Assets.xcassets/Menu01Icon.imageset/Contents.json
new file mode 100644
index 0000000000..7f5300327e
--- /dev/null
+++ b/mobile/native/darwin/Apps/ensu/ensu/Assets.xcassets/Menu01Icon.imageset/Contents.json
@@ -0,0 +1,16 @@
+{
+ "images" : [
+ {
+ "filename" : "Menu01Icon.svg",
+ "idiom" : "universal"
+ }
+ ],
+ "info" : {
+ "author" : "xcode",
+ "version" : 1
+ },
+ "properties" : {
+ "preserves-vector-representation" : true,
+ "template-rendering-intent" : "template"
+ }
+}
diff --git a/mobile/native/darwin/Apps/ensu/ensu/Assets.xcassets/Menu01Icon.imageset/Menu01Icon.svg b/mobile/native/darwin/Apps/ensu/ensu/Assets.xcassets/Menu01Icon.imageset/Menu01Icon.svg
new file mode 100644
index 0000000000..bb017d5115
--- /dev/null
+++ b/mobile/native/darwin/Apps/ensu/ensu/Assets.xcassets/Menu01Icon.imageset/Menu01Icon.svg
@@ -0,0 +1,5 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
+ <path d="M4 5L20 5" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" />
+ <path d="M4 12L20 12" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" />
+ <path d="M4 19L20 19" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" />
+</svg>
diff --git a/mobile/native/darwin/Apps/ensu/ensu/Assets.xcassets/PlusSignIcon.imageset/Contents.json b/mobile/native/darwin/Apps/ensu/ensu/Assets.xcassets/PlusSignIcon.imageset/Contents.json
new file mode 100644
index 0000000000..4c35411ac8
--- /dev/null
+++ b/mobile/native/darwin/Apps/ensu/ensu/Assets.xcassets/PlusSignIcon.imageset/Contents.json
@@ -0,0 +1,16 @@
+{
+ "images" : [
+ {
+ "filename" : "PlusSignIcon.svg",
+ "idiom" : "universal"
+ }
+ ],
+ "info" : {
+ "author" : "xcode",
+ "version" : 1
+ },
+ "properties" : {
+ "preserves-vector-representation" : true,
+ "template-rendering-intent" : "template"
+ }
+}
diff --git a/mobile/native/darwin/Apps/ensu/ensu/Assets.xcassets/PlusSignIcon.imageset/PlusSignIcon.svg b/mobile/native/darwin/Apps/ensu/ensu/Assets.xcassets/PlusSignIcon.imageset/PlusSignIcon.svg
new file mode 100644
index 0000000000..031cca02af
--- /dev/null
+++ b/mobile/native/darwin/Apps/ensu/ensu/Assets.xcassets/PlusSignIcon.imageset/PlusSignIcon.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
+ <path d="M12 4V20M20 12H4" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" />
+</svg>
diff --git a/mobile/native/darwin/Apps/ensu/ensu/Assets.xcassets/RefreshIcon.imageset/Contents.json b/mobile/native/darwin/Apps/ensu/ensu/Assets.xcassets/RefreshIcon.imageset/Contents.json
new file mode 100644
index 0000000000..4e281f915b
--- /dev/null
+++ b/mobile/native/darwin/Apps/ensu/ensu/Assets.xcassets/RefreshIcon.imageset/Contents.json
@@ -0,0 +1,16 @@
+{
+ "images" : [
+ {
+ "filename" : "RefreshIcon.svg",
+ "idiom" : "universal"
+ }
+ ],
+ "info" : {
+ "author" : "xcode",
+ "version" : 1
+ },
+ "properties" : {
+ "preserves-vector-representation" : true,
+ "template-rendering-intent" : "template"
+ }
+}
diff --git a/mobile/native/darwin/Apps/ensu/ensu/Assets.xcassets/RefreshIcon.imageset/RefreshIcon.svg b/mobile/native/darwin/Apps/ensu/ensu/Assets.xcassets/RefreshIcon.imageset/RefreshIcon.svg
new file mode 100644
index 0000000000..50f487eb6a
--- /dev/null
+++ b/mobile/native/darwin/Apps/ensu/ensu/Assets.xcassets/RefreshIcon.imageset/RefreshIcon.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
+ <path d="M20.0092 2V5.13219C20.0092 5.42605 19.6418 5.55908 19.4537 5.33333C17.6226 3.2875 14.9617 2 12 2C6.47715 2 2 6.47715 2 12C2 17.5228 6.47715 22 12 22C17.5228 22 22 17.5228 22 12" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" />
+</svg>
diff --git a/mobile/native/darwin/Apps/ensu/ensu/Assets.xcassets/RepeatIcon.imageset/Contents.json b/mobile/native/darwin/Apps/ensu/ensu/Assets.xcassets/RepeatIcon.imageset/Contents.json
new file mode 100644
index 0000000000..93e358083a
--- /dev/null
+++ b/mobile/native/darwin/Apps/ensu/ensu/Assets.xcassets/RepeatIcon.imageset/Contents.json
@@ -0,0 +1,16 @@
+{
+ "images" : [
+ {
+ "filename" : "RepeatIcon.svg",
+ "idiom" : "universal"
+ }
+ ],
+ "info" : {
+ "author" : "xcode",
+ "version" : 1
+ },
+ "properties" : {
+ "preserves-vector-representation" : true,
+ "template-rendering-intent" : "template"
+ }
+}
diff --git a/mobile/native/darwin/Apps/ensu/ensu/Assets.xcassets/RepeatIcon.imageset/RepeatIcon.svg b/mobile/native/darwin/Apps/ensu/ensu/Assets.xcassets/RepeatIcon.imageset/RepeatIcon.svg
new file mode 100644
index 0000000000..a76656eba6
--- /dev/null
+++ b/mobile/native/darwin/Apps/ensu/ensu/Assets.xcassets/RepeatIcon.imageset/RepeatIcon.svg
@@ -0,0 +1,4 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
+ <path d="M16.3884 3L17.3913 3.97574C17.8393 4.41165 18.0633 4.62961 17.9844 4.81481C17.9056 5 17.5888 5 16.9552 5H9.19422C5.22096 5 2 8.13401 2 12C2 13.4872 2.47668 14.8662 3.2895 16" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" />
+ <path d="M7.61156 21L6.60875 20.0243C6.16074 19.5883 5.93673 19.3704 6.01557 19.1852C6.09441 19 6.4112 19 7.04478 19H14.8058C18.779 19 22 15.866 22 12C22 10.5128 21.5233 9.13383 20.7105 8" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" />
+</svg>
diff --git a/mobile/native/darwin/Apps/ensu/ensu/Assets.xcassets/Search01Icon.imageset/Contents.json b/mobile/native/darwin/Apps/ensu/ensu/Assets.xcassets/Search01Icon.imageset/Contents.json
new file mode 100644
index 0000000000..633cc85e50
--- /dev/null
+++ b/mobile/native/darwin/Apps/ensu/ensu/Assets.xcassets/Search01Icon.imageset/Contents.json
@@ -0,0 +1,16 @@
+{
+ "images" : [
+ {
+ "filename" : "Search01Icon.svg",
+ "idiom" : "universal"
+ }
+ ],
+ "info" : {
+ "author" : "xcode",
+ "version" : 1
+ },
+ "properties" : {
+ "preserves-vector-representation" : true,
+ "template-rendering-intent" : "template"
+ }
+}
diff --git a/mobile/native/darwin/Apps/ensu/ensu/Assets.xcassets/Search01Icon.imageset/Search01Icon.svg b/mobile/native/darwin/Apps/ensu/ensu/Assets.xcassets/Search01Icon.imageset/Search01Icon.svg
new file mode 100644
index 0000000000..fb1a91d671
--- /dev/null
+++ b/mobile/native/darwin/Apps/ensu/ensu/Assets.xcassets/Search01Icon.imageset/Search01Icon.svg
@@ -0,0 +1,4 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
+ <path d="M17 17L21 21" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" />
+ <path d="M19 11C19 6.58172 15.4183 3 11 3C6.58172 3 3 6.58172 3 11C3 15.4183 6.58172 19 11 19C15.4183 19 19 15.4183 19 11Z" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" />
+</svg>
diff --git a/mobile/native/darwin/Apps/ensu/ensu/Assets.xcassets/Settings01Icon.imageset/Contents.json b/mobile/native/darwin/Apps/ensu/ensu/Assets.xcassets/Settings01Icon.imageset/Contents.json
new file mode 100644
index 0000000000..d7c41ac166
--- /dev/null
+++ b/mobile/native/darwin/Apps/ensu/ensu/Assets.xcassets/Settings01Icon.imageset/Contents.json
@@ -0,0 +1,16 @@
+{
+ "images" : [
+ {
+ "filename" : "Settings01Icon.svg",
+ "idiom" : "universal"
+ }
+ ],
+ "info" : {
+ "author" : "xcode",
+ "version" : 1
+ },
+ "properties" : {
+ "preserves-vector-representation" : true,
+ "template-rendering-intent" : "template"
+ }
+}
diff --git a/mobile/native/darwin/Apps/ensu/ensu/Assets.xcassets/Settings01Icon.imageset/Settings01Icon.svg b/mobile/native/darwin/Apps/ensu/ensu/Assets.xcassets/Settings01Icon.imageset/Settings01Icon.svg
new file mode 100644
index 0000000000..417bb71e72
--- /dev/null
+++ b/mobile/native/darwin/Apps/ensu/ensu/Assets.xcassets/Settings01Icon.imageset/Settings01Icon.svg
@@ -0,0 +1,4 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
+ <path d="M21.3175 7.14139L20.8239 6.28479C20.4506 5.63696 20.264 5.31305 19.9464 5.18388C19.6288 5.05472 19.2696 5.15664 18.5513 5.36048L17.3311 5.70418C16.8725 5.80994 16.3913 5.74994 15.9726 5.53479L15.6357 5.34042C15.2766 5.11043 15.0004 4.77133 14.8475 4.37274L14.5136 3.37536C14.294 2.71534 14.1842 2.38533 13.9228 2.19657C13.6615 2.00781 13.3143 2.00781 12.6199 2.00781H11.5051C10.8108 2.00781 10.4636 2.00781 10.2022 2.19657C9.94085 2.38533 9.83106 2.71534 9.61149 3.37536L9.27753 4.37274C9.12465 4.77133 8.84845 5.11043 8.48937 5.34042L8.15249 5.53479C7.73374 5.74994 7.25259 5.80994 6.79398 5.70418L5.57375 5.36048C4.85541 5.15664 4.49625 5.05472 4.17867 5.18388C3.86109 5.31305 3.67445 5.63696 3.30115 6.28479L2.80757 7.14139C2.45766 7.74864 2.2827 8.05227 2.31666 8.37549C2.35061 8.69871 2.58483 8.95918 3.05326 9.48012L4.0843 10.6328C4.3363 10.9518 4.51521 11.5078 4.51521 12.0077C4.51521 12.5078 4.33636 13.0636 4.08433 13.3827L3.05326 14.5354C2.58483 15.0564 2.35062 15.3168 2.31666 15.6401C2.2827 15.9633 2.45766 16.2669 2.80757 16.8741L3.30114 17.7307C3.67443 18.3785 3.86109 18.7025 4.17867 18.8316C4.49625 18.9608 4.85542 18.8589 5.57377 18.655L6.79394 18.3113C7.25263 18.2055 7.73387 18.2656 8.15267 18.4808L8.4895 18.6752C8.84851 18.9052 9.12464 19.2442 9.2775 19.6428L9.61149 20.6403C9.83106 21.3003 9.94085 21.6303 10.2022 21.8191C10.4636 22.0078 10.8108 22.0078 11.5051 22.0078H12.6199C13.3143 22.0078 13.6615 22.0078 13.9228 21.8191C14.1842 21.6303 14.294 21.3003 14.5136 20.6403L14.8476 19.6428C15.0004 19.2442 15.2765 18.9052 15.6356 18.6752L15.9724 18.4808C16.3912 18.2656 16.8724 18.2055 17.3311 18.3113L18.5513 18.655C19.2696 18.8589 19.6288 18.9608 19.9464 18.8316C20.264 18.7025 20.4506 18.3785 20.8239 17.7307L21.3175 16.8741C21.6674 16.2669 21.8423 15.9633 21.8084 15.6401C21.7744 15.3168 21.5402 15.0564 21.0718 14.5354L20.0407 13.3827C19.7887 13.0636 19.6098 12.5078 19.6098 12.0077C19.6098 11.5078 19.7888 10.9518 20.0407 10.6328L21.0718 9.48012C21.5402 8.95918 21.7744 8.69871 21.8084 8.37549C21.8423 8.05227 21.6674 7.74864 21.3175 7.14139Z" stroke="currentColor" stroke-linecap="round" stroke-width="2" />
+ <path d="M15.5195 12C15.5195 13.933 13.9525 15.5 12.0195 15.5C10.0865 15.5 8.51953 13.933 8.51953 12C8.51953 10.067 10.0865 8.5 12.0195 8.5C13.9525 8.5 15.5195 10.067 15.5195 12Z" stroke="currentColor" stroke-width="2" />
+</svg>
diff --git a/mobile/native/darwin/Apps/ensu/ensu/Assets.xcassets/SlidersHorizontalIcon.imageset/Contents.json b/mobile/native/darwin/Apps/ensu/ensu/Assets.xcassets/SlidersHorizontalIcon.imageset/Contents.json
new file mode 100644
index 0000000000..1d6ab04cc7
--- /dev/null
+++ b/mobile/native/darwin/Apps/ensu/ensu/Assets.xcassets/SlidersHorizontalIcon.imageset/Contents.json
@@ -0,0 +1,16 @@
+{
+ "images" : [
+ {
+ "filename" : "SlidersHorizontalIcon.svg",
+ "idiom" : "universal"
+ }
+ ],
+ "info" : {
+ "author" : "xcode",
+ "version" : 1
+ },
+ "properties" : {
+ "preserves-vector-representation" : true,
+ "template-rendering-intent" : "template"
+ }
+}
diff --git a/mobile/native/darwin/Apps/ensu/ensu/Assets.xcassets/SlidersHorizontalIcon.imageset/SlidersHorizontalIcon.svg b/mobile/native/darwin/Apps/ensu/ensu/Assets.xcassets/SlidersHorizontalIcon.imageset/SlidersHorizontalIcon.svg
new file mode 100644
index 0000000000..6f1041d429
--- /dev/null
+++ b/mobile/native/darwin/Apps/ensu/ensu/Assets.xcassets/SlidersHorizontalIcon.imageset/SlidersHorizontalIcon.svg
@@ -0,0 +1,11 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
+ <path d="M3.99963 5.00055L9.99963 5.00031" stroke="currentColor" stroke-linecap="round" stroke-width="2" />
+ <path d="M12.9996 5.00031L19.9996 5.00031" stroke="currentColor" stroke-linecap="round" stroke-width="2" />
+ <path d="M15.9996 9.00031L15.9996 15.0003" stroke="currentColor" stroke-linecap="round" stroke-width="2" />
+ <path d="M9.99963 2.00031L9.99963 8.00031" stroke="currentColor" stroke-linecap="round" stroke-width="2" />
+ <path d="M11.9996 16.0003L11.9996 22.0003" stroke="currentColor" stroke-linecap="round" stroke-width="2" />
+ <path d="M15.9996 12.0001L19.9996 12.0003" stroke="currentColor" stroke-linecap="round" stroke-width="2" />
+ <path d="M3.99963 12.0005L12.9996 12.0003" stroke="currentColor" stroke-linecap="round" stroke-width="2" />
+ <path d="M11.9996 19.0003L19.9996 19.0003" stroke="currentColor" stroke-linecap="round" stroke-width="2" />
+ <path d="M3.99963 19.0005L8.99963 19.0003" stroke="currentColor" stroke-linecap="round" stroke-width="2" />
+</svg>
diff --git a/mobile/native/darwin/Apps/ensu/ensu/Assets.xcassets/StopCircleIcon.imageset/Contents.json b/mobile/native/darwin/Apps/ensu/ensu/Assets.xcassets/StopCircleIcon.imageset/Contents.json
new file mode 100644
index 0000000000..dc85a2d85b
--- /dev/null
+++ b/mobile/native/darwin/Apps/ensu/ensu/Assets.xcassets/StopCircleIcon.imageset/Contents.json
@@ -0,0 +1,16 @@
+{
+ "images" : [
+ {
+ "filename" : "StopCircleIcon.svg",
+ "idiom" : "universal"
+ }
+ ],
+ "info" : {
+ "author" : "xcode",
+ "version" : 1
+ },
+ "properties" : {
+ "preserves-vector-representation" : true,
+ "template-rendering-intent" : "template"
+ }
+}
diff --git a/mobile/native/darwin/Apps/ensu/ensu/Assets.xcassets/StopCircleIcon.imageset/StopCircleIcon.svg b/mobile/native/darwin/Apps/ensu/ensu/Assets.xcassets/StopCircleIcon.imageset/StopCircleIcon.svg
new file mode 100644
index 0000000000..8c9947995c
--- /dev/null
+++ b/mobile/native/darwin/Apps/ensu/ensu/Assets.xcassets/StopCircleIcon.imageset/StopCircleIcon.svg
@@ -0,0 +1,4 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
+ <circle cx="12" cy="12" r="10" stroke="currentColor" stroke-width="2" />
+ <path d="M9.38886 15.1629C9.89331 15.5 10.5955 15.5 12 15.5C13.4045 15.5 14.1067 15.5 14.6111 15.1629C14.8295 15.017 15.017 14.8295 15.1629 14.6111C15.5 14.1067 15.5 13.4045 15.5 12C15.5 10.5955 15.5 9.89331 15.1629 9.38886C15.017 9.17048 14.8295 8.98298 14.6111 8.83706C14.1067 8.5 13.4045 8.5 12 8.5C10.5955 8.5 9.89331 8.5 9.38886 8.83706C9.17048 8.98298 8.98298 9.17048 8.83706 9.38886C8.5 9.89331 8.5 10.5955 8.5 12C8.5 13.4045 8.5 14.1067 8.83706 14.6111C8.98298 14.8295 9.17048 15.017 9.38886 15.1629Z" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" />
+</svg>
diff --git a/mobile/native/darwin/Apps/ensu/ensu/Assets.xcassets/ViewIcon.imageset/Contents.json b/mobile/native/darwin/Apps/ensu/ensu/Assets.xcassets/ViewIcon.imageset/Contents.json
new file mode 100644
index 0000000000..c02071aee2
--- /dev/null
+++ b/mobile/native/darwin/Apps/ensu/ensu/Assets.xcassets/ViewIcon.imageset/Contents.json
@@ -0,0 +1,16 @@
+{
+ "images" : [
+ {
+ "filename" : "ViewIcon.svg",
+ "idiom" : "universal"
+ }
+ ],
+ "info" : {
+ "author" : "xcode",
+ "version" : 1
+ },
+ "properties" : {
+ "preserves-vector-representation" : true,
+ "template-rendering-intent" : "template"
+ }
+}
diff --git a/mobile/native/darwin/Apps/ensu/ensu/Assets.xcassets/ViewIcon.imageset/ViewIcon.svg b/mobile/native/darwin/Apps/ensu/ensu/Assets.xcassets/ViewIcon.imageset/ViewIcon.svg
new file mode 100644
index 0000000000..9f453047bc
--- /dev/null
+++ b/mobile/native/darwin/Apps/ensu/ensu/Assets.xcassets/ViewIcon.imageset/ViewIcon.svg
@@ -0,0 +1,4 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
+ <path d="M21.544 11.045C21.848 11.4713 22 11.6845 22 12C22 12.3155 21.848 12.5287 21.544 12.955C20.1779 14.8706 16.6892 19 12 19C7.31078 19 3.8221 14.8706 2.45604 12.955C2.15201 12.5287 2 12.3155 2 12C2 11.6845 2.15201 11.4713 2.45604 11.045C3.8221 9.12944 7.31078 5 12 5C16.6892 5 20.1779 9.12944 21.544 11.045Z" stroke="currentColor" stroke-width="2" />
+ <path d="M15 12C15 10.3431 13.6569 9 12 9C10.3431 9 9 10.3431 9 12C9 13.6569 10.3431 15 12 15C13.6569 15 15 13.6569 15 12Z" stroke="currentColor" stroke-width="2" />
+</svg>
diff --git a/mobile/native/darwin/Apps/ensu/ensu/Assets.xcassets/ViewOffSlashIcon.imageset/Contents.json b/mobile/native/darwin/Apps/ensu/ensu/Assets.xcassets/ViewOffSlashIcon.imageset/Contents.json
new file mode 100644
index 0000000000..b070ed6ee9
--- /dev/null
+++ b/mobile/native/darwin/Apps/ensu/ensu/Assets.xcassets/ViewOffSlashIcon.imageset/Contents.json
@@ -0,0 +1,16 @@
+{
+ "images" : [
+ {
+ "filename" : "ViewOffSlashIcon.svg",
+ "idiom" : "universal"
+ }
+ ],
+ "info" : {
+ "author" : "xcode",
+ "version" : 1
+ },
+ "properties" : {
+ "preserves-vector-representation" : true,
+ "template-rendering-intent" : "template"
+ }
+}
diff --git a/mobile/native/darwin/Apps/ensu/ensu/Assets.xcassets/ViewOffSlashIcon.imageset/ViewOffSlashIcon.svg b/mobile/native/darwin/Apps/ensu/ensu/Assets.xcassets/ViewOffSlashIcon.imageset/ViewOffSlashIcon.svg
new file mode 100644
index 0000000000..13d7e46bb9
--- /dev/null
+++ b/mobile/native/darwin/Apps/ensu/ensu/Assets.xcassets/ViewOffSlashIcon.imageset/ViewOffSlashIcon.svg
@@ -0,0 +1,5 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
+ <path d="M19.439 15.439C20.3636 14.5212 21.0775 13.6091 21.544 12.955C21.848 12.5287 22 12.3155 22 12C22 11.6845 21.848 11.4713 21.544 11.045C20.1779 9.12944 16.6892 5 12 5C11.0922 5 10.2294 5.15476 9.41827 5.41827M6.74742 6.74742C4.73118 8.1072 3.24215 9.94266 2.45604 11.045C2.15201 11.4713 2 11.6845 2 12C2 12.3155 2.15201 12.5287 2.45604 12.955C3.8221 14.8706 7.31078 19 12 19C13.9908 19 15.7651 18.2557 17.2526 17.2526" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" />
+ <path d="M9.85786 10C9.32783 10.53 9 11.2623 9 12.0711C9 13.6887 10.3113 15 11.9289 15C12.7377 15 13.47 14.6722 14 14.1421" stroke="currentColor" stroke-linecap="round" stroke-width="2" />
+ <path d="M3 3L21 21" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" />
+</svg>
diff --git a/mobile/native/darwin/Apps/ensu/ensu/Auth/AuthFlowView.swift b/mobile/native/darwin/Apps/ensu/ensu/Auth/AuthFlowView.swift
index 7c3c923ccf..1c95a5918b 100644
--- a/mobile/native/darwin/Apps/ensu/ensu/Auth/AuthFlowView.swift
+++ b/mobile/native/darwin/Apps/ensu/ensu/Auth/AuthFlowView.swift
@@ -69,9 +69,7 @@ struct AuthFlowView: View {
}
},
center: {
- Text("ensu")
- .font(EnsuTypography.h3)
- .foregroundStyle(EnsuColor.textPrimary)
+ EnsuLogo(height: 20)
},
trailing: {
Button("Close") {
@@ -99,9 +97,7 @@ struct AuthFlowView: View {
#if os(iOS)
.toolbar {
ToolbarItem(placement: .principal) {
- Text("ensu")
- .font(EnsuTypography.h3)
- .foregroundStyle(EnsuColor.textPrimary)
+ EnsuLogo(height: 20)
}
ToolbarItem(placement: trailingPlacement) {
@@ -216,9 +212,7 @@ struct AuthFlowView: View {
}
ToolbarItem(placement: .principal) {
- Text("ensu")
- .font(EnsuTypography.h3)
- .foregroundStyle(EnsuColor.textPrimary)
+ EnsuLogo(height: 20)
}
ToolbarItem(placement: trailingPlacement) {
diff --git a/mobile/native/darwin/Apps/ensu/ensu/Chat/ChatView.swift b/mobile/native/darwin/Apps/ensu/ensu/Chat/ChatView.swift
index 35cdc92c6e..9d777bcde7 100644
--- a/mobile/native/darwin/Apps/ensu/ensu/Chat/ChatView.swift
+++ b/mobile/native/darwin/Apps/ensu/ensu/Chat/ChatView.swift
@@ -17,6 +17,7 @@ struct ChatView: View {
@State private var showDeveloperAlert = false
@State private var showDeveloperSettings = false
@State private var showSignOutAlert = false
+ @State private var showAttachmentDownloads = false
private var editingMessage: ChatMessage? {
guard let editingId = viewModel.editingMessageId else { return nil }
@@ -62,10 +63,23 @@ struct ChatView: View {
isDrawerOpen = false
}
}
+ .onChange(of: viewModel.syncErrorMessage) { message in
+ guard let message else { return }
+ showToast(message, duration: 2)
+ viewModel.syncErrorMessage = nil
+ }
}
.sheet(isPresented: $showModelSettings) {
ModelSettingsView()
}
+ .sheet(isPresented: $showAttachmentDownloads) {
+ AttachmentDownloadsSheet(
+ downloads: viewModel.attachmentDownloads,
+ sessionTitle: { viewModel.sessionTitle(for: $0) },
+ onCancel: { viewModel.cancelAttachmentDownload($0) },
+ onDismiss: { showAttachmentDownloads = false }
+ )
+ }
.platformFullScreenCover(isPresented: $showDeveloperSettings) {
DeveloperSettingsView { message in
showToast(message, duration: 2)
@@ -119,13 +133,16 @@ struct ChatView: View {
private func mainContent(showsMenuButton: Bool) -> some View {
VStack(spacing: 0) {
ChatAppBar(
- title: "ensu",
sessionTitle: viewModel.currentSession?.title ?? "New chat",
showBrand: viewModel.messages.isEmpty,
showSignIn: !appState.isLoggedIn,
showsMenuButton: showsMenuButton,
+ attachmentDownloadSummary: viewModel.attachmentDownloadSummary,
onMenu: { isDrawerOpen.toggle() },
- onSignIn: { isShowingAuth = true }
+ onSignIn: { isShowingAuth = true },
+ onAttachmentDownloads: {
+ showAttachmentDownloads = true
+ }
)
Divider()
@@ -163,6 +180,7 @@ struct ChatView: View {
isDownloading: viewModel.isDownloading,
editingMessage: editingMessage,
isProcessingAttachments: viewModel.isProcessingAttachments,
+ isAttachmentDownloadBlocked: viewModel.isAttachmentDownloadBlocked,
onSend: {
viewModel.sendDraft()
},
@@ -218,7 +236,7 @@ struct ChatView: View {
deleteSession = session
},
onSync: {
- viewModel.retryDownload()
+ viewModel.syncNow()
},
onShowLogs: {
showToast("Logs are not available yet.", duration: 2)
@@ -289,14 +307,101 @@ private struct ToastMessage: Identifiable {
let text: String
}
+private struct AttachmentDownloadsSheet: View {
+ let downloads: [AttachmentDownloadItem]
+ let sessionTitle: (UUID) -> String
+ let onCancel: (String) -> Void
+ let onDismiss: () -> Void
+
+ var body: some View {
+ VStack(spacing: 0) {
+ HStack {
+ Text("Attachment downloads")
+ .font(EnsuTypography.h3Bold)
+ Spacer()
+ Button("Close", action: onDismiss)
+ .font(EnsuTypography.small)
+ .foregroundStyle(EnsuColor.accent)
+ }
+ .padding(.horizontal, EnsuSpacing.pageHorizontal)
+ .padding(.vertical, EnsuSpacing.sm)
+
+ Divider()
+ .background(EnsuColor.border)
+
+ if downloads.isEmpty {
+ Text("No pending downloads")
+ .font(EnsuTypography.body)
+ .foregroundStyle(EnsuColor.textMuted)
+ .padding(.top, EnsuSpacing.lg)
+ Spacer()
+ } else {
+ List(downloads) { item in
+ HStack(spacing: EnsuSpacing.md) {
+ VStack(alignment: .leading, spacing: 4) {
+ Text(item.name)
+ .font(EnsuTypography.body)
+ .foregroundStyle(EnsuColor.textPrimary)
+ .lineLimit(1)
+ Text("\(sessionTitle(item.sessionId)) β€’ \(item.formattedSize)")
+ .font(EnsuTypography.mini)
+ .foregroundStyle(EnsuColor.textMuted)
+ if item.status == .failed, let errorMessage = item.errorMessage, !errorMessage.isEmpty {
+ Text(errorMessage)
+ .font(EnsuTypography.mini)
+ .foregroundStyle(EnsuColor.error)
+ .lineLimit(2)
+ }
+ }
+
+ Spacer()
+
+ Text(statusText(for: item.status))
+ .font(EnsuTypography.mini)
+ .foregroundStyle(EnsuColor.textMuted)
+
+ if item.status == .queued || item.status == .downloading {
+ Button(action: { onCancel(item.id) }) {
+ Image(systemName: "xmark.circle.fill")
+ .foregroundStyle(EnsuColor.textMuted)
+ }
+ .buttonStyle(.plain)
+ }
+ }
+ .padding(.vertical, 4)
+ }
+ .listStyle(.plain)
+ }
+ }
+ .frame(minHeight: 320)
+ .background(EnsuColor.backgroundBase)
+ }
+
+ private func statusText(for status: AttachmentDownloadItem.Status) -> String {
+ switch status {
+ case .queued:
+ return "Queued"
+ case .downloading:
+ return "Downloading"
+ case .completed:
+ return "Completed"
+ case .failed:
+ return "Failed"
+ case .canceled:
+ return "Canceled"
+ }
+ }
+}
+
private struct ChatAppBar: View {
- let title: String
let sessionTitle: String
let showBrand: Bool
let showSignIn: Bool
let showsMenuButton: Bool
+ let attachmentDownloadSummary: (completed: Int, total: Int)?
let onMenu: () -> Void
let onSignIn: () -> Void
+ let onAttachmentDownloads: () -> Void
private let centerInset: CGFloat = 72
@@ -324,15 +429,36 @@ private struct ChatAppBar: View {
.foregroundStyle(EnsuColor.accent)
}
.buttonStyle(.plain)
+ } else if let summary = attachmentDownloadSummary {
+ Button(action: onAttachmentDownloads) {
+ HStack(spacing: 6) {
+ Image(systemName: "arrow.down.circle")
+ .font(.system(size: 14, weight: .semibold))
+ .foregroundStyle(EnsuColor.textPrimary)
+ Text("\(summary.completed)/\(summary.total)")
+ .font(EnsuTypography.mini)
+ .foregroundStyle(EnsuColor.textMuted)
+ }
+ .padding(.horizontal, 8)
+ .padding(.vertical, 6)
+ .background(EnsuColor.fillFaint)
+ .clipShape(RoundedRectangle(cornerRadius: 8, style: .continuous))
+ }
+ .buttonStyle(.plain)
}
}
- Text(showBrand ? title : sessionTitle)
- .font(showBrand ? EnsuTypography.h3Bold : EnsuTypography.large)
- .foregroundStyle(EnsuColor.textPrimary)
- .lineLimit(1)
- .minimumScaleFactor(0.85)
- .padding(.horizontal, centerInset)
+ if showBrand {
+ EnsuLogo(height: 20)
+ .padding(.horizontal, centerInset)
+ } else {
+ Text(sessionTitle)
+ .font(EnsuTypography.large)
+ .foregroundStyle(EnsuColor.textPrimary)
+ .lineLimit(1)
+ .minimumScaleFactor(0.85)
+ .padding(.horizontal, centerInset)
+ }
}
.padding(.horizontal, EnsuSpacing.pageHorizontal)
.padding(.vertical, EnsuSpacing.sm)
diff --git a/mobile/native/darwin/Apps/ensu/ensu/Chat/ChatViewModel.swift b/mobile/native/darwin/Apps/ensu/ensu/Chat/ChatViewModel.swift
index 977bc3313f..0f13bd3285 100644
--- a/mobile/native/darwin/Apps/ensu/ensu/Chat/ChatViewModel.swift
+++ b/mobile/native/darwin/Apps/ensu/ensu/Chat/ChatViewModel.swift
@@ -1,4 +1,5 @@
import Foundation
+import EnteCore
struct ChatAttachment: Identifiable, Equatable {
enum Kind {
@@ -36,6 +37,27 @@ struct ChatAttachment: Identifiable, Equatable {
}
}
+struct AttachmentDownloadItem: Identifiable, Equatable {
+ enum Status {
+ case queued
+ case downloading
+ case completed
+ case failed
+ case canceled
+ }
+
+ let id: String
+ let sessionId: UUID
+ let name: String
+ let size: Int64
+ var status: Status
+ var errorMessage: String? = nil
+
+ var formattedSize: String {
+ ByteCountFormatter.string(fromByteCount: size, countStyle: .file)
+ }
+}
+
struct ChatMessage: Identifiable, Equatable {
enum Role: String {
case user
@@ -137,9 +159,13 @@ final class ChatViewModel: ObservableObject {
@Published var draftAttachments: [ChatAttachment] = []
@Published var editingMessageId: UUID?
@Published var downloadToast: DownloadToastState?
+ @Published var attachmentDownloads: [AttachmentDownloadItem] = []
+ @Published var currentSessionMissingAttachments: [AttachmentDownloadItem] = []
+ @Published var syncErrorMessage: String?
private let provider: InferenceRsProvider
private let chatDb: LlmChatDb
+ private let syncEngine: LlmChatSync
private let attachmentsDir: URL
private let modelSettings = ModelSettingsStore.shared
@@ -150,6 +176,12 @@ final class ChatViewModel: ObservableObject {
private var stopRequested = false
private var activeGenerationId: UUID?
private var activeGenerationSessionId: UUID?
+ private var pendingSyncRequested = false
+ private var pendingSyncShowErrors = false
+
+ private var attachmentDownloadQueue: [String] = []
+ private var attachmentDownloadTasks: [String: Task<Void, Never>] = [:]
+ private let maxAttachmentDownloads = 2
init() {
let baseDir = FileManager.default.urls(for: .applicationSupportDirectory, in: .userDomainMask).first
@@ -176,40 +208,42 @@ final class ChatViewModel: ObservableObject {
fatalError("Failed to open chat DB: \(error)")
}
- // Load sessions/messages.
- let loaded = (try? chatDb.listSessions()) ?? []
- var sessions: [ChatSession] = []
+ let syncMetaDir = dbDir.appendingPathComponent("sync_meta", isDirectory: true)
+ try? FileManager.default.createDirectory(at: syncMetaDir, withIntermediateDirectories: true, attributes: nil)
+ let encryptedAttachmentsDir = dbDir.appendingPathComponent("chat_attachments_encrypted", isDirectory: true)
+ try? FileManager.default.createDirectory(at: encryptedAttachmentsDir, withIntermediateDirectories: true, attributes: nil)
- if loaded.isEmpty {
- if let created = try? chatDb.createSession(title: "New chat"),
- let id = UUID(uuidString: created.uuid) {
- sessions = [ChatSession(
- id: id,
- title: created.title,
- lastMessage: "",
- updatedAt: Date(timeIntervalSince1970: Double(created.updatedAtUs) / 1_000_000.0)
- )]
- }
- } else {
- sessions = loaded.compactMap { session in
- guard let id = UUID(uuidString: session.uuid) else { return nil }
- let lastMessage = (try? chatDb.getMessages(sessionUuid: session.uuid))?.last?.text ?? ""
- return ChatSession(
- id: id,
- title: session.title,
- lastMessage: lastMessage,
- updatedAt: Date(timeIntervalSince1970: Double(session.updatedAtUs) / 1_000_000.0)
- )
- }
+ let syncEngine: LlmChatSync
+ do {
+ syncEngine = try LlmChatSync.open(
+ mainDbPath: mainDbPath,
+ attachmentsDbPath: attachmentsDbPath,
+ dbKey: key,
+ attachmentsDir: encryptedAttachmentsDir.path,
+ metaDir: syncMetaDir.path,
+ plaintextDir: attachmentsDir.path
+ )
+ } catch {
+ fatalError("Failed to open chat sync: \(error)")
}
- if sessions.isEmpty {
- sessions = [ChatSession(title: "New chat", lastMessage: "", updatedAt: Date())]
+ // Load sessions/messages.
+ let loaded = (try? chatDb.listSessions()) ?? []
+ let sessions: [ChatSession] = loaded.compactMap { session in
+ guard let id = UUID(uuidString: session.uuid) else { return nil }
+ let lastMessage = (try? chatDb.getMessages(sessionUuid: session.uuid))?.last?.text ?? ""
+ return ChatSession(
+ id: id,
+ title: session.title,
+ lastMessage: lastMessage,
+ updatedAt: Date(timeIntervalSince1970: Double(session.updatedAtUs) / 1_000_000.0)
+ )
}
// Stored properties.
self.provider = provider
self.chatDb = chatDb
+ self.syncEngine = syncEngine
self.attachmentsDir = attachmentsDir
self.sessions = sessions
@@ -224,6 +258,9 @@ final class ChatViewModel: ObservableObject {
if let current = self.currentSessionId {
loadMessagesFromDb(for: current)
rebuildMessages(for: current)
+ queueMissingAttachments(for: current)
+ } else {
+ refreshAttachmentDownloadState()
}
}
@@ -232,6 +269,36 @@ final class ChatViewModel: ObservableObject {
return sessions.first { $0.id == currentSessionId }
}
+ var isAttachmentDownloadBlocked: Bool {
+ !currentSessionMissingAttachments.isEmpty
+ }
+
+ var attachmentDownloadProgress: Double? {
+ let active = attachmentDownloads.filter { $0.status != .canceled }
+ let total = active.count
+ guard total > 0 else { return nil }
+ guard active.contains(where: { $0.status == .queued || $0.status == .downloading || $0.status == .failed }) else {
+ return nil
+ }
+ let completed = active.filter { $0.status == .completed }.count
+ return Double(completed) / Double(total)
+ }
+
+ var attachmentDownloadSummary: (completed: Int, total: Int)? {
+ let active = attachmentDownloads.filter { $0.status != .canceled }
+ let total = active.count
+ guard total > 0 else { return nil }
+ guard active.contains(where: { $0.status == .queued || $0.status == .downloading || $0.status == .failed }) else {
+ return nil
+ }
+ let completed = active.filter { $0.status == .completed }.count
+ return (completed, total)
+ }
+
+ func sessionTitle(for sessionId: UUID) -> String {
+ sessions.first { $0.id == sessionId }?.title ?? "Chat"
+ }
+
func startNewSession() {
generationTask?.cancel()
provider.stopGeneration()
@@ -247,16 +314,9 @@ final class ChatViewModel: ObservableObject {
draftAttachments = []
editingMessageId = nil
- let created = (try? chatDb.createSession(title: "New chat"))
- let sessionId = created.flatMap { UUID(uuidString: $0.uuid) } ?? UUID()
- let updatedAt = created.map { Date(timeIntervalSince1970: Double($0.updatedAtUs) / 1_000_000.0) } ?? Date()
-
- let session = ChatSession(id: sessionId, title: created?.title ?? "New chat", lastMessage: "", updatedAt: updatedAt)
- sessions.insert(session, at: 0)
- currentSessionId = session.id
- messageStore[session.id] = []
- branchSelections[session.id] = [:]
- rebuildMessages(for: session.id)
+ currentSessionId = nil
+ messages = []
+ refreshAttachmentDownloadState()
}
func selectSession(_ session: ChatSession) {
@@ -273,6 +333,7 @@ final class ChatViewModel: ObservableObject {
currentSessionId = session.id
loadMessagesFromDb(for: session.id)
rebuildMessages(for: session.id)
+ queueMissingAttachments(for: session.id)
}
func deleteSession(_ session: ChatSession) {
@@ -293,13 +354,58 @@ final class ChatViewModel: ObservableObject {
sessions.removeAll { $0.id == session.id }
messageStore[session.id] = nil
branchSelections[session.id] = nil
+ purgeAttachmentDownloads(for: session.id)
if currentSessionId == session.id {
currentSessionId = sessions.first?.id
if let next = currentSessionId {
loadMessagesFromDb(for: next)
rebuildMessages(for: next)
+ queueMissingAttachments(for: next)
} else {
messages = []
+ refreshAttachmentDownloadState()
+ }
+ }
+ syncNow()
+ }
+
+ func syncNow(showErrors: Bool = true) {
+ if isGenerating {
+ pendingSyncRequested = true
+ pendingSyncShowErrors = pendingSyncShowErrors || showErrors
+ return
+ }
+
+ let shouldSync = pendingSyncRequested || showErrors
+ let shouldShowErrors = pendingSyncShowErrors || showErrors
+ pendingSyncRequested = false
+ pendingSyncShowErrors = false
+ guard shouldSync else { return }
+ performSync(showErrors: shouldShowErrors)
+ }
+
+ private func performSync(showErrors: Bool) {
+ guard let auth = buildSyncAuth() else {
+ if showErrors {
+ syncErrorMessage = "Sync failed: Sign in to sync"
+ }
+ return
+ }
+
+ Task.detached { [weak self] in
+ guard let self else { return }
+ do {
+ _ = try self.syncEngine.sync(auth: auth)
+ await MainActor.run {
+ self.reloadFromDb()
+ }
+ } catch {
+ let message = syncErrorMessage(from: error)
+ await MainActor.run {
+ if showErrors {
+ self.syncErrorMessage = "Sync failed: \(message)"
+ }
+ }
}
}
}
@@ -318,7 +424,7 @@ final class ChatViewModel: ObservableObject {
}
func addImageAttachment(data: Data, fileName: String?) {
- guard !isGenerating && !isDownloading else { return }
+ guard !isGenerating && !isDownloading && !isAttachmentDownloadBlocked else { return }
isProcessingAttachments = true
Task.detached { [weak self] in
@@ -345,7 +451,7 @@ final class ChatViewModel: ObservableObject {
}
func addDocumentAttachment(url: URL) {
- guard !isGenerating && !isDownloading else { return }
+ guard !isGenerating && !isDownloading && !isAttachmentDownloadBlocked else { return }
isProcessingAttachments = true
Task.detached { [weak self] in
@@ -383,6 +489,11 @@ final class ChatViewModel: ObservableObject {
let sessionId = currentSessionId ?? createSessionForDraft()
+ if !missingAttachments(for: sessionId).isEmpty {
+ queueMissingAttachments(for: sessionId)
+ return
+ }
+
let parentId: UUID? = {
if let editingId = editingMessageId {
let existing = messageStore[sessionId]?.first { $0.id == editingId }
@@ -393,7 +504,7 @@ final class ChatViewModel: ObservableObject {
let meta: [AttachmentMeta] = attachments.map { attachment in
AttachmentMeta(
- id: attachment.id.uuidString,
+ id: attachment.id.uuidString.lowercased(),
kind: attachment.kind == .image ? .image : .document,
size: attachment.size,
name: attachment.name
@@ -434,6 +545,7 @@ final class ChatViewModel: ObservableObject {
updateSessionPreview(sessionId: sessionId, preview: trimmed, date: timestamp)
rebuildMessages(for: sessionId)
startGeneration(for: userNode)
+ syncNow(showErrors: false)
}
func stopGenerating() {
@@ -479,8 +591,13 @@ final class ChatViewModel: ObservableObject {
let userNode = messageStore[sessionId]?.first(where: { $0.id == parent }) else {
return
}
+ if !missingAttachments(for: sessionId).isEmpty {
+ queueMissingAttachments(for: sessionId)
+ return
+ }
provider.resetContext()
startGeneration(for: userNode)
+ syncNow(showErrors: false)
}
func changeBranch(for message: ChatMessage, delta: Int) {
@@ -508,6 +625,7 @@ final class ChatViewModel: ObservableObject {
currentSessionId = session.id
messageStore[session.id] = []
branchSelections[session.id] = [:]
+ refreshAttachmentDownloadState()
return session.id
}
@@ -544,6 +662,7 @@ final class ChatViewModel: ObservableObject {
activeGenerationId = nil
activeGenerationSessionId = nil
}
+ syncNow(showErrors: false)
return
}
if self.activeGenerationId == generationId {
@@ -554,6 +673,7 @@ final class ChatViewModel: ObservableObject {
activeGenerationId = nil
activeGenerationSessionId = nil
}
+ syncNow(showErrors: false)
return
}
@@ -641,6 +761,7 @@ final class ChatViewModel: ObservableObject {
if currentSessionId == parent.sessionId {
rebuildMessages(for: parent.sessionId)
}
+ syncNow(showErrors: false)
}
private func handleProgress(_ progress: InferenceDownloadProgress) {
@@ -675,6 +796,225 @@ final class ChatViewModel: ObservableObject {
isDownloading = progress.percent >= 0 && progress.percent < 100
}
+ private func buildSyncAuth() -> SyncAuth? {
+ guard CredentialStore.shared.hasConfiguredAccount,
+ let token = CredentialStore.shared.token,
+ let masterKey = CredentialStore.shared.masterKey else {
+ return nil
+ }
+
+ let baseUrl = EnsuDeveloperSettings.networkConfiguration.apiEndpoint.absoluteString
+ let version = Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String
+ return SyncAuth(
+ baseUrl: baseUrl,
+ authToken: token,
+ masterKey: masterKey,
+ userAgent: EntePlatform.current.userAgent,
+ clientPackage: EnteApp.ensu.packageIdentifier,
+ clientVersion: version
+ )
+ }
+
+ private nonisolated func syncErrorMessage(from error: Error) -> String {
+ if let syncError = error as? SyncError {
+ switch syncError {
+ case let .Message(message):
+ return message
+ }
+ }
+ let description = error.localizedDescription
+ if description.isEmpty {
+ return String(describing: error)
+ }
+ return description
+ }
+
+ private func queueMissingAttachments(for sessionId: UUID) {
+ let missing = missingAttachments(for: sessionId)
+ guard !missing.isEmpty else {
+ refreshAttachmentDownloadState()
+ return
+ }
+
+ var updated = attachmentDownloads
+ for item in missing {
+ if let existingIndex = updated.firstIndex(where: { $0.id == item.id }) {
+ if updated[existingIndex].status == .failed || updated[existingIndex].status == .canceled {
+ updated[existingIndex].status = .queued
+ updated[existingIndex].errorMessage = nil
+ }
+ } else {
+ updated.append(item)
+ }
+ }
+
+ attachmentDownloads = updated
+ for item in missing {
+ if !attachmentDownloadQueue.contains(item.id) && attachmentDownloadTasks[item.id] == nil {
+ attachmentDownloadQueue.append(item.id)
+ }
+ }
+
+ refreshAttachmentDownloadState()
+ startNextAttachmentDownloads()
+ }
+
+ private func missingAttachments(for sessionId: UUID) -> [AttachmentDownloadItem] {
+ guard let nodes = messageStore[sessionId], !nodes.isEmpty else { return [] }
+ var seen = Set<String>()
+ var missing: [AttachmentDownloadItem] = []
+
+ for node in nodes {
+ for attachment in node.attachments {
+ let id = attachment.id.uuidString.lowercased()
+ if seen.contains(id) { continue }
+ seen.insert(id)
+ let path = attachmentsDir.appendingPathComponent(id).path
+ if FileManager.default.fileExists(atPath: path) {
+ attachmentDownloadTasks[id]?.cancel()
+ attachmentDownloadTasks[id] = nil
+ attachmentDownloadQueue.removeAll { $0 == id }
+ attachmentDownloads.removeAll { $0.id == id }
+ continue
+ }
+ let existing = attachmentDownloads.first { $0.id == id }
+ let status = existing?.status ?? .queued
+ missing.append(AttachmentDownloadItem(
+ id: id,
+ sessionId: sessionId,
+ name: attachment.name,
+ size: attachment.size,
+ status: status,
+ errorMessage: existing?.errorMessage
+ ))
+ }
+ }
+
+ return missing
+ }
+
+ private func startNextAttachmentDownloads() {
+ guard attachmentDownloadTasks.count < maxAttachmentDownloads else { return }
+ guard let auth = buildSyncAuth() else { return }
+
+ while attachmentDownloadTasks.count < maxAttachmentDownloads, !attachmentDownloadQueue.isEmpty {
+ let id = attachmentDownloadQueue.removeFirst()
+ guard let index = attachmentDownloads.firstIndex(where: { $0.id == id }) else { continue }
+ if attachmentDownloads[index].status == .canceled || attachmentDownloads[index].status == .completed {
+ continue
+ }
+ let sessionId = attachmentDownloads[index].sessionId
+ attachmentDownloads[index].status = .downloading
+
+ let task = Task.detached { [weak self] in
+ guard let self else { return }
+ do {
+ _ = try self.syncEngine.downloadAttachment(
+ attachmentId: id,
+ sessionUuid: sessionId.uuidString,
+ auth: auth
+ )
+ await MainActor.run {
+ self.updateAttachmentDownloadStatus(id: id, status: .completed, errorMessage: nil)
+ }
+ } catch {
+ let message = self.syncErrorMessage(from: error)
+ await MainActor.run {
+ self.updateAttachmentDownloadStatus(id: id, status: .failed, errorMessage: message)
+ }
+ }
+ }
+ attachmentDownloadTasks[id] = task
+ }
+ }
+
+ private func updateAttachmentDownloadStatus(
+ id: String,
+ status: AttachmentDownloadItem.Status,
+ errorMessage: String?
+ ) {
+ if let index = attachmentDownloads.firstIndex(where: { $0.id == id }) {
+ if attachmentDownloads[index].status != .canceled {
+ attachmentDownloads[index].status = status
+ attachmentDownloads[index].errorMessage = status == .failed ? errorMessage : nil
+ }
+ }
+ attachmentDownloadTasks[id] = nil
+ refreshAttachmentDownloadState()
+ startNextAttachmentDownloads()
+ }
+
+ private func refreshAttachmentDownloadState() {
+ if let sessionId = currentSessionId {
+ currentSessionMissingAttachments = missingAttachments(for: sessionId)
+ } else {
+ currentSessionMissingAttachments = []
+ }
+ }
+
+ func cancelAttachmentDownload(_ id: String) {
+ if let task = attachmentDownloadTasks[id] {
+ task.cancel()
+ attachmentDownloadTasks[id] = nil
+ }
+ if let index = attachmentDownloads.firstIndex(where: { $0.id == id }) {
+ attachmentDownloads[index].status = .canceled
+ }
+ attachmentDownloadQueue.removeAll { $0 == id }
+ refreshAttachmentDownloadState()
+ startNextAttachmentDownloads()
+ }
+
+ private func purgeAttachmentDownloads(for sessionId: UUID) {
+ let ids = attachmentDownloads.filter { $0.sessionId == sessionId }.map { $0.id }
+ for id in ids {
+ attachmentDownloadTasks[id]?.cancel()
+ attachmentDownloadTasks[id] = nil
+ attachmentDownloadQueue.removeAll { $0 == id }
+ attachmentDownloads.removeAll { $0.id == id }
+ }
+ refreshAttachmentDownloadState()
+ startNextAttachmentDownloads()
+ }
+
+ private func reloadFromDb() {
+ let loaded = (try? chatDb.listSessions()) ?? []
+ let refreshed: [ChatSession] = loaded.compactMap { session in
+ guard let id = UUID(uuidString: session.uuid) else { return nil }
+ let lastMessage = (try? chatDb.getMessages(sessionUuid: session.uuid))?.last?.text ?? ""
+ return ChatSession(
+ id: id,
+ title: session.title,
+ lastMessage: lastMessage,
+ updatedAt: Date(timeIntervalSince1970: Double(session.updatedAtUs) / 1_000_000.0)
+ )
+ }
+
+ let selected = currentSessionId
+ let resolved = selected.flatMap { id in
+ refreshed.first(where: { $0.id == id })?.id
+ } ?? (selected == nil ? nil : refreshed.first?.id)
+
+ sessions = refreshed
+ currentSessionId = resolved
+ messages = []
+ messageStore = [:]
+ branchSelections = [:]
+
+ for session in refreshed {
+ messageStore[session.id] = []
+ branchSelections[session.id] = [:]
+ }
+
+ if let current = resolved {
+ loadMessagesFromDb(for: current)
+ rebuildMessages(for: current)
+ queueMissingAttachments(for: current)
+ } else {
+ refreshAttachmentDownloadState()
+ }
+ }
+
private func loadMessagesFromDb(for sessionId: UUID) {
guard messageStore[sessionId] != nil else {
messageStore[sessionId] = []
@@ -857,14 +1197,14 @@ final class ChatViewModel: ObservableObject {
private nonisolated func writeAttachment(data: Data, attachmentId: UUID) throws -> URL {
let dir = try attachmentsDirectory()
- let destination = dir.appendingPathComponent(attachmentId.uuidString)
+ let destination = dir.appendingPathComponent(attachmentId.uuidString.lowercased())
try data.write(to: destination, options: .atomic)
return destination
}
private nonisolated func copyAttachment(from url: URL, attachmentId: UUID) throws -> URL {
let dir = try attachmentsDirectory()
- let destination = dir.appendingPathComponent(attachmentId.uuidString)
+ let destination = dir.appendingPathComponent(attachmentId.uuidString.lowercased())
let needsSecurity = url.startAccessingSecurityScopedResource()
defer {
diff --git a/mobile/native/darwin/Apps/ensu/ensu/Chat/MessageInputView.swift b/mobile/native/darwin/Apps/ensu/ensu/Chat/MessageInputView.swift
index 143b9296a9..eff3b03728 100644
--- a/mobile/native/darwin/Apps/ensu/ensu/Chat/MessageInputView.swift
+++ b/mobile/native/darwin/Apps/ensu/ensu/Chat/MessageInputView.swift
@@ -10,6 +10,7 @@ struct MessageInputView: View {
let isDownloading: Bool
let editingMessage: ChatMessage?
let isProcessingAttachments: Bool
+ let isAttachmentDownloadBlocked: Bool
let onSend: () -> Void
let onStop: () -> Void
let onCancelEdit: () -> Void
@@ -20,15 +21,20 @@ struct MessageInputView: View {
@StateObject private var keyboard = KeyboardObserver()
@FocusState private var isFocused: Bool
@State private var isImagePickerPresented = false
- @State private var isDocumentPickerPresented = false
private var placeholder: String {
- isDownloading ? "Downloading model... (queue messages)" : "Compose your message..."
+ if isDownloading {
+ return "Downloading model... (queue messages)"
+ }
+ if isAttachmentDownloadBlocked {
+ return "Downloading attachments..."
+ }
+ return "Compose your message..."
}
private var canSend: Bool {
let hasContent = !text.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty || !attachments.isEmpty
- return hasContent && !isGenerating && !isDownloading
+ return hasContent && !isGenerating && !isDownloading && !isAttachmentDownloadBlocked
}
var body: some View {
@@ -90,23 +96,16 @@ struct MessageInputView: View {
}
if editingMessage == nil {
- Menu {
- Button("Image") {
- isImagePickerPresented = true
- }
- Button("Document") {
- isDocumentPickerPresented = true
- }
+ Button {
+ isImagePickerPresented = true
} label: {
Image(systemName: "paperclip")
.font(attachmentIconFont)
.frame(width: 32, height: 32, alignment: .center)
}
- .disabled(isGenerating || isDownloading)
+ .disabled(isGenerating || isDownloading || isAttachmentDownloadBlocked)
.foregroundStyle(EnsuColor.textMuted)
#if os(macOS)
- .menuStyle(.borderlessButton)
- .menuIndicator(.hidden)
.buttonStyle(.plain)
.frame(width: 32, height: 32, alignment: .center)
#endif
@@ -121,17 +120,6 @@ struct MessageInputView: View {
}
)
}
- .sheet(isPresented: $isDocumentPickerPresented) {
- DocumentPicker(
- onPick: { url in
- onAddDocument(url)
- isDocumentPickerPresented = false
- },
- onCancel: {
- isDocumentPickerPresented = false
- }
- )
- }
}
Button {
diff --git a/mobile/native/darwin/Apps/ensu/ensu/Chat/MessageListView.swift b/mobile/native/darwin/Apps/ensu/ensu/Chat/MessageListView.swift
index 807e257857..1551ecc077 100644
--- a/mobile/native/darwin/Apps/ensu/ensu/Chat/MessageListView.swift
+++ b/mobile/native/darwin/Apps/ensu/ensu/Chat/MessageListView.swift
@@ -1,4 +1,5 @@
import SwiftUI
+import QuickLook
struct MessageListView: View {
let messages: [ChatMessage]
@@ -13,6 +14,7 @@ struct MessageListView: View {
@State private var isAtBottom = true
@State private var autoScrollEnabled = true
+ @State private var previewItem: AttachmentPreviewItem?
var body: some View {
GeometryReader { proxy in
@@ -32,7 +34,8 @@ struct MessageListView: View {
message: message,
onEdit: { onEdit(message) },
onCopy: { onCopy(message) },
- onBranchChange: { delta in onBranchChange(message, delta) }
+ onBranchChange: { delta in onBranchChange(message, delta) },
+ onOpenAttachment: openAttachment
)
.id(message.id)
} else {
@@ -41,7 +44,8 @@ struct MessageListView: View {
onCopy: { onCopy(message) },
onShowRaw: { onShowRaw(message) },
onRetry: { onRetry(message) },
- onBranchChange: { delta in onBranchChange(message, delta) }
+ onBranchChange: { delta in onBranchChange(message, delta) },
+ onOpenAttachment: openAttachment
)
.id(message.id)
}
@@ -97,6 +101,9 @@ struct MessageListView: View {
}
}
}
+ .sheet(item: $previewItem) { item in
+ QuickLookPreview(url: item.url)
+ }
}
private func scrollToBottom(_ proxy: ScrollViewProxy, force: Bool = false) {
@@ -105,6 +112,12 @@ struct MessageListView: View {
proxy.scrollTo("bottom", anchor: .bottom)
}
}
+
+ private func openAttachment(_ attachment: ChatAttachment) {
+ guard let url = attachment.url else { return }
+ guard FileManager.default.fileExists(atPath: url.path) else { return }
+ previewItem = AttachmentPreviewItem(url: url)
+ }
}
private struct BottomOffsetKey: PreferenceKey {
@@ -115,11 +128,52 @@ private struct BottomOffsetKey: PreferenceKey {
}
}
+private struct AttachmentPreviewItem: Identifiable {
+ let url: URL
+ var id: String { url.path }
+}
+
+private struct QuickLookPreview: UIViewControllerRepresentable {
+ let url: URL
+
+ func makeUIViewController(context: Context) -> QLPreviewController {
+ let controller = QLPreviewController()
+ controller.dataSource = context.coordinator
+ return controller
+ }
+
+ func updateUIViewController(_ uiViewController: QLPreviewController, context: Context) {
+ context.coordinator.url = url
+ uiViewController.reloadData()
+ }
+
+ func makeCoordinator() -> Coordinator {
+ Coordinator(url: url)
+ }
+
+ final class Coordinator: NSObject, QLPreviewControllerDataSource {
+ var url: URL
+
+ init(url: URL) {
+ self.url = url
+ }
+
+ func numberOfPreviewItems(in controller: QLPreviewController) -> Int {
+ 1
+ }
+
+ func previewController(_ controller: QLPreviewController, previewItemAt index: Int) -> QLPreviewItem {
+ url as NSURL
+ }
+ }
+}
+
private struct UserMessageBubbleView: View {
let message: ChatMessage
let onEdit: () -> Void
let onCopy: () -> Void
let onBranchChange: (Int) -> Void
+ let onOpenAttachment: (ChatAttachment) -> Void
var body: some View {
HStack(alignment: .bottom) {
@@ -135,6 +189,9 @@ private struct UserMessageBubbleView: View {
icon: attachment.iconName,
isUploading: attachment.isUploading
)
+ .onTapGesture {
+ onOpenAttachment(attachment)
+ }
}
}
.frame(maxWidth: .infinity, alignment: .trailing)
@@ -175,6 +232,7 @@ private struct AssistantMessageBubbleView: View {
let onShowRaw: () -> Void
let onRetry: () -> Void
let onBranchChange: (Int) -> Void
+ let onOpenAttachment: (ChatAttachment) -> Void
var body: some View {
HStack(alignment: .bottom) {
diff --git a/mobile/native/darwin/Apps/ensu/ensu/Chat/SessionDrawerView.swift b/mobile/native/darwin/Apps/ensu/ensu/Chat/SessionDrawerView.swift
index efc4c35d22..2c4f0be340 100644
--- a/mobile/native/darwin/Apps/ensu/ensu/Chat/SessionDrawerView.swift
+++ b/mobile/native/darwin/Apps/ensu/ensu/Chat/SessionDrawerView.swift
@@ -53,10 +53,7 @@ struct SessionDrawerView: View {
private var drawerHeader: some View {
VStack(alignment: .leading, spacing: EnsuSpacing.md) {
HStack {
- Text("ensu")
- .font(EnsuTypography.h2)
- .tracking(1)
- .foregroundStyle(EnsuColor.textPrimary)
+ EnsuLogo(height: 28)
.contentShape(Rectangle())
.onTapGesture {
onDeveloperTap()
@@ -113,28 +110,27 @@ struct SessionDrawerView: View {
}
private func sessionTile(_ session: ChatSession) -> some View {
- Button {
- onSelectSession(session)
- } label: {
- HStack(alignment: .center, spacing: EnsuSpacing.sm) {
- VStack(alignment: .leading, spacing: 4) {
- Text(session.title)
- .font(session.id == currentSessionId ? EnsuFont.ui(size: 16, weight: .semibold) : EnsuTypography.small)
- .foregroundStyle(EnsuColor.textPrimary)
- Text(session.lastMessage)
- .font(EnsuTypography.mini)
- .foregroundStyle(EnsuColor.textMuted)
- .lineLimit(1)
- }
- Spacer()
- ActionButton(icon: "trash", color: EnsuColor.textMuted) {
- onDeleteSession(session)
- }
+ HStack(alignment: .center, spacing: EnsuSpacing.sm) {
+ VStack(alignment: .leading, spacing: 4) {
+ Text(session.title)
+ .font(session.id == currentSessionId ? EnsuFont.ui(size: 16, weight: .semibold) : EnsuTypography.small)
+ .foregroundStyle(EnsuColor.textPrimary)
+ Text(session.lastMessage)
+ .font(EnsuTypography.mini)
+ .foregroundStyle(EnsuColor.textMuted)
+ .lineLimit(1)
+ }
+ Spacer()
+ ActionButton(icon: "trash", color: EnsuColor.textMuted) {
+ onDeleteSession(session)
}
- .padding(.horizontal, EnsuSpacing.lg)
- .padding(.vertical, EnsuSpacing.sm)
}
- .buttonStyle(.plain)
+ .padding(.horizontal, EnsuSpacing.lg)
+ .padding(.vertical, EnsuSpacing.sm)
+ .contentShape(Rectangle())
+ .onTapGesture {
+ onSelectSession(session)
+ }
}
private var footer: some View {
diff --git a/mobile/native/darwin/Apps/ensu/ensu/Components/EnsuLogo.swift b/mobile/native/darwin/Apps/ensu/ensu/Components/EnsuLogo.swift
new file mode 100644
index 0000000000..580c5a5e73
--- /dev/null
+++ b/mobile/native/darwin/Apps/ensu/ensu/Components/EnsuLogo.swift
@@ -0,0 +1,20 @@
+import SwiftUI
+
+struct EnsuLogo: View {
+ var height: CGFloat = 24
+ var horizontalPadding: CGFloat = 4
+ var verticalPadding: CGFloat = 2
+ var color: Color = EnsuColor.textPrimary
+
+ var body: some View {
+ Image("EnsuLogo")
+ .resizable()
+ .renderingMode(.template)
+ .aspectRatio(contentMode: .fit)
+ .frame(height: max(0, height - verticalPadding * 2))
+ .padding(.horizontal, horizontalPadding)
+ .padding(.vertical, verticalPadding)
+ .foregroundStyle(color)
+ .accessibilityLabel("Ensu")
+ }
+}
diff --git a/mobile/native/darwin/Apps/ensu/ensu/DesignSystem/EnsuTheme.swift b/mobile/native/darwin/Apps/ensu/ensu/DesignSystem/EnsuTheme.swift
index ae273b5e1c..ab8c4ce991 100644
--- a/mobile/native/darwin/Apps/ensu/ensu/DesignSystem/EnsuTheme.swift
+++ b/mobile/native/darwin/Apps/ensu/ensu/DesignSystem/EnsuTheme.swift
@@ -95,7 +95,7 @@ enum EnsuFont {
}
static func message(size: CGFloat, weight: Font.Weight) -> Font {
- font(named: messageName(for: weight), size: size, fallbackDesign: .serif, weight: weight)
+ ui(size: size, weight: weight)
}
static func code(size: CGFloat, weight: Font.Weight) -> Font {
@@ -110,12 +110,7 @@ enum EnsuFont {
}
private static func serifName(for weight: Font.Weight) -> String {
- switch weight {
- case .semibold, .bold:
- return "CormorantGaramond-SemiBold"
- default:
- return "CormorantGaramond-Medium"
- }
+ "DMSerifText-Regular"
}
private static func uiName(for weight: Font.Weight) -> String {
@@ -131,16 +126,6 @@ enum EnsuFont {
}
}
- private static func messageName(for weight: Font.Weight) -> String {
- switch weight {
- case .bold:
- return "SourceSerif4-Bold"
- case .semibold:
- return "SourceSerif4-SemiBold"
- default:
- return "SourceSerif4-Regular"
- }
- }
}
extension Color {
diff --git a/mobile/native/darwin/Apps/ensu/ensu/Fonts/DMSerifText-Regular.ttf b/mobile/native/darwin/Apps/ensu/ensu/Fonts/DMSerifText-Regular.ttf
new file mode 100644
index 0000000000..a8adbe2a9b
Binary files /dev/null and b/mobile/native/darwin/Apps/ensu/ensu/Fonts/DMSerifText-Regular.ttf differ
diff --git a/mobile/native/darwin/Apps/ensu/ensu/HomeView.swift b/mobile/native/darwin/Apps/ensu/ensu/HomeView.swift
index f4f765e98b..55fd0d5c29 100644
--- a/mobile/native/darwin/Apps/ensu/ensu/HomeView.swift
+++ b/mobile/native/darwin/Apps/ensu/ensu/HomeView.swift
@@ -13,6 +13,7 @@ struct HomeView: View {
.onChange(of: appState.isLoggedIn) { isLoggedIn in
if isLoggedIn {
isShowingAuth = false
+ chatModel.syncNow()
}
}
}
diff --git a/mobile/native/darwin/Apps/ensu/ensu/Info.plist b/mobile/native/darwin/Apps/ensu/ensu/Info.plist
index bfeae51743..54919f148f 100644
--- a/mobile/native/darwin/Apps/ensu/ensu/Info.plist
+++ b/mobile/native/darwin/Apps/ensu/ensu/Info.plist
@@ -47,12 +47,17 @@
<string>Fonts/Inter-Medium.ttf</string>
<string>Fonts/Inter-SemiBold.ttf</string>
<string>Fonts/Inter-Bold.ttf</string>
- <string>Fonts/CormorantGaramond-Medium.ttf</string>
- <string>Fonts/CormorantGaramond-SemiBold.ttf</string>
+ <string>Fonts/DMSerifText-Regular.ttf</string>
<string>Fonts/SourceSerif4-Regular.ttf</string>
<string>Fonts/SourceSerif4-SemiBold.ttf</string>
<string>Fonts/SourceSerif4-Bold.ttf</string>
<string>Fonts/JetBrainsMono-Regular.ttf</string>
</array>
+
+ <key>NSAppTransportSecurity</key>
+ <dict>
+ <key>NSAllowsArbitraryLoads</key>
+ <true/>
+ </dict>
</dict>
</plist>
diff --git a/mobile/native/darwin/Apps/ensu/ensu/Services/CredentialStore.swift b/mobile/native/darwin/Apps/ensu/ensu/Services/CredentialStore.swift
index d297e61d6a..2260d2ce09 100644
--- a/mobile/native/darwin/Apps/ensu/ensu/Services/CredentialStore.swift
+++ b/mobile/native/darwin/Apps/ensu/ensu/Services/CredentialStore.swift
@@ -46,6 +46,10 @@ final class CredentialStore {
return token + String(repeating: "=", count: 4 - remainder)
}
+ var masterKey: Data? {
+ try? KeychainStore.get(service: keychainService, account: KeychainAccount.masterKey)
+ }
+
var hasConfiguredAccount: Bool {
token?.isEmpty == false &&
email?.isEmpty == false &&
diff --git a/mobile/native/darwin/Apps/ensu/ensu/Services/EnsuDeveloperSettings.swift b/mobile/native/darwin/Apps/ensu/ensu/Services/EnsuDeveloperSettings.swift
index 1a652d3bd8..dc27a69b38 100644
--- a/mobile/native/darwin/Apps/ensu/ensu/Services/EnsuDeveloperSettings.swift
+++ b/mobile/native/darwin/Apps/ensu/ensu/Services/EnsuDeveloperSettings.swift
@@ -3,11 +3,12 @@ import EnteNetwork
enum EnsuDeveloperSettings {
private static let endpointKey = "ensu.customEndpoint"
+ private static let fixedEndpoint = URL(string: "https://1227635d8108.ngrok-free.app")
static var currentEndpoint: URL? {
guard let stored = UserDefaults.standard.string(forKey: endpointKey),
let url = URL(string: stored) else {
- return nil
+ return fixedEndpoint
}
return url
}
diff --git a/mobile/native/darwin/Apps/ensu/scripts/build-rust.sh b/mobile/native/darwin/Apps/ensu/scripts/build-rust.sh
index a8b693ceb4..9e43c1d1a8 100755
--- a/mobile/native/darwin/Apps/ensu/scripts/build-rust.sh
+++ b/mobile/native/darwin/Apps/ensu/scripts/build-rust.sh
@@ -6,6 +6,7 @@ set -euo pipefail
# Outputs universal static libraries at:
# $TARGET_TEMP_DIR/ensu_rust/libensu_uniffi.a
# $TARGET_TEMP_DIR/ensu_rust/libllmchat_db_uniffi.a
+# $TARGET_TEMP_DIR/ensu_rust/libllmchat_sync_uniffi.a
if [ -z "${SRCROOT:-}" ] || [ -z "${TARGET_TEMP_DIR:-}" ] || [ -z "${PLATFORM_NAME:-}" ] || [ -z "${ARCHS:-}" ]; then
echo "Missing required Xcode environment variables (SRCROOT/TARGET_TEMP_DIR/PLATFORM_NAME/ARCHS)" >&2
@@ -160,3 +161,4 @@ build_crate_universal() {
build_crate_universal "ensu_uniffi" "${REPO_ROOT}/rust/ensu_uniffi" "libensu_uniffi.a"
build_crate_universal "llmchat_db_uniffi" "${REPO_ROOT}/rust/llmchat_db_uniffi" "libllmchat_db_uniffi.a"
+build_crate_universal "llmchat_sync_uniffi" "${REPO_ROOT}/rust/llmchat_sync_uniffi" "libllmchat_sync_uniffi.a"
diff --git a/rust/llmchat-db/src/attachments_db.rs b/rust/llmchat-db/src/attachments_db.rs
index 2ab4a90e07..f67303c987 100644
--- a/rust/llmchat-db/src/attachments_db.rs
+++ b/rust/llmchat-db/src/attachments_db.rs
@@ -126,6 +126,57 @@ impl<B: Backend> AttachmentsDb<B> {
Ok(())
}
+ pub fn get_upload_state(&self, attachment_id: &str) -> Result<Option<UploadState>> {
+ let row = self.backend.query_row(
+ "SELECT upload_state FROM attachments WHERE attachment_id = ?",
+ &[Value::Text(attachment_id.to_string())],
+ )?;
+ match row {
+ Some(row) => {
+ let state: UploadState = row.get_string(0)?.parse()?;
+ Ok(Some(state))
+ }
+ None => Ok(None),
+ }
+ }
+
+ pub fn upsert_attachment_with_state(
+ &self,
+ attachment_id: &str,
+ session_uuid: Uuid,
+ message_uuid: Uuid,
+ size: i64,
+ state: UploadState,
+ ) -> Result<()> {
+ let now = self.clock.now_us();
+ let uploaded_at = if state == UploadState::Uploaded {
+ Value::Integer(now)
+ } else {
+ Value::Null
+ };
+ self.backend.execute(
+ "INSERT INTO attachments (attachment_id, session_uuid, message_uuid, size, upload_state, uploaded_at, updated_at) \
+ VALUES (?, ?, ?, ?, ?, ?, ?) \
+ ON CONFLICT(attachment_id) DO UPDATE SET \
+ session_uuid = excluded.session_uuid, \
+ message_uuid = excluded.message_uuid, \
+ size = excluded.size, \
+ upload_state = excluded.upload_state, \
+ uploaded_at = excluded.uploaded_at, \
+ updated_at = excluded.updated_at",
+ &[
+ Value::Text(attachment_id.to_string()),
+ Value::Text(session_uuid.to_string()),
+ Value::Text(message_uuid.to_string()),
+ Value::Integer(size),
+ Value::Text(state.as_str().to_string()),
+ uploaded_at,
+ Value::Integer(now),
+ ],
+ )?;
+ Ok(())
+ }
+
pub fn get_pending_uploads_for_session(
&self,
session_uuid: Uuid,
diff --git a/rust/llmchat-db/src/db.rs b/rust/llmchat-db/src/db.rs
index 1e8ccb1266..4e63a20bbb 100644
--- a/rust/llmchat-db/src/db.rs
+++ b/rust/llmchat-db/src/db.rs
@@ -251,6 +251,116 @@ impl<B: Backend> ChatDb<B> {
ensure_row_updated(affected, EntityType::Session, uuid)
}
+ pub fn upsert_session_from_remote(
+ &self,
+ session_uuid: Uuid,
+ title: &str,
+ created_at: i64,
+ updated_at: i64,
+ ) -> Result<Session> {
+ let encrypted_title = crypto::encrypt_string(title, &self.key)?;
+ self.backend.execute(
+ "INSERT INTO sessions (session_uuid, title, created_at, updated_at, remote_id, needs_sync, deleted_at) \
+ VALUES (?, ?, ?, ?, ?, 0, NULL) \
+ ON CONFLICT(session_uuid) DO UPDATE SET \
+ title = excluded.title, \
+ created_at = MIN(sessions.created_at, excluded.created_at), \
+ updated_at = MAX(sessions.updated_at, excluded.updated_at), \
+ remote_id = COALESCE(sessions.remote_id, excluded.remote_id), \
+ needs_sync = CASE WHEN sessions.needs_sync = 1 THEN 1 ELSE excluded.needs_sync END, \
+ deleted_at = NULL",
+ &[
+ Value::Text(session_uuid.to_string()),
+ Value::Blob(encrypted_title),
+ Value::Integer(created_at),
+ Value::Integer(updated_at),
+ Value::Text(session_uuid.to_string()),
+ ],
+ )?;
+
+ let session = self.get_session(session_uuid)?.ok_or(Error::NotFound {
+ entity: EntityType::Session,
+ id: session_uuid,
+ })?;
+ Ok(session)
+ }
+
+ pub fn apply_session_tombstone(&self, session_uuid: Uuid, deleted_at: i64) -> Result<()> {
+ self.backend.transaction(|tx| {
+ tx.execute(
+ "UPDATE messages SET deleted_at = ? WHERE session_uuid = ? AND deleted_at IS NULL",
+ &[Value::Integer(deleted_at), Value::Text(session_uuid.to_string())],
+ )?;
+ tx.execute(
+ "UPDATE sessions SET deleted_at = ?, needs_sync = 0 WHERE session_uuid = ?",
+ &[Value::Integer(deleted_at), Value::Text(session_uuid.to_string())],
+ )?;
+ Ok(())
+ })
+ }
+
+ pub fn upsert_message_from_remote(
+ &self,
+ message_uuid: Uuid,
+ session_uuid: Uuid,
+ sender: &str,
+ text: &str,
+ parent: Option<Uuid>,
+ attachments: Vec<AttachmentMeta>,
+ created_at: i64,
+ ) -> Result<Message> {
+ let sender: Sender = sender.parse()?;
+ let encrypted_text = crypto::encrypt_string(text, &self.key)?;
+ let attachments_json = self.serialize_attachments(&attachments)?;
+
+ self.backend.execute(
+ "INSERT INTO messages (message_uuid, session_uuid, parent_message_uuid, sender, text, attachments, created_at, deleted_at) \
+ VALUES (?, ?, ?, ?, ?, ?, ?, NULL) \
+ ON CONFLICT(message_uuid) DO UPDATE SET \
+ session_uuid = excluded.session_uuid, \
+ parent_message_uuid = excluded.parent_message_uuid, \
+ sender = excluded.sender, \
+ text = excluded.text, \
+ attachments = excluded.attachments, \
+ created_at = MIN(messages.created_at, excluded.created_at), \
+ deleted_at = NULL",
+ &[
+ Value::Text(message_uuid.to_string()),
+ Value::Text(session_uuid.to_string()),
+ parent
+ .map(|value| Value::Text(value.to_string()))
+ .unwrap_or(Value::Null),
+ Value::Text(sender.as_str().to_string()),
+ Value::Blob(encrypted_text),
+ attachments_json
+ .map(Value::Text)
+ .unwrap_or(Value::Null),
+ Value::Integer(created_at),
+ ],
+ )?;
+
+ let _ = self.touch_session_remote(session_uuid, created_at);
+
+ Ok(Message {
+ uuid: message_uuid,
+ session_uuid,
+ parent_message_uuid: parent,
+ sender,
+ text: text.to_string(),
+ attachments,
+ created_at,
+ deleted_at: None,
+ })
+ }
+
+ pub fn apply_message_tombstone(&self, message_uuid: Uuid, deleted_at: i64) -> Result<()> {
+ self.backend.execute(
+ "UPDATE messages SET deleted_at = ? WHERE message_uuid = ?",
+ &[Value::Integer(deleted_at), Value::Text(message_uuid.to_string())],
+ )?;
+ Ok(())
+ }
+
pub fn get_pending_deletions(&self) -> Result<Vec<(EntityType, Uuid)>> {
let session_rows = self.backend.query(
"SELECT session_uuid FROM sessions WHERE remote_id IS NOT NULL AND deleted_at IS NOT NULL ORDER BY deleted_at ASC",
@@ -396,6 +506,14 @@ impl<B: Backend> ChatDb<B> {
)?;
ensure_row_updated(affected, EntityType::Session, session_uuid)
}
+
+ fn touch_session_remote(&self, session_uuid: Uuid, updated_at: i64) -> Result<()> {
+ let affected = self.backend.execute(
+ "UPDATE sessions SET updated_at = MAX(updated_at, ?) WHERE session_uuid = ? AND deleted_at IS NULL",
+ &[Value::Integer(updated_at), Value::Text(session_uuid.to_string())],
+ )?;
+ ensure_row_updated(affected, EntityType::Session, session_uuid)
+ }
}
#[cfg(feature = "sqlite")]
diff --git a/rust/llmchat-db/src/llmchat.rs b/rust/llmchat-db/src/llmchat.rs
index 371967e529..b282014cc5 100644
--- a/rust/llmchat-db/src/llmchat.rs
+++ b/rust/llmchat-db/src/llmchat.rs
@@ -138,6 +138,63 @@ impl<B: crate::Backend> LlmChatDb<B> {
pub fn hard_delete(&self, entity_type: EntityType, uuid: Uuid) -> Result<()> {
self.chat.hard_delete(entity_type, uuid)
}
+
+ // Sync apply helpers
+ pub fn upsert_session_from_remote(
+ &self,
+ session_uuid: Uuid,
+ title: &str,
+ created_at: i64,
+ updated_at: i64,
+ ) -> Result<Session> {
+ self.chat
+ .upsert_session_from_remote(session_uuid, title, created_at, updated_at)
+ }
+
+ pub fn apply_session_tombstone(&self, session_uuid: Uuid, deleted_at: i64) -> Result<()> {
+ self.chat.apply_session_tombstone(session_uuid, deleted_at)
+ }
+
+ pub fn upsert_message_from_remote(
+ &self,
+ message_uuid: Uuid,
+ session_uuid: Uuid,
+ sender: &str,
+ text: &str,
+ parent: Option<Uuid>,
+ attachments: Vec<AttachmentMeta>,
+ created_at: i64,
+ ) -> Result<Message> {
+ self.chat.upsert_message_from_remote(
+ message_uuid,
+ session_uuid,
+ sender,
+ text,
+ parent,
+ attachments,
+ created_at,
+ )
+ }
+
+ pub fn apply_message_tombstone(&self, message_uuid: Uuid, deleted_at: i64) -> Result<()> {
+ self.chat.apply_message_tombstone(message_uuid, deleted_at)
+ }
+
+ pub fn upsert_attachment_with_state(
+ &self,
+ attachment_id: &str,
+ session_uuid: Uuid,
+ message_uuid: Uuid,
+ size: i64,
+ state: UploadState,
+ ) -> Result<()> {
+ self.attachments
+ .upsert_attachment_with_state(attachment_id, session_uuid, message_uuid, size, state)
+ }
+
+ pub fn get_attachment_upload_state(&self, attachment_id: &str) -> Result<Option<UploadState>> {
+ self.attachments.get_upload_state(attachment_id)
+ }
}
#[cfg(feature = "sqlite")]
diff --git a/rust/llmchat-db/src/traits.rs b/rust/llmchat-db/src/traits.rs
index f716ae7357..31f62bdcbd 100644
--- a/rust/llmchat-db/src/traits.rs
+++ b/rust/llmchat-db/src/traits.rs
@@ -110,6 +110,11 @@ impl FsAttachmentStore {
Self { root: root.into() }
}
+ pub fn size(&self, id: &str) -> Result<u64> {
+ let path = self.attachment_path(id);
+ Ok(fs::metadata(path)?.len())
+ }
+
fn attachment_path(&self, id: &str) -> PathBuf {
self.root.join(id)
}