feat(#125): pre-fill clarification input and route response via clarify.respond
This commit is contained in:
1 parent
399691ed34
commit
cbd743a5c9
3 files changed
+43
-2
No files matched your search
@@ -790,7 +790,7 @@ private fun ClarifyDialog(
|
||||
onOptionSelected: (String) -> Unit,
|
||||
onDismiss: () -> Unit,
|
||||
) {
|
||||
var typedText by rememberSaveable { mutableStateOf("") }
|
||||
var typedText by rememberSaveable(clarify) { mutableStateOf(clarify.text) }
|
||||
|
||||
AlertDialog(
|
||||
onDismissRequest = onDismiss,
|
||||
|
||||
@@ -886,8 +886,33 @@ class ChatViewModel(
|
||||
}
|
||||
|
||||
fun respondToClarify(option: String) {
|
||||
val sessionId = _uiState.value.currentSessionId ?: return
|
||||
_uiState.update { it.copy(clarifyRequest = null) }
|
||||
sendMessage(option)
|
||||
|
||||
val userMessage =
|
||||
ChatMessage(
|
||||
role = MessageRole.USER,
|
||||
content = option,
|
||||
)
|
||||
|
||||
_uiState.update { state ->
|
||||
state.copy(
|
||||
messages = state.messages + userMessage,
|
||||
isAgentTyping = true,
|
||||
)
|
||||
}
|
||||
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
dao.upsert(userMessage.toEntity(sessionId))
|
||||
}
|
||||
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
wsClient.send(
|
||||
method = WsMethods.CLARIFY_RESPOND,
|
||||
params = mapOf("session_id" to sessionId, "response" to option),
|
||||
onSent = { id -> trackRequest(id, WsMethods.CLARIFY_RESPOND) },
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
fun clearError() {
|
||||
|
||||
Reference in new issue
Block a user