fix(android): tapping a Cuprate mode starts the node
All checks were successful
android-ci / android (pull_request) Successful in 12m50s

Selecting mainnet pruned only persisted ChainConfig, so the screen
updated the storage line and nothing else. Store, then Start when the
storage floor allows. Filled button is the stored choice.
This commit is contained in:
agent 2026-09-19 14:33:20 -04:00
commit 3868452a4a
No known key found for this signature in database
3 changed files with 106 additions and 18 deletions

View file

@ -394,6 +394,30 @@ fun chainStorageBlockedReason(
}
}
enum class CuprateMode {
MainnetPruned,
MainnetFull,
Testnet,
}
fun selectedCuprateMode(inProcess: Boolean, mainnet: Boolean, prune: Boolean): CuprateMode? =
when {
!inProcess -> null
!mainnet -> CuprateMode.Testnet
prune -> CuprateMode.MainnetPruned
else -> CuprateMode.MainnetFull
}
/**
* Tapping a mode used to only persist `ChainConfig`, which looked like a no-op
* besides the storage line. Start when the storage floor would allow Start and
* a launch is not already in flight.
*/
fun shouldStartAfterSelectingChain(
storageBlocked: String?,
starting: Boolean,
): Boolean = storageBlocked == null && !starting
/**
* Bytes as a screen-sized string. Binary units (a "GB" that is really a GiB is how
* a store that needs 3 GiB ends up on a device with 2.8).

View file

@ -258,6 +258,23 @@ fun WalletScreen(
scope.launch {
vm.setInProcessCuprate(bins, mainnet, prune)
.onFailure { daemonError = it.message ?: it.toString() }
.onSuccess {
// The mode buttons used to only persist the choice,
// which read as a no-op besides the storage line.
// Start is still the core launch; tapping a mode
// fires it when the storage gate would allow Start.
if (shouldStartAfterSelectingChain(
chainStorageBlockedReason(
vm.chainFreeBytes(),
mainnet = mainnet,
prune = prune,
),
starting = starting,
)
) {
vm.startWalletChild()
}
}
}
},
starting = starting,
@ -734,30 +751,34 @@ private fun WalletChildCard(
) { Text("Receive-only") }
}
// The third chain source. Never a default: selecting it is what stores
// `ChainChoice.InProcessCuprate`, and the warning below is what the user
// reads before Start.
// Tapping a mode stores it and, when the storage floor allows,
// starts the node. Filled = the stored choice.
Spacer(Modifier.height(8.dp))
OutlinedButton(
val mode = selectedCuprateMode(
inProcess = inProcess,
mainnet = chain?.mainnet == true,
prune = chain?.prune == true,
)
CuprateModeButton(
label = "Mainnet pruned",
selected = mode == CuprateMode.MainnetPruned,
testTag = "wallet-chain-mainnet-pruned",
onClick = { onInProcessNode(true, true) },
modifier = Modifier
.fillMaxWidth()
.testTag("wallet-chain-mainnet-pruned"),
) { Text("Mainnet pruned") }
)
Spacer(Modifier.height(4.dp))
OutlinedButton(
CuprateModeButton(
label = "Mainnet full",
selected = mode == CuprateMode.MainnetFull,
testTag = "wallet-chain-mainnet-full",
onClick = { onInProcessNode(true, false) },
modifier = Modifier
.fillMaxWidth()
.testTag("wallet-chain-mainnet-full"),
) { Text("Mainnet full") }
)
Spacer(Modifier.height(4.dp))
OutlinedButton(
CuprateModeButton(
label = "Testnet (experimental)",
selected = mode == CuprateMode.Testnet,
testTag = "wallet-chain-in-process",
onClick = { onInProcessNode(false, false) },
modifier = Modifier
.fillMaxWidth()
.testTag("wallet-chain-in-process"),
) { Text("Testnet (experimental)") }
)
if (inProcess) {
Spacer(Modifier.height(8.dp))
@ -836,6 +857,23 @@ private fun WalletChildCard(
}
}
@Composable
private fun CuprateModeButton(
label: String,
selected: Boolean,
testTag: String,
onClick: () -> Unit,
) {
val modifier = Modifier
.fillMaxWidth()
.testTag(testTag)
if (selected) {
Button(onClick = onClick, modifier = modifier) { Text(label) }
} else {
OutlinedButton(onClick = onClick, modifier = modifier) { Text(label) }
}
}
/**
* The SDK record as the pure model `WalletChildStatusText.kt` renders. Field for
* field, nothing inferred.