docs+tui: reachability stance (no sealed mailbox) and peer-unreachable queued footer
Add a Reachability section to docs/THREAT_MODEL.md: no sealed mailbox or server-side message store, the chat outbox is local-device retry only, and there is no mutual-online indicator — a send is a one-shot Noise IK session and an unanswered dial queues locally with the retry clock shown. OutboxSummary now carries the outstanding row's attempt count and soonest retry, so the footer reads 'peer unreachable, queued (n/8, retry 45s)' instead of a bare 'n queued'. Tests updated to the real outbox wording; the Android KDoc note stops claiming the footer copy is mirrored (Android shows per-row 'queued (try n/8, retry …)' via OutboxDetail).
This commit is contained in:
parent
918fa4d8a8
commit
dff37fe00e
4 changed files with 79 additions and 14 deletions
34
src/tui.rs
34
src/tui.rs
|
|
@ -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() {
|
||||
|
|
|
|||
Loading…
Reference in a new issue