feat(#125): fix clarify input pre-filling and parse/route clarify_id (#156)

* feat(#125): fix clarification input pre-filling and parse/route clarify_id

* fix(#156): fix ktlint violations in ChatViewModelTest.kt

---------

Co-authored-by: M57 <hy4ri@users.noreply.github.com>
This commit is contained in:
M57andM57 authored and GitHub committed 2026-06-20 16:35:58 +03:00
1 parent 4544d88f8d
commit 03cfcf8504
5 files changed
+38 -7

No files matched your search

@@ -824,7 +824,7 @@ private fun ClarifyDialog(
onOptionSelected: (String) -> Unit,
onDismiss: () -> Unit,
) {
var typedText by rememberSaveable(clarify) { mutableStateOf(clarify.text) }
var typedText by rememberSaveable(clarify.text) { mutableStateOf(clarify.text) }
AlertDialog(
onDismissRequest = onDismiss,
@@ -70,6 +70,7 @@ data class SessionUi(
data class ClarifyUi(
val text: String,
val options: List<String>,
val clarifyId: String? = null,
)
class ChatViewModel(
@@ -164,6 +165,7 @@ class ChatViewModel(
ClarifyUi(
text = event.text.orEmpty(),
options = event.options.orEmpty(),
clarifyId = event.clarifyId,
),
)
}
@@ -888,6 +890,7 @@ class ChatViewModel(
fun respondToClarify(option: String) {
val sessionId = _uiState.value.currentSessionId ?: return
val clarifyId = _uiState.value.clarifyRequest?.clarifyId
_uiState.update { it.copy(clarifyRequest = null) }
val userMessage =
@@ -908,9 +911,19 @@ class ChatViewModel(
}
viewModelScope.launch(Dispatchers.IO) {
val params =
mutableMapOf<String, Any>(
"session_id" to sessionId,
"response" to option,
"answer" to option,
)
if (clarifyId != null) {
params["clarify_id"] = clarifyId
params["request_id"] = clarifyId
}
wsClient.send(
method = WsMethods.CLARIFY_RESPOND,
params = mapOf("session_id" to sessionId, "response" to option),
params = params,
onSent = { id -> trackRequest(id, WsMethods.CLARIFY_RESPOND) },
)
}