feat(tui): per-message outbox delivery state (queued/sending/sent/failed) + N queued footer #48

Merged
sirius merged 1 commit from feat/tui-outbox-state into main 2026-09-12 20:32:39 +00:00
Owner

What

Per-message delivery state in the chat pane, read from the local outbox, plus a
live N queued footer summary.

Row Marker
delivered you: ping ✓
queued (2nd attempt, 45s out) you: pong ◷ queued (try 2/8, retry 45s)
sending you: pong » sending
failed you: pong ✗ failed: connection timed out
inbound them: pong (no marker)

Footer while rows are outstanding: 2 queued; any terminal failure keeps a
fail-closed send failed: {short} statement (! prefixed when colour is off).
States are the store/outbox ones (Queued / Sending / Sent / Failed) — no
parallel model, no new wire prefix, no server.

Stacked base — read this

PR #27 is merged (e6e2a15), so docs/TUI.md and the src/tui.rs chrome
conventions are now on main. The one dependency still open is PR #45
(feat/local-outbox), whose API this card renders:

git rev-list --count origin/main..origin/feat/local-outbox   # 1  => still open

feat/tui-outbox-state = origin/main (4338e8a) merged with
origin/feat/local-outbox (clean), then this card's commit on top. Review the
src/tui.rs / tests/tui_spec.rs / docs/TUI.md diff; the src/outbox.rs,
src/store.rs and src/node.rs hunks belong to #45 and disappear once it lands.
Do not merge before #45. No README changes.

Scope

Allowed files only: src/tui.rs, tests/tui_spec.rs, docs/TUI.md.
README.md, src/node.rs, src/store.rs, src/outbox.rs untouched (the last
three are byte-identical to the parents' heads — cargo fmt run only on my
files).

How it is verified

Real output from this worktree:

$ cargo test
... 26 suites: test result: ok.  (0 failed; 3 ignored network tests unchanged)
tui_spec: 20 passed; 0 failed
$ cargo clippy --all-targets -- -D warnings
Finished `dev` profile [unoptimized + debuginfo] target(s) in 1.60s

New tests (tests/tui_spec.rs):

  • queued_and_delivered_messages_render_different_markers — distinct, assertable
    markers for a queued vs a delivered row, incl. try 2/8 / retry 45s.
  • delivery_markers_have_exercised_ascii_fallbacks — ONIONWIRE_ASCII=1 frame is
    pure ASCII and the fallbacks are exact (failed: …, queued (try 1/8, retry 30s),
    sending, ok); the fallback path is exercised, not just declared.
  • chat_and_footer_rows_fit_80x24_and_wrap_instead_of_clipping — draws the real
    draw_chat + status_footer at 80x24, asserts every chat and footer row is
    <= 80, that both markers render, and that an over-long message wraps instead
    of being clipped. Floor 80x24 / target 120x40 are now stated in docs/TUI.md.
  • footer_summary_counts_queued_and_keeps_fail_closed — 2 queued,
    send failed: {short} (incl. the ! ornament with NO_COLOR), and
    {n} queued, send failed: … for the mixed case.
  • renders_a_queued_row_from_a_real_outbox_send — real Store + real
    Outbox::send against a dead onion → pending() row → render; no hand-written
    fixture for the state.
  • retry_age_and_failure_reason_are_short_forms,
    delivery_tag_reads_the_outbox_status_enum — unit level.

Frame dump (real helpers, --nocapture):

===== AFTER outbox 80x24 (real draw_chat + status_footer) =====
┌> chat  alice─────────────────────────────────────────────────────────────────┐
│you: ok  ✓                                                                    │
│them: pong                                                                    │
│you: this is a very long chat line that should wrap inside the chat pane      │
│instead of running off the right edge of an 80-column terminal and colliding  │
│with the roster border  ◷ queued (try 3/8, retry 45s)                         │
└──────────────────────────────────────────────────────────────────────────────┘
1 queued TOR  me:abcdef01… onion:abcdefgh… Tab F2 F3 F4 F5 Ctrl-Q ? help

