diff --git a/composeApp/src/commonMain/composeResources/values/strings.xml b/composeApp/src/commonMain/composeResources/values/strings.xml
index fa7d0073..7232b68b 100644
--- a/composeApp/src/commonMain/composeResources/values/strings.xml
+++ b/composeApp/src/commonMain/composeResources/values/strings.xml
@@ -196,6 +196,11 @@
Propose translation
Publish new key package
Re-broadcast
+ Asked the members who have not answered to take another look
+ Everyone has answered. There is nobody left to ask.
+ One member has not answered. They may never have received it.
+ %1$s members have not answered. They may never have received it.
+ Asked again just now. You can ask again in a few minutes.
Read to the end of the list to sign.
Recovery phrase
Ready to sign
diff --git a/composeApp/src/commonMain/kotlin/to/curare/compose/ui/composable/FrostSigningScreen.kt b/composeApp/src/commonMain/kotlin/to/curare/compose/ui/composable/FrostSigningScreen.kt
index 0bf81af2..f1254e56 100644
--- a/composeApp/src/commonMain/kotlin/to/curare/compose/ui/composable/FrostSigningScreen.kt
+++ b/composeApp/src/commonMain/kotlin/to/curare/compose/ui/composable/FrostSigningScreen.kt
@@ -13,6 +13,7 @@ import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.verticalScroll
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Block
+import androidx.compose.material.icons.filled.Campaign
import androidx.compose.material.icons.filled.CheckCircle
import androidx.compose.material.icons.filled.Draw
import androidx.compose.material.icons.filled.ErrorOutline
@@ -34,6 +35,7 @@ import androidx.compose.material3.TextButton
import androidx.compose.material3.TopAppBar
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
+import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.text.style.TextAlign
@@ -58,7 +60,13 @@ import to.curare.compose.ui.theme.spacing
import to.curare.compose.ui.composable.widgets.Decorative
import curare.composeapp.generated.resources.Res
import org.jetbrains.compose.resources.stringResource
+import curare.composeapp.generated.resources.ask_again
+import curare.composeapp.generated.resources.asked_again
+import curare.composeapp.generated.resources.asked_again_recently
import curare.composeapp.generated.resources.declined_to_sign
+import curare.composeapp.generated.resources.everyone_has_answered_this_session
+import curare.composeapp.generated.resources.members_have_not_answered
+import curare.composeapp.generated.resources.one_member_has_not_answered
import curare.composeapp.generated.resources.don_t_sign
import curare.composeapp.generated.resources.has_not_taken_part_yet
import curare.composeapp.generated.resources.members
@@ -70,6 +78,7 @@ import curare.composeapp.generated.resources.signed_their_part
import curare.composeapp.generated.resources.events_signed_together
import androidx.compose.material3.SnackbarHost
import to.curare.compose.ui.composable.widgets.LocalSnackbarHostState
+import to.curare.compose.ui.composable.widgets.rememberNotifier
import to.curare.compose.ui.composable.widgets.NavigateBackButton
import to.curare.compose.ui.theme.readableContent
import to.curare.compose.ui.theme.ConformancePreviews
@@ -115,6 +124,13 @@ fun FrostSigningScreen(
}
}
+ // Both of these are composable and an onClick lambda is not, so they are
+ // read here rather than in the handler. The notifier takes the caller's
+ // scope on purpose -- see rememberNotifier.
+ val notify = rememberNotifier(rememberCoroutineScope())
+ val askedAgain = stringResource(Res.string.asked_again)
+ val everyoneAnswered = stringResource(Res.string.everyone_has_answered_this_session)
+
Scaffold(
snackbarHost = { SnackbarHost(LocalSnackbarHostState.current) },
topBar = {
@@ -261,6 +277,57 @@ fun FrostSigningScreen(
}
}
+ // The coordinator's knock, under the list of doors it is for.
+ //
+ // A session can wait forever on a member whose copy of the
+ // proposal never arrived -- MLS dropped the generation it came
+ // in at, or a disappearing-message group expired it off the
+ // relay -- and neither heals on its own. Repeating the proposal
+ // is the only thing that reaches them, and it also names them,
+ // so that a member whose own answer went missing on the way
+ // here says it again.
+ if (state.canResend) {
+ HorizontalDivider()
+
+ Text(
+ text = if (state.silent.size == 1) {
+ stringResource(Res.string.one_member_has_not_answered)
+ } else {
+ stringResource(
+ Res.string.members_have_not_answered,
+ state.silent.size
+ )
+ },
+ style = MaterialTheme.typography.bodySmall
+ )
+
+ // Disabled rather than hidden while the cooldown runs. A
+ // control that vanishes after a tap reads as one that
+ // failed, and what happened is that it worked.
+ val waiting = state.resendAvailableAt != null
+
+ if (waiting) {
+ Text(
+ text = stringResource(Res.string.asked_again_recently),
+ style = MaterialTheme.typography.bodySmall,
+ color = MaterialTheme.colorScheme.onSurfaceVariant
+ )
+ }
+
+ Button(
+ enabled = !waiting && !frostSigningViewModel.isActionPending.value,
+ onClick = {
+ frostSigningViewModel.resend { sent ->
+ notify(if (sent) askedAgain else everyoneAnswered)
+ }
+ }
+ ) {
+ Icon(Icons.Default.Campaign, contentDescription = Decorative)
+ Spacer(modifier = Modifier.width(MaterialTheme.spacing.space125))
+ Text(stringResource(Res.string.ask_again))
+ }
+ }
+
// Asked rather than re-derived: the manager owns when a session
// is still waiting on its owner, and a second copy of that rule
// here is a second copy to keep in step.
diff --git a/composeApp/src/commonMain/kotlin/to/curare/compose/ui/composable/widgets/chat/ChatTranscript.kt b/composeApp/src/commonMain/kotlin/to/curare/compose/ui/composable/widgets/chat/ChatTranscript.kt
index c3da195e..d7631fc2 100644
--- a/composeApp/src/commonMain/kotlin/to/curare/compose/ui/composable/widgets/chat/ChatTranscript.kt
+++ b/composeApp/src/commonMain/kotlin/to/curare/compose/ui/composable/widgets/chat/ChatTranscript.kt
@@ -33,6 +33,7 @@ import androidx.compose.material.icons.filled.CheckCircle
import androidx.compose.material.icons.filled.ChevronRight
import androidx.compose.material.icons.filled.ErrorOutline
import androidx.compose.material.icons.filled.CallMerge
+import androidx.compose.material.icons.filled.Campaign
import androidx.compose.material.icons.filled.FactCheck
import androidx.compose.material.icons.filled.Draw
import androidx.compose.material.icons.filled.Download
@@ -825,6 +826,10 @@ private fun RitualNotice(
// A refusal the session survived. Quiet on purpose: it is not an error,
// and the one that ends a session is written as a failure instead.
ChatMessage.TYPE_FROST_DECLINED -> Icons.Default.Block
+ // Nothing moved; somebody knocked. Its own icon rather than the
+ // proposal's, so that a resend does not read as a second proposal --
+ // which is the one thing a session must never have.
+ ChatMessage.TYPE_FROST_RESENT -> Icons.Default.Campaign
ChatMessage.TYPE_FROST_APPROVAL_NEEDED -> Icons.Default.Draw
ChatMessage.TYPE_CHRONICLE_REQUESTED -> Icons.Default.History
diff --git a/composeApp/src/commonMain/kotlin/to/curare/compose/ui/view/model/FrostSigningViewModel.kt b/composeApp/src/commonMain/kotlin/to/curare/compose/ui/view/model/FrostSigningViewModel.kt
index 1f730feb..08c0a212 100644
--- a/composeApp/src/commonMain/kotlin/to/curare/compose/ui/view/model/FrostSigningViewModel.kt
+++ b/composeApp/src/commonMain/kotlin/to/curare/compose/ui/view/model/FrostSigningViewModel.kt
@@ -133,6 +133,35 @@ class FrostSigningViewModel(
}
}
+ /**
+ * Asks the members this session has heard nothing from to take another look.
+ *
+ * Unlike [approve] and [decline] this does not navigate away: the point of
+ * pressing it is to go on watching whether anybody answers, and the screen
+ * is the only place that says who has. [onResult] is handed whether anything
+ * actually went out, so the caller can say which happened -- a resend inside
+ * the cooldown, or one where everybody has since answered, publishes nothing
+ * and should not claim to have.
+ */
+ fun resend(onResult: (sent: Boolean) -> Unit) {
+ val state = frostSigningUIState as? FrostSigningUIState.Loaded ?: return
+ val sessionId = state.session?.id ?: return
+
+ if (isActionPending.value) return
+ isActionPending.value = true
+
+ viewModelScope.launch(Dispatchers.IO) {
+ val sent = frostSigningRepository.resend(
+ localChatRoom = state.localChatRoom,
+ sessionId = sessionId
+ )
+
+ isActionPending.value = false
+
+ viewModelScope.launch(Dispatchers.Main) { onResult.invoke(sent) }
+ }
+ }
+
fun decline(onDone: () -> Unit) {
val state = frostSigningUIState as? FrostSigningUIState.Loaded ?: return
val sessionId = state.session?.id ?: return
diff --git a/composeApp/src/commonMain/kotlin/to/curare/compose/ui/view/state/FrostSigningUIState.kt b/composeApp/src/commonMain/kotlin/to/curare/compose/ui/view/state/FrostSigningUIState.kt
index cbcedb3b..55e267a3 100644
--- a/composeApp/src/commonMain/kotlin/to/curare/compose/ui/view/state/FrostSigningUIState.kt
+++ b/composeApp/src/commonMain/kotlin/to/curare/compose/ui/view/state/FrostSigningUIState.kt
@@ -1,11 +1,15 @@
package to.curare.compose.ui.view.state
import com.vitorpamplona.quartz.nip01Core.core.HexKey
+import kotlin.time.Clock
+import kotlin.time.Instant
import to.curare.compose.database.model.FrostSigningItem
import to.curare.compose.database.model.FrostSigningSession
import to.curare.compose.database.model.Participant
import to.curare.compose.database.model.intermdiate.LocalChatRoom
import to.curare.compose.database.model.intermdiate.LocalParticipant
+import to.curare.compose.database.model.types.FrostSigningStage
+import to.curare.compose.managers.FrostSigningManager
sealed interface FrostSigningUIState {
data class Loaded(
@@ -76,6 +80,52 @@ sealed interface FrostSigningUIState {
return inRoom + elsewhere
}
+
+ /**
+ * The share holders this session has heard nothing at all from.
+ *
+ * Whose door to knock on, as a set rather than as a list of rows: it is
+ * what decides whether there is anything to knock about. A member who
+ * refused is not here -- they answered, and asking again would be asking
+ * a question they have closed.
+ *
+ * Derived rather than collected. Everything it is made of is already on
+ * this state, and a second flow for it would be a second thing that can
+ * disagree with the rows the screen draws.
+ */
+ val silent: Set get() =
+ shareHolders - offeredNonce - signed - declined - localChatRoom.chatRoom.userPublicKey
+
+ /**
+ * Whether this device may ask the quiet members to take another look.
+ *
+ * The coordinator's, and nobody else's: `acceptProposal` takes a
+ * session's coordinator from the author of the proposal that opened it,
+ * so a resend from anybody else would have a member who was missing the
+ * session believe the resender coordinates -- and then drop the real
+ * coordinator's signer set. See `FrostSigningManager.resend`.
+ *
+ * An abandoned session is not resent either. Its nonce seeds have been
+ * published against an aggregate already, so the retry is a fresh
+ * proposal, which is what the status line says.
+ *
+ * The cooldown is deliberately not read here. A control that vanishes
+ * after a tap reads as one that failed, so the section stays and the
+ * button inside it is what goes quiet -- see [resendAvailableAt].
+ */
+ val canResend: Boolean get() {
+ val session = session ?: return false
+
+ return session.isCoordinator() &&
+ session.stage != FrostSigningStage.FAILED &&
+ items.isNotEmpty() &&
+ silent.isNotEmpty()
+ }
+
+ /** When the next resend may go out, or null when one may go out now. */
+ val resendAvailableAt: Instant? get() = session?.resentAt
+ ?.plus(FrostSigningManager.RESEND_COOLDOWN)
+ ?.takeIf { it > Clock.System.now() }
}
data class Error(