feat(android): surface outbox delivery state in chat (queued/sending/delivered/failed) #56
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/android-outbox-state"
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?
What
The Compose chat now renders the core's own outbox state per message and at chat level, instead of implying a message either sent or did not.
✓✓◷ queued» sending✗ failed: <reason>Plus a chat-level footer while anything is outstanding —
N queued, and a fail-closedsend failed: <reason>statement that stays visible after retries are exhausted (mirrorssrc/tui.rs::OutboxSummary::note, so both clients read the same).Also fixed, because it is now false:
ChatScreen's empty-chat copy no longer says "Sends fail closed … There is no outbox in v1" — it now describes the local outbox and that a queued message is local-only until the peer's onion takes it.WireViewModel.send()(WireViewModel.kt:118) returns the SDKSendStateinstead of dropping it; aQUEUEDsend shows "Queued: their onion is unreachable. The message stays on this device and is retried until it lands."The exact API consumed
Nothing was added to the SDK — this card's scope is
android/only.uniffi.onionwire_sdk.SendState(SENT/QUEUED), returned byWire::sendcrates/onionwire-sdk/src/lib.rs:95,:229ChatMessage.delivery: String?—"sent"/"queued"/"sending"/"failed: <reason>",nullfor inboundcrates/onionwire-sdk/src/lib.rs:113(filled by:319 delivery_of)Node::outbox_status_of_message— the source of that stringsrc/node.rs:558(oversrc/outbox.rs:200, overOutboxStatusatsrc/store.rs:104)No parallel enum and no timeout guessing:
Deliveryis a 1:1 projection of the four statuses, and a missing or unrecognised status renders as queued, never delivered, because the only direction that cannot lie is "not confirmed delivered yet".Base / stack — read before merging
The SDK accessor this UI consumes is not on
mainyet — it lands with PR #51. Per this card's instruction ("if the SDK lifecycle PR exists … base on that branch instead"), this branch is stacked:My own diff is
android/only — 4 files, +482/−21:Forgejo will report
mergeable: falseuntil #48/#50/#51 land — same as its siblings; the branch was not rebased onto those branches' work-in-progress Rust files (they are outside this card's scope).Verification (real output)
APK:
Proof the new UI + SDK surface is actually packaged (not just compiled):
Unit tests —
MessageDeliveryTest, 10 tests, 0 failures (app/build/test-results/testDebugUnitTest/TEST-com.siriusdevops.onionwire.ui.MessageDeliveryTest.xml):The test asserts the assertable semantics, not a screenshot: each of the four states must produce its own
testTag(delivery-sent/delivery-queued/delivery-sending/delivery-failed) and its owncontentDescriptionsentence, the four handles and the four sentences must be pairwise distinct, and no glyph may appear in any announcement.compose.ui.testis not on the JVM unit-test classpath andandroid/app/build.gradle.ktsis outside this card's allowed scope (android/app/src/{main/java,res,test}), so the assertion target is the state model the Composable renders from — the Composable applies exactlyd.testTagandd.contentDescription, so a marker change without an announcement change fails the test. Same shape asInviteAddFlowTest.Not done — and why
ChatScreen's marker for a queued row readsqueued, without the TUI's(try n/8, retry 45s). Those two numbers live onOutboxEntry.attempts/next_attempt_at(src/store.rs:149-159), and the SDK exposes no record for them:ChatMessage.deliveryis aString, andWirehas nooutboxPending()/outboxStatusOfMessage(). Adding one means touchingcrates/onionwire-sdk/**, which this card forbids. The exact accessor needed:Filed as a follow-up card rather than blocking this one, because the four states this card's acceptance criteria name are all renderable today.
README (deferred)
README.mdis owned by another open PR; not touched. Proposed wording (for the Android feature list, if it needs one):Hotspot
android/app/src/main/java/com/siriusdevops/onionwire/WireViewModel.kt— PR #49 (feat/tor-lifecycle, mine, open) also edits this file (lock()/onCleared()→stopNode(),unlock()joins the teardown scope). The hunks do not overlap (send()vs. the history/teardown lifecycle), but whoever merges second should rebase.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.queued (try 3/8, retry 45s)from the SDK outbox rows #59queued (try 3/8, retry 45s)from the SDK outbox rows #59e0e4bed498a7fefce5d8a7fefce5d8toe9ea041385e9ea041385tob91101d17ab91101d17ato31065620403106562040toc4b824a83dThe TUI can say why a queued row is still queued ('queued (try n/8, retry 45s)') because it reads OutboxEntry::attempts and next_attempt_at directly. The SDK exposed neither: ChatMessage.delivery is a flat 'queued'/'sending'/'failed: <reason>' string and Wire had no outbox accessor, so an Android chat row could only invent a countdown. Adds OutboxRow { message_id, status, attempts, next_attempt_at, last_error } and Wire::outbox(pubkey_hex) over Node::outbox_pending, plus outbox_max_attempts() so the client renders 'try n/8' against the core's own budget instead of a hardcoded 8. Additive: Wire::send() and ChatMessage.delivery are untouched. # Conflicts: # crates/onionwire-sdk/src/lib.rsqueued (try 3/8, retry 45s)from the SDK's outbox rows