feat(client): redesign native UI, themes, settings and avatars

Separate conversation drafts and voice view state, add native settings and restricted CSS themes, implement validated avatar cropping, and refresh dependencies with documented desktop compatibility backports.
This commit is contained in:
Loki 2026-10-24 14:23:48 +02:00
parent 44d284a568
commit 8e5ab56611
Signed by: boba
GPG key ID: 253067914055423B
276 changed files with 53546 additions and 3399 deletions

View file

@ -23,22 +23,25 @@ pub fn process_net_events(state: &mut AppState) {
state.ui.private_mode = private_mode;
if restored {
state.ui.status_msg = Some("reconnected".into());
if let Some(ch) = state.ui.active_channel.clone() {
let net = state.net.clone();
tokio::spawn(async move {
net.send(NetCommand::JoinChannel { channel_id: ch }).await;
});
}
let text_channel = state.ui.active_channel.clone();
let voice_channel = state.ui.voice_target.clone();
let net = state.net.clone();
tokio::spawn(async move {
if let Some(channel_id) = text_channel {
net.send(NetCommand::JoinChannel { channel_id }).await;
}
if let Some(channel_id) = voice_channel {
net.send(NetCommand::JoinChannel { channel_id }).await;
}
});
} else {
state.ui.seed_default_channels();
state.ui.active_channel = Some("general".into());
state.ui.status_msg = None;
let net = state.net.clone();
tokio::spawn(async move {
net.send(NetCommand::JoinChannel {
channel_id: "general".into(),
})
.await;
net.send(NetCommand::ChannelList).await;
net.send(NetCommand::GuildList).await;
net.send(NetCommand::FriendList).await;
net.send(NetCommand::BlockList).await;
});
}
}
@ -51,17 +54,22 @@ pub fn process_net_events(state: &mut AppState) {
state.ui.status_msg = Some(format!("connection lost: {reason}"));
} else {
state.ui.conn = ConnState::Disconnected;
state.ui.voice_target = None;
state.ui.showing_voice = false;
state.ui.clear_server_conversations();
state.ui.channels.clear();
state.ui.active_channel = None;
state.ui.user_names.clear();
state.ui.rtt_ms = None;
state.ui.status_msg = Some(format!("disconnected: {reason}"));
}
state.ui.dm_conversations.clear();
state.ui.dm_messages.clear();
state.ui.active_dm_id = None;
state.ui.new_dm_input = None;
state.ui.private_mode = false;
if !will_retry {
state.ui.dm_conversations.clear();
state.ui.dm_messages.clear();
state.ui.active_dm_id = None;
state.ui.new_dm_input = None;
state.ui.private_mode = false;
}
}
NetEvent::Reconnecting {
attempt,
@ -209,10 +217,27 @@ pub fn process_net_events(state: &mut AppState) {
}
event => process_net_event(&mut state.ui, &state.net, event),
}
sync_voice_audio(state);
flush_encoded_voice(state);
}
// Capture/playback runs independently from incoming control packets.
sync_voice_audio(state);
flush_encoded_voice(state);
if let Some(pipeline) = state.audio.as_ref() {
pipeline.sync_controls(vnox_client::audio::AudioSync {
mic_enabled: state.ui.mic_enabled && !state.ui.deafen,
vad_mode: state.ui.vad_mode,
vad_threshold: 40.0,
input_volume: 100.0,
ptt_held: state.ui.ptt_held,
output_volume: if state.ui.deafen {
0.0
} else {
state.ui.output_volume
},
jitter_size: 1,
adaptive_buffer: true,
voice_bitrate_kbps: state.ui.voice_bitrate,
noise_suppress: false,
});
state.ui.local_speaking = pipeline.local_speaking();
state.ui.remote_speaking = pipeline.remote_speaking(500);
} else {
@ -335,8 +360,14 @@ fn chat_handle(ui: &mut UiState, net: &NetHandle, event: NetEvent) {
members: mems,
});
}
if ui.active_channel.is_none() {
ui.active_channel = Some(channel_id.clone());
if kind == "voice" {
ui.voice_target = Some(channel_id.clone());
// A newly acknowledged join is also an explicit retry after an audio error.
if matches!(ui.voice, VoiceUiState::Error(_)) {
ui.voice = VoiceUiState::Off;
}
} else if ui.active_channel.is_none() && ui.active_dm_id.is_none() {
ui.select_text_channel(channel_id.clone());
}
let net = net.clone();
let ch_id = channel_id;
@ -370,6 +401,10 @@ fn chat_handle(ui: &mut UiState, net: &NetHandle, event: NetEvent) {
ui.active_channel = ui.channels.first().map(|c| c.id.clone());
}
ui.messages.remove(&channel_id);
if ui.voice_target.as_deref() == Some(&channel_id) {
ui.voice_target = None;
ui.showing_voice = false;
}
}
NetEvent::ChannelListEvent { channels } => {
let old: std::collections::HashMap<String, crate::ui::state::Channel> =
@ -393,6 +428,21 @@ fn chat_handle(ui: &mut UiState, net: &NetHandle, event: NetEvent) {
}
})
.collect();
if ui.active_channel.is_none()
&& ui.active_dm_id.is_none()
&& !ui.browsing_dms
&& let Some(id) = ui
.channels
.iter()
.find(|c| c.kind == "text")
.map(|c| c.id.clone())
{
ui.select_text_channel(id.clone());
let net = net.clone();
tokio::spawn(async move {
net.send(NetCommand::JoinChannel { channel_id: id }).await;
});
}
}
NetEvent::UserJoin {
channel_id,
@ -437,7 +487,7 @@ fn chat_handle(ui: &mut UiState, net: &NetHandle, event: NetEvent) {
}
ui.dm_messages
.insert(dm_id.clone(), messages.into_iter().map(into_msg).collect());
ui.active_dm_id = Some(dm_id);
ui.select_dm(dm_id);
}
NetEvent::ChatMessage {
message_id,
@ -729,6 +779,11 @@ pub fn pipeline_config(channel_id: &str, state: &AppState) -> PipelineConfig {
pub fn start_voice(state: &mut AppState, channel_id: &str) {
let cfg = pipeline_config(channel_id, state);
if matches!(state.ui.voice, VoiceUiState::Error(_))
&& state.last_pipeline_config.as_ref() == Some(&cfg)
{
return;
}
if state.voice_channel.as_deref() == Some(channel_id)
&& state.audio.is_some()
&& state.last_pipeline_config.as_ref() == Some(&cfg)
@ -753,7 +808,7 @@ pub fn start_voice(state: &mut AppState, channel_id: &str) {
Err(e) => {
tracing::warn!("audio start failed: {e}");
state.voice_channel = None;
state.last_pipeline_config = None;
state.last_pipeline_config = Some(cfg);
state.ui.voice = VoiceUiState::Error(e.to_string());
state.ui.status_msg = Some(format!("microphone error: {e}"));
}
@ -773,13 +828,7 @@ pub fn sync_voice_audio(state: &mut AppState) {
stop_voice(state);
return;
}
let active_voice = state
.ui
.active_channel
.as_ref()
.and_then(|id| state.ui.channels.iter().find(|c| &c.id == id))
.filter(|c| c.kind == "voice")
.map(|c| c.id.clone());
let active_voice = state.ui.voice_target.clone();
match active_voice {
Some(id) => start_voice(state, &id),
None => stop_voice(state),