feat(gui): forward --relay flag to host/viewer children
gui::run() dropped the parsed --relay value, so a relay chosen on the GUI command line (pixelpass --gui --relay URL) never reached the headless host/viewer children -- only the PIXELPASS_RELAY env-var form propagated (via inheritance). Thread the flag into the app and append --relay <url> to both child arg vectors. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
+18
-2
@@ -584,7 +584,11 @@ impl ApplicationHandler<UserEvent> for App {
|
||||
/// Launch the GUI. Blocks until the window is closed (or the tray Quit is
|
||||
/// chosen). Runs on the main thread, a winit requirement, which is where `main`
|
||||
/// calls it from.
|
||||
pub fn run() -> anyhow::Result<()> {
|
||||
/// `relay` is the parent's `--relay` flag (if any), forwarded to every child
|
||||
/// process so a relay chosen on the GUI command line reaches the headless
|
||||
/// host/viewer. (The `PIXELPASS_RELAY` env var is inherited regardless; this
|
||||
/// covers the flag form.)
|
||||
pub fn run(relay: Option<String>) -> anyhow::Result<()> {
|
||||
let event_loop = EventLoop::<UserEvent>::with_user_event()
|
||||
.build()
|
||||
.map_err(|e| anyhow::anyhow!("failed to build the event loop: {e}"))?;
|
||||
@@ -607,6 +611,7 @@ pub fn run() -> anyhow::Result<()> {
|
||||
tray,
|
||||
close_to_tray: gui_settings.close_to_tray,
|
||||
show_qr: gui_settings.show_qr,
|
||||
relay,
|
||||
waker,
|
||||
};
|
||||
let mut app = App {
|
||||
@@ -845,6 +850,9 @@ struct PixelPassApp {
|
||||
/// Persisted preference: render the QR-code panel on the host screen.
|
||||
/// Defaults to on; toggled in Settings.
|
||||
show_qr: bool,
|
||||
/// The parent's `--relay` flag, forwarded to host/viewer children so the
|
||||
/// flag form reaches them (env-var form is inherited automatically).
|
||||
relay: Option<String>,
|
||||
/// Wakes the winit loop when a spawned child emits/exits.
|
||||
waker: Waker,
|
||||
}
|
||||
@@ -1230,6 +1238,10 @@ impl PixelPassApp {
|
||||
if self.host.window {
|
||||
args.push("--window".to_string());
|
||||
}
|
||||
if let Some(relay) = &self.relay {
|
||||
args.push("--relay".to_string());
|
||||
args.push(relay.clone());
|
||||
}
|
||||
|
||||
match ChildProc::spawn(&args, self.waker.clone()) {
|
||||
Ok(p) => self.host.proc = Some(p),
|
||||
@@ -1503,7 +1515,11 @@ impl PixelPassApp {
|
||||
|
||||
let ticket = self.viewer.ticket_input.trim().to_string();
|
||||
self.viewer.connecting_to = ticket_endpoint_id(&ticket).map(|id| short_id(&id));
|
||||
let args = vec![ticket, "--output".to_string(), "json".to_string()];
|
||||
let mut args = vec![ticket, "--output".to_string(), "json".to_string()];
|
||||
if let Some(relay) = &self.relay {
|
||||
args.push("--relay".to_string());
|
||||
args.push(relay.clone());
|
||||
}
|
||||
match ChildProc::spawn(&args, self.waker.clone()) {
|
||||
Ok(p) => self.viewer.proc = Some(p),
|
||||
Err(e) => self.viewer.error = Some(format!("Couldn't connect: {e}")),
|
||||
|
||||
+1
-1
@@ -25,7 +25,7 @@ async fn main() -> Result<()> {
|
||||
if cli.gui {
|
||||
#[cfg(feature = "gui")]
|
||||
{
|
||||
return gui::run();
|
||||
return gui::run(cli.relay);
|
||||
}
|
||||
#[cfg(not(feature = "gui"))]
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user