fix: resolve all build compilation and style check warnings (#597)

* fix: resolve all build compilation and style check warnings

* fix: remove unused import in SystemViewModel
This commit is contained in:
M57 authored and GitHub committed 2026-07-14 21:55:37 +03:00
1 parent 48f5ffbe52
commit d1fc477bcd
28 files changed
+293 -192

No files matched your search

@@ -655,7 +655,7 @@ fun parseToolOutput(
val truncated = if (raw.length > 100) raw.take(100) + "…" else raw
if (truncated.isNotBlank()) "${config.summaryPrefix}$truncated" else null
} else {
null ?: obj
obj
.get("context")
?.takeIf { !it.isJsonNull }
?.asString
@@ -764,7 +764,7 @@ fun parseToolOutput(
val duration = obj.get("duration_s")?.takeIf { !it.isJsonNull }?.asDouble
return ParsedToolData(
toolName = resolvedToolName ?: "",
toolName = resolvedToolName,
args = args,
result = dataSource.entrySet().associate { it.key to it.value.toString() },
summaryText = factSummaryText,
@@ -900,7 +900,7 @@ fun parseToolOutput(
val duration = obj.get("duration_s")?.takeIf { !it.isJsonNull }?.asDouble
return ParsedToolData(
toolName = resolvedToolName ?: "",
toolName = resolvedToolName,
args = args,
result = dataSource.entrySet().associate { it.key to it.value.toString() },
summaryText = ssSummaryText,
@@ -922,13 +922,24 @@ fun parseToolOutput(
val mainOutput =
when {
errorMsg != null -> "❌ $errorMsg"
!success -> "❌ Failed"
usage != null -> "✅ $action in ${target ?: "memory"}\n $usage"
else -> "✅ ${target?.capitalize() ?: "Memory"} $action done"
else -> "✅ ${target?.replaceFirstChar {
if (it.isLowerCase()) {
it.titlecase(
java.util.Locale.getDefault(),
)
} else {
it.toString()
}
} ?: "Memory"} $action done"
}
val duration = obj.get("duration_s")?.takeIf { !it.isJsonNull }?.asDouble
return ParsedToolData(
toolName = resolvedToolName ?: "",
toolName = resolvedToolName,
args = args,
result = dataSource.entrySet().associate { it.key to it.value.toString() },
summaryText = summaryText,
@@ -985,7 +996,7 @@ fun parseToolOutput(
}
val duration = obj.get("duration_s")?.takeIf { !it.isJsonNull }?.asDouble
return ParsedToolData(
toolName = resolvedToolName ?: "",
toolName = resolvedToolName,
args = args,
result = dataSource.entrySet().associate { it.key to it.value.toString() },
summaryText = summaryText,
@@ -1047,7 +1058,7 @@ fun parseToolOutput(
}
val duration = obj.get("duration_s")?.takeIf { !it.isJsonNull }?.asDouble
return ParsedToolData(
toolName = resolvedToolName ?: "",
toolName = resolvedToolName,
args = args,
result = dataSource.entrySet().associate { it.key to it.value.toString() },
summaryText = summaryText,
@@ -1081,7 +1092,7 @@ fun parseToolOutput(
}?.joinToString("\n\n") ?: "📚 No skills found"
val duration = obj.get("duration_s")?.takeIf { !it.isJsonNull }?.asDouble
return ParsedToolData(
toolName = resolvedToolName ?: "",
toolName = resolvedToolName,
args = args,
result = dataSource.entrySet().associate { it.key to it.value.toString() },
summaryText = summaryText,
@@ -1120,7 +1131,7 @@ fun parseToolOutput(
}
val duration = obj.get("duration_s")?.takeIf { !it.isJsonNull }?.asDouble
return ParsedToolData(
toolName = resolvedToolName ?: "",
toolName = resolvedToolName,
args = args,
result = dataSource.entrySet().associate { it.key to it.value.toString() },
summaryText = summaryText,
@@ -1181,7 +1192,7 @@ fun parseToolOutput(
}
val duration = obj.get("duration_s")?.takeIf { !it.isJsonNull }?.asDouble
return ParsedToolData(
toolName = resolvedToolName ?: "",
toolName = resolvedToolName,
args = args,
result = dataSource.entrySet().associate { it.key to it.value.toString() },
summaryText = summaryText,
@@ -1229,7 +1240,7 @@ fun parseToolOutput(
}
val duration = obj.get("duration_s")?.takeIf { !it.isJsonNull }?.asDouble
return ParsedToolData(
toolName = resolvedToolName ?: "",
toolName = resolvedToolName,
args = args,
result = dataSource.entrySet().associate { it.key to it.value.toString() },
summaryText = summaryText,
@@ -1256,7 +1267,7 @@ fun parseToolOutput(
}
val duration = obj.get("duration_s")?.takeIf { !it.isJsonNull }?.asDouble
return ParsedToolData(
toolName = resolvedToolName ?: "",
toolName = resolvedToolName,
args = args,
result = dataSource.entrySet().associate { it.key to it.value.toString() },
summaryText = summaryText,
@@ -1273,7 +1284,7 @@ fun parseToolOutput(
val success = dataSource.get("success")?.takeIf { !it.isJsonNull }?.asBoolean ?: true
val errorMsg = dataSource.get("error")?.takeIf { !it.isJsonNull }?.asString
val urlSummary = urls?.joinToString(", ") { it.asString?.take(40) ?: "?" } ?: ""
val urlSummary = urls?.joinToString(", ") { it.asString.take(40) } ?: ""
val summaryText = "🕸️ ${urls?.size() ?: 0} page(s)"
val mainOutput =
when {
@@ -1293,7 +1304,7 @@ fun parseToolOutput(
}
val duration = obj.get("duration_s")?.takeIf { !it.isJsonNull }?.asDouble
return ParsedToolData(
toolName = resolvedToolName ?: "",
toolName = resolvedToolName,
args = args,
result = dataSource.entrySet().associate { it.key to it.value.toString() },
summaryText = summaryText,
@@ -1328,7 +1339,7 @@ fun parseToolOutput(
}?.joinToString("\n\n") ?: "🔍 No matching tools"
val duration = obj.get("duration_s")?.takeIf { !it.isJsonNull }?.asDouble
return ParsedToolData(
toolName = resolvedToolName ?: "",
toolName = resolvedToolName,
args = args,
result = dataSource.entrySet().associate { it.key to it.value.toString() },
summaryText = summaryText,
@@ -1372,7 +1383,7 @@ fun parseToolOutput(
}
val duration = obj.get("duration_s")?.takeIf { !it.isJsonNull }?.asDouble
return ParsedToolData(
toolName = resolvedToolName ?: "",
toolName = resolvedToolName,
args = args,
result = dataSource.entrySet().associate { it.key to it.value.toString() },
summaryText = summaryText,
@@ -1410,7 +1421,7 @@ fun parseToolOutput(
}
val duration = obj.get("duration_s")?.takeIf { !it.isJsonNull }?.asDouble
return ParsedToolData(
toolName = resolvedToolName ?: "",
toolName = resolvedToolName,
args = args,
result = dataSource.entrySet().associate { it.key to it.value.toString() },
summaryText = summaryText,
@@ -1443,7 +1454,7 @@ fun parseToolOutput(
}
val duration = obj.get("duration_s")?.takeIf { !it.isJsonNull }?.asDouble
return ParsedToolData(
toolName = resolvedToolName ?: "",
toolName = resolvedToolName,
args = args,
result = dataSource.entrySet().associate { it.key to it.value.toString() },
summaryText = summaryText,
@@ -1488,7 +1499,7 @@ fun parseToolOutput(
}
val duration = obj.get("duration_s")?.takeIf { !it.isJsonNull }?.asDouble
return ParsedToolData(
toolName = resolvedToolName ?: "",
toolName = resolvedToolName,
args = args,
result = dataSource.entrySet().associate { it.key to it.value.toString() },
summaryText = summaryText,
@@ -1557,75 +1568,80 @@ fun parseToolOutput(
buildString {
if (errorMsg != null) {
append("❌ $errorMsg")
} else if (multimodalText != null) {
append(multimodalText)
if (textSummary != null && multimodalText != textSummary) {
append("\n\n$textSummary")
}
} else if (summaryText != null) {
append(summaryText)
} else if (textSummary != null) {
append(textSummary)
} else if (appsArr != null) {
appsArr.forEachIndexed { idx, el ->
if (el.isJsonObject) {
val obj = el.asJsonObject
val name =
obj
.get("name")
?.takeIf { !it.isJsonNull }
?.asString ?: "?"
val pid =
obj
.get("pid")
?.takeIf { !it.isJsonNull }
?.asInt
append("${idx + 1}. $name")
if (pid != null) append(" (PID: $pid)")
append("\n")
} else {
val textPart = multimodalText ?: summaryText ?: textSummary
if (textPart != null) {
append(textPart)
if (textPart == multimodalText && textSummary != null && multimodalText != textSummary) {
append("\n\n$textSummary")
}
}
} else if (elementsArr != null) {
append("🖥️ ${elementsArr.size()} interactable elements")
if (mode != null) append(" (mode: $mode)")
if (width != null && height != null) append(" • ${width}x$height")
if (textSummary != null) append("\n\n$textSummary")
// Show first few elements as preview
val previewCount = minOf(elementsArr.size(), 5)
if (previewCount > 0) {
append("\n\n")
for (i in 0 until previewCount) {
val el = elementsArr[i]
if (appsArr != null) {
if (isNotEmpty()) append("\n\n")
appsArr.forEachIndexed { idx, el ->
if (el.isJsonObject) {
val obj = el.asJsonObject
val idx =
val name =
obj
.get("index")
.get("name")
?.takeIf { !it.isJsonNull }
?.asString ?: "?"
val pid =
obj
.get("pid")
?.takeIf { !it.isJsonNull }
?.asInt
val role =
obj
.get("role")
?.takeIf { !it.isJsonNull }
?.asString
val label =
obj
.get("label")
?.takeIf { !it.isJsonNull }
?.asString
append(" #$idx ${role ?: ""}${label?.let { " '$it'" } ?: ""}\n")
append("${idx + 1}. $name")
if (pid != null) append(" (PID: $pid)")
append("\n")
}
}
if (elementsArr.size() > previewCount) {
append(" ... and ${elementsArr.size() - previewCount} more")
} else if (elementsArr != null) {
if (isNotEmpty()) append("\n\n")
append("🖥️ ${elementsArr.size()} interactable elements")
if (mode != null) append(" (mode: $mode)")
if (width != null && height != null) append(" • ${width}x$height")
if (textSummary != null) append("\n\n$textSummary")
// Show first few elements as preview
val previewCount = minOf(elementsArr.size(), 5)
if (previewCount > 0) {
append("\n\n")
for (i in 0 until previewCount) {
val el = elementsArr[i]
if (el.isJsonObject) {
val obj = el.asJsonObject
val idx =
obj
.get("index")
?.takeIf { !it.isJsonNull }
?.asInt
val role =
obj
.get("role")
?.takeIf { !it.isJsonNull }
?.asString
val label =
obj
.get("label")
?.takeIf { !it.isJsonNull }
?.asString
append(" #$idx ${role ?: ""}${label?.let { " '$it'" } ?: ""}\n")
}
}
if (elementsArr.size() > previewCount) {
append(" ... and ${elementsArr.size() - previewCount} more")
}
}
} else if (action != null &&
(multimodalText == null && summaryText == null && textSummary == null)
) {
append("$action:")
if (ok != null) append(" ${if (ok) "✅ ok" else "❌ failed"}")
if (message != null) append("\n$message")
} else if (isEmpty()) {
append("🖥️ Computer use action")
}
} else if (action != null) {
append("$action:")
if (ok != null) append(" ${if (ok) "✅ ok" else "❌ failed"}")
if (message != null) append("\n$message")
} else {
append("🖥️ Computer use action")
}
if (visionAnalysis != null) {
append("\n\n━━━ Vision Analysis ━━━\n$visionAnalysis")
@@ -1633,7 +1649,7 @@ fun parseToolOutput(
}
val duration = obj.get("duration_s")?.takeIf { !it.isJsonNull }?.asDouble
return ParsedToolData(
toolName = resolvedToolName ?: "",
toolName = resolvedToolName,
args = args,
result = dataSource.entrySet().associate { it.key to it.value.toString() },
summaryText = summaryLine,
@@ -1657,8 +1673,16 @@ fun parseToolOutput(
(
dataSource.get("output")?.takeIf { !it.isJsonNull }?.asString
?: listOfNotNull(
dataSource.get("stdout")?.takeIf { !it.isJsonNull }?.asString?.takeIf { it.isNotEmpty() },
dataSource.get("stderr")?.takeIf { !it.isJsonNull }?.asString?.takeIf { it.isNotEmpty() },
dataSource
.get("stdout")
?.takeIf { !it.isJsonNull }
?.asString
?.takeIf { it.isNotEmpty() },
dataSource
.get("stderr")
?.takeIf { !it.isJsonNull }
?.asString
?.takeIf { it.isNotEmpty() },
).joinToString("\n").takeIf { it.isNotEmpty() }
)?.takeIf { it.isNotEmpty() }
val exitCode = (dataSource.get("exit_code") ?: dataSource.get("exitCode"))?.toIntOrNull()
@@ -2331,6 +2355,9 @@ private fun JsonElement?.toIntOrNull(): Int? {
is JsonPrimitive -> {
content.toIntOrNull() ?: content.toDoubleOrNull()?.toInt()
}
else -> null
else -> {
null
}
}
}
@@ -1197,7 +1197,7 @@ private fun SudoPromptDialog(
modifier = Modifier.fillMaxWidth().testTag("sudo_password_input"),
singleLine = true,
visualTransformation = PasswordVisualTransformation(),
keyboardOptions = KeyboardOptions(autoCorrect = false, keyboardType = KeyboardType.Password),
keyboardOptions = KeyboardOptions(autoCorrectEnabled = false, keyboardType = KeyboardType.Password),
)
}
},
@@ -1247,7 +1247,7 @@ private fun SecretPromptDialog(
modifier = Modifier.fillMaxWidth().testTag("secret_value_input"),
singleLine = true,
visualTransformation = PasswordVisualTransformation(),
keyboardOptions = KeyboardOptions(autoCorrect = false, keyboardType = KeyboardType.Password),
keyboardOptions = KeyboardOptions(autoCorrectEnabled = false, keyboardType = KeyboardType.Password),
)
}
},
@@ -2156,9 +2156,13 @@ private fun ReactionHeartsOverlay(
val emojis =
remember(reactionKind) {
when (reactionKind) {
"ily", "<3", "good bot" ->
"ily", "<3", "good bot" -> {
listOf("💗", "❤️", "💕", "💖", "🩷", "💘", "💝")
else -> listOf("💗", "❤️", "💕", "💖")
}
else -> {
listOf("💗", "❤️", "💕", "💖")
}
}
}
@@ -649,7 +649,7 @@ class ChatViewModel(
_uiState.update {
it.copy(
isLoading = false,
errorMessage = "Error${if (method != null) " ($method)" else ""}: $errorMsg",
errorMessage = "Error ($method): $errorMsg",
)
}
}
@@ -1084,8 +1084,10 @@ class ChatViewModel(
val body = trimmed.removePrefix("/").trimStart()
// Must be exactly "model" with no argument (or just whitespace).
return body.equals("model", ignoreCase = true) ||
body.startsWith("model ", ignoreCase = true) &&
body.substringAfter("model").trim().isEmpty()
(
body.startsWith("model ", ignoreCase = true) &&
body.substringAfter("model").trim().isEmpty()
)
}
/** Preload model options so the picker opens instantly (no spinner on /model). */
@@ -1343,7 +1345,7 @@ class ChatViewModel(
}
}
is NetworkResult.Failure -> Unit
is NetworkResult.Failure -> {}
}
} finally {
isSyncingMessages = false
@@ -1352,7 +1354,10 @@ class ChatViewModel(
}
private suspend fun fetchServerMessageCount(sessionId: String): Int {
val known = _uiState.value.sessions.find { it.id == sessionId }?.messageCount
val known =
_uiState.value.sessions
.find { it.id == sessionId }
?.messageCount
if (known != null) return known
val result =
withContext(Dispatchers.IO) {
@@ -1762,7 +1767,7 @@ class ChatViewModel(
return@launch
}
val body = ticketResp.body?.string().orEmpty()
val body = ticketResp.body.string()
val ticket = JSONObject(body).optString("ticket").takeIf { it.isNotBlank() }
if (ticket.isNullOrBlank()) {
@@ -104,13 +104,16 @@ fun MarkdownText(
Column(modifier = modifier.fillMaxWidth()) {
for (block in blocks) {
when (block) {
is MdBlock.Code -> CodeBlockCard(code = block.code, textColor = textColor)
is MdBlock.Code -> {
CodeBlockCard(code = block.code, textColor = textColor)
}
is MdBlock.Hr ->
is MdBlock.Hr -> {
HorizontalDivider(
modifier = Modifier.padding(vertical = 8.dp),
color = textColor.copy(alpha = 0.25f),
)
}
is MdBlock.Heading -> {
val fontSize =
@@ -291,7 +294,9 @@ fun MarkdownText(
}
}
is MdBlock.Table -> MarkdownTable(block = block, textColor = textColor)
is MdBlock.Table -> {
MarkdownTable(block = block, textColor = textColor)
}
is MdBlock.Footnotes -> {
HorizontalDivider(
@@ -510,7 +515,9 @@ internal fun parseBlocks(src: String): List<MdBlock> {
}
}
line.isBlank() -> i++
line.isBlank() -> {
i++
}
isHorizontalRule(line) -> {
blocks.add(MdBlock.Hr)
@@ -944,19 +951,36 @@ internal fun parseInline(
}
internal sealed interface MdBlock {
data class Code(val code: String) : MdBlock
data class Code(
val code: String,
) : MdBlock
data class Heading(val level: Int, val text: String) : MdBlock
data class Heading(
val level: Int,
val text: String,
) : MdBlock
data class Bullet(val text: String) : MdBlock
data class Bullet(
val text: String,
) : MdBlock
data class Task(val checked: Boolean, val text: String) : MdBlock
data class Task(
val checked: Boolean,
val text: String,
) : MdBlock
data class Ordered(val index: Int, val text: String) : MdBlock
data class Ordered(
val index: Int,
val text: String,
) : MdBlock
data class Quote(val text: String) : MdBlock
data class Quote(
val text: String,
) : MdBlock
data class Paragraph(val text: String) : MdBlock
data class Paragraph(
val text: String,
) : MdBlock
data class Table(
val header: List<String>,
@@ -966,9 +990,13 @@ internal sealed interface MdBlock {
object Hr : MdBlock
data class DefList(val items: List<DefItem>) : MdBlock
data class DefList(
val items: List<DefItem>,
) : MdBlock
data class Footnotes(val notes: List<FnNote>) : MdBlock
data class Footnotes(
val notes: List<FnNote>,
) : MdBlock
}
internal data class DefItem(