moving
This commit is contained in:
@@ -59,6 +59,52 @@ pub fn run() {
|
||||
commands::onboarding::reset_first_launch,
|
||||
])
|
||||
.setup(|app| {
|
||||
// Create the configured window here so the Windows certifier can
|
||||
// opt into a loopback-only WebView CDP port without shipping
|
||||
// remote debugging enabled for normal launches.
|
||||
let main_window_config = app
|
||||
.config()
|
||||
.app
|
||||
.windows
|
||||
.iter()
|
||||
.find(|window| window.label == "main")
|
||||
.cloned()
|
||||
.ok_or_else(|| {
|
||||
std::io::Error::new(
|
||||
std::io::ErrorKind::NotFound,
|
||||
"configured main window is missing",
|
||||
)
|
||||
})?;
|
||||
let mut main_window = tauri::WebviewWindowBuilder::from_config(
|
||||
app.handle(),
|
||||
&main_window_config,
|
||||
)?;
|
||||
#[cfg(windows)]
|
||||
if let Some(raw_port) = std::env::var_os("WAGGLE_CERTIFIER_WEBVIEW_DEBUG_PORT") {
|
||||
let raw_port = raw_port.to_string_lossy();
|
||||
let port = raw_port.parse::<u16>().map_err(|_| {
|
||||
std::io::Error::new(
|
||||
std::io::ErrorKind::InvalidInput,
|
||||
"WAGGLE_CERTIFIER_WEBVIEW_DEBUG_PORT must be an integer",
|
||||
)
|
||||
})?;
|
||||
if port < 1024 {
|
||||
return Err(std::io::Error::new(
|
||||
std::io::ErrorKind::InvalidInput,
|
||||
"WAGGLE_CERTIFIER_WEBVIEW_DEBUG_PORT must be >= 1024",
|
||||
)
|
||||
.into());
|
||||
}
|
||||
let browser_args = format!(
|
||||
"--disable-features=msWebOOUI,msPdfOOUI,msSmartScreenProtection --remote-debugging-port={port}"
|
||||
);
|
||||
main_window = main_window.additional_browser_args(&browser_args);
|
||||
eprintln!(
|
||||
"[waggle] WebView certifier debug endpoint enabled on 127.0.0.1:{port}"
|
||||
);
|
||||
}
|
||||
main_window.build()?;
|
||||
|
||||
tray::setup_tray(app.handle())?;
|
||||
|
||||
// Register global hotkey: Ctrl+Shift+W to toggle window visibility
|
||||
@@ -90,18 +136,17 @@ pub fn run() {
|
||||
);
|
||||
}
|
||||
|
||||
// Auto-start the sidecar service before the webview loads so the
|
||||
// React app finds it already healthy on localhost:3333.
|
||||
// Auto-start an owned sidecar launch before the webview loads.
|
||||
// Its verified endpoint may differ from the preferred port.
|
||||
let service_state = app.state::<ServiceState>();
|
||||
let port = service_state.port;
|
||||
match service::spawn_service_sync(port, &service_state.process) {
|
||||
Ok(()) => eprintln!("[waggle] Sidecar spawn initiated on port {}", port),
|
||||
match service::spawn_service_sync(&service_state) {
|
||||
Ok(()) => eprintln!("[waggle] Owned sidecar spawn initiated"),
|
||||
Err(e) => eprintln!("[waggle] Failed to auto-start sidecar: {}", e),
|
||||
}
|
||||
|
||||
// Start service watchdog
|
||||
let app_handle_watchdog = app.handle().clone();
|
||||
service::start_watchdog(app_handle_watchdog, port);
|
||||
service::start_watchdog(app_handle_watchdog);
|
||||
|
||||
Ok(())
|
||||
})
|
||||
@@ -115,15 +160,10 @@ pub fn run() {
|
||||
.build(tauri::generate_context!())
|
||||
.expect("error while building tauri application")
|
||||
.run(|app_handle, event| {
|
||||
// R7-002: kill the sidecar on app exit so it doesn't orphan and hold port 3333.
|
||||
// R7-002: kill only the owned sidecar launch on app exit.
|
||||
if let tauri::RunEvent::Exit = event {
|
||||
if let Some(state) = app_handle.try_state::<ServiceState>() {
|
||||
if let Ok(mut proc) = state.process.lock() {
|
||||
if let Some(mut child) = proc.take() {
|
||||
let _ = child.kill();
|
||||
let _ = child.wait();
|
||||
}
|
||||
}
|
||||
let _ = service::stop_service_sync(&state);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user