interactive: Host/View entry menu, clipboard copy, player picker

Bare `pixelpass` now opens a dialoguer-driven Host/View menu instead of
going straight to host mode. Host path copies the ticket to the system
clipboard via arboard with silent print-only fallback. View path
prompts for the ticket, then after the local listener binds prompts
mpv-vs-VLC and spawns it detached (setsid + null stdio) so the player
survives pixelpass exiting.

Headless invocations (`pixelpass <ticket>`, `pixelpass --repair`)
unchanged. Per spec at ~/Documents/pixelpass-interactive-mode-spec.md.
This commit is contained in:
2026-05-18 15:46:57 -04:00
parent 4cab9f6b20
commit bb437a73cf
9 changed files with 410 additions and 15 deletions
+22 -4
View File
@@ -1,4 +1,4 @@
use anyhow::Result;
use anyhow::{Context, Result};
use iroh::Endpoint;
use iroh::endpoint::presets;
use iroh_tickets::endpoint::EndpointTicket;
@@ -22,7 +22,17 @@ pub async fn run(ticket: EndpointTicket, opts: ViewerOpts) -> Result<()> {
let listener = TcpListener::bind(("127.0.0.1", opts.port)).await?;
let port = listener.local_addr()?.port();
print_viewer_banner(port);
let url = format!("http://127.0.0.1:{port}");
if opts.interactive {
let player = crate::interactive::prompt_player()?;
player
.spawn(&url)
.with_context(|| "failed to launch player")?;
print_viewer_banner_interactive();
} else {
print_viewer_banner(&url);
}
let result = tokio::select! {
accepted = listener.accept() => {
@@ -40,8 +50,7 @@ pub async fn run(ticket: EndpointTicket, opts: ViewerOpts) -> Result<()> {
result
}
fn print_viewer_banner(port: u16) {
let url = format!("http://127.0.0.1:{port}");
fn print_viewer_banner(url: &str) {
eprintln!();
eprintln!("┌─ PixelPass · viewer ───────────────────────────────────────");
eprintln!("│ Connected to host. Open the stream in your player:");
@@ -55,3 +64,12 @@ fn print_viewer_banner(port: u16) {
eprintln!("└────────────────────────────────────────────────────────────");
eprintln!();
}
fn print_viewer_banner_interactive() {
eprintln!();
eprintln!("┌─ PixelPass · viewer ───────────────────────────────────────");
eprintln!("│ Player launched. Close it (or press Ctrl+C here) to");
eprintln!("│ disconnect.");
eprintln!("└────────────────────────────────────────────────────────────");
eprintln!();
}