voelin-ui: watch a streaming user's stream from the channel list

The user asked to click a user who streams in the channel list and join
their stream. Three ways now:

- The LIVE mark on a streaming user's row in the channel tree joins the
  stream at once (a button for screen readers too).
- Clicking the user opens their dialog as before; while they stream it
  offers "Watch <name>'s stream".
- The member card offers "Watch stream" too.

All go through `watch_client`: it watches the user's stream when it is
known, and otherwise (a stream that started before we joined or in
another channel, still being looked up) remembers the request and starts
watching as soon as `StreamsChanged` brings the stream.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
selikhovandClaude Opus 5.5 committed 2026-10-04 03:01:21 +03:00
1 parent 7975645e6a
commit b6f23827b3
9 files changed
+87 -2

No files matched your search

+4
View File
@@ -388,6 +388,9 @@ pub(crate) struct App {
pub share_error: String,
/// The stream in the viewer.
pub watch: Option<Watch>,
/// A client whose stream was asked for before it was known (session,
/// client): watched when the lookup brings it.
pub pending_watch: Option<(i64, u16)>,
/// Stream volume in percent, kept between streams.
pub stream_volume: f32,
/// `VOELIN_DEMO_STREAM`: the viewer shows a local test stream.
@@ -595,6 +598,7 @@ pub fn run(options: RunOptions) -> Result<()> {
share_busy: false,
share_error: String::new(),
watch: None,
pending_watch: None,
stream_volume: 100.0,
demo: switches.demo_stream,
demo_ui: switches.demo_ui,
+5
View File
@@ -22,6 +22,11 @@ pub(super) fn wire(ui: &MainWindow) {
bridge.on_watch_stream(|id| {
with_app(|app| app.watch_stream(id.to_string()));
});
bridge.on_watch_client(|client| {
if let Ok(client) = u16::try_from(client) {
with_app(|app| app.watch_client(client));
}
});
bridge.on_show_viewer(|| {
with_app(|app| app.show_viewer(true));
});
+5
View File
@@ -70,6 +70,7 @@ impl App {
volume: playback.volume * 100.0,
muted: playback.muted,
known: uid.is_some(),
streaming: client.streaming == Some(true),
})
})
.unwrap_or_default();
@@ -91,6 +92,10 @@ impl App {
self.open_member(-1);
}
}
"watch" => {
self.open_member(-1);
self.watch_client(client_id);
}
"poke" => {
self.command(|session| Command::Poke {
session,
+1
View File
@@ -207,6 +207,7 @@ impl App {
name: info.nickname.into(),
volume: playback.volume * 100.0,
muted: playback.muted,
streaming: info.streaming == Some(true),
});
}
true
+31 -1
View File
@@ -179,10 +179,19 @@ impl App {
.iter()
.find(|s| view.state.own_client != Some(s.streamer.0))
.map(|s| s.id.clone());
// A client whose stream was asked for while it was looked up.
let pending = self
.pending_watch
.filter(|(s, _)| *s == session as i64)
.and_then(|(_, client)| streams.iter().find(|s| s.streamer.0 == client))
.map(|s| s.id.clone());
view.streams = streams;
self.refresh_streams();
self.refresh_servers();
if autowatch && let Some(id) = first {
if let Some(id) = pending {
self.pending_watch = None;
self.watch_stream(id);
} else if autowatch && let Some(id) = first {
self.watch_stream(id);
}
}
@@ -763,6 +772,27 @@ impl App {
self.refresh_tree();
}
/// Watch the stream of `client` (a click on a streaming user in the
/// channel tree or the members): at once if it is known, else as soon as
/// the lookup brings it (it may have started in another channel or
/// before we joined).
pub(crate) fn watch_client(&mut self, client: u16) {
let Some(session) = self.current else { return };
let Some(view) = self.sessions.get(&session) else { return };
if view.state.own_client == Some(client) {
return;
}
if let Some(id) = view.streams.iter().find(|s| s.streamer.0 == client).map(|s| s.id.clone())
{
self.pending_watch = None;
self.watch_stream(id);
} else if view.presence.clients.get(&client).is_some_and(|c| c.streaming == Some(true)) {
let name = view.nickname(client);
self.pending_watch = Some((session, client));
self.set_status(format!("Looking up {name}'s stream…"));
}
}
/// `VOELIN_OPEN=watch`: watch the first stream of our channel.
pub(crate) fn watch_first_stream(&mut self) {
let Some(id) = self.view().and_then(|v| {
+7
View File
@@ -105,6 +105,8 @@ export struct MemberCard {
muted: bool,
// The client has a unique id, so contacts and private chats work.
known: bool,
// The client streams: the card offers to watch it.
streaming: bool,
}
export struct ChatTab {
@@ -299,6 +301,8 @@ export struct ClientAudio {
name: string,
volume: float,
muted: bool,
// The client streams: the dialog offers to watch it.
streaming: bool,
}
// The appearance settings (`ui.*` keys).
@@ -489,6 +493,9 @@ export global Bridge {
callback respond-viewer(int, bool);
callback kick-viewer(int);
callback watch-stream(string);
// Watch the stream of a client (a streaming user in the tree or the
// members), as soon as it is known.
callback watch-client(int);
callback show-viewer();
callback hide-viewer();
callback leave-stream();
+18 -1
View File
@@ -226,9 +226,26 @@ component TreeRow inherits Rectangle {
alignment: center;
SpeakingBars { }
}
// A click on someone's LIVE mark watches their stream.
if item.streaming: VerticalLayout {
alignment: center;
LiveBadge { }
LiveBadge {
accessible-role: AccessibleRole.button;
accessible-label: item.myself ? @tr("Your stream") : @tr("Watch {}'s stream", item.name);
accessible-action-default => {
if !item.myself {
Bridge.watch-client(item.id);
}
}
TouchArea {
mouse-cursor: item.myself ? MouseCursor.default : MouseCursor.pointer;
clicked => {
if !item.myself {
Bridge.watch-client(item.id);
}
}
}
}
}
if item.local-muted: Icon {
source: Icons.volume-x;
@@ -499,6 +499,15 @@ export component ClientAudioDialog inherits Modal {
Bridge.client-audio-changed(Bridge.client-audio);
}
}
if Bridge.client-audio.streaming: Button {
kind: ButtonKind.primary;
icon: Icons.monitor;
text: @tr("Watch {}'s stream", Bridge.client-audio.name);
clicked => {
Bridge.watch-client(Bridge.client-audio.id);
done();
}
}
Rectangle { vertical-stretch: 1; }
Footer {
Button {
@@ -308,6 +308,13 @@ export component MemberCardPopup inherits Rectangle {
}
}
Divider { }
if Bridge.member-card.streaming: Button {
small: true;
kind: ButtonKind.primary;
icon: Icons.monitor;
text: @tr("Watch stream");
clicked => { Bridge.member-action("watch"); }
}
HorizontalLayout {
spacing: Theme.space-2;
Button {