mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2026-08-10 08:27:04 +00:00
feat(nip46): show a connected app's relays on its detail screen
The list row's "N relays" count wasn't inspectable, so a user debugging why the signer holds a background relay connection couldn't see which relays an app uses. Add a Relays section to the (already tap-through) detail screen listing each relay URL, with a note that Amethyst keeps a background connection to each while the app stays connected. Apps that brought no relays of their own (the bunker flow) show that they ride the account's inbox relays and add no extra connection. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015FHr2mu5SiHwYNR7evYUuF
This commit is contained in:
+55
@@ -189,6 +189,12 @@ fun ConnectedAppDetailScreen(
|
||||
AppIdentityHeader(current)
|
||||
}
|
||||
|
||||
// Relays this remote client is reached on — the whole reason it costs a background
|
||||
// connection, so surface them for debugging relay footprint.
|
||||
if (nip46Client != null) {
|
||||
Nip46RelaysSection(nip46Info?.relays.orEmpty())
|
||||
}
|
||||
|
||||
// Signing trust level section
|
||||
if (current.signerPolicy != null) {
|
||||
SectionHeader(stringResource(R.string.napplet_connected_app_trust_level))
|
||||
@@ -284,6 +290,55 @@ fun ConnectedAppDetailScreen(
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Lists the relays a NIP-46 remote client is reached on. When the client brought its own relays
|
||||
* (the `nostrconnect://` flow) each one is a background connection Amethyst keeps open while the app
|
||||
* stays connected — exactly what a user debugging relay footprint wants to see. An empty set means
|
||||
* the client talks over the account's inbox relays (the bunker flow), so it adds no extra connection.
|
||||
*/
|
||||
@Composable
|
||||
private fun Nip46RelaysSection(relays: Set<String>) {
|
||||
SectionHeader(stringResource(R.string.nip46_signer_app_relays_title))
|
||||
Surface(
|
||||
color = MaterialTheme.colorScheme.surfaceVariant,
|
||||
shape = MaterialTheme.shapes.medium,
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
) {
|
||||
Column(modifier = Modifier.padding(vertical = 12.dp, horizontal = 16.dp), verticalArrangement = Arrangement.spacedBy(8.dp)) {
|
||||
if (relays.isEmpty()) {
|
||||
Text(
|
||||
stringResource(R.string.nip46_signer_app_relays_inbox),
|
||||
style = MaterialTheme.typography.bodySmall,
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||
)
|
||||
} else {
|
||||
relays.forEach { relay ->
|
||||
Row(verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(10.dp)) {
|
||||
Icon(
|
||||
MaterialSymbols.Dns,
|
||||
contentDescription = null,
|
||||
tint = MaterialTheme.colorScheme.primary,
|
||||
modifier = Modifier.size(18.dp),
|
||||
)
|
||||
Text(
|
||||
relay,
|
||||
style = MaterialTheme.typography.bodyMedium,
|
||||
fontFamily = FontFamily.Monospace,
|
||||
maxLines = 1,
|
||||
overflow = TextOverflow.Ellipsis,
|
||||
)
|
||||
}
|
||||
}
|
||||
Text(
|
||||
stringResource(R.string.nip46_signer_app_relays_own_hint),
|
||||
style = MaterialTheme.typography.labelSmall,
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun Nip46AppHeader(
|
||||
title: String,
|
||||
|
||||
@@ -930,6 +930,9 @@
|
||||
<string name="nip46_signer_manage_apps">Manage connected apps</string>
|
||||
<string name="nip46_signer_apps_empty">No apps are connected to your signer yet.\n\nScan or paste an app\'s code to connect it. Connected apps appear here, and idle ones are removed automatically after a week.</string>
|
||||
<string name="nip46_signer_app_last_used">used %1$s</string>
|
||||
<string name="nip46_signer_app_relays_title">Relays</string>
|
||||
<string name="nip46_signer_app_relays_inbox">Signs over your inbox relays — this app brought none of its own, so it keeps no extra background connection.</string>
|
||||
<string name="nip46_signer_app_relays_own_hint">Amethyst holds a background connection to each of these while this app stays connected. Forget the app to drop them.</string>
|
||||
<plurals name="nip46_signer_app_relay_count">
|
||||
<item quantity="one">%1$d relay</item>
|
||||
<item quantity="other">%1$d relays</item>
|
||||
|
||||
Reference in New Issue
Block a user