fix: unify PiP window creation through single frontend code path

Rust global shortcuts (Ctrl+1-5) now emit a pip:open event instead of
creating windows directly, so geometry restore, loading spinner and
state tracking all work regardless of how the PiP is opened.
This commit is contained in:
2026-02-24 15:32:55 -06:00
parent 78978813cd
commit 4cb0760c50
2 changed files with 13 additions and 18 deletions

View File

@@ -1,7 +1,7 @@
use tauri::{
menu::{Menu, MenuItem},
tray::{MouseButton, MouseButtonState, TrayIconBuilder, TrayIconEvent},
Manager, WebviewWindowBuilder, WindowEvent,
Emitter, Manager, WindowEvent,
};
use tauri_plugin_global_shortcut::{Code, GlobalShortcutExt, Modifiers, Shortcut, ShortcutState};
@@ -22,23 +22,8 @@ fn open_pip_terminal(app: &tauri::AppHandle, idx: u8) {
return;
}
// Create new PiP window — the page itself handles terminal connection or showing "new session" modal
let url = format!("/transcript-debug/{}?pip=1", idx);
let x = 1520.0_f64; // sensible default, will be near right edge on 1920px screens
let y = 60.0 + (idx as f64 - 1.0) * 40.0;
let _ = WebviewWindowBuilder::new(
app,
&label,
tauri::WebviewUrl::App(url.into()),
)
.title(&format!("T{} - Agent UI", idx))
.inner_size(380.0, 620.0)
.position(x, y)
.decorations(false)
.resizable(true)
.focused(true)
.build();
// Delegate creation to frontend (handles geometry restore, loading spinner, state tracking)
let _ = app.emit("pip:open", idx);
}
#[cfg_attr(mobile, tauri::mobile_entry_point)]