feat(android): chat row renders queued (try 3/8, retry 45s) from the SDK's outbox rows
Consumes the SDK surface from PR #58 (`Wire.outbox(pubkeyHex)` → `OutboxRow { messageId, status, attempts, nextAttemptAt, lastError }` and `outboxMaxAttempts()`): a queued chat row now says *why* it is still queued instead of a flat `queued`. * `OutboxDetail.kt` — `retryInText` mirrors `src/tui.rs::retry_in_text` (`<= 0` → `retry now`; `< 60` → `retry {n}s`; else `retry {ceil-minutes}m`), and `outboxDetails` joins the SDK's rows onto the chat rows. The denominator is the core's `outboxMaxAttempts()`/`Rust` budget, fetched once — never 8. * A terminal `"failed"` row keeps the marker's own `failed: <reason>` and gets **no** countdown: `nextAttemptAt` on a failed row is the last time it was scheduled for, so a countdown there would promise an attempt that never comes. `"sending"` stays bare, matching the TUI. * `ChatScreen` polls the outbox rows on the same 2s cadence as the bodies and renders the countdown against an injectable `nowSeconds` (the store holds an absolute instant, the app computes the age). * The join is positional — `ChatMessage` carries no `messages.id` — and fail-closed: mismatched row counts, an unknown status, or a status that contradicts the one the SDK resolved for that message drops every detail and leaves the flat markers. `ChatMessage.id` would remove the positional part; filed as follow-up. * `OutboxDetailTest` (17 tests) asserts the three `retry_in_text` buckets, the `queued (try 3/8, retry 45s)` wording, that a failed row shows no countdown, that the denominator comes from the caller, and the three fail-closed cases. 32 unit tests, 0 failures. Android base: PR #56 (`feat/android-outbox-state`, t_f46a9863) — the Android half of the #52/#56 duplicate pair, which is not merged here. SDK base: PR #58 on PR #51.
This commit is contained in:
parent
7b68cb4a9f
commit
fc2b2197c7
5 changed files with 494 additions and 10 deletions
|
|
@ -20,6 +20,7 @@ import kotlinx.coroutines.withContext
|
|||
import uniffi.onionwire_sdk.ChatMessage
|
||||
import uniffi.onionwire_sdk.FriendInfo
|
||||
import uniffi.onionwire_sdk.InviteInfo
|
||||
import uniffi.onionwire_sdk.OutboxRow
|
||||
import uniffi.onionwire_sdk.RotateOutcome
|
||||
import uniffi.onionwire_sdk.SendState
|
||||
import uniffi.onionwire_sdk.Wire
|
||||
|
|
@ -362,6 +363,23 @@ class WireViewModel(app: Application) : AndroidViewModel(app) {
|
|||
suspend fun messages(pubkeyHex: String): List<ChatMessage> =
|
||||
requireWire().messages(pubkeyHex)
|
||||
|
||||
/**
|
||||
* The core's outbox rows for one friend: the `"queued"` / `"sending"` /
|
||||
* `"failed"` rows behind [ChatMessage.delivery], each with the attempt count
|
||||
* and absolute next-attempt time the store holds. Empty means nothing is
|
||||
* outstanding for them. Read this instead of guessing a retry schedule in
|
||||
* the app.
|
||||
*/
|
||||
suspend fun outbox(pubkeyHex: String): List<OutboxRow> =
|
||||
requireWire().outbox(pubkeyHex)
|
||||
|
||||
/**
|
||||
* The core's retry budget — the denominator in `try n/8`. A constant of the
|
||||
* outbox, not per-node state, so it is fetched from the SDK rather than
|
||||
* duplicated here; the app must not hardcode it.
|
||||
*/
|
||||
suspend fun outboxMaxAttempts(): UInt = uniffi.onionwire_sdk.outboxMaxAttempts()
|
||||
|
||||
/**
|
||||
* Sends one chat message and reports what the core did with it.
|
||||
*
|
||||
|
|
|
|||
Loading…
Reference in a new issue