From 14a55f7c85441424fa3c25275f3069fc9ac1963a Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 26 Sep 2026 15:09:37 +0000 Subject: [PATCH] wip: tsc-ui TSC_AUTOSHARE development switch Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01NJvYyRmTjKcb9i8eyYXK5G --- crates/tsc-ui/src/app.rs | 8 +++++++- crates/tsc-ui/src/streams.rs | 19 ++++++++++++++++++- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/crates/tsc-ui/src/app.rs b/crates/tsc-ui/src/app.rs index 1628efa..b2610ae 100644 --- a/crates/tsc-ui/src/app.rs +++ b/crates/tsc-ui/src/app.rs @@ -156,6 +156,8 @@ pub(crate) struct App { pub stream_volume: f32, /// `TSC_DEMO_STREAM`: the viewer shows a local test stream. pub demo: bool, + /// `TSC_AUTOSHARE=test-pattern`: share the test pattern once streams work. + pub autoshare: bool, /// The notices are in the About page's model. notices_loaded: bool, } @@ -197,7 +199,8 @@ pub fn run(options: RunOptions) -> Result<()> { // TSC_SCREENSHOT= saves the window after TSC_SCREENSHOT_DELAY seconds and exits, // TSC_DEMO_STREAM=1 shows a local test stream in the viewer, // TSC_OPEN=share|settings[:]|about opens that on start, TSC_AUTOWATCH=1 - // watches the first stream that shows up. + // watches the first stream that shows up, TSC_AUTOSHARE=test-pattern shares + // the test pattern (accepting everyone) once connected to a TeamSpeak 6 server. let dir: PathBuf = match (options.data_dir, std::env::var_os("TSC_DATA_DIR")) { (Some(dir), _) => dir, (None, Some(dir)) => dir.into(), @@ -268,6 +271,7 @@ pub fn run(options: RunOptions) -> Result<()> { watch: None, stream_volume: 100.0, demo, + autoshare: std::env::var("TSC_AUTOSHARE").is_ok_and(|v| v == "test-pattern"), notices_loaded: false, }; APP.with(|a| *a.borrow_mut() = Some(app)); @@ -839,6 +843,7 @@ impl App { self.refresh_servers(); self.refresh_toolbar(); self.refresh_streams(); + self.autoshare(); } Event::ServerInfo { session, name, flavor, capabilities } => { self.sessions.entry(session as i64).or_default().capabilities = capabilities; @@ -851,6 +856,7 @@ impl App { self.set_status(format!("Connected to {name} ({kind})")); } self.refresh_streams(); + self.autoshare(); } Event::Presence { session, presence } => { self.sessions.entry(session as i64).or_default().presence = presence; diff --git a/crates/tsc-ui/src/streams.rs b/crates/tsc-ui/src/streams.rs index b577692..34e8351 100644 --- a/crates/tsc-ui/src/streams.rs +++ b/crates/tsc-ui/src/streams.rs @@ -2,7 +2,7 @@ //! viewer. The engine runs the stream sessions; `video.rs` captures, //! encodes and decodes. -use slint::ComponentHandle; +use slint::{ComponentHandle, Model}; use tsc_core::stream::{EndReason, LeaveReason, StreamSetup, ViewerInfo, ViewerState}; use tsc_core::{Command, Event, StreamState, WatchState}; @@ -338,6 +338,23 @@ impl App { } } + /// Development switch `TSC_AUTOSHARE`: share the test pattern once. + pub(crate) fn autoshare(&mut self) { + if !self.autoshare || !self.view().is_some_and(|v| v.streams_available()) { + return; + } + self.autoshare = false; + let mut form = self.open_share(); + let Some(ui) = self.ui.upgrade() else { return }; + let sources = ui.global::().get_share_sources(); + let pattern = (0..sources.row_count()) + .find(|&i| sources.row_data(i).is_some_and(|s| s.name == "Test pattern")); + let Some(index) = pattern else { return }; + form.source = index as i32; + form.auto_accept = true; + self.start_share(form); + } + pub(crate) fn start_share(&mut self, form: ShareForm) { let Some(session) = self.current else { return }; if self.share_busy || self.share.is_some() {