From b65d0297e0ee6713153cb784bebf8c7468f36104 Mon Sep 17 00:00:00 2001 From: M57 <41645758+Hy4ri@users.noreply.github.com> Date: Tue, 7 Jul 2026 12:34:18 +0300 Subject: [PATCH] refactor(cleanup): remove 5 orphaned symbols (no behavior change) (#484) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - ChatViewModel: drop fetchAndDisplayStatus/Sessions/Stats — left behind after slash-command dispatch rework (e7b2973c); /status /sessions /stats now route to backend via SlashCommandDispatcher.RpcDispatch -> WS COMMAND_DISPATCH. Zero call sites, grep-confirmed. - AuthManager: drop KEY_SELECTED_PROFILE_ID const — selected profile id moved to ServerStore StateFlow (getSelectedProfileId/setSelectedProfileId). Legacy PREFS key never read. - Theme: drop ENABLE_DYNAMIC_COLOR const — theming reads useDynamicColors setting (Theme.kt:318), not this const. Dead since that refactor. Verification: ktlintCheck PASS, compileDebugKotlin PASS (local SDK). Per behavior-preserving-cleanup: grep zero refs, not exported, no dynamic/reflection access, git blame shows original intent superseded. --- .../hermescontrol/data/local/AuthManager.kt | 1 - .../java/com/m57/hermescontrol/theme/Theme.kt | 5 -- .../hermescontrol/ui/chat/ChatViewModel.kt | 87 ------------------- 3 files changed, 93 deletions(-) diff --git a/app/src/main/java/com/m57/hermescontrol/data/local/AuthManager.kt b/app/src/main/java/com/m57/hermescontrol/data/local/AuthManager.kt index 4e964759..15e59835 100644 --- a/app/src/main/java/com/m57/hermescontrol/data/local/AuthManager.kt +++ b/app/src/main/java/com/m57/hermescontrol/data/local/AuthManager.kt @@ -35,7 +35,6 @@ object AuthManager { private const val PREFS_FILE = "hermes_secure_prefs" private const val KEY_TOKEN = "auth_token" - private const val KEY_SELECTED_PROFILE_ID = "selected_profile_id" private const val KEY_SESSION_COOKIE = "session_cookie" @Volatile diff --git a/app/src/main/java/com/m57/hermescontrol/theme/Theme.kt b/app/src/main/java/com/m57/hermescontrol/theme/Theme.kt index 6723ed51..c7afb6eb 100644 --- a/app/src/main/java/com/m57/hermescontrol/theme/Theme.kt +++ b/app/src/main/java/com/m57/hermescontrol/theme/Theme.kt @@ -26,11 +26,6 @@ enum class BottomNavDisplayMode { ICON_AND_TEXT, ICON_ONLY, TEXT_ONLY } val LocalThemePreference = compositionLocalOf { ThemePreference.SYSTEM } val LocalThemePreset = compositionLocalOf { ThemePreset.DEFAULT } -/** - * Set to true to opt into Material You dynamic color (Android 12+). - */ -private const val ENABLE_DYNAMIC_COLOR = true - private val HermesDarkColorScheme = darkColorScheme( primary = HermesPurple, diff --git a/app/src/main/java/com/m57/hermescontrol/ui/chat/ChatViewModel.kt b/app/src/main/java/com/m57/hermescontrol/ui/chat/ChatViewModel.kt index aaf403b9..8c069c4b 100644 --- a/app/src/main/java/com/m57/hermescontrol/ui/chat/ChatViewModel.kt +++ b/app/src/main/java/com/m57/hermescontrol/ui/chat/ChatViewModel.kt @@ -836,93 +836,6 @@ class ChatViewModel( } } - private fun fetchAndDisplayStatus() { - viewModelScope.launch { - val result = - withContext(Dispatchers.IO) { - safeApiCall { ApiClient.hermesApi.getStatus() } - } - when (result) { - is NetworkResult.Success -> { - val body = result.data - val platformsStr = - body.gateway_platforms?.entries?.joinToString("\n") { (k, v) -> - val status = v?.state ?: "Unknown" - val err = v?.error_code?.let { " (Error: $it)" } ?: "" - " • **$k**: $status$err" - } ?: "No active platforms" - addAssistantMessage( - """ - **Hermes Gateway Status:** - • **Version:** ${body.version ?: "Unknown"} - • **Gateway Running:** ${body.gateway_running ?: false} - • **Active Sessions:** ${body.active_sessions ?: 0} - • **Auth Required:** ${body.auth_required ?: false} - - **Platforms:** - $platformsStr - """.trimIndent(), - ) - } - - is NetworkResult.Failure -> { - addAssistantMessage("Failed to retrieve status: ${result.error.message}") - } - } - } - } - - private fun fetchAndDisplaySessions() { - viewModelScope.launch { - val result = - withContext(Dispatchers.IO) { - safeApiCall { ApiClient.hermesApi.getSessions() } - } - when (result) { - is NetworkResult.Success -> { - val body = result.data - val sessionsStr = - body.sessions.joinToString("\n") { s -> - "• **${s.title ?: "Untitled"}** (ID: `${s.id}`, Messages: ${s.message_count ?: 0})" - } - addAssistantMessage("**Sessions List:**\n$sessionsStr") - } - - is NetworkResult.Failure -> { - addAssistantMessage("Failed to list sessions: ${result.error.message}") - } - } - } - } - - private fun fetchAndDisplayStats() { - viewModelScope.launch { - val result = - withContext(Dispatchers.IO) { - safeApiCall { ApiClient.hermesApi.getSystemStats() } - } - when (result) { - is NetworkResult.Success -> { - val body = result.data - val cpuPct = body.cpu_percent?.let { String.format("%.1f%%", it) } ?: "N/A" - val memPct = body.memory?.percent?.let { String.format("%.1f%%", it) } ?: "N/A" - addAssistantMessage( - """ - **System Resource Stats:** - • **CPU Usage:** $cpuPct - • **Memory Usage:** $memPct - • **Uptime:** ${body.uptime_seconds?.let { "${it.toLong()}s" } ?: "N/A"} - """.trimIndent(), - ) - } - - is NetworkResult.Failure -> { - addAssistantMessage("Failed to retrieve system stats: ${result.error.message}") - } - } - } - } - private fun addAssistantMessage(text: String) { val msg = ChatMessage(role = MessageRole.ASSISTANT, content = text) _uiState.update { it.copy(messages = it.messages + msg) }