Merge pull request 'docs+tui: reachability stance (no sealed mailbox) and peer-unreachable queued footer' (#99) from wt/t_d662c8a6 into main
Some checks failed
android-ci / android (push) Successful in 8m31s
ci / test (push) Successful in 4m57s
ci / sdk (push) Successful in 1m5s
ci / fuzz (push) Failing after 36s

Reviewed-on: #99
This commit is contained in:
sirius 2026-09-18 01:02:21 +00:00
commit 407b11f2f8
4 changed files with 79 additions and 14 deletions

View file

@ -204,11 +204,22 @@ pub struct OutboxSummary {
pub failed: usize,
/// First terminal failure, for the fail-closed footer copy.
pub first_error: Option<String>,
/// Highest attempt count across outstanding rows (0 when nothing is
/// outstanding). With `DEFAULT_MAX_ATTEMPTS` this is the `n` in `(n/8)`.
pub attempts: u32,
/// Seconds until the earliest scheduled retry, relative to the render
/// `now`. `None` while nothing is outstanding.
pub next_in_secs: Option<i64>,
}
impl OutboxSummary {
/// Footer note, or `None` when nothing is outstanding. Any terminal failure
/// keeps a `send failed` statement so the fail-closed copy stays visible.
///
/// An outstanding row is a reachability statement, not just a count: the
/// peer's onion did not answer *this* dial, so the note names that and the
/// retry it is waiting on (`peer unreachable, queued (n/8, retry 45s)`).
/// There is no mutual-online indicator to fall back on.
pub fn note(&self) -> Option<String> {
let reason = || {
short_send_reason(
@ -216,12 +227,19 @@ impl OutboxSummary {
FAIL_REASON_BUDGET,
)
};
let queued = || {
format!(
"peer unreachable, queued ({}/{DEFAULT_MAX_ATTEMPTS}, {})",
self.attempts,
retry_in_text(self.next_in_secs.unwrap_or(0))
)
};
match (self.queued, self.failed) {
(0, 0) => None,
(queued, 0) => Some(format!("{queued} queued")),
(0, 1) => Some(format!("send failed: {}", reason())),
(0, failed) => Some(format!("send failed: {} ({failed} failed)", reason())),
(queued, _) => Some(format!("{queued} queued, send failed: {}", reason())),
(_, 0) => Some(queued()),
(_, _) => Some(format!("{}, send failed: {}", queued(), reason())),
}
}
}
@ -244,7 +262,17 @@ pub fn chat_with_delivery(
summary.failed += 1;
summary.first_error.get_or_insert_with(|| why.clone());
}
_ => summary.queued += 1,
_ => {
summary.queued += 1;
// The note is the reachability statement for the selected
// friend: highest attempt count, soonest scheduled retry.
summary.attempts = summary.attempts.max(entry.attempts);
let secs = entry.next_attempt_at - now;
summary.next_in_secs = Some(match summary.next_in_secs {
Some(prev) => prev.min(secs),
None => secs,
});
}
}
}
if msgs.is_empty() {