Helpers renamed / moved

  • App::chat_lines() → App::chat_view() (private, returns lines and the
    outbox summary; nothing in tests/tui_spec.rs / tests/tui_frames.rs
    asserts on it).
  • App::pane_block() kept; its body moved to the free pane_block_for() so the
    extracted draw_chat() can style the pane. draw_chat is new and public.
  • status_footer() signature unchanged; the ! ornament now triggers on
    note.contains("send failed") instead of starts_with, so
    {n} queued, send failed: … keeps its fail-closed marker. Existing chrome
    assertions (TOR, me:, ? help at 80/120) still pass.

Known limitation (honest)

A delivered row is deleted from the outbox, so absence means Sent; pending rows
are matched to chat rows by body, newest send first — the outbox exposes
message_id but store::Message has no id and Node::list_messages does not
surface one, and src/node.rs is out of scope for this card. Consequence: two
identical bodies where only the newer one is still queued attach the marker to
the newer send. Follow-up card created for an id-bearing accessor so the marker
can join exactly.

README (deferred)

README.md is owned by PR #38 — not touched. In "First run", the sentence

… type in the composer, Enter to send. Footer shows sending, then sent or
send failed — the TUI stays usable while Tor retries (up to 180s). Fail
closed: if their onion is down, send fails — no outbox.

should become (coordinate with PR #45, which already supersedes the "no outbox"
clause):

… type in the composer, Enter to send. Every line carries its delivery state:
✓ once it crossed the circuit, ◷ queued (try n/8, retry 45s) while the
outbox is still retrying (30s doubling, 8 attempts, then terminal), » sending
mid-attempt and ✗ failed: <reason> when retries are exhausted. The footer
summarises the selected thread (2 queued, or send failed: … once an attempt
is terminal). ONIONWIRE_ASCII=1 prints ok / queued / sending / failed
instead of the glyphs. A queued message is local-only until a circuit takes it.

