Pin the colour of a chat's avatar with a test that fails when it falls back to black

The ui-vm gate's minor "server_tint falls back to black" was closed by a
fallback in App::conversation_item, `.unwrap_or_else(|| vm::avatar::tint(&title))`,
that no test could fail: replacing it with `.unwrap_or_default()` (opaque
black) left cargo test -p voelin-ui -p voelin-ui-vm green.

The choice of (kind, session) -> colour is now a pure function in
voelin-ui-vm, servers::logic::conversation_tint(state, kind, session, title),
and messages.rs calls it. A test pins the three cases: a server chat of a
server in the list takes the rail's colour, a server chat whose server is
gone takes the colour of its title, and a channel's or a person's chat (with
or without a known server) takes the colour of its title. The titles are
chosen so that the title's colour differs from the server's, and the test
asserts that. App::server_tint, whose only caller this was, is removed.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
faumarayandClaude Sonnet 5.5 committed 2026-10-24 23:36:19 +03:00
1 parent 9e7452ec2a
commit 08a899cf01
3 files changed
+46 -14

No files matched your search

+1 -7
View File
@@ -201,13 +201,7 @@ impl App {
ago: ago(ts).into(),
unread: chat.unread,
initials: vm::avatar::initials(&title).into(),
// A server's chat in the server's colour; a name's own colour
// when the server is gone.
tint: match (kind, session) {
(0, Some(s)) => self.server_tint(s),
_ => None,
}
.unwrap_or_else(|| vm::avatar::tint(&title)),
tint: vm::servers::logic::conversation_tint(&self.state, kind, session, &title),
avatar,
online,
selected: open.is_some_and(|o| {
-7
View File
@@ -286,13 +286,6 @@ impl App {
}
}
/// A server's colour, as the rail shows it ([`logic::server_tint`]);
/// none for a server that is not in the list (a chat that outlived its
/// bookmark), where the caller picks a colour of its own.
pub(crate) fn server_tint(&self, id: i64) -> Option<vm::Rgb> {
logic::server_tint(&self.state, id)
}
/// The rail: servers with their state, unread count (without private
/// chats) and streams; what the chat strip and the private chats have
/// unread.