fix(android): surface the outbox send state instead of denying it #52
Loading…
Reference in a new issue
No description provided.
Delete branch "wt/t_7233051b"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Why
crates/onionwire-sdkhas returnedSendStateand a per-rowChatMessage.deliverysince the local outbox landed (PR #45 / the SDK fix in #51), butandroid/appstill rendered "Sends fail closed: if their onion is down the message is not spooled anywhere. There is no outbox in v1." and threw the returned state away — so a queued send looked exactly like a delivered one.What changed (android/app only)
WireViewModel.send()now returnsSendState(uniffi.onionwire_sdk.SendState, generated,SENT/QUEUED).ChatScreenno longer discards it. AQUEUEDsend raises a hint — "Queued: their onion is unreachable. The message is local-only in this device's outbox until the retry worker gets a circuit through." — that clears after 6s; the durable signal is the row marker and the footer.Outgoing rows render
ChatMessage.deliverywith the TUI's vocabulary (docs/TUI.md→ "Delivery state (outbox)"):deliverysent✓queued◷ queuedsending» sendingfailed: <reason>✗ failed: <reason>(reason elided past 48 chars)Incoming rows are unmarked (the SDK returns
null). An outgoing row whose outbox entry is gone readssent— that is the SDK's rule, not a guess here. A state this build cannot read renders no marker rather than a tick: a missing marker never claims delivery, a wrong tick does.Footer keeps the TUI's
{n} queuedwhile the outbox still owns rows (queued+sending).The empty-chat copy now describes the outbox: fail closed to a third party, but the message is queued local-only in this device's outbox, 8 attempts, backoff capped at 30 min.
New pure
ui/Delivery.ktholds the mapping, so the vocabulary is unit-testable without a device. Note:ChatMessage.deliverydoes not carry the attempt count / next-retry time the TUI shows, so the Android marker is◷ queuedwithout(try n/8, retry 45s)— that needs an SDK field, deliberately not invented here.Verified
./gradlew :app:assembleDebug :app:testDebugUnitTest→ BUILD SUCCESSFUL (Kotlin compiles against the regenerated bindings;:sdk:preBuildran the host cdylib +uniffi-bindgenand the arm64-v8acargo-ndkbuild).DeliveryMarkerTest+ the 5 existingInviteAddFlowTest.app-debug.apk, 41,976,312 bytes, sha25642a96b8342f97cf07e30401b933474f8efb418dc181bddec959f4936a7ba2f67, containslib/arm64-v8a/libonionwire_sdk.so; the dex contains the new copy and no longer contains "There is no outbox".Stacking
Base
mainfor the same reason #50/#51 are: the generated Kotlin only hasSendState/deliveryonce the SDK fix is in. My diff isandroid/app/**only —git diff --stat wt/t_9a29fd3c wt/t_7233051b:Merge order stays #48 → #50 → #51 → this one.
Not in this PR
README.md:115/159on this stack still say "no outbox, no retry queue" for the TUI — stale since #45, owned by the TUI PRs, not touched here.N queuedfooter`Node::send()` became `Result<OutboxStatus, String>` in the local-outbox work, which broke `crates/onionwire-sdk` (E0308 at src/lib.rs:195) — and nothing noticed, because the SDK is a separate cargo workspace that root CI never compiles and android-release.yml only builds on a v*.*.* tag. - `Wire::send()` now returns `WResult<SendState>` (`Sent` | `Queued`) instead of swallowing the outcome as `()`. A queued send is local-only until the retry worker gets a circuit through, so the Kotlin boundary must be able to tell it apart from a delivered one. - `ChatMessage` gains `delivery: Option<String>` ("sent" | "queued" | "sending" | "failed: <reason>"), populated from the message's outbox row; `None` for incoming messages. An outgoing row with no outbox row was accepted on the first attempt, so it reads "sent". - New `sdk` job in `.forgejo/workflows/ci.yml`: `cargo test --locked` + `cargo clippy --locked --all-targets -- -D warnings` in `crates/onionwire-sdk` in the same rust:1.91-bookworm container, with its own target volume (the SDK resolves the root crate with rustls, so sharing the root job's target dir would thrash feature-unified artifacts). - Drift found while un-rotting it: the SDK `Cargo.lock` was stale (missing `sha2`, added to the root crate by the zeroize work), so `--locked` failed; and the SDK README still said "no outbox, no spool in v1" and "identity keys in sqlite are plaintext", both untrue since the outbox and SQLCipher landed. Tests: crates/onionwire-sdk 4 passed (2 new unit tests over the status mapping), clippy clean; root `cargo test --locked` clean. The CI job body was smoke-run locally in the same container image before being committed.The SDK has returned `SendState` and a per-row `ChatMessage.delivery` since the local outbox landed, but the app still said "there is no outbox in v1" and threw the state away. - `WireViewModel.send()` returns `SendState`; `ChatScreen` no longer discards it. A `QUEUED` send raises a "local-only until the retry worker gets a circuit through" hint instead of pretending success. - Outgoing rows render the TUI's delivery markers from `ChatMessage.delivery` (`✓` / `◷ queued` / `» sending` / `✗ failed: <reason>`), plus the TUI's `{n} queued` footer while the outbox still owns rows. Incoming rows stay unmarked; an unreadable state renders no marker rather than a tick. - The empty-chat copy describes the outbox (8 attempts, backoff capped at 30 min, local-only until it lands) instead of denying it exists. - New pure `Delivery.kt` so the vocabulary is unit-testable without a device. Verified: `./gradlew :app:assembleDebug :app:testDebugUnitTest` → BUILD SUCCESSFUL, 15 tests / 0 failures (10 new), APK contains the new copy and no longer the "There is no outbox" string. Stacked on the SDK fix (PR #51).queued (try 3/8, retry 45s)from the SDK outbox rows #59queued (try 3/8, retry 45s)from the SDK outbox rows #5950aaaef232d55b58f64dd55b58f64dto4bc0d6684d4bc0d6684dtod47cccf3c4d47cccf3c4to92d921e759