## What Per-message delivery state in the chat pane, read from the local outbox, plus a live `N queued` footer summary. | Row | Marker | |---|---| | delivered | `you: ping ✓` | | queued (2nd attempt, 45s out) | `you: pong ◷ queued (try 2/8, retry 45s)` | | sending | `you: pong » sending` | | failed | `you: pong ✗ failed: connection timed out` | | inbound | `them: pong` (no marker) | Footer while rows are outstanding: `2 queued`; any terminal failure keeps a fail-closed `send failed: {short}` statement (`! ` prefixed when colour is off). States are the store/outbox ones (`Queued` / `Sending` / `Sent` / `Failed`) — no parallel model, no new wire prefix, no server. ## Stacked base — **read this** PR #27 is **merged** (`e6e2a15`), so `docs/TUI.md` and the `src/tui.rs` chrome conventions are now on `main`. The one dependency still open is PR **#45** (`feat/local-outbox`), whose API this card renders: ``` git rev-list --count origin/main..origin/feat/local-outbox # 1 => still open ``` `feat/tui-outbox-state` = `origin/main` (`4338e8a`) merged with `origin/feat/local-outbox` (clean), then this card's commit on top. Review the `src/tui.rs` / `tests/tui_spec.rs` / `docs/TUI.md` diff; the `src/outbox.rs`, `src/store.rs` and `src/node.rs` hunks belong to #45 and disappear once it lands. **Do not merge before #45.** No README changes. ## Scope Allowed files only: `src/tui.rs`, `tests/tui_spec.rs`, `docs/TUI.md`. `README.md`, `src/node.rs`, `src/store.rs`, `src/outbox.rs` untouched (the last three are byte-identical to the parents' heads — `cargo fmt` run only on my files). ## How it is verified Real output from this worktree: ``` $ cargo test ... 26 suites: test result: ok. (0 failed; 3 ignored network tests unchanged) tui_spec: 20 passed; 0 failed $ cargo clippy --all-targets -- -D warnings Finished `dev` profile [unoptimized + debuginfo] target(s) in 1.60s ``` New tests (`tests/tui_spec.rs`): - `queued_and_delivered_messages_render_different_markers` — distinct, assertable markers for a queued vs a delivered row, incl. `try 2/8` / `retry 45s`. - `delivery_markers_have_exercised_ascii_fallbacks` — `ONIONWIRE_ASCII=1` frame is pure ASCII and the fallbacks are exact (`failed: …`, `queued (try 1/8, retry 30s)`, `sending`, `ok`); the fallback path is exercised, not just declared. - `chat_and_footer_rows_fit_80x24_and_wrap_instead_of_clipping` — draws the real `draw_chat` + `status_footer` at 80x24, asserts every chat and footer row is `<= 80`, that both markers render, and that an over-long message wraps instead of being clipped. Floor 80x24 / target 120x40 are now stated in `docs/TUI.md`. - `footer_summary_counts_queued_and_keeps_fail_closed` — `2 queued`, `send failed: {short}` (incl. the `! ` ornament with `NO_COLOR`), and `{n} queued, send failed: …` for the mixed case. - `renders_a_queued_row_from_a_real_outbox_send` — real `Store` + real `Outbox::send` against a dead onion → `pending()` row → render; no hand-written fixture for the state. - `retry_age_and_failure_reason_are_short_forms`, `delivery_tag_reads_the_outbox_status_enum` — unit level. Frame dump (real helpers, `--nocapture`): ``` ===== AFTER outbox 80x24 (real draw_chat + status_footer) ===== ┌> chat alice─────────────────────────────────────────────────────────────────┐ │you: ok ✓ │ │them: pong │ │you: this is a very long chat line that should wrap inside the chat pane │ │instead of running off the right edge of an 80-column terminal and colliding │ │with the roster border ◷ queued (try 3/8, retry 45s) │ └──────────────────────────────────────────────────────────────────────────────┘ 1 queued TOR me:abcdef01… onion:abcdefgh… Tab F2 F3 F4 F5 Ctrl-Q ? help ``` ## Helpers renamed / moved - `App::chat_lines()` → `App::chat_view()` (private, returns lines **and** the outbox summary; nothing in `tests/tui_spec.rs` / `tests/tui_frames.rs` asserts on it). - `App::pane_block()` kept; its body moved to the free `pane_block_for()` so the extracted `draw_chat()` can style the pane. `draw_chat` is new and public. - `status_footer()` signature unchanged; the `! ` ornament now triggers on `note.contains("send failed")` instead of `starts_with`, so `{n} queued, send failed: …` keeps its fail-closed marker. Existing chrome assertions (`TOR`, `me:`, `? help` at 80/120) still pass. ## Known limitation (honest) A delivered row is deleted from the outbox, so absence means `Sent`; pending rows are matched to chat rows **by body, newest send first** — the outbox exposes `message_id` but `store::Message` has no id and `Node::list_messages` does not surface one, and `src/node.rs` is out of scope for this card. Consequence: two identical bodies where only the newer one is still queued attach the marker to the newer send. Follow-up card created for an id-bearing accessor so the marker can join exactly. ## README (deferred) `README.md` is owned by PR #38 — not touched. In "First run", the sentence > … type in the composer, Enter to send. Footer shows `sending`, then `sent` or > `send failed` — the TUI stays usable while Tor retries (up to 180s). Fail > closed: if their onion is down, send fails — no outbox. should become (coordinate with PR #45, which already supersedes the "no outbox" clause): > … type in the composer, Enter to send. Every line carries its delivery state: > `✓` once it crossed the circuit, `◷ queued (try n/8, retry 45s)` while the > outbox is still retrying (30s doubling, 8 attempts, then terminal), `» sending` > mid-attempt and `✗ failed: <reason>` when retries are exhausted. The footer > summarises the selected thread (`2 queued`, or `send failed: …` once an attempt > is terminal). `ONIONWIRE_ASCII=1` prints `ok` / `queued` / `sending` / `failed` > instead of the glyphs. A queued message is local-only until a circuit takes it.
feat(tui): ASCII chrome, invite wrap, alert truncate, remaining copy
Some checks failed
ci / test (pull_request) Failing after 4m39s
35b8caa716
ONIONWIRE_ASCII (and NO_COLOR) switches truncation to ... and ASCII
borders. Share/paste wrap at : so a mouse-copy cannot lose a mid-hex
line. Alerts truncate to the frame; empty threads and paste errors keep
the next-step hint. Skip the optional 40-row wordmark.
feat(outbox): local retry queue for chat sends
All checks were successful
ci / test (pull_request) Successful in 3m21s
ad59a171b3
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.
feat(tui): per-message outbox delivery state + N queued footer
All checks were successful
ci / test (pull_request) Successful in 3m28s
43d68a2565
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` and 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.

Tests: cargo test 26/26 suites ok (tui_spec 20/20, incl. a real Store + real
`Outbox::send` -> `pending()` -> render path), clippy --all-targets -D warnings
clean.
sirius force-pushed feat/tui-outbox-state from 43d68a2565
All checks were successful
ci / test (pull_request) Successful in 3m28s
to 7c6de696a1
All checks were successful
ci / test (pull_request) Successful in 3m16s
2026-09-12 18:12:57 +00:00
Compare
Author
Owner

CI + verification on the rebased head

Rebased on origin/main 4338e8a (PR #27 merged) + origin/feat/local-outbox; head is now 7c6de69.

  • Forgejo CI run #157 (test, #48, 7c6de69): success — https://forgejo.siriusdevops.com/sirius/onionwire/actions/runs/157
  • Local: cargo test → 26/26 suites ok (tui_spec 20 passed; 3 ignored network tests unchanged); cargo clippy --all-targets -- -D warnings → clean.
  • git status shows only src/tui.rs, tests/tui_spec.rs, docs/TUI.md changed by this card; README.md, src/node.rs, src/store.rs, src/outbox.rs untouched.

Follow-up card for the exact id join (removes the body-match caveat): t_19109ff7.

## CI + verification on the rebased head Rebased on `origin/main` `4338e8a` (PR #27 merged) + `origin/feat/local-outbox`; head is now `7c6de69`. - Forgejo CI run #157 (`test`, `#48`, `7c6de69`): **success** — https://forgejo.siriusdevops.com/sirius/onionwire/actions/runs/157 - Local: `cargo test` → 26/26 suites ok (`tui_spec` 20 passed; 3 ignored network tests unchanged); `cargo clippy --all-targets -- -D warnings` → clean. - `git status` shows only `src/tui.rs`, `tests/tui_spec.rs`, `docs/TUI.md` changed by this card; `README.md`, `src/node.rs`, `src/store.rs`, `src/outbox.rs` untouched. Follow-up card for the exact id join (removes the body-match caveat): **t_19109ff7**.
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.
Author
Owner

