The same pass the server had, on the Kotlin side: comments restating what the code says are gone, and the ones recording a measurement, a constraint or an incident are kept but cut to a few lines each. 6540 comment lines to 5674, and 920 lines off the app. Two doc comments had drifted onto the item above the one they describe -- `contextAfter`'s onto `sessionWorking` in Events.kt, and `UsageMonitor`'s equivalent on the server was fixed in the previous commit. Each is back on its own item, which is the only non-comment line this diff moves. The comments are reflowed to the column limit at their own indentation: several were written wide, and ktfmt re-wrapped them into lines holding a single orphan word. `/tmp` script, not kept -- ktfmt is idempotent over the result, which is the check. Left alone deliberately: this codebase's remaining comment density is high because the comments carry things the code cannot say -- what a null means, what a number was measured against, which bug a guard exists for. Of the 238 one-line doc comments in the app, five were pure restatement of the name and were removed; the rest each say something the signature does not. ktfmtFormat, compileDebugKotlin, lintDebug and testDebugUnitTest pass; cargo test (127), clippy --all-targets and fmt still clean. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
33 lines
1.4 KiB
Kotlin
33 lines
1.4 KiB
Kotlin
package com.example.aiapp
|
|
|
|
/**
|
|
* What a session with no model of its own is called, in the button and in the list it opens.
|
|
*
|
|
* One constant rather than a literal in each place, because the two have to agree: a picker whose
|
|
* options cannot say every state its button can display is one you can leave and not get back to.
|
|
* It is also the Claude CLI's own word for "whatever is configured".
|
|
*/
|
|
const val DEFAULT_MODEL = "default"
|
|
|
|
/**
|
|
* A model's name as a person reads it.
|
|
*
|
|
* Providers answer with their own full identifier -- Claude Code resolves `haiku` to `claude-
|
|
* haiku-4-5-20251001` and reports that, which is the honest answer to "what is this session using"
|
|
* and far too long for a button in a row that also holds Stop and Send.
|
|
*
|
|
* So the two ends that identify nothing are dropped and nothing else is: the vendor prefix, which
|
|
* is the same on every model this app can show, and the release date, which distinguishes builds of
|
|
* one model rather than one model from another. Anything that does not look like that is returned
|
|
* untouched.
|
|
*
|
|
* A display decision, not a correction: the full name is what the session reports.
|
|
*/
|
|
fun modelLabel(model: String?): String {
|
|
val name = model?.takeIf { it.isNotBlank() } ?: return DEFAULT_MODEL
|
|
return name.removePrefix("claude-").replace(DATED_SUFFIX, "")
|
|
}
|
|
|
|
/** A trailing `-YYYYMMDD`, which is how these identifiers carry their release date. */
|
|
private val DATED_SUFFIX = Regex("""-\d{8}$""")
|