fix(chat): align block indents and format multiline expressions

This commit is contained in:
Hy4ri committed 2026-06-20 11:18:08 +03:00
1 parent 5ba266cefd
commit 890ca05d16
1 file changed
+11 -5
@@ -197,7 +197,8 @@ class ChatViewModel(
private fun handleMessageStart(event: WsEvent.MessageStart) { private fun handleMessageStart(event: WsEvent.MessageStart) {
if (!isCurrentSession(event.sessionId)) return if (!isCurrentSession(event.sessionId)) return
// Create the streaming message as a standalone state field. // Create the streaming message as a standalone state field.
val msg = ChatMessage( val msg =
ChatMessage(
role = MessageRole.ASSISTANT, role = MessageRole.ASSISTANT,
content = "", content = "",
isStreaming = true, isStreaming = true,
@@ -219,14 +220,16 @@ class ChatViewModel(
val current = state.streamingMessage val current = state.streamingMessage
if (current != null) { if (current != null) {
state.copy( state.copy(
streamingMessage = current.copy( streamingMessage =
current.copy(
content = current.content + event.token, content = current.content + event.token,
), ),
isThinking = false, isThinking = false,
) )
} else { } else {
// Fallback: no MessageStart was received — create one now // Fallback: no MessageStart was received — create one now
val msg = ChatMessage( val msg =
ChatMessage(
role = MessageRole.ASSISTANT, role = MessageRole.ASSISTANT,
content = event.token, content = event.token,
isStreaming = true, isStreaming = true,
@@ -259,7 +262,8 @@ class ChatViewModel(
_uiState.update { state -> _uiState.update { state ->
val streaming = state.streamingMessage val streaming = state.streamingMessage
val msg = if (streaming != null) { val msg =
if (streaming != null) {
streaming.copy( streaming.copy(
content = event.text, content = event.text,
isStreaming = false, isStreaming = false,
@@ -336,7 +340,8 @@ class ChatViewModel(
// ── Tool events ────────────────────────────────────────────────────── // ── Tool events ──────────────────────────────────────────────────────
private fun handleToolStart(event: WsEvent.ToolStart) { private fun handleToolStart(event: WsEvent.ToolStart) {
val toolMessage = ChatMessage( val toolMessage =
ChatMessage(
role = MessageRole.TOOL, role = MessageRole.TOOL,
content = event.data.toString(), content = event.data.toString(),
toolName = event.name, toolName = event.name,
@@ -914,6 +919,7 @@ class ChatViewModel(
} }
} }
} }
}
// ── Search ──────────────────────────────────────────────────────────── // ── Search ────────────────────────────────────────────────────────────