test(daemon): drive the whole CLI suite against a daemon, and fix what it caught

SOULSEEK_E2E_MODE=daemon makes the existing e2e harness serve every session
from a daemon instead of the command's own login, so the same 83 tests assert
the same records and exit codes both ways. CI runs the suite twice.

Two defects it found:

serve judged whether anything was shared from this run's configuration
rather than from the session, so routed to a daemon it would start with
nothing to serve and report success.

The TUI showed an empty conversation when attached, because the daemon's
message history was never asked for. It is now a SessionApi method, empty
locally, which puts the difference behind the seam.

main.rs is now a thin entry point over the library rather than a second copy
of every module, so the program compiles once instead of twice.
This commit is contained in:
Michel de Graaf
2026-07-27 10:58:27 +02:00
parent 834fbcd35b
commit a69f52c657
12 changed files with 663 additions and 578 deletions
+11 -11
View File
@@ -162,14 +162,14 @@ impl RemoteSession {
let pending = Arc::new(Pending::default());
let mirror = Arc::new(Mirror::default());
let closed = Arc::new(AtomicBool::new(false));
let hung_up = Arc::new(AtomicBool::new(false));
{
let pending = Arc::clone(&pending);
let mirror = Arc::clone(&mirror);
let closed = Arc::clone(&closed);
let hung_up = Arc::clone(&hung_up);
std::thread::spawn(move || {
read_loop(read, &pending, &mirror);
closed.store(true, Ordering::Relaxed);
hung_up.store(true, Ordering::Relaxed);
pending.fail_all();
});
}
@@ -181,7 +181,7 @@ impl RemoteSession {
mirror,
next_id: AtomicU64::new(1),
username: String::new(),
closed,
closed: hung_up,
};
let token = if endpoint.self_authenticating() {
@@ -341,17 +341,11 @@ impl RemoteSession {
/// One parameterless request, for the control commands that only need to
/// ask a daemon something once.
///
pub fn ask_for<R: DeserializeOwned>(&self, method: Method) -> Result<R> {
self.request(method, ())
}
/// The daemon's chat history, which a remote client needs to rebuild a
/// conversation it was not attached for. Not part of [`SessionApi`]
/// because a local session keeps this in the TUI's own snapshot.
pub fn message_history(&self) -> Result<Vec<ChatMessageDto>> {
self.request::<_, Messages>(Method::MessageHistory, ())
.map(|history| history.messages)
}
}
/// Turn the daemon's view of a transfer back into the library's, with the
@@ -739,6 +733,12 @@ impl SessionApi for RemoteSession {
.map(Into::into)
}
fn message_history(&self) -> Vec<ChatMessageDto> {
self.request::<_, Messages>(Method::MessageHistory, ())
.map(|history| history.messages)
.unwrap_or_default()
}
fn shared_counts(&self) -> (u32, u32) {
let shares = self.shares();
(shares.folders, shares.files)