refactor: remove verified dead code across data, UI, and resources (#680)
* refactor: remove unused dead code across data, UI, and resources * fix: resolve dangling references left by dead-code removal Restore empty object Motion (braces required) and remove the 12 stale test usages that still called the now-deleted production symbols: - ServerStoreTest: removeServer/switchToServer tests - ServerEndpointTest: isCleartext assertions - ConnectViewModelTest: onHostChange/onPortChange tests + 3 dropped R.string refs - SettingsViewModelTest: renameProfile tests + clearNavigateToLogin - E2eIntegrationTest: previewSkill tests + onHostChange/onPortChange calls Verified locally: compileDebugUnitTestKotlin + 48 tests pass. * fix: remove unused imports flagged by ktlint Drops 4 no-longer-referenced imports left by the dead-code removal: - HermesApiService: SkillScanResponse (scanHubSkill removed) - ServerEndpointTest: assertFalse, assertTrue (isCleartext assertions dropped) - SettingsViewModelTest: assertFalse (rename tests removed) --------- Co-authored-by: M57 <hy4ri@users.noreply.github.com>
This commit is contained in:
1 parent
58420d7b2a
commit
2e97ee9a84
29 files changed
+10
-550
No files matched your search
@@ -86,24 +86,6 @@ class AchievementsViewModel : ViewModel(), ToastHost {
|
||||
)
|
||||
}
|
||||
|
||||
fun loadScanStatus() {
|
||||
safeLaunchLoad(
|
||||
apiCall = { safeApiCall { api.getAchievementScanStatus() } },
|
||||
onStart = { /* silent background refresh */ },
|
||||
onSuccess = { status ->
|
||||
_uiState.update {
|
||||
it.copy(
|
||||
scanState = status.state,
|
||||
scanLastError = status.lastError,
|
||||
scanLastDurationMs = status.lastDurationMs,
|
||||
scanRunCount = status.runCount,
|
||||
)
|
||||
}
|
||||
},
|
||||
onError = { /* silent — scan runs independently */ },
|
||||
)
|
||||
}
|
||||
|
||||
fun loadRecentUnlocks() {
|
||||
safeLaunchLoad(
|
||||
apiCall = { safeApiCall { api.getRecentUnlocks() } },
|
||||
|
||||
@@ -260,6 +260,4 @@ class BillingViewModel : ViewModel() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun clearActionMessage() = _uiState.update { it.copy(actionMessage = null) }
|
||||
}
|
||||
@@ -260,10 +260,6 @@ class ChannelsViewModel :
|
||||
)
|
||||
}
|
||||
|
||||
fun dismissRestartNeeded() {
|
||||
_uiState.update { it.copy(restartNeeded = false) }
|
||||
}
|
||||
|
||||
// ── Telegram onboarding ────────────────────────────────────────────────
|
||||
|
||||
fun startTelegramOnboarding() {
|
||||
@@ -502,10 +498,6 @@ class ChannelsViewModel :
|
||||
}
|
||||
}
|
||||
|
||||
fun dismissOnboardingError() {
|
||||
_uiState.update { it.copy(onboardingError = null) }
|
||||
}
|
||||
|
||||
override fun clearToast() {
|
||||
_uiState.update { it.copy(toastMessage = null) }
|
||||
}
|
||||
|
||||
@@ -91,7 +91,6 @@ import com.m57.hermescontrol.theme.LocalHermesStatusColors
|
||||
import com.m57.hermescontrol.theme.SystemMessageColor
|
||||
import com.m57.hermescontrol.theme.ToolChipColor
|
||||
import com.m57.hermescontrol.theme.ToolChipColorLight
|
||||
import com.m57.hermescontrol.theme.UserBubble
|
||||
import com.m57.hermescontrol.theme.onColorFor
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
@@ -1607,10 +1607,6 @@ class ChatViewModel(
|
||||
|
||||
// ── UI actions ───────────────────────────────────────────────────────
|
||||
|
||||
fun toggleSessionPicker() {
|
||||
_uiState.update { it.copy(showSessionPicker = !it.showSessionPicker) }
|
||||
}
|
||||
|
||||
/**
|
||||
* Dismiss the active clarify prompt and reject it (tell the agent no answer
|
||||
* was given).
|
||||
|
||||
@@ -96,20 +96,6 @@ class ConnectViewModel(
|
||||
_uiState.update { it.copy(baseUrl = trimmed, transportWarning = warning, errorMessage = null) }
|
||||
}
|
||||
|
||||
fun onHostChange(value: String) {
|
||||
val endpoint = AuthManager.endpoint()
|
||||
val next = endpoint.baseUrl.newBuilder().host(value.trim()).build().toString()
|
||||
onBaseUrlChange(next)
|
||||
}
|
||||
|
||||
fun onPortChange(value: String) {
|
||||
val portText = value.filter { c -> c.isDigit() }
|
||||
val port = portText.toIntOrNull() ?: return
|
||||
val endpoint = AuthManager.endpoint()
|
||||
val next = endpoint.baseUrl.newBuilder().port(port).build().toString()
|
||||
onBaseUrlChange(next)
|
||||
}
|
||||
|
||||
fun connect() {
|
||||
val state = _uiState.value
|
||||
if (state.token.isBlank()) {
|
||||
|
||||
@@ -234,10 +234,6 @@ class SessionsViewModel : ViewModel(), ToastHost {
|
||||
}
|
||||
}
|
||||
|
||||
fun exitSelecting() {
|
||||
_uiState.update { it.copy(isSelecting = false, selectedIds = emptySet()) }
|
||||
}
|
||||
|
||||
fun toggleSessionSelection(id: String) {
|
||||
_uiState.update {
|
||||
val updated = it.selectedIds.toMutableSet()
|
||||
@@ -258,14 +254,6 @@ class SessionsViewModel : ViewModel(), ToastHost {
|
||||
|
||||
// ── Rename ───────────────────────────────────────────────────────────
|
||||
|
||||
fun startRenaming(sessionId: String) {
|
||||
_uiState.update { it.copy(renamingSessionId = sessionId) }
|
||||
}
|
||||
|
||||
fun cancelRenaming() {
|
||||
_uiState.update { it.copy(renamingSessionId = null) }
|
||||
}
|
||||
|
||||
fun renameSession(
|
||||
sessionId: String,
|
||||
newTitle: String,
|
||||
@@ -308,27 +296,6 @@ class SessionsViewModel : ViewModel(), ToastHost {
|
||||
}
|
||||
}
|
||||
|
||||
// ── Copy prompt ──────────────────────────────────────────────────────
|
||||
|
||||
fun copySessionPrompt(sessionId: String) {
|
||||
viewModelScope.launch {
|
||||
val result =
|
||||
safeApiCall {
|
||||
ApiClient.hermesApi.getSessionPrompt(sessionId)
|
||||
}
|
||||
when (result) {
|
||||
is NetworkResult.Success -> {
|
||||
val promptText = result.data.prompt ?: "No prompt available"
|
||||
_uiState.update { it.copy(toastMessage = promptText) }
|
||||
}
|
||||
|
||||
is NetworkResult.Failure -> {
|
||||
_uiState.update { it.copy(toastMessage = "Failed to get prompt: ${result.error.message}") }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ── Delete (single) ──────────────────────────────────────────────────
|
||||
|
||||
fun requestDeleteSession(sessionId: String) {
|
||||
|
||||
@@ -108,22 +108,6 @@ class SettingsViewModel(
|
||||
ApiClient.rebuild()
|
||||
}
|
||||
|
||||
fun onRenameProfileNameChange(value: String) {
|
||||
_uiState.update { it.copy(renameProfileName = value, isSaved = false) }
|
||||
}
|
||||
|
||||
fun renameProfile() {
|
||||
val currentId = _uiState.value.selectedProfileId ?: return
|
||||
val newName = _uiState.value.renameProfileName.trim()
|
||||
if (newName.isBlank()) return
|
||||
val updatedProfiles =
|
||||
AuthManager.getConnectionProfiles().map {
|
||||
if (it.id == currentId) it.copy(name = newName) else it
|
||||
}
|
||||
AuthManager.saveConnectionProfiles(updatedProfiles)
|
||||
viewModelScope.launch(ioDispatcher) { loadSettings() }
|
||||
}
|
||||
|
||||
fun deleteProfile(profileId: String) {
|
||||
val updatedProfiles = AuthManager.getConnectionProfiles().filter { it.id != profileId }
|
||||
AuthManager.saveConnectionProfiles(updatedProfiles)
|
||||
@@ -235,10 +219,6 @@ class SettingsViewModel(
|
||||
ApiClient.rebuild()
|
||||
}
|
||||
|
||||
fun clearNavigateToLogin() {
|
||||
_uiState.update { it.copy(navigateToLogin = false) }
|
||||
}
|
||||
|
||||
// ── Delete confirmation ──────────────────────────────────────────────
|
||||
|
||||
fun requestDeleteProfile(profileId: String) {
|
||||
|
||||
@@ -205,17 +205,6 @@ class SkillsViewModel(
|
||||
}
|
||||
}
|
||||
|
||||
fun clearHubPreview() {
|
||||
_uiState.update {
|
||||
it.copy(
|
||||
hubPreviewIdentifier = null,
|
||||
hubPreviewContent = null,
|
||||
isHubPreviewing = false,
|
||||
hubPreviewError = null,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
// ── Hub install ─────────────────────────────────────────────────────────
|
||||
|
||||
fun installSkill(identifier: String) {
|
||||
@@ -293,43 +282,6 @@ class SkillsViewModel(
|
||||
}
|
||||
}
|
||||
|
||||
// ── SKILL.md preview ────────────────────────────────────────────────────
|
||||
|
||||
fun previewSkill(skillName: String) {
|
||||
_uiState.update {
|
||||
it.copy(
|
||||
previewSkillName = skillName,
|
||||
previewSkillContent = null,
|
||||
isLoadingPreview = true,
|
||||
)
|
||||
}
|
||||
viewModelScope.launch {
|
||||
val result =
|
||||
withContext(Dispatchers.IO) {
|
||||
safeApiCall { ApiClient.hermesApi.getSkillContent(skillName) }
|
||||
}
|
||||
when (result) {
|
||||
is NetworkResult.Success -> {
|
||||
_uiState.update {
|
||||
it.copy(
|
||||
isLoadingPreview = false,
|
||||
previewSkillContent = result.data.content,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
is NetworkResult.Failure -> {
|
||||
_uiState.update {
|
||||
it.copy(
|
||||
isLoadingPreview = false,
|
||||
toastMessage = "Failed to load preview: ${result.error.message}",
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun clearPreview() {
|
||||
_uiState.update {
|
||||
it.copy(
|
||||
|
||||
@@ -700,23 +700,4 @@ class SystemViewModel :
|
||||
override fun clearToast() {
|
||||
_uiState.update { it.copy(toastMessage = null) }
|
||||
}
|
||||
|
||||
fun clearTransientState() {
|
||||
actionPollingJob?.cancel()
|
||||
_uiState.update {
|
||||
it.copy(
|
||||
errorMessage = null,
|
||||
toastMessage = null,
|
||||
activeAction = null,
|
||||
actionLog = null,
|
||||
isLoading = false,
|
||||
addingCred = false,
|
||||
creatingHook = false,
|
||||
sharing = false,
|
||||
checkingUpdate = false,
|
||||
updateConfirmOpen = false,
|
||||
hookModalOpen = false,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user