diff --git a/crates/client/src/gui/camera_view.rs b/crates/client/src/gui/camera_view.rs index 2814999..a75998e 100644 --- a/crates/client/src/gui/camera_view.rs +++ b/crates/client/src/gui/camera_view.rs @@ -2,8 +2,9 @@ use common::model::Id; use common::share::{Fps, Kind, Quality, Resolution}; use gpui_kit::{ - AnyElement, AppContext as _, Context, Entity, InteractiveElement, IntoElement, ParentElement, - StatefulInteractiveElement, Styled, Task, Window, component::Icon, div, px, + AnyElement, AppContext as _, Context, Div, Entity, FontWeight, InteractiveElement, IntoElement, + ParentElement, StatefulInteractiveElement, Styled, Task, Window, assets::IconName, + component::Icon, div, px, }; use super::{ @@ -13,6 +14,7 @@ use super::{ share_view::{self, FRAME_TICK}, surface::Surface, text, + wave::mini_wave, widget::spawn_warn, }; use crate::share::session::WatchQuality; @@ -214,9 +216,10 @@ impl Yumush { .id("stage_strip") .flex() .flex_shrink_0() - .h(px(108.)) - .gap(px(6.)) - .p(px(6.)) + .h(px(206.)) + .gap(px(8.)) + .p(px(8.)) + .bg(palette.window) .overflow_x_scroll() .border_b_1() .border_color(palette.border) @@ -266,6 +269,7 @@ impl Yumush { .flex_1() .min_h_0() .p(px(8.)) + .bg(palette.window) .flex() .flex_col() .gap(px(8.)) @@ -312,7 +316,6 @@ fn stage_tile( .filter(|tile| tile.shown) .map(|tile| tile.surface.clone()); let user = yumush.chat.author(user_id); - let name = user.map_or("Someone", |user| user.username.as_str()); let content = match (surface, user) { (Some(surface), _) => surface.into_any_element(), (None, Some(user)) => div() @@ -323,8 +326,8 @@ fn stage_tile( .child(avatar( palette, user, - px(36.), - text(14.), + px(56.), + text(20.), &yumush.chat.avatars, )) .into_any_element(), @@ -343,9 +346,9 @@ fn stage_tile( .tip("Watch") .relative() .flex_shrink_0() - .w(px(171.)) - .h(px(96.)) - .rounded(px(8.)) + .w(px(338.)) + .h(px(190.)) + .rounded(px(10.)) .overflow_hidden() .bg(gpui_kit::black()) .border_2() @@ -358,20 +361,10 @@ fn stage_tile( }) .child(content) .child( - div() + tile_label(yumush, palette, (user_id, kind)) .absolute() - .left(px(6.)) - .bottom(px(6.)) - .px(px(6.)) - .py(px(2.)) - .rounded(px(4.)) - .bg(palette.panel) - .text_size(text(11.)) - .flex() - .items_center() - .gap(px(4.)) - .child(Icon::new(share_view::kind_icon(kind)).w(px(12.)).h(px(12.))) - .child(name.to_string()), + .left(px(8.)) + .bottom(px(8.)), ) } @@ -390,7 +383,6 @@ fn grid_cell( .map(|tile| tile.surface.clone()); let speaking = yumush.chat.waves.speaking.contains(&user_id); let user = yumush.chat.author(user_id); - let name = user.map_or("Someone", |user| user.username.as_str()); let content = match (surface, user) { (Some(surface), _) => surface.into_any_element(), (None, Some(user)) => div() @@ -426,23 +418,10 @@ fn grid_cell( }) .child(content) .child( - div() + tile_label(yumush, palette, (user_id, kind)) .absolute() - .left(px(6.)) - .bottom(px(6.)) - .px(px(6.)) - .py(px(2.)) - .rounded(px(4.)) - .bg(palette.panel) - .text_size(text(11.)) - .flex() - .items_center() - .gap(px(4.)) - .children( - (kind == Kind::Screen) - .then(|| Icon::new(share_view::kind_icon(kind)).w(px(12.)).h(px(12.))), - ) - .child(name.to_string()), + .left(px(8.)) + .bottom(px(8.)), ); if shared { @@ -458,3 +437,57 @@ fn grid_cell( cell.into_any_element() } } + +pub(super) fn tile_label(yumush: &Yumush, palette: Palette, (user_id, kind): (Id, Kind)) -> Div { + let tone = match kind { + Kind::Screen => palette.screen, + Kind::Camera => palette.camera, + }; + let name = yumush + .chat + .author(user_id) + .map_or("Someone", |user| user.username.as_str()); + let wave = yumush + .chat + .waves + .speaking + .contains(&user_id) + .then(|| yumush.chat.waves.voice(user_id)) + .flatten(); + let shared = yumush + .chat + .voice_community() + .and_then(|community_id| yumush.chat.share_of(community_id, user_id, kind)) + .is_some(); + let muted = yumush.chat.server_muted.contains(&user_id) + || (yumush.is_me(user_id) && yumush.chat.voice_flags().is_some_and(|(muted, _)| muted)); + + div() + .h(px(24.)) + .px(px(8.)) + .rounded(px(12.)) + .bg(gpui_kit::black().opacity(0.72)) + .flex() + .items_center() + .gap(px(6.)) + .text_size(text(12.)) + .children(shared.then(|| { + Icon::new(share_view::kind_icon(kind)) + .w(px(13.)) + .h(px(13.)) + .text_color(tone) + })) + .child( + div() + .font_weight(FontWeight::SEMIBOLD) + .text_color(palette.tinted(user_id)) + .child(name.to_string()), + ) + .children(wave.map(|history| mini_wave(history, 10., palette.ok))) + .children((muted && wave.is_none()).then(|| { + Icon::new(IconName::MicOff) + .w(px(12.)) + .h(px(12.)) + .text_color(palette.danger) + })) +} diff --git a/crates/client/src/gui/chat.rs b/crates/client/src/gui/chat.rs index a60228e..bf472b7 100644 --- a/crates/client/src/gui/chat.rs +++ b/crates/client/src/gui/chat.rs @@ -3053,12 +3053,12 @@ fn stage_button( }), ) .tip(if active { "Hide" } else { name }) - .size(px(22.)) + .size(px(26.)) .flex() .items_center() .justify_center() - .rounded(px(4.)) - .when(active, |this| this.bg(palette.hover)) + .rounded(px(6.)) + .when(active, |this| this.bg(palette.accent.opacity(0.13))) .text_color(if active { palette.accent } else { diff --git a/crates/client/src/gui/share_view.rs b/crates/client/src/gui/share_view.rs index e7eb8c2..685684b 100644 --- a/crates/client/src/gui/share_view.rs +++ b/crates/client/src/gui/share_view.rs @@ -461,10 +461,35 @@ impl Yumush { (IconName::Maximize, "Fullscreen") }; let audio = viewer.kind == Kind::Screen; - let name = self + let tone = match viewer.kind { + Kind::Screen => palette.screen, + Kind::Camera => palette.camera, + }; + let hud = self .chat - .author(viewer.user_id) - .map_or("Someone", |user| user.username.as_str()); + .share_sample + .watching + .iter() + .find(|(user_id, kind, _)| *user_id == viewer.user_id && *kind == viewer.kind) + .map(|(_, _, stats)| { + let quality = stats.layer.as_ref().map_or("…".to_string(), |layer| { + format!( + "{}p{}", + layer.quality.resolution.height(), + layer.quality.fps.value() + ) + }); + let loss = if stats.loss * 100. > 0.5 { + format!(" · {:.1}% loss", stats.loss * 100.) + } else { + String::new() + }; + format!( + "{quality} · {:.1} Mb · {:.0} fps{loss}", + stats.kbps as f32 / 1000., + stats.fps + ) + }); div() .flex_1() @@ -483,63 +508,87 @@ impl Yumush { }) .when(viewer.shown, |video| video.child(viewer.surface.clone())), ) + .child( + camera_view::tile_label(self, palette, (viewer.user_id, viewer.kind)) + .absolute() + .left(px(10.)) + .top(px(10.)), + ) + .children(hud.map(|hud| { + div() + .absolute() + .right(px(10.)) + .top(px(10.)) + .h(px(24.)) + .px(px(8.)) + .flex() + .items_center() + .rounded(px(12.)) + .bg(gpui_kit::black().opacity(0.72)) + .text_size(text(11.)) + .text_color(tone) + .child(hud) + })) .child( div() .absolute() .left_0() .right_0() - .bottom_0() - .h(px(44.)) - .on_mouse_up(MouseButton::Left, |_, _, cx| cx.stop_propagation()) - .px(px(12.)) + .bottom(px(12.)) .flex() - .items_center() - .gap(px(8.)) - .bg(gpui_kit::black().opacity(0.55)) + .justify_center() + .on_mouse_up(MouseButton::Left, |_, _, cx| cx.stop_propagation()) .opacity(0.) .group_hover("viewer", |style| style.opacity(1.)) - .text_size(text(12.)) - .text_color(palette.text) - .child(Icon::new(kind_icon(viewer.kind)).w(px(14.)).h(px(14.))) - .child(name.to_string()) - .child(div().flex_1()) - .children(audio.then(|| { - let muted = self.settings.share.volume == 0.; - icon_button( - format!("share_mute_{muted}"), - palette, - if muted { - IconName::VolumeX - } else { - IconName::Volume2 - }, - if muted { "Unmute" } else { "Mute" }, - entity_action(entity, |yumush, window, cx| { - yumush.toggle_share_mute(window, cx) - }), - ) - })) - .children(audio.then(|| { - div().w(px(80.)).child( - Slider::new(&viewer.volume) - .bg(palette.accent) - .text_color(palette.text), - ) - })) - .child(icon_button( - format!("share_fullscreen_{}", viewer.fullscreen), - palette, - fullscreen_icon, - fullscreen_tip, - entity_action(entity, |yumush, _, cx| yumush.toggle_fullscreen(cx)), - )) - .child(icon_button( - "share_close".to_string(), - palette, - IconName::X, - "Close", - entity_action(entity, |yumush, _, cx| yumush.close_viewer(cx)), - )), + .child( + div() + .h(px(38.)) + .px(px(4.)) + .flex() + .items_center() + .gap(px(4.)) + .rounded(px(10.)) + .bg(gpui_kit::black().opacity(0.85)) + .border_1() + .border_color(palette.border) + .children(audio.then(|| { + let muted = self.settings.share.volume == 0.; + icon_button( + format!("share_mute_{muted}"), + palette, + if muted { + IconName::VolumeX + } else { + IconName::Volume2 + }, + if muted { "Unmute" } else { "Mute" }, + entity_action(entity, |yumush, window, cx| { + yumush.toggle_share_mute(window, cx) + }), + ) + })) + .children(audio.then(|| { + div().w(px(80.)).child( + Slider::new(&viewer.volume) + .bg(palette.screen) + .text_color(palette.text), + ) + })) + .child(icon_button( + format!("share_fullscreen_{}", viewer.fullscreen), + palette, + fullscreen_icon, + fullscreen_tip, + entity_action(entity, |yumush, _, cx| yumush.toggle_fullscreen(cx)), + )) + .child(icon_button( + "share_close".to_string(), + palette, + IconName::X, + "Close", + entity_action(entity, |yumush, _, cx| yumush.close_viewer(cx)), + )), + ), ) } } diff --git a/harness/usage.sh b/harness/usage.sh new file mode 100755 index 0000000..4bc0a2f --- /dev/null +++ b/harness/usage.sh @@ -0,0 +1,15 @@ +#!/usr/bin/env bash +set -euo pipefail +STATE="${HARNESS_STATE:-/tmp/claude-1000/yumush-harness}" +NAME="${1:-alice}" +SPAN="${SPAN:-10}" +PID=$(awk -v n="$NAME" '$1 == n {print $2}' "$STATE/pids" | tail -1) +ticks() { awk '{print $14 + $15}' "/proc/$PID/stat"; } +engine() { cat /proc/"$PID"/fdinfo/* 2>/dev/null | awk -v e="drm-engine-$1:" '$1 == e {s += $2} END {print s + 0}'; } +memory() { cat /proc/"$PID"/fdinfo/* 2>/dev/null | awk -v m="drm-memory-$1:" '$1 == m {s += $2} END {print s + 0}'; } +kib() { awk -v k="$1:" '$1 == k {print $2}' "/proc/$PID/smaps_rollup"; } +t=$(ticks); g=$(engine gfx); e=$(engine enc); d=$(engine dec) +sleep "$SPAN" +T=$(ticks); G=$(engine gfx); E=$(engine enc); D=$(engine dec) +pct() { awk -v a="$1" -v b="$2" -v s="$SPAN" "BEGIN {printf \"%.1f\", (b - a) / s / $3}"; } +echo "$NAME cpu $(pct "$t" "$T" 1)% gfx $(pct "$g" "$G" 1e7)% enc $(pct "$e" "$E" 1e7)% dec $(pct "$d" "$D" 1e7)% pss $(( $(kib Pss) / 1024 ))M rss $(( $(kib Rss) / 1024 ))M vram $(( $(memory vram) / 1024 ))M gtt $(( $(memory gtt) / 1024 ))M threads $(awk '/^Threads/ {print $2}' "/proc/$PID/status") disk $(du -sh "$STATE/clients/$NAME" | cut -f1)"