Thin the app's comments
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>
This commit is contained in:
1 parent
79682f03a7
commit
edc39c7371
68 files changed
+2077
-2997
No files matched your search
@@ -27,17 +27,14 @@ import java.time.OffsetDateTime
|
||||
* A dialog rather than a screen. Usage is something you check *against* what you were reading --
|
||||
* "can I start this" is asked with the transcript still on screen -- and pushing a whole screen for
|
||||
* it took the session away to answer a question about the session. It also has no navigation of its
|
||||
* own: there is nothing here to open, so the only thing its Back could ever have meant was "put
|
||||
* this away", which is what dismissing does. The system back gesture dismisses it, since a `Dialog`
|
||||
* handles that itself.
|
||||
* own, so the only thing its Back could ever have meant was "put this away".
|
||||
*/
|
||||
@Composable
|
||||
fun UsageDialog(feed: UsageFeed, onDismiss: () -> Unit) {
|
||||
// A plain Dialog rather than an AlertDialog, for the spacing alone. AlertDialog fixes the
|
||||
// gaps between its title, its content and its buttons at sizes meant for a sentence of prose
|
||||
// and a decision; this is a dense read-out, and those gaps left a band of empty dialog above
|
||||
// Close that was taller than a bar. Everything else here is what AlertDialog would have
|
||||
// drawn -- the same container colour, the same corner -- so nothing about it looks foreign.
|
||||
// A plain Dialog rather than an AlertDialog, for the spacing alone. AlertDialog fixes the gaps
|
||||
// between its title, content and buttons at sizes meant for a sentence of prose and a decision;
|
||||
// this is a dense read-out, and those gaps left a band of empty dialog above Close that was
|
||||
// taller than a bar.
|
||||
Dialog(onDismissRequest = onDismiss) {
|
||||
Surface(
|
||||
shape = MaterialTheme.shapes.extraLarge,
|
||||
@@ -49,11 +46,9 @@ fun UsageDialog(feed: UsageFeed, onDismiss: () -> Unit) {
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
) {
|
||||
// Deliberately not subtitled with the provider this was opened from. These
|
||||
// numbers belong to an account on a particular machine, reported by whichever
|
||||
// paid service answered there -- naming the session's provider here made an
|
||||
// echo session's screen read "echo" above a line reading "claude", which is a
|
||||
// claim about echo that nothing measured. Each machine names itself and the
|
||||
// service it came from, which is the true scope.
|
||||
// numbers belong to an account on a particular machine -- naming the session's
|
||||
// provider here made an echo session's screen read "echo" above a line reading
|
||||
// "claude". Each machine names itself and the service it came from.
|
||||
Text(
|
||||
"Usage",
|
||||
style = MaterialTheme.typography.headlineSmall,
|
||||
@@ -69,10 +64,9 @@ fun UsageDialog(feed: UsageFeed, onDismiss: () -> Unit) {
|
||||
}
|
||||
}
|
||||
Spacer(Modifier.height(8.dp))
|
||||
// Scrolls rather than being trimmed: a machine can report any number of windows
|
||||
// and there can be any number of machines, and a dialog is the one place where
|
||||
// running out of room is silent. `fill = false` so a short read-out keeps a short
|
||||
// dialog instead of stretching to the window.
|
||||
// Scrolls rather than being trimmed: a machine can report any number of windows and
|
||||
// there can be any number of machines, and a dialog is the one place where running
|
||||
// out of room is silent. `fill = false` so a short read-out keeps a short dialog.
|
||||
Column(Modifier.weight(1f, fill = false).verticalScroll(rememberScrollState())) {
|
||||
UsageBody(feed.snapshots)
|
||||
}
|
||||
@@ -93,8 +87,8 @@ private fun UsageBody(state: LoadState<List<UsageSnapshot>>) {
|
||||
is LoadState.Error -> Text(current.message, color = MaterialTheme.colorScheme.error)
|
||||
is LoadState.Loaded ->
|
||||
if (current.value.isEmpty()) {
|
||||
// Not an error and not a blank screen: no machine offers a paid service,
|
||||
// so there is genuinely nothing to report and saying so is the answer.
|
||||
// Not an error and not a blank screen: no machine offers a paid service, so
|
||||
// there is genuinely nothing to report and saying so is the answer.
|
||||
Text(
|
||||
"No machine here runs anything with usage limits.",
|
||||
style = MaterialTheme.typography.bodyMedium,
|
||||
@@ -103,17 +97,16 @@ private fun UsageBody(state: LoadState<List<UsageSnapshot>>) {
|
||||
} else {
|
||||
// No card around each machine. A card is a step up the surface ladder, and
|
||||
// inside a dialog -- itself a raised surface -- the step barely renders while
|
||||
// costing 16dp of padding on every side. What separates one machine from the
|
||||
// next is the line naming it, which is enough for a list this short.
|
||||
// costing 16dp on every side. What separates one machine from the next is the
|
||||
// line naming it.
|
||||
current.value.forEachIndexed { index, snapshot ->
|
||||
if (index > 0) {
|
||||
Spacer(Modifier.height(20.dp))
|
||||
}
|
||||
// Machine and service on one line: which account these numbers belong to
|
||||
// is decided by both together, and stacked as a heading over a subtitle
|
||||
// they read as a section of their own rather than as the label they are.
|
||||
// Small and quiet, because the numbers below are what somebody opened
|
||||
// this to see.
|
||||
// Machine and service on one line: which account these numbers belong to is
|
||||
// decided by both together, and stacked as a heading over a subtitle they
|
||||
// read as a section of their own. Small and quiet, because the numbers
|
||||
// below are what somebody opened this to see.
|
||||
Text(
|
||||
"${snapshot.setupName.ifEmpty { snapshot.setup }} · ${snapshot.provider}",
|
||||
style = MaterialTheme.typography.bodySmall,
|
||||
@@ -121,8 +114,8 @@ private fun UsageBody(state: LoadState<List<UsageSnapshot>>) {
|
||||
)
|
||||
SnapshotState(snapshot)
|
||||
snapshot.windows.forEachIndexed { windowIndex, window ->
|
||||
// Between the bars, not after the last one: a trailing gap here is
|
||||
// what put a band of empty dialog above the Close button.
|
||||
// Between the bars, not after the last one: a trailing gap here is what
|
||||
// put a band of empty dialog above the Close button.
|
||||
if (windowIndex > 0) {
|
||||
Spacer(Modifier.height(12.dp))
|
||||
}
|
||||
@@ -139,8 +132,7 @@ private fun UsageBody(state: LoadState<List<UsageSnapshot>>) {
|
||||
*
|
||||
* The distinction the old single message could not draw. A machine nobody has logged in on is
|
||||
* working exactly as somebody set it up, so it reads as a plain statement -- marking it would be
|
||||
* the interface nagging about a decision already made, and would dilute the marks that do mean
|
||||
* something. Only the two faults are coloured as faults.
|
||||
* the interface nagging about a decision already made. Only the two faults are coloured as faults.
|
||||
*/
|
||||
@Composable
|
||||
private fun SnapshotState(snapshot: UsageSnapshot) {
|
||||
@@ -152,8 +144,8 @@ private fun SnapshotState(snapshot: UsageSnapshot) {
|
||||
style = MaterialTheme.typography.bodyMedium,
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||
)
|
||||
// Reached but refused, versus never reached at all: different things to go and do,
|
||||
// so they say different things rather than sharing one "unavailable".
|
||||
// Reached but refused, versus never reached at all: different things to go and do, so they
|
||||
// say different things rather than sharing one "unavailable".
|
||||
"failed" ->
|
||||
Text(
|
||||
snapshot.detail ?: "Couldn't read the limits from this machine.",
|
||||
@@ -200,10 +192,9 @@ private fun WindowBar(window: UsageWindow) {
|
||||
/**
|
||||
* "resets in 3h 12m" -- close enough for deciding whether to start a big task -- or nothing.
|
||||
*
|
||||
* Null for a window that is not running, which is the case this row has always drawn as nothing and
|
||||
* is right to: there is no end to report. What it used to get wrong is the other missing case, a
|
||||
* timestamp that arrived and could not be read: that was printed raw, so a parse failure appeared
|
||||
* as an ISO string in the middle of a sentence written for a person. Both cases are named in
|
||||
* Null for a window that is not running: there is no end to report. What this used to get wrong is
|
||||
* the other missing case, a timestamp that arrived and could not be read -- printed raw, so a parse
|
||||
* failure appeared as an ISO string in a sentence written for a person. Both are named in
|
||||
* [WindowEnd], and the session bar words them the same way.
|
||||
*/
|
||||
private fun resetLine(window: UsageWindow): String? =
|
||||
|
||||
Reference in new issue
Block a user