2026-09-10 23:07:22 -04:00
|
|
|
//! Composer Enter must send chat to the selected friend, not only slash commands.
|
|
|
|
|
|
2026-09-11 22:33:55 -04:00
|
|
|
use onionwire::tui::{
|
fix(sdk): surface Sent/Queued on send(), and build the SDK in CI
`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.
# Conflicts:
# crates/onionwire-sdk/src/lib.rs
2026-09-12 15:16:38 -04:00
|
|
|
ComposerAction, SlashCmd, TUI_POLL, WipeKind, composer_enter, take_job_result,
|
2026-09-11 22:33:55 -04:00
|
|
|
};
|
|
|
|
|
use std::sync::mpsc;
|
|
|
|
|
use std::time::{Duration, Instant};
|
2026-09-10 23:07:22 -04:00
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn enter_plain_text_is_send() {
|
|
|
|
|
assert_eq!(
|
|
|
|
|
composer_enter("hello wire"),
|
|
|
|
|
Some(ComposerAction::Send("hello wire".into()))
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn enter_trims_but_sends() {
|
|
|
|
|
assert_eq!(
|
|
|
|
|
composer_enter(" hi there "),
|
|
|
|
|
Some(ComposerAction::Send("hi there".into()))
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn enter_empty_does_nothing() {
|
|
|
|
|
assert_eq!(composer_enter(""), None);
|
|
|
|
|
assert_eq!(composer_enter(" "), None);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn enter_slash_cmds_are_not_chat() {
|
|
|
|
|
assert_eq!(
|
|
|
|
|
composer_enter("/wipe"),
|
|
|
|
|
Some(ComposerAction::Cmd(SlashCmd::Wipe(WipeKind::Messages)))
|
|
|
|
|
);
|
|
|
|
|
assert_eq!(
|
|
|
|
|
composer_enter("/who"),
|
|
|
|
|
Some(ComposerAction::Cmd(SlashCmd::Who))
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn enter_unknown_slash_is_not_chat() {
|
|
|
|
|
assert_eq!(
|
|
|
|
|
composer_enter("/nope"),
|
|
|
|
|
Some(ComposerAction::UnknownSlash("/nope".into()))
|
|
|
|
|
);
|
|
|
|
|
}
|
2026-09-11 22:33:55 -04:00
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn take_job_result_is_nonblocking_when_empty() {
|
|
|
|
|
let (tx, rx) = mpsc::channel::<String>();
|
|
|
|
|
let start = Instant::now();
|
|
|
|
|
assert_eq!(take_job_result(&rx), None);
|
|
|
|
|
assert!(
|
|
|
|
|
start.elapsed() < Duration::from_millis(50),
|
|
|
|
|
"empty job rx must not wait on the 180s send retry"
|
|
|
|
|
);
|
|
|
|
|
drop(tx);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn take_job_result_reads_status_without_blocking() {
|
|
|
|
|
let (tx, rx) = mpsc::channel();
|
|
|
|
|
tx.send("sent".into()).unwrap();
|
|
|
|
|
assert_eq!(take_job_result(&rx).as_deref(), Some("sent"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn tui_poll_is_short_so_keys_keep_working() {
|
|
|
|
|
assert!(TUI_POLL <= Duration::from_millis(200));
|
|
|
|
|
assert!(TUI_POLL > Duration::ZERO);
|
|
|
|
|
}
|