Take ktfmt's formatting on the files just added
Four files went in unformatted: I ran the formatter mid-change and then kept editing. ktfmtCheck is part of finishing, not part of starting. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
d580461bd5
commit
8fe13634cb
4 files changed
+39
-21
No files matched your search
@@ -28,8 +28,8 @@ import org.json.JSONObject
|
||||
* Every tool's input arrives as JSON, and showing it raw makes the reader parse `{"command":"…",
|
||||
* "timeout":120000}` themselves to find the one line they care about. So the fields that carry the
|
||||
* meaning are pulled out -- the command a shell will run, what it is for, how long it may take --
|
||||
* and anything left over is still shown, because dropping a field would be claiming the tool has
|
||||
* no other input when it might.
|
||||
* and anything left over is still shown, because dropping a field would be claiming the tool has no
|
||||
* other input when it might.
|
||||
*/
|
||||
data class ToolInput(
|
||||
/** The thing that will actually be run or read, if this tool has one. */
|
||||
@@ -70,13 +70,21 @@ fun parseToolInput(tool: String, input: String): ToolInput {
|
||||
} catch (_: org.json.JSONException) {
|
||||
// Not an object: older transcripts and some tools send a bare
|
||||
// string. It is still the input, so it is still shown.
|
||||
return ToolInput(null, null, null, input.takeIf { it.isNotBlank() }?.let { listOf(it) }.orEmpty())
|
||||
return ToolInput(
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
input.takeIf { it.isNotBlank() }?.let { listOf(it) }.orEmpty(),
|
||||
)
|
||||
}
|
||||
val (subjectKey, language) = SUBJECTS[tool] ?: (null to null)
|
||||
val subject = subjectKey?.let { json.optString(it) }?.takeIf { it.isNotBlank() }
|
||||
val description = DESCRIPTIONS.firstNotNullOfOrNull { json.optString(it).takeIf { v -> v.isNotBlank() } }
|
||||
val description = DESCRIPTIONS.firstNotNullOfOrNull {
|
||||
json.optString(it).takeIf { v -> v.isNotBlank() }
|
||||
}
|
||||
val rest =
|
||||
json.keys()
|
||||
json
|
||||
.keys()
|
||||
.asSequence()
|
||||
.filter { it != subjectKey || subject == null }
|
||||
.filter { it !in DESCRIPTIONS || description == null }
|
||||
@@ -107,7 +115,9 @@ fun ToolInputView(tool: String, input: String, modifier: Modifier = Modifier) {
|
||||
fontFamily = FontFamily.Monospace,
|
||||
softWrap = false,
|
||||
modifier =
|
||||
Modifier.padding(top = 4.dp).fillMaxWidth().horizontalScroll(rememberScrollState()),
|
||||
Modifier.padding(top = 4.dp)
|
||||
.fillMaxWidth()
|
||||
.horizontalScroll(rememberScrollState()),
|
||||
)
|
||||
}
|
||||
parsed.rest.forEach {
|
||||
@@ -136,14 +146,21 @@ private fun highlighted(code: String, language: SyntaxLanguage?): AnnotatedStrin
|
||||
return remember(code, language, theme, plain) {
|
||||
if (language == null) return@remember AnnotatedString(code)
|
||||
val marks =
|
||||
Highlights.Builder(code = code, language = language, theme = theme).build().getHighlights()
|
||||
Highlights.Builder(code = code, language = language, theme = theme)
|
||||
.build()
|
||||
.getHighlights()
|
||||
buildAnnotatedString {
|
||||
append(code)
|
||||
marks.forEach { mark ->
|
||||
when (mark) {
|
||||
is ColorHighlight ->
|
||||
addStyle(
|
||||
SpanStyle(color = androidx.compose.ui.graphics.Color(mark.rgb or 0xFF000000.toInt())),
|
||||
SpanStyle(
|
||||
color =
|
||||
androidx.compose.ui.graphics.Color(
|
||||
mark.rgb or 0xFF000000.toInt()
|
||||
)
|
||||
),
|
||||
mark.location.start,
|
||||
mark.location.end,
|
||||
)
|
||||
|
||||
Reference in new issue
Block a user