π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Collapse Ensu Android domain/data modules into app-ui
Manav Rathi756c76f16a96
diff --git a/mobile/native/android/apps/ensu/app-ui/build.gradle.kts b/mobile/native/android/apps/ensu/app-ui/build.gradle.ktsindex 7a2b43a69e..115a37a36e 100644--- a/mobile/native/android/apps/ensu/app-ui/build.gradle.kts+++ b/mobile/native/android/apps/ensu/app-ui/build.gradle.kts@@ -4,6 +4,7 @@ import java.util.Propertiesplugins {id("com.android.application")id("org.jetbrains.kotlin.android")+ id("org.jetbrains.kotlin.plugin.serialization")}configurations.configureEach {@@ -147,10 +148,14 @@ dependencies {implementation("androidx.lifecycle:lifecycle-viewmodel-compose:2.7.0")implementation("androidx.navigation:navigation-compose:2.7.7")implementation("com.google.accompanist:accompanist-navigation-animation:0.34.0")- implementation(project(":domain"))- implementation(project(":data"))implementation(project(":rust"))+ implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.8.0")+ implementation("androidx.datastore:datastore-preferences:1.1.1")+ implementation("androidx.security:security-crypto:1.1.0-alpha06")+ implementation("com.squareup.okhttp3:okhttp:4.12.0")+ implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.6.3")+implementation("com.github.gregcockroft:AndroidMath:v1.1.0") {exclude(group = "com.google.guava", module = "listenablefuture")}diff --git a/mobile/native/android/apps/ensu/data/src/main/java/io/ente/ensu/data/AdvancedSettingsDataStore.kt b/mobile/native/android/apps/ensu/app-ui/src/main/java/io/ente/ensu/data/AdvancedSettingsDataStore.ktsimilarity index 100%rename from mobile/native/android/apps/ensu/data/src/main/java/io/ente/ensu/data/AdvancedSettingsDataStore.ktrename to mobile/native/android/apps/ensu/app-ui/src/main/java/io/ente/ensu/data/AdvancedSettingsDataStore.ktdiff --git a/mobile/native/android/apps/ensu/data/src/main/java/io/ente/ensu/data/AndroidDeviceCapabilityProvider.kt b/mobile/native/android/apps/ensu/app-ui/src/main/java/io/ente/ensu/data/AndroidDeviceCapabilityProvider.ktsimilarity index 79%rename from mobile/native/android/apps/ensu/data/src/main/java/io/ente/ensu/data/AndroidDeviceCapabilityProvider.ktrename to mobile/native/android/apps/ensu/app-ui/src/main/java/io/ente/ensu/data/AndroidDeviceCapabilityProvider.ktindex 8122fcbd8a..d75d918a46 100644--- a/mobile/native/android/apps/ensu/data/src/main/java/io/ente/ensu/data/AndroidDeviceCapabilityProvider.kt+++ b/mobile/native/android/apps/ensu/app-ui/src/main/java/io/ente/ensu/data/AndroidDeviceCapabilityProvider.kt@@ -4,12 +4,11 @@ import android.app.ActivityManagerimport android.content.Contextimport io.ente.ensu.domain.device.CHAT_MIN_RAM_BYTESimport io.ente.ensu.domain.device.ChatDeviceCapability-import io.ente.ensu.domain.device.DeviceCapabilityProvider-class AndroidDeviceCapabilityProvider(context: Context) : DeviceCapabilityProvider {+class AndroidDeviceCapabilityProvider(context: Context) {private val appContext = context.applicationContext- override fun chatCapability(): ChatDeviceCapability {+ fun chatCapability(): ChatDeviceCapability {val activityManager = appContext.getSystemService(ActivityManager::class.java)?: return ChatDeviceCapability.Unknownval memoryInfo = ActivityManager.MemoryInfo()diff --git a/mobile/native/android/apps/ensu/data/src/main/java/io/ente/ensu/data/SessionPreferencesDataStore.kt b/mobile/native/android/apps/ensu/app-ui/src/main/java/io/ente/ensu/data/SessionPreferencesDataStore.ktsimilarity index 83%rename from mobile/native/android/apps/ensu/data/src/main/java/io/ente/ensu/data/SessionPreferencesDataStore.ktrename to mobile/native/android/apps/ensu/app-ui/src/main/java/io/ente/ensu/data/SessionPreferencesDataStore.ktindex 6023722fcc..3212fdb081 100644--- a/mobile/native/android/apps/ensu/data/src/main/java/io/ente/ensu/data/SessionPreferencesDataStore.kt+++ b/mobile/native/android/apps/ensu/app-ui/src/main/java/io/ente/ensu/data/SessionPreferencesDataStore.kt@@ -8,27 +8,26 @@ import androidx.datastore.preferences.core.editimport androidx.datastore.preferences.core.stringPreferencesKeyimport androidx.datastore.preferences.preferencesDataStoreFileimport androidx.datastore.preferences.core.PreferenceDataStoreFactory-import io.ente.ensu.domain.preferences.SessionPreferencesimport kotlinx.coroutines.flow.Flowimport kotlinx.coroutines.flow.mapimport org.json.JSONObject-class SessionPreferencesDataStore(context: Context) : SessionPreferences {+class SessionPreferencesDataStore(context: Context) {private val dataStore: DataStore<Preferences> = getDataStore(context.applicationContext)- override val selectedSessionId: Flow<String?> = dataStore.data.map { preferences ->+ val selectedSessionId: Flow<String?> = dataStore.data.map { preferences ->preferences[Keys.SELECTED_SESSION_ID]}- override val sessionSummaries: Flow<Map<String, String>> = dataStore.data.map { preferences ->+ val sessionSummaries: Flow<Map<String, String>> = dataStore.data.map { preferences ->decodeSessionSummaries(preferences[Keys.SESSION_SUMMARIES])}- override val modelDownloadRequested: Flow<Boolean> = dataStore.data.map { preferences ->+ val modelDownloadRequested: Flow<Boolean> = dataStore.data.map { preferences ->preferences[Keys.MODEL_DOWNLOAD_REQUESTED] ?: false}- override suspend fun setSelectedSessionId(sessionId: String?) {+ suspend fun setSelectedSessionId(sessionId: String?) {dataStore.edit { preferences ->if (sessionId == null) {preferences.remove(Keys.SELECTED_SESSION_ID)@@ -38,7 +37,7 @@ class SessionPreferencesDataStore(context: Context) : SessionPreferences {}}- override suspend fun setSessionSummary(sessionId: String, summary: String?) {+ suspend fun setSessionSummary(sessionId: String, summary: String?) {dataStore.edit { preferences ->val summaries = decodeSessionSummaries(preferences[Keys.SESSION_SUMMARIES]).toMutableMap()if (summary.isNullOrBlank()) {@@ -50,7 +49,7 @@ class SessionPreferencesDataStore(context: Context) : SessionPreferences {}}- override suspend fun setModelDownloadRequested(requested: Boolean) {+ suspend fun setModelDownloadRequested(requested: Boolean) {dataStore.edit { preferences ->preferences[Keys.MODEL_DOWNLOAD_REQUESTED] = requested}diff --git a/mobile/native/android/apps/ensu/data/src/main/java/io/ente/ensu/data/chat/ChatRecovery.kt b/mobile/native/android/apps/ensu/app-ui/src/main/java/io/ente/ensu/data/chat/ChatRecovery.ktsimilarity index 100%rename from mobile/native/android/apps/ensu/data/src/main/java/io/ente/ensu/data/chat/ChatRecovery.ktrename to mobile/native/android/apps/ensu/app-ui/src/main/java/io/ente/ensu/data/chat/ChatRecovery.ktdiff --git a/mobile/native/android/apps/ensu/data/src/main/java/io/ente/ensu/data/chat/RustChatRepository.kt b/mobile/native/android/apps/ensu/app-ui/src/main/java/io/ente/ensu/data/chat/RustChatRepository.ktsimilarity index 91%rename from mobile/native/android/apps/ensu/data/src/main/java/io/ente/ensu/data/chat/RustChatRepository.ktrename to mobile/native/android/apps/ensu/app-ui/src/main/java/io/ente/ensu/data/chat/RustChatRepository.ktindex f4ded02fde..c58e2c2370 100644--- a/mobile/native/android/apps/ensu/data/src/main/java/io/ente/ensu/data/chat/RustChatRepository.kt+++ b/mobile/native/android/apps/ensu/app-ui/src/main/java/io/ente/ensu/data/chat/RustChatRepository.kt@@ -3,7 +3,6 @@ package io.ente.ensu.data.chatimport android.content.Contextimport io.ente.ensu.data.storage.CredentialStoreimport io.ente.ensu.data.storage.FilePathManager-import io.ente.ensu.domain.chat.ChatRepositoryimport io.ente.ensu.domain.model.Attachmentimport io.ente.ensu.domain.model.AttachmentTypeimport io.ente.ensu.domain.model.ChatMessage@@ -20,7 +19,7 @@ import java.io.Fileclass RustChatRepository(context: Context,private val credentialStore: CredentialStore-) : ChatRepository {+) {private val filePaths = FilePathManager(context)private val attachmentsDir = filePaths.attachmentsDir@@ -29,7 +28,7 @@ class RustChatRepository(private var dbKey = credentialStore.getOrCreateChatDbKey()private var db: EnsuDb = openDb(dbFile, dbKey)- override fun listSessions(): List<ChatSession> = withDbRecovery {+ fun listSessions(): List<ChatSession> = withDbRecovery {val sessions = db.listSessions()sessions.map { session ->val messages = runCatching { db.getMessages(session.uuid) }.getOrNull().orEmpty()@@ -46,7 +45,7 @@ class RustChatRepository(}}- override fun createSession(title: String): ChatSession = withDbRecovery {+ fun createSession(title: String): ChatSession = withDbRecovery {val session = db.createSession(title)ChatSession(id = session.uuid,@@ -56,11 +55,11 @@ class RustChatRepository()}- override fun deleteSession(sessionId: String) = withDbRecovery {+ fun deleteSession(sessionId: String) = withDbRecovery {db.deleteSession(sessionId)}- override fun getMessages(sessionId: String): List<ChatMessage> = withDbRecovery {+ fun getMessages(sessionId: String): List<ChatMessage> = withDbRecovery {db.getMessages(sessionId).map { message ->ChatMessage(id = message.uuid,@@ -89,7 +88,7 @@ class RustChatRepository(}}- override fun insertMessage(+ fun insertMessage(sessionId: String,parentId: String?,author: MessageAuthor,@@ -131,15 +130,15 @@ class RustChatRepository()}- override fun updateMessageText(messageId: String, text: String) = withDbRecovery {+ fun updateMessageText(messageId: String, text: String) = withDbRecovery {db.updateMessageText(messageId, text)}- override fun updateSessionTitle(sessionId: String, title: String) = withDbRecovery {+ fun updateSessionTitle(sessionId: String, title: String) = withDbRecovery {db.updateSessionTitle(sessionId, title)}- override fun deleteAllData() {+ fun deleteAllData() {// Full reset removes current storage plus legacy sync leftovers.dbFile.delete()attachmentsDbFile.delete()diff --git a/mobile/native/android/apps/ensu/data/src/main/java/io/ente/ensu/data/llm/EnsuRustDefaults.kt b/mobile/native/android/apps/ensu/app-ui/src/main/java/io/ente/ensu/data/llm/EnsuRustDefaults.ktsimilarity index 100%rename from mobile/native/android/apps/ensu/data/src/main/java/io/ente/ensu/data/llm/EnsuRustDefaults.ktrename to mobile/native/android/apps/ensu/app-ui/src/main/java/io/ente/ensu/data/llm/EnsuRustDefaults.ktdiff --git a/mobile/native/android/apps/ensu/data/src/main/java/io/ente/ensu/data/llm/InferenceRsProvider.kt b/mobile/native/android/apps/ensu/app-ui/src/main/java/io/ente/ensu/data/llm/InferenceRsProvider.ktsimilarity index 97%rename from mobile/native/android/apps/ensu/data/src/main/java/io/ente/ensu/data/llm/InferenceRsProvider.ktrename to mobile/native/android/apps/ensu/app-ui/src/main/java/io/ente/ensu/data/llm/InferenceRsProvider.ktindex 372439c6a6..24ab32f5d8 100644--- a/mobile/native/android/apps/ensu/data/src/main/java/io/ente/ensu/data/llm/InferenceRsProvider.kt+++ b/mobile/native/android/apps/ensu/app-ui/src/main/java/io/ente/ensu/data/llm/InferenceRsProvider.kt@@ -5,13 +5,12 @@ import android.content.Contextimport android.net.Uriimport android.os.Environmentimport android.util.Log-import io.ente.ensu.domain.device.DeviceCapabilityProvider+import io.ente.ensu.data.AndroidDeviceCapabilityProviderimport io.ente.ensu.domain.device.requireChatSupportedimport io.ente.ensu.domain.llm.DownloadProgressimport io.ente.ensu.domain.llm.GenerationSummaryimport io.ente.ensu.domain.llm.LlmMessageimport io.ente.ensu.domain.llm.LlmModelTarget-import io.ente.ensu.domain.llm.LlmProviderimport io.ente.ensu.domain.util.formatBytesimport io.ente.ensu.bindings.LlmContextHandleimport io.ente.ensu.bindings.LlmContextParams@@ -55,10 +54,10 @@ import kotlin.math.maxclass InferenceRsProvider(context: Context,private val modelDir: File,- private val deviceCapabilityProvider: DeviceCapabilityProvider,+ private val deviceCapabilityProvider: AndroidDeviceCapabilityProvider,private val legacyModelDir: File? = null,private val ioDispatcher: kotlinx.coroutines.CoroutineDispatcher = Dispatchers.IO-) : LlmProvider {+) {private data class LoadedModelKey(val id: String,val requestedContextLength: Int?@@ -106,7 +105,7 @@ class InferenceRsProvider(modelDir.mkdirs()}- override suspend fun ensureModelReady(+ suspend fun ensureModelReady(target: LlmModelTarget,onProgress: (DownloadProgress) -> Unit) {@@ -117,7 +116,7 @@ class InferenceRsProvider(}}- override suspend fun generateChat(+ suspend fun generateChat(target: LlmModelTarget,messages: List<LlmMessage>,imageFiles: List<File>,@@ -161,7 +160,7 @@ class InferenceRsProvider(GenerationSummary(summary.jobId, summary.generatedTokens ?: 0, summary.totalTimeMs)}- override suspend fun prewarmImageInference(target: LlmModelTarget) {+ suspend fun prewarmImageInference(target: LlmModelTarget) {withContext(ioDispatcher) {runCatching {modelLoadMutex.withLock {@@ -181,14 +180,14 @@ class InferenceRsProvider(}}- override val isManualDownloadActive: Boolean get() = manualDownloadActive+ val isManualDownloadActive: Boolean get() = manualDownloadActive- override fun isModelDownloaded(target: LlmModelTarget): Boolean {+ fun isModelDownloaded(target: LlmModelTarget): Boolean {migrateLegacyDownloads(target)return isDownloadComplete(target)}- override suspend fun estimateModelDownloadSize(target: LlmModelTarget): Long? = withContext(ioDispatcher) {+ suspend fun estimateModelDownloadSize(target: LlmModelTarget): Long? = withContext(ioDispatcher) {val modelFile = ModelDownloadSupport.modelPathFor(modelDir, target)val mmprojFile = ModelDownloadSupport.mmprojPathFor(modelDir, target)val mmprojUrl = target.mmprojUrl@@ -210,7 +209,7 @@ class InferenceRsProvider(if (sizes.isEmpty()) null else sizes.sum()}- override suspend fun currentDownloadProgress(target: LlmModelTarget): DownloadProgress? =+ suspend fun currentDownloadProgress(target: LlmModelTarget): DownloadProgress? =withContext(ioDispatcher) {migrateLegacyDownloads(target)val targets = ModelDownloadSupport.expectedTargets(modelDir, target)@@ -300,7 +299,7 @@ class InferenceRsProvider(DownloadProgress(percent = percent, status = status)}- override fun loadedContextLength(target: LlmModelTarget): Int? {+ fun loadedContextLength(target: LlmModelTarget): Int? {val modelKey = LoadedModelKey(target.id, target.contextLength)return if (currentModelKey == modelKey && contextHandle != null && modelHandle != null) {currentContextLength@@ -309,7 +308,7 @@ class InferenceRsProvider(}}- override fun stopGeneration() {+ fun stopGeneration() {val jobId = currentJobIdif (jobId != null) {llmCancel(jobId)@@ -318,7 +317,7 @@ class InferenceRsProvider(}}- override fun resetContext() {+ fun resetContext() {val model = modelHandle ?: returnval contextParams = LlmContextParams(contextSize = currentContextLength,@@ -329,7 +328,7 @@ class InferenceRsProvider(contextHandle = llmCreateContext(model, contextParams)}- override fun cancelDownload() {+ fun cancelDownload() {manualDownloadCancelled = trueval ids = loadAllDownloadRecords().map { it.downloadId }.distinct()if (ids.isNotEmpty() && downloadManager != null) {diff --git a/mobile/native/android/apps/ensu/data/src/main/java/io/ente/ensu/data/llm/ModelDownloadSupport.kt b/mobile/native/android/apps/ensu/app-ui/src/main/java/io/ente/ensu/data/llm/ModelDownloadSupport.ktsimilarity index 100%rename from mobile/native/android/apps/ensu/data/src/main/java/io/ente/ensu/data/llm/ModelDownloadSupport.ktrename to mobile/native/android/apps/ensu/app-ui/src/main/java/io/ente/ensu/data/llm/ModelDownloadSupport.ktdiff --git a/mobile/native/android/apps/ensu/data/src/main/java/io/ente/ensu/data/logging/FileLogRepository.kt b/mobile/native/android/apps/ensu/app-ui/src/main/java/io/ente/ensu/data/logging/FileLogRepository.ktsimilarity index 97%rename from mobile/native/android/apps/ensu/data/src/main/java/io/ente/ensu/data/logging/FileLogRepository.ktrename to mobile/native/android/apps/ensu/app-ui/src/main/java/io/ente/ensu/data/logging/FileLogRepository.ktindex 1ea9c5d378..114422118e 100644--- a/mobile/native/android/apps/ensu/data/src/main/java/io/ente/ensu/data/logging/FileLogRepository.kt+++ b/mobile/native/android/apps/ensu/app-ui/src/main/java/io/ente/ensu/data/logging/FileLogRepository.kt@@ -2,7 +2,6 @@ package io.ente.ensu.data.loggingimport android.content.Contextimport android.util.Log-import io.ente.ensu.domain.logging.LogRepositoryimport io.ente.ensu.domain.model.LogEntryimport io.ente.ensu.domain.model.LogLevelimport kotlinx.coroutines.CoroutineScope@@ -32,7 +31,7 @@ class FileLogRepository(private val context: Context,private val maxLogFiles: Int = 5,private val maxEntriesInMemory: Int = 500-) : LogRepository {+) {private val ioScope = CoroutineScope(SupervisorJob() + Dispatchers.IO)private val writeMutex = Mutex()@@ -43,14 +42,14 @@ class FileLogRepository(private val logsDir: File = File(context.filesDir, "logs")private val _logs = MutableStateFlow<List<LogEntry>>(emptyList())- override val logs: StateFlow<List<LogEntry>> = _logs.asStateFlow()+ val logs: StateFlow<List<LogEntry>> = _logs.asStateFlow()init {ensureLogDir()pruneOldLogFiles()}- override fun log(level: LogLevel, message: String, details: String?, tag: String?, throwable: Throwable?) {+ fun log(level: LogLevel, message: String, details: String? = null, tag: String? = null, throwable: Throwable? = null) {val resolvedTag = tag ?: "ensu"val entry = LogEntryBuilder.buildEntry(level = level,diff --git a/mobile/native/android/apps/ensu/data/src/main/java/io/ente/ensu/data/logging/LogEntryBuilder.kt b/mobile/native/android/apps/ensu/app-ui/src/main/java/io/ente/ensu/data/logging/LogEntryBuilder.ktsimilarity index 100%rename from mobile/native/android/apps/ensu/data/src/main/java/io/ente/ensu/data/logging/LogEntryBuilder.ktrename to mobile/native/android/apps/ensu/app-ui/src/main/java/io/ente/ensu/data/logging/LogEntryBuilder.ktdiff --git a/mobile/native/android/apps/ensu/data/src/main/java/io/ente/ensu/data/logging/LogSanitizer.kt b/mobile/native/android/apps/ensu/app-ui/src/main/java/io/ente/ensu/data/logging/LogSanitizer.ktsimilarity index 100%rename from mobile/native/android/apps/ensu/data/src/main/java/io/ente/ensu/data/logging/LogSanitizer.ktrename to mobile/native/android/apps/ensu/app-ui/src/main/java/io/ente/ensu/data/logging/LogSanitizer.ktdiff --git a/mobile/native/android/apps/ensu/data/src/main/java/io/ente/ensu/data/storage/CredentialStore.kt b/mobile/native/android/apps/ensu/app-ui/src/main/java/io/ente/ensu/data/storage/CredentialStore.ktsimilarity index 100%rename from mobile/native/android/apps/ensu/data/src/main/java/io/ente/ensu/data/storage/CredentialStore.ktrename to mobile/native/android/apps/ensu/app-ui/src/main/java/io/ente/ensu/data/storage/CredentialStore.ktdiff --git a/mobile/native/android/apps/ensu/data/src/main/java/io/ente/ensu/data/storage/FilePathManager.kt b/mobile/native/android/apps/ensu/app-ui/src/main/java/io/ente/ensu/data/storage/FilePathManager.ktsimilarity index 100%rename from mobile/native/android/apps/ensu/data/src/main/java/io/ente/ensu/data/storage/FilePathManager.ktrename to mobile/native/android/apps/ensu/app-ui/src/main/java/io/ente/ensu/data/storage/FilePathManager.ktdiff --git a/mobile/native/android/apps/ensu/domain/src/main/kotlin/io/ente/ensu/domain/device/ChatDeviceCapability.kt b/mobile/native/android/apps/ensu/app-ui/src/main/java/io/ente/ensu/domain/device/ChatDeviceCapability.ktsimilarity index 93%rename from mobile/native/android/apps/ensu/domain/src/main/kotlin/io/ente/ensu/domain/device/ChatDeviceCapability.ktrename to mobile/native/android/apps/ensu/app-ui/src/main/java/io/ente/ensu/domain/device/ChatDeviceCapability.ktindex b1b36e46a3..ba4d2abb9f 100644--- a/mobile/native/android/apps/ensu/domain/src/main/kotlin/io/ente/ensu/domain/device/ChatDeviceCapability.kt+++ b/mobile/native/android/apps/ensu/app-ui/src/main/java/io/ente/ensu/domain/device/ChatDeviceCapability.kt@@ -22,9 +22,6 @@ sealed interface ChatDeviceCapability {}}-interface DeviceCapabilityProvider {- fun chatCapability(): ChatDeviceCapability-}class UnsupportedDeviceMemoryException(val capability: ChatDeviceCapability.UnsupportedLowMemorydiff --git a/mobile/native/android/apps/ensu/app-ui/src/main/java/io/ente/ensu/domain/llm/LlmModels.kt b/mobile/native/android/apps/ensu/app-ui/src/main/java/io/ente/ensu/domain/llm/LlmModels.ktnew file mode 100644index 0000000000..98ea5fe287--- /dev/null+++ b/mobile/native/android/apps/ensu/app-ui/src/main/java/io/ente/ensu/domain/llm/LlmModels.kt@@ -0,0 +1,34 @@+package io.ente.ensu.domain.llm++++data class LlmModelTarget(+ val id: String,+ val url: String,+ val mmprojUrl: String? = null,+ val contextLength: Int? = null,+ val maxTokens: Int? = null+)++data class DownloadProgress(+ val percent: Int,+ val status: String+)++enum class LlmMessageRole {+ User,+ Assistant,+ System+}++data class LlmMessage(+ val text: String,+ val role: LlmMessageRole,+ val hasAttachments: Boolean = false+)++data class GenerationSummary(+ val jobId: Long,+ val generatedTokens: Int,+ val totalTimeMs: Long?+)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/app-ui/src/main/java/io/ente/ensu/domain/model/AttachmentDownload.ktsimilarity index 100%rename from mobile/native/android/apps/ensu/domain/src/main/kotlin/io/ente/ensu/domain/model/AttachmentDownload.ktrename to mobile/native/android/apps/ensu/app-ui/src/main/java/io/ente/ensu/domain/model/AttachmentDownload.ktdiff --git a/mobile/native/android/apps/ensu/domain/src/main/kotlin/io/ente/ensu/domain/model/ChatModels.kt b/mobile/native/android/apps/ensu/app-ui/src/main/java/io/ente/ensu/domain/model/ChatModels.ktsimilarity index 100%rename from mobile/native/android/apps/ensu/domain/src/main/kotlin/io/ente/ensu/domain/model/ChatModels.ktrename to mobile/native/android/apps/ensu/app-ui/src/main/java/io/ente/ensu/domain/model/ChatModels.ktdiff --git a/mobile/native/android/apps/ensu/domain/src/main/kotlin/io/ente/ensu/domain/model/EnsuDefaults.kt b/mobile/native/android/apps/ensu/app-ui/src/main/java/io/ente/ensu/domain/model/EnsuDefaults.ktsimilarity index 100%rename from mobile/native/android/apps/ensu/domain/src/main/kotlin/io/ente/ensu/domain/model/EnsuDefaults.ktrename to mobile/native/android/apps/ensu/app-ui/src/main/java/io/ente/ensu/domain/model/EnsuDefaults.ktdiff --git a/mobile/native/android/apps/ensu/domain/src/main/kotlin/io/ente/ensu/domain/model/LogEntry.kt b/mobile/native/android/apps/ensu/app-ui/src/main/java/io/ente/ensu/domain/model/LogEntry.ktsimilarity index 100%rename from mobile/native/android/apps/ensu/domain/src/main/kotlin/io/ente/ensu/domain/model/LogEntry.ktrename to mobile/native/android/apps/ensu/app-ui/src/main/java/io/ente/ensu/domain/model/LogEntry.ktdiff --git a/mobile/native/android/apps/ensu/domain/src/main/kotlin/io/ente/ensu/domain/model/TitleSanitizer.kt b/mobile/native/android/apps/ensu/app-ui/src/main/java/io/ente/ensu/domain/model/TitleSanitizer.ktsimilarity index 100%rename from mobile/native/android/apps/ensu/domain/src/main/kotlin/io/ente/ensu/domain/model/TitleSanitizer.ktrename to mobile/native/android/apps/ensu/app-ui/src/main/java/io/ente/ensu/domain/model/TitleSanitizer.ktdiff --git a/mobile/native/android/apps/ensu/domain/src/main/kotlin/io/ente/ensu/domain/state/AppState.kt b/mobile/native/android/apps/ensu/app-ui/src/main/java/io/ente/ensu/domain/state/AppState.ktsimilarity index 100%rename from mobile/native/android/apps/ensu/domain/src/main/kotlin/io/ente/ensu/domain/state/AppState.ktrename to mobile/native/android/apps/ensu/app-ui/src/main/java/io/ente/ensu/domain/state/AppState.ktdiff --git a/mobile/native/android/apps/ensu/domain/src/main/kotlin/io/ente/ensu/domain/state/ChatState.kt b/mobile/native/android/apps/ensu/app-ui/src/main/java/io/ente/ensu/domain/state/ChatState.ktsimilarity index 100%rename from mobile/native/android/apps/ensu/domain/src/main/kotlin/io/ente/ensu/domain/state/ChatState.ktrename to mobile/native/android/apps/ensu/app-ui/src/main/java/io/ente/ensu/domain/state/ChatState.ktdiff --git a/mobile/native/android/apps/ensu/domain/src/main/kotlin/io/ente/ensu/domain/state/DeveloperSettingsState.kt b/mobile/native/android/apps/ensu/app-ui/src/main/java/io/ente/ensu/domain/state/DeveloperSettingsState.ktsimilarity index 100%rename from mobile/native/android/apps/ensu/domain/src/main/kotlin/io/ente/ensu/domain/state/DeveloperSettingsState.ktrename to mobile/native/android/apps/ensu/app-ui/src/main/java/io/ente/ensu/domain/state/DeveloperSettingsState.ktdiff --git a/mobile/native/android/apps/ensu/domain/src/main/kotlin/io/ente/ensu/domain/state/ModelSettingsState.kt b/mobile/native/android/apps/ensu/app-ui/src/main/java/io/ente/ensu/domain/state/ModelSettingsState.ktsimilarity index 100%rename from mobile/native/android/apps/ensu/domain/src/main/kotlin/io/ente/ensu/domain/state/ModelSettingsState.ktrename to mobile/native/android/apps/ensu/app-ui/src/main/java/io/ente/ensu/domain/state/ModelSettingsState.ktdiff --git a/mobile/native/android/apps/ensu/domain/src/main/kotlin/io/ente/ensu/domain/store/AppStore.kt b/mobile/native/android/apps/ensu/app-ui/src/main/java/io/ente/ensu/domain/store/AppStore.ktsimilarity index 92%rename from mobile/native/android/apps/ensu/domain/src/main/kotlin/io/ente/ensu/domain/store/AppStore.ktrename to mobile/native/android/apps/ensu/app-ui/src/main/java/io/ente/ensu/domain/store/AppStore.ktindex 50fa22baa7..9a0e1123bc 100644--- a/mobile/native/android/apps/ensu/domain/src/main/kotlin/io/ente/ensu/domain/store/AppStore.kt+++ b/mobile/native/android/apps/ensu/app-ui/src/main/java/io/ente/ensu/domain/store/AppStore.kt@@ -1,15 +1,15 @@package io.ente.ensu.domain.store-import io.ente.ensu.domain.chat.ChatRepository+import io.ente.ensu.data.chat.RustChatRepositoryimport io.ente.ensu.domain.device.ChatDeviceCapability-import io.ente.ensu.domain.device.DeviceCapabilityProvider-import io.ente.ensu.domain.llm.LlmProvider-import io.ente.ensu.domain.logging.LogRepository+import io.ente.ensu.data.AndroidDeviceCapabilityProvider+import io.ente.ensu.data.llm.InferenceRsProvider+import io.ente.ensu.data.logging.FileLogRepositoryimport io.ente.ensu.domain.model.Attachmentimport io.ente.ensu.domain.model.ChatMessageimport io.ente.ensu.domain.model.EnsuDefaultsimport io.ente.ensu.domain.model.LogLevel-import io.ente.ensu.domain.preferences.SessionPreferences+import io.ente.ensu.data.SessionPreferencesDataStoreimport io.ente.ensu.domain.state.AppStateimport io.ente.ensu.domain.state.DeveloperSettingsStateimport io.ente.ensu.domain.state.ModelSettingsState@@ -20,12 +20,12 @@ import kotlinx.coroutines.flow.asStateFlowimport kotlinx.coroutines.launchclass AppStore(- private val sessionPreferences: SessionPreferences,- private val chatRepository: ChatRepository,- private val llmProvider: LlmProvider,- private val deviceCapabilityProvider: DeviceCapabilityProvider,+ private val sessionPreferences: SessionPreferencesDataStore,+ private val chatRepository: RustChatRepository,+ private val llmProvider: InferenceRsProvider,+ private val deviceCapabilityProvider: AndroidDeviceCapabilityProvider,val ensuDefaults: EnsuDefaults,- private val logRepository: LogRepository,+ private val logRepository: FileLogRepository,private val clock: () -> Long = { System.currentTimeMillis() }) {private val _state = MutableStateFlow(AppState())diff --git a/mobile/native/android/apps/ensu/domain/src/main/kotlin/io/ente/ensu/domain/store/AttachmentStoreActions.kt b/mobile/native/android/apps/ensu/app-ui/src/main/java/io/ente/ensu/domain/store/AttachmentStoreActions.ktsimilarity index 100%rename from mobile/native/android/apps/ensu/domain/src/main/kotlin/io/ente/ensu/domain/store/AttachmentStoreActions.ktrename to mobile/native/android/apps/ensu/app-ui/src/main/java/io/ente/ensu/domain/store/AttachmentStoreActions.ktdiff --git a/mobile/native/android/apps/ensu/domain/src/main/kotlin/io/ente/ensu/domain/store/ChatStoreActions.kt b/mobile/native/android/apps/ensu/app-ui/src/main/java/io/ente/ensu/domain/store/ChatStoreActions.ktsimilarity index 99%rename from mobile/native/android/apps/ensu/domain/src/main/kotlin/io/ente/ensu/domain/store/ChatStoreActions.ktrename to mobile/native/android/apps/ensu/app-ui/src/main/java/io/ente/ensu/domain/store/ChatStoreActions.ktindex f1e6b866a0..8688442318 100644--- a/mobile/native/android/apps/ensu/domain/src/main/kotlin/io/ente/ensu/domain/store/ChatStoreActions.kt+++ b/mobile/native/android/apps/ensu/app-ui/src/main/java/io/ente/ensu/domain/store/ChatStoreActions.kt@@ -1,12 +1,12 @@package io.ente.ensu.domain.store-import io.ente.ensu.domain.chat.ChatRepository+import io.ente.ensu.data.chat.RustChatRepositoryimport io.ente.ensu.domain.device.isChatSupported-import io.ente.ensu.domain.logging.LogRepository+import io.ente.ensu.data.logging.FileLogRepositoryimport io.ente.ensu.domain.llm.LlmMessageimport io.ente.ensu.domain.llm.LlmMessageRoleimport io.ente.ensu.domain.llm.LlmModelTarget-import io.ente.ensu.domain.llm.LlmProvider+import io.ente.ensu.data.llm.InferenceRsProviderimport io.ente.ensu.domain.model.Attachmentimport io.ente.ensu.domain.model.ChatMessageimport io.ente.ensu.domain.model.ChatSession@@ -15,7 +15,7 @@ import io.ente.ensu.domain.model.LogLevelimport io.ente.ensu.domain.model.MessageAuthorimport io.ente.ensu.domain.model.sanitizeTitleTextimport io.ente.ensu.domain.model.sessionTitleFromText-import io.ente.ensu.domain.preferences.SessionPreferences+import io.ente.ensu.data.SessionPreferencesDataStoreimport io.ente.ensu.domain.state.AppStateimport java.text.SimpleDateFormatimport java.util.Date@@ -36,11 +36,11 @@ import kotlin.math.mininternal class ChatStoreActions(private val state: MutableStateFlow<AppState>,- private val sessionPreferences: SessionPreferences,- private val chatRepository: ChatRepository,- private val llmProvider: LlmProvider,+ private val sessionPreferences: SessionPreferencesDataStore,+ private val chatRepository: RustChatRepository,+ private val llmProvider: InferenceRsProvider,private val clock: () -> Long,- private val logRepository: LogRepository,+ private val logRepository: FileLogRepository,private val messageStore: MutableMap<String, MutableList<ChatMessage>>,private val attachmentActions: AttachmentStoreActions,private val modelSettingsActions: ModelSettingsActions,diff --git a/mobile/native/android/apps/ensu/domain/src/main/kotlin/io/ente/ensu/domain/store/DbLoadHelpers.kt b/mobile/native/android/apps/ensu/app-ui/src/main/java/io/ente/ensu/domain/store/DbLoadHelpers.ktsimilarity index 100%rename from mobile/native/android/apps/ensu/domain/src/main/kotlin/io/ente/ensu/domain/store/DbLoadHelpers.ktrename to mobile/native/android/apps/ensu/app-ui/src/main/java/io/ente/ensu/domain/store/DbLoadHelpers.ktdiff --git a/mobile/native/android/apps/ensu/domain/src/main/kotlin/io/ente/ensu/domain/store/DownloadProgressTracker.kt b/mobile/native/android/apps/ensu/app-ui/src/main/java/io/ente/ensu/domain/store/DownloadProgressTracker.ktsimilarity index 100%rename from mobile/native/android/apps/ensu/domain/src/main/kotlin/io/ente/ensu/domain/store/DownloadProgressTracker.ktrename to mobile/native/android/apps/ensu/app-ui/src/main/java/io/ente/ensu/domain/store/DownloadProgressTracker.ktdiff --git a/mobile/native/android/apps/ensu/domain/src/main/kotlin/io/ente/ensu/domain/store/ModelSettingsActions.kt b/mobile/native/android/apps/ensu/app-ui/src/main/java/io/ente/ensu/domain/store/ModelSettingsActions.ktsimilarity index 98%rename from mobile/native/android/apps/ensu/domain/src/main/kotlin/io/ente/ensu/domain/store/ModelSettingsActions.ktrename to mobile/native/android/apps/ensu/app-ui/src/main/java/io/ente/ensu/domain/store/ModelSettingsActions.ktindex e3bda13767..a57cc069ac 100644--- a/mobile/native/android/apps/ensu/domain/src/main/kotlin/io/ente/ensu/domain/store/ModelSettingsActions.kt+++ b/mobile/native/android/apps/ensu/app-ui/src/main/java/io/ente/ensu/domain/store/ModelSettingsActions.kt@@ -2,11 +2,11 @@ package io.ente.ensu.domain.storeimport io.ente.ensu.domain.device.isChatSupportedimport io.ente.ensu.domain.llm.LlmModelTarget-import io.ente.ensu.domain.llm.LlmProvider-import io.ente.ensu.domain.logging.LogRepository+import io.ente.ensu.data.llm.InferenceRsProvider+import io.ente.ensu.data.logging.FileLogRepositoryimport io.ente.ensu.domain.model.EnsuDefaultsimport io.ente.ensu.domain.model.LogLevel-import io.ente.ensu.domain.preferences.SessionPreferences+import io.ente.ensu.data.SessionPreferencesDataStoreimport io.ente.ensu.domain.state.AppStateimport io.ente.ensu.domain.state.ModelSettingsStateimport kotlinx.coroutines.CoroutineScope@@ -19,9 +19,9 @@ import kotlinx.coroutines.isActiveinternal class ModelSettingsActions(private val state: MutableStateFlow<AppState>,- private val sessionPreferences: SessionPreferences,- private val llmProvider: LlmProvider,- private val logRepository: LogRepository,+ private val sessionPreferences: SessionPreferencesDataStore,+ private val llmProvider: InferenceRsProvider,+ private val logRepository: FileLogRepository,private val ensuDefaults: EnsuDefaults) {private var scope: CoroutineScope? = nulldiff --git a/mobile/native/android/apps/ensu/domain/src/main/kotlin/io/ente/ensu/domain/util/ByteFormatter.kt b/mobile/native/android/apps/ensu/app-ui/src/main/java/io/ente/ensu/domain/util/ByteFormatter.ktsimilarity index 100%rename from mobile/native/android/apps/ensu/domain/src/main/kotlin/io/ente/ensu/domain/util/ByteFormatter.ktrename to mobile/native/android/apps/ensu/app-ui/src/main/java/io/ente/ensu/domain/util/ByteFormatter.ktdiff --git a/mobile/native/android/apps/ensu/data/build.gradle.kts b/mobile/native/android/apps/ensu/data/build.gradle.ktsdeleted file mode 100644index 5a8f4e620c..0000000000--- a/mobile/native/android/apps/ensu/data/build.gradle.kts+++ /dev/null@@ -1,33 +0,0 @@-plugins {- id("com.android.library")- id("org.jetbrains.kotlin.android")- id("org.jetbrains.kotlin.plugin.serialization")-}--android {- namespace = "io.ente.ensu.data"- compileSdk = 34-- defaultConfig {- minSdk = 24- }-- compileOptions {- sourceCompatibility = JavaVersion.VERSION_17- targetCompatibility = JavaVersion.VERSION_17- }-- kotlinOptions {- jvmTarget = "17"- }-}--dependencies {- implementation(project(":domain"))- implementation(project(":rust"))- implementation("androidx.core:core-ktx:1.12.0")- implementation("androidx.datastore:datastore-preferences:1.1.1")- implementation("androidx.security:security-crypto:1.1.0-alpha06")- implementation("com.squareup.okhttp3:okhttp:4.12.0")- implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.6.3")-}diff --git a/mobile/native/android/apps/ensu/domain/build.gradle.kts b/mobile/native/android/apps/ensu/domain/build.gradle.ktsdeleted file mode 100644index 868fecc2f8..0000000000--- a/mobile/native/android/apps/ensu/domain/build.gradle.kts+++ /dev/null@@ -1,11 +0,0 @@-plugins {- id("org.jetbrains.kotlin.jvm")-}--kotlin {- jvmToolchain(17)-}--dependencies {- implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.8.0")-}diff --git a/mobile/native/android/apps/ensu/domain/src/main/kotlin/io/ente/ensu/domain/chat/ChatRepository.kt b/mobile/native/android/apps/ensu/domain/src/main/kotlin/io/ente/ensu/domain/chat/ChatRepository.ktdeleted file mode 100644index 5bcf3f86e1..0000000000--- a/mobile/native/android/apps/ensu/domain/src/main/kotlin/io/ente/ensu/domain/chat/ChatRepository.kt+++ /dev/null@@ -1,26 +0,0 @@-package io.ente.ensu.domain.chat--import io.ente.ensu.domain.model.Attachment-import io.ente.ensu.domain.model.ChatMessage-import io.ente.ensu.domain.model.ChatSession-import io.ente.ensu.domain.model.MessageAuthor--interface ChatRepository {- fun listSessions(): List<ChatSession>- fun createSession(title: String): ChatSession- fun deleteSession(sessionId: String)-- fun getMessages(sessionId: String): List<ChatMessage>-- fun insertMessage(- sessionId: String,- parentId: String?,- author: MessageAuthor,- text: String,- attachments: List<Attachment>- ): ChatMessage-- fun updateMessageText(messageId: String, text: String)- fun updateSessionTitle(sessionId: String, title: String)- fun deleteAllData()-}diff --git a/mobile/native/android/apps/ensu/domain/src/main/kotlin/io/ente/ensu/domain/llm/LlmProvider.kt b/mobile/native/android/apps/ensu/domain/src/main/kotlin/io/ente/ensu/domain/llm/LlmProvider.ktdeleted file mode 100644index e8377550b6..0000000000--- a/mobile/native/android/apps/ensu/domain/src/main/kotlin/io/ente/ensu/domain/llm/LlmProvider.kt+++ /dev/null@@ -1,63 +0,0 @@-package io.ente.ensu.domain.llm--import java.io.File---data class LlmModelTarget(- val id: String,- val url: String,- val mmprojUrl: String? = null,- val contextLength: Int? = null,- val maxTokens: Int? = null-)--data class DownloadProgress(- val percent: Int,- val status: String-)--enum class LlmMessageRole {- User,- Assistant,- System-}--data class LlmMessage(- val text: String,- val role: LlmMessageRole,- val hasAttachments: Boolean = false-)--data class GenerationSummary(- val jobId: Long,- val generatedTokens: Int,- val totalTimeMs: Long?-)--interface LlmProvider {- suspend fun ensureModelReady(- target: LlmModelTarget,- onProgress: (DownloadProgress) -> Unit- )-- suspend fun generateChat(- target: LlmModelTarget,- messages: List<LlmMessage>,- imageFiles: List<File>,- temperature: Float,- maxTokens: Int?,- onToken: (String) -> Unit- ): GenerationSummary-- suspend fun prewarmImageInference(target: LlmModelTarget)-- fun isModelDownloaded(target: LlmModelTarget): Boolean- val isManualDownloadActive: Boolean- suspend fun estimateModelDownloadSize(target: LlmModelTarget): Long?- suspend fun currentDownloadProgress(target: LlmModelTarget): DownloadProgress?- fun loadedContextLength(target: LlmModelTarget): Int?-- fun stopGeneration()- fun resetContext()- fun cancelDownload()-}diff --git a/mobile/native/android/apps/ensu/domain/src/main/kotlin/io/ente/ensu/domain/logging/LogRepository.kt b/mobile/native/android/apps/ensu/domain/src/main/kotlin/io/ente/ensu/domain/logging/LogRepository.ktdeleted file mode 100644index 0c6bb18a85..0000000000--- a/mobile/native/android/apps/ensu/domain/src/main/kotlin/io/ente/ensu/domain/logging/LogRepository.kt+++ /dev/null@@ -1,16 +0,0 @@-package io.ente.ensu.domain.logging--import io.ente.ensu.domain.model.LogEntry-import io.ente.ensu.domain.model.LogLevel-import kotlinx.coroutines.flow.StateFlow--interface LogRepository {- val logs: StateFlow<List<LogEntry>>- fun log(- level: LogLevel,- message: String,- details: String? = null,- tag: String? = null,- throwable: Throwable? = null- )-}diff --git a/mobile/native/android/apps/ensu/domain/src/main/kotlin/io/ente/ensu/domain/preferences/SessionPreferences.kt b/mobile/native/android/apps/ensu/domain/src/main/kotlin/io/ente/ensu/domain/preferences/SessionPreferences.ktdeleted file mode 100644index e7f96febfb..0000000000--- a/mobile/native/android/apps/ensu/domain/src/main/kotlin/io/ente/ensu/domain/preferences/SessionPreferences.kt+++ /dev/null@@ -1,12 +0,0 @@-package io.ente.ensu.domain.preferences--import kotlinx.coroutines.flow.Flow--interface SessionPreferences {- val selectedSessionId: Flow<String?>- val sessionSummaries: Flow<Map<String, String>>- val modelDownloadRequested: Flow<Boolean>- suspend fun setSelectedSessionId(sessionId: String?)- suspend fun setSessionSummary(sessionId: String, summary: String?)- suspend fun setModelDownloadRequested(requested: Boolean)-}diff --git a/mobile/native/android/apps/ensu/settings.gradle.kts b/mobile/native/android/apps/ensu/settings.gradle.ktsindex aad9c73e73..e934976d38 100644--- a/mobile/native/android/apps/ensu/settings.gradle.kts+++ b/mobile/native/android/apps/ensu/settings.gradle.kts@@ -16,6 +16,6 @@ dependencyResolutionManagement {}rootProject.name = "ensu"-include(":app-ui", ":domain", ":data", ":rust")+include(":app-ui", ":rust")project(":rust").projectDir = file("../../packages/rust")