android: show the chain daemon's sync height on the wallet status line
All checks were successful
android-ci / android (pull_request) Successful in 12m45s

The SDK surface from the rust-dev parent (#129) carries `WalletChildStatus.height`
and `target_height` (Rust `u64` → generated Kotlin `ULong`), so the wallet status
line can say how far the chain daemon has got instead of only naming it.

* `WalletChildInput` mirrors both fields as `ULong` — checked against the
  generated `uniffi.onionwire_sdk.WalletChildStatus`, not assumed. Defaults stay
  `0uL` so every existing fixture is unchanged.
* `walletChildLine` appends ` · sync h/t` after the source and the `node` segment,
  before the error em-dash, and only when either value is non-zero: `0/0` is
  unknown (probe failed, daemon not up), not `0%`, and a zero target still prints
  as `/0`. No percent, no progress bar, no ETA.
* `WalletScreen.toInput()` copies both fields field-for-field; the status row's
  screen-reader sentence moved into `walletChildStatusDescription`, which carries
  the same `sync h/t` the eye reads. One line, still no second widget.
* Tests cover the three sync cases plus the spoken row; the old exact-line
  assertions (`off · receive-only`, `connecting · local node`,
  `ready · remote onion daemon`) are untouched. `:app:testDebugUnitTest`: 114
  tests, 0 failures.
* `android/CUPRATE_DAEMON.md` no longer claims the record has no height field.
This commit is contained in:
agent 2026-09-19 19:50:04 -04:00
commit e697045515
No known key found for this signature in database
4 changed files with 134 additions and 5 deletions

View file

@ -45,6 +45,20 @@ data class WalletChildInput(
* empty for an in-process source that has not been read yet.
*/
val nodeState: String = "",
/**
* Blocks the chain daemon had at the last probe — the core's `height`, from
* the wallet RPC or, when that RPC is refused, from the in-process daemon
* over loopback. `0` means unknown: never probed, the child is off/exited, or
* the probe failed. It is **not** caught up, and it is never a wallet-scan
* height.
*
* `ULong` because that is what UniFFI generates for the Rust `u64` (checked
* against `uniffi.onionwire_sdk.WalletChildStatus`, not assumed) — this model
* mirrors that record field for field.
*/
val height: ULong = 0uL,
/** Blocks the daemon was syncing towards — the core's `target_height`. `0` means none reported (also not caught up). */
val targetHeight: ULong = 0uL,
val lastError: String? = null,
)
@ -274,6 +288,8 @@ fun walletChildLine(input: WalletChildInput?): String {
val phase = walletChildPhase(input)
val source = input?.chainSource?.takeIf { it.isNotBlank() } ?: "no chain source"
val node = nodePhase(input)
val height = input?.height ?: 0uL
val target = input?.targetHeight ?: 0uL
val why = input?.lastError?.takeIf { it.isNotBlank() }
return buildString {
append(phase.label)
@ -285,6 +301,16 @@ fun walletChildLine(input: WalletChildInput?): String {
append(" · node ")
append(node.label)
}
// The daemon's own height, when it reported one: `sync h/t`, the segment
// the core's own line uses. No percent, no progress bar, no ETA — `0/0`
// is unknown (the probe failed, or the daemon is not up), not "0%", and
// when both are zero the segment is absent rather than printed as `0/0`.
if (height > 0uL || target > 0uL) {
append(" · sync ")
append(height.toString())
append('/')
append(target.toString())
}
when {
why != null -> append(" — ").append(shortSendReason(why))
phase is WalletChildPhase.Exited -> append(" — the child process is gone")
@ -292,6 +318,15 @@ fun walletChildLine(input: WalletChildInput?): String {
}
}
/**
* The whole status row as one screen-reader sentence: the phase's own sentence,
* then the same line the eye reads — including the daemon's `sync h/t` when the
* core reported one. A screen reader is never told less than the sighted user,
* and it is a sentence either way.
*/
fun walletChildStatusDescription(input: WalletChildInput?): String =
"${walletChildPhase(input).contentDescription}. ${walletChildLine(input)}"
/**
* A `.onion` daemon is only reachable through the `arti` SOCKS child, and this
* build does not ship one — say that before the user presses Start rather than

View file

@ -681,7 +681,7 @@ private fun WalletChildCard(
.fillMaxWidth()
.testTag(phase.testTag)
.semantics(mergeDescendants = true) {
contentDescription = "${phase.contentDescription}. ${walletChildLine(input)}"
contentDescription = walletChildStatusDescription(input)
},
)
@ -886,6 +886,8 @@ internal fun WalletChildStatus.toInput(): WalletChildInput = WalletChildInput(
chainInProcess = chainInProcess,
nodeAvailable = nodeAvailable,
nodeState = nodeState,
height = height,
targetHeight = targetHeight,
lastError = lastError,
)