Correction + final head

The previous comment named 7c6de69 — that was the base merge (main + feat/local-outbox) pushed without this card's commit (staging mistake on my side). The commit is now on the branch and pushed.

  • Final head: ebd3a30 — feat(tui): per-message outbox delivery state + \N queued` footer`
  • Forgejo CI run #158 (test, #48, ebd3a30): success — https://forgejo.siriusdevops.com/sirius/onionwire/actions/runs/158
  • PR diff now carries this card's 3 files: src/tui.rs, tests/tui_spec.rs, docs/TUI.md (11 changed files total = those 3 plus PR #45's 9 until it merges).
  • Local on ebd3a30: cargo test → 26/26 suites ok (tui_spec 20 passed); cargo clippy --all-targets -- -D warnings → exit 0.

Follow-up card for the exact id join (removes the body-match caveat): t_19109ff7.

### Correction + final head The previous comment named `7c6de69` — that was the *base* merge (main + `feat/local-outbox`) pushed without this card's commit (staging mistake on my side). The commit is now on the branch and pushed. - Final head: **`ebd3a30`** — `feat(tui): per-message outbox delivery state + \`N queued\` footer` - Forgejo CI run **#158** (`test`, `#48`, `ebd3a30`): **success** — https://forgejo.siriusdevops.com/sirius/onionwire/actions/runs/158 - PR diff now carries this card's 3 files: `src/tui.rs`, `tests/tui_spec.rs`, `docs/TUI.md` (11 changed files total = those 3 plus PR #45's 9 until it merges). - Local on `ebd3a30`: `cargo test` → 26/26 suites ok (`tui_spec` 20 passed); `cargo clippy --all-targets -- -D warnings` → exit 0. Follow-up card for the exact id join (removes the body-match caveat): **t_19109ff7**.
sirius changed target branch from main to feat/local-outbox 2026-09-12 18:42:49 +00:00
sirius force-pushed feat/tui-outbox-state from ebd3a306e8
All checks were successful
ci / test (pull_request) Successful in 3m20s
to b79f1fd6f3
All checks were successful
ci / test (pull_request) Successful in 4m9s
2026-09-12 18:42:51 +00:00
Compare
sirius changed target branch from feat/local-outbox to main 2026-09-12 19:40:30 +00:00
sirius merged commit cecad2b364 into main 2026-09-12 20:32:39 +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!48
No description provided.