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

View File

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

View File

@ -45,7 +45,7 @@ class ModelSelectionViewModel @Inject constructor(
fun toggleSearchState(active: Boolean) {
_isSearchActive.value = active
if (active) {
resetSelection()
resetPreselection()
} else {
searchFieldState.clearText()
}
@ -163,6 +163,14 @@ class ModelSelectionViewModel @Inject constructor(
_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
*
@ -181,6 +189,13 @@ class ModelSelectionViewModel @Inject constructor(
else -> false
}
/**
* Dismiss the RAM warnings
*/
fun dismissRamWarning() {
_showRamWarning.value = false
}
/**
* Acknowledge RAM warnings and confirm currently pre-selected model
*
@ -195,27 +210,12 @@ class ModelSelectionViewModel @Inject constructor(
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
*/
fun onBackPressed() {
if (_preselectedModel.value != null) {
resetSelection()
resetPreselection()
}
}