From d9582d9b86ad5064e185057ffbaa60c8bb33101f Mon Sep 17 00:00:00 2001 From: OpenClaw Date: Sat, 7 Mar 2026 08:52:18 +0800 Subject: [PATCH] Add structured output detection helper --- .../cn/xiaobai/openclawapp/feature/chat/ChatScreen.kt | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/composeApp/src/commonMain/kotlin/cn/xiaobai/openclawapp/feature/chat/ChatScreen.kt b/composeApp/src/commonMain/kotlin/cn/xiaobai/openclawapp/feature/chat/ChatScreen.kt index 87c2257..5e98896 100644 --- a/composeApp/src/commonMain/kotlin/cn/xiaobai/openclawapp/feature/chat/ChatScreen.kt +++ b/composeApp/src/commonMain/kotlin/cn/xiaobai/openclawapp/feature/chat/ChatScreen.kt @@ -388,3 +388,13 @@ private fun MessageBubble( } } } + +private fun looksStructuredOutput(text: String): Boolean { + val trimmed = text.trim() + if (trimmed.isEmpty()) return false + if ((trimmed.startsWith("{") && trimmed.endsWith("}")) || (trimmed.startsWith("[") && trimmed.endsWith("]"))) { + return true + } + val lineCount = trimmed.lines().size + return lineCount >= 4 || trimmed.contains("\n ") || trimmed.contains("\t") +}