fix(android): surface the outbox send state instead of denying it #52

Merged
sirius merged 1 commit from wt/t_7233051b into wt/t_9a29fd3c 2026-09-12 23:05:41 +00:00
Owner

Why

crates/onionwire-sdk has returned SendState and a per-row ChatMessage.delivery since the local outbox landed (PR #45 / the SDK fix in #51), but android/app still 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 returns SendState (uniffi.onionwire_sdk.SendState, generated, SENT/QUEUED).

  • ChatScreen no longer discards it. A QUEUED send 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.delivery with the TUI's vocabulary (docs/TUI.md → "Delivery state (outbox)"):

    delivery row marker
    sent ✓
    queued ◷ queued
    sending » sending
    failed: <reason> ✗ failed: <reason> (reason elided past 48 chars)

    Incoming rows are unmarked (the SDK returns null). An outgoing row whose outbox entry is gone reads sent — 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} queued while 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.kt holds the mapping, so the vocabulary is unit-testable without a device. Note: ChatMessage.delivery does not carry the attempt count / next-retry time the TUI shows, so the Android marker is ◷ queued without (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:preBuild ran the host cdylib + uniffi-bindgen and the arm64-v8a cargo-ndk build).
  • 15 tests, 0 failures: 10 new DeliveryMarkerTest + the 5 existing InviteAddFlowTest.
  • APK evidence: app-debug.apk, 41,976,312 bytes, sha256 42a96b8342f97cf07e30401b933474f8efb418dc181bddec959f4936a7ba2f67, contains lib/arm64-v8a/libonionwire_sdk.so; the dex contains the new copy and no longer contains "There is no outbox".

Stacking

Base main for the same reason #50/#51 are: the generated Kotlin only has SendState/delivery once the SDK fix is in. My diff is android/app/** only — git diff --stat wt/t_9a29fd3c wt/t_7233051b:

 .../com/siriusdevops/onionwire/WireViewModel.kt    |  11 +-
 .../com/siriusdevops/onionwire/ui/ChatScreen.kt    | 116 +++++++++++++++++----
 .../java/com/siriusdevops/onionwire/ui/Delivery.kt |  78 ++++++++++++++
 .../onionwire/ui/DeliveryMarkerTest.kt             |  85 +++++++++++++++
 4 files changed, 271 insertions(+), 19 deletions(-)

Merge order stays #48 → #50 → #51 → this one.

Not in this PR

  • No R8/minify change (unchanged release posture).
  • No Rust change.
  • README.md:115/159 on this stack still say "no outbox, no retry queue" for the TUI — stale since #45, owned by the TUI PRs, not touched here.
## Why `crates/onionwire-sdk` has returned `SendState` and a per-row `ChatMessage.delivery` since the local outbox landed (PR #45 / the SDK fix in #51), but `android/app` still 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 returns `SendState` (`uniffi.onionwire_sdk.SendState`, generated, `SENT`/`QUEUED`). * `ChatScreen` no longer discards it. A `QUEUED` send 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.delivery` with the TUI's vocabulary (`docs/TUI.md` → "Delivery state (outbox)"): | `delivery` | row marker | |---|---| | `sent` | `✓` | | `queued` | `◷ queued` | | `sending` | `» sending` | | `failed: <reason>` | `✗ failed: <reason>` (reason elided past 48 chars) | Incoming rows are unmarked (the SDK returns `null`). An outgoing row whose outbox entry is gone reads `sent` — 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} queued` while 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.kt` holds the mapping, so the vocabulary is unit-testable without a device. Note: `ChatMessage.delivery` does not carry the attempt count / next-retry time the TUI shows, so the Android marker is `◷ queued` without `(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:preBuild` ran the host cdylib + `uniffi-bindgen` and the arm64-v8a `cargo-ndk` build). * 15 tests, 0 failures: 10 new `DeliveryMarkerTest` + the 5 existing `InviteAddFlowTest`. * APK evidence: `app-debug.apk`, 41,976,312 bytes, sha256 `42a96b8342f97cf07e30401b933474f8efb418dc181bddec959f4936a7ba2f67`, contains `lib/arm64-v8a/libonionwire_sdk.so`; the dex contains the new copy and **no longer** contains "There is no outbox". ## Stacking Base `main` for the same reason #50/#51 are: the generated Kotlin only has `SendState`/`delivery` once the SDK fix is in. My diff is `android/app/**` only — `git diff --stat wt/t_9a29fd3c wt/t_7233051b`: ``` .../com/siriusdevops/onionwire/WireViewModel.kt | 11 +- .../com/siriusdevops/onionwire/ui/ChatScreen.kt | 116 +++++++++++++++++---- .../java/com/siriusdevops/onionwire/ui/Delivery.kt | 78 ++++++++++++++ .../onionwire/ui/DeliveryMarkerTest.kt | 85 +++++++++++++++ 4 files changed, 271 insertions(+), 19 deletions(-) ``` Merge order stays #48 → #50 → #51 → this one. ## Not in this PR * No R8/minify change (unchanged release posture). * No Rust change. * `README.md:115/159` on this stack still say "no outbox, no retry queue" for the TUI — stale since #45, owned by the TUI PRs, not touched here.
feat(outbox): local retry queue for chat sends
All checks were successful
ci / test (pull_request) Successful in 3m22s
068b655c19
Queue a chat send locally when the peer's v3 onion is unreachable and retry
it with exponential backoff (30s doubling, capped at 30 min, 8 attempts then
terminal Failed). Still peer-to-peer: no server, no store-and-forward relay,
no new frame prefix — every attempt is a fresh Noise IK handshake.

- src/outbox.rs: Outbox + Deliverer + ArtiDeliverer, pure backoff_secs(),
  is_permanent_send_error(), background worker (15s scan).
- store: `outbox` table (no body column — the body is read from the joined
  messages row, under that row's existing AEAD + AAD), append_message_id(),
  queue/due/pending/mark_* helpers, reset_sending_outbox(), wipe.
- Node::send() returns Result<OutboxStatus, String> (Sent/Queued) instead of
  Err on transport failure; protocol errors still fail immediately and are
  never queued.
- Retry triggers: timer, unlock/foreground (spawn_flush_all), and "that peer
  was just seen" (handshake or connect_onion -> spawn_flush_friend).
- File transfer and payment/rcp frames stay fail-closed.
- docs/PROTOCOL.md + docs/THREAT_MODEL.md: replace the no-queue statements;
  add the seizure/cadence delta to the threat model.

src/tui.rs gets one forced arm change (Ok(()) -> Ok(_)); UI surfacing is
child card t_d9a5b065.
Merge remote-tracking branch 'origin/feat/local-outbox' into feat/tui-outbox-state
All checks were successful
ci / test (pull_request) Successful in 3m16s
7c6de696a1
feat(tui): per-message outbox delivery state + N queued footer
All checks were successful
ci / test (pull_request) Successful in 3m20s
ebd3a306e8
Chat rows now carry the state the local outbox actually holds: `✓` delivered,
`◷ queued (try n/8, retry 45s)` while the retry worker still has it, `» sending`
mid-attempt and `✗ failed: <short reason>` once attempts are exhausted. The
footer replaces the flat `sent` / `send failed` copy with the live count
(`2 queued`), and keeps a fail-closed `send failed: …` statement as long as any
row is terminally failed.

States come from the outbox API (`Node::outbox_pending` → `Queued` / `Sending` /
`Failed`; a delivered row is deleted, so absence is `Sent`). No parallel state
model, no new wire prefix. Every new glyph has an ASCII fallback (`ok` plus the
state word) exercised by a test.

- `chat_with_delivery()` / `delivery_tag()` / `retry_in_text()` /
  `short_send_reason()` / `OutboxSummary::note()` are pure and unit-tested.
- `draw_chat()` is now the real chat-pane renderer (extracted from
  `App::draw_main`) so width/wrap is testable without a `Node`.
- docs/TUI.md: delivery markers, copy, and the 80x24 floor / 120x40 target.

Verified: cargo test 26/26 suites ok (tui_spec 20/20, incl. a real Store +
Outbox::send -> pending() -> render path); clippy --all-targets -D warnings clean.
feat(tui): join outbox rows to chat rows by message id
All checks were successful
ci / test (pull_request) Successful in 3m27s
afff5f8dff
`chat_with_delivery` matched pending outbox rows to chat rows by body
because `store::Message` carried no id, so an older send that was still
queued showed a delivered mark whenever a newer send of the same text had
already crossed the circuit.

`store::Message` now carries its `messages.id`, and the TUI joins
`OutboxEntry::message_id` == `Message::id`. The body match and its
newest-first fallback are gone.

`list_messages()` keeps its signature; callers that do not need the id
are untouched.
fix(sdk): surface Sent/Queued on send(), and build the SDK in CI
All checks were successful
ci / test (pull_request) Successful in 3m37s
ci / sdk (pull_request) Successful in 10m7s
08a4accf37
`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.
fix(android): surface the outbox send state instead of denying it
All checks were successful
ci / test (pull_request) Successful in 3m7s
ci / sdk (pull_request) Successful in 51s
50aaaef232
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).
sirius changed target branch from main to wt/t_9a29fd3c 2026-09-12 21:11:00 +00:00
sirius force-pushed wt/t_7233051b from 50aaaef232
All checks were successful
ci / test (pull_request) Successful in 3m7s
ci / sdk (pull_request) Successful in 51s
to d55b58f64d 2026-09-12 21:11:01 +00:00
Compare
sirius force-pushed wt/t_7233051b from d55b58f64d to 4bc0d6684d 2026-09-12 21:11:57 +00:00 Compare
sirius force-pushed wt/t_7233051b from 4bc0d6684d to d47cccf3c4 2026-09-12 21:15:41 +00:00 Compare
sirius force-pushed wt/t_7233051b from d47cccf3c4 to 92d921e759 2026-09-12 22:15:13 +00:00 Compare
sirius merged commit 6867a6c430 into wt/t_9a29fd3c 2026-09-12 23:05:41 +00:00
sirius deleted branch wt/t_7233051b 2026-09-12 23:08:15 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
sirius/onionwire!52
No description provided.