bugfix: reset preselection upon running the preselected model

This commit is contained in:
Han Yin 2025-08-21 09:21:36 -07:00
parent 1e1be75456
commit 365a7c8ae8
3 changed files with 24 additions and 23 deletions

View File

@ -201,7 +201,7 @@ fun AppContent(
else TopBarConfig.Default( else TopBarConfig.Default(
title = "Pick your model", title = "Pick your model",
navigationIcon = NavigationIcon.Menu { navigationIcon = NavigationIcon.Menu {
modelSelectionViewModel.resetSelection() modelSelectionViewModel.resetPreselection()
openDrawer() openDrawer()
} }
), ),
@ -231,10 +231,11 @@ fun AppContent(
), ),
runAction = BottomBarConfig.ModelSelection.RunActionConfig( runAction = BottomBarConfig.ModelSelection.RunActionConfig(
preselection = preselection, preselection = preselection,
onClickRun = { preselection -> onClickRun = {
if (modelSelectionViewModel.selectModel(preselection)) { if (modelSelectionViewModel.selectModel(it)) {
navigationActions.navigateToModelLoading()
modelSelectionViewModel.toggleSearchState(false) modelSelectionViewModel.toggleSearchState(false)
modelSelectionViewModel.resetPreselection()
navigationActions.navigateToModelLoading()
} }
} }
) )

View File

@ -155,7 +155,7 @@ fun ModelSelectionScreen(
if (selected) { if (selected) {
toggleSearchFocusAndIme(false) toggleSearchFocusAndIme(false)
} else { } else {
viewModel.resetSelection() viewModel.resetPreselection()
toggleSearchFocusAndIme(true) toggleSearchFocusAndIme(true)
} }
}, },
@ -185,7 +185,7 @@ fun ModelSelectionScreen(
model = model, model = model,
isSelected = if (model == preselection?.modelInfo) true else null, isSelected = if (model == preselection?.modelInfo) true else null,
onSelected = { selected -> onSelected = { selected ->
if (!selected) viewModel.resetSelection() if (!selected) viewModel.resetPreselection()
}, },
isExpanded = model == preselection?.modelInfo, isExpanded = model == preselection?.modelInfo,
onExpanded = { expanded -> onExpanded = { expanded ->

View File

@ -45,7 +45,7 @@ class ModelSelectionViewModel @Inject constructor(
fun toggleSearchState(active: Boolean) { fun toggleSearchState(active: Boolean) {
_isSearchActive.value = active _isSearchActive.value = active
if (active) { if (active) {
resetSelection() resetPreselection()
} else { } else {
searchFieldState.clearText() searchFieldState.clearText()
} }
@ -163,6 +163,14 @@ class ModelSelectionViewModel @Inject constructor(
_showRamWarning.value = false _showRamWarning.value = false
} }
/**
* Reset preselected model to none (before navigating away)
*/
fun resetPreselection() {
_preselectedModel.value = null
_showRamWarning.value = false
}
/** /**
* Select the currently pre-selected model * Select the currently pre-selected model
* *
@ -181,6 +189,13 @@ class ModelSelectionViewModel @Inject constructor(
else -> false else -> false
} }
/**
* Dismiss the RAM warnings
*/
fun dismissRamWarning() {
_showRamWarning.value = false
}
/** /**
* Acknowledge RAM warnings and confirm currently pre-selected model * Acknowledge RAM warnings and confirm currently pre-selected model
* *
@ -195,27 +210,12 @@ class ModelSelectionViewModel @Inject constructor(
false false
} }
/**
* Dismiss the RAM warnings
*/
fun dismissRamWarning() {
_showRamWarning.value = false
}
/**
* Reset selected model to none (before navigating away)
*/
fun resetSelection() {
_preselectedModel.value = null
_showRamWarning.value = false
}
/** /**
* Handle back press from both back button and top bar * Handle back press from both back button and top bar
*/ */
fun onBackPressed() { fun onBackPressed() {
if (_preselectedModel.value != null) { if (_preselectedModel.value != null) {
resetSelection() resetPreselection()
} }
} }