From b5e3acbb720bc02bebdf6b1beb30727b671e3c06 Mon Sep 17 00:00:00 2001 From: YokiiroBW Date: Mon, 27 Jul 2026 04:25:37 +0800 Subject: [PATCH] feat(pet): log where the floating pet window actually ended up The floating pet still does not appear, and the two explanations offered so far are not sufficient. The rebuild path genuinely never called show(), which is fixed and correct on its own reading of the code, but it did not resolve the symptom. A missing Suspense boundary around the lazy pet view looked like a second cause and is not one: removing the wrapper still renders the pet, so React 19 tolerates it. That claim is retracted in the comment rather than left standing. The window is transparent and undecorated, so "did not appear" covers a window placed off-screen, a window that reports hidden, and a window present with nothing painted in it. Log the monitor work area, the position and size after placement, and the visibility the window reports, at default level so no filter is needed to read it. The Suspense wrapper stays. Relying on React tolerating a lazy component with no boundary is not a contract, and the bubble and quick views already have their own. Refs: N-11, F-61. Co-Authored-By: Claude Opus 5 --- src-tauri/src/lib.rs | 26 ++++++++++++++++++++++++-- src/App.tsx | 13 ++++++++++++- 2 files changed, 36 insertions(+), 3 deletions(-) diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs index 238e8b9..98d689a 100644 --- a/src-tauri/src/lib.rs +++ b/src-tauri/src/lib.rs @@ -334,10 +334,32 @@ fn reveal_pet_window(app: &AppHandle, window: &tauri::WebviewWindow) -> Result<( window .set_always_on_top(true) .map_err(|error| error.to_string())?; - if let Some(monitor) = available_monitor_info(app)?.first() { + let monitors = available_monitor_info(app)?; + if let Some(monitor) = monitors.first() { place_pet_on_monitor(window, monitor, pet::PetPositionMode::Edge)?; } - window.show().map_err(|error| error.to_string()) + window.show().map_err(|error| error.to_string())?; + + // At default level on purpose. The window is transparent and undecorated, + // so "it did not appear" covers a window placed off-screen, a window that + // reports hidden, and a window that is there with nothing painted in it. + // Only the first two are visible from here, and they need no log filter to + // be worth reading. + let position = window.outer_position().ok(); + let size = window.outer_size().ok(); + tracing::info!( + target: "astrbot::pet", + monitors = monitors.len(), + monitor_work_area = monitors.first().map(|m| format!( + "{}x{}+{}+{}", + m.work_width, m.work_height, m.work_left, m.work_top + )).unwrap_or_else(|| "".into()).as_str(), + position = position.map(|p| format!("{},{}", p.x, p.y)).unwrap_or_else(|| "".into()).as_str(), + size = size.map(|s| format!("{}x{}", s.width, s.height)).unwrap_or_else(|| "".into()).as_str(), + visible = window.is_visible().unwrap_or(false), + "pet window revealed" + ); + Ok(()) } #[tauri::command] diff --git a/src/App.tsx b/src/App.tsx index a8d68e9..6605baf 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -130,7 +130,18 @@ export function App() { }, [isBubbleView, isPetView, isQuickView, petDisplayMode]); if (isBubbleView) return ; - if (isPetView) return ; + // `DesktopPetView` is lazy and this branch returns before the shell's own + // boundary, so it had none. React 19 turned out to tolerate that — removing + // this wrapper still rendered the pet — so it is not the reason the floating + // pet does not appear. Kept because relying on that tolerance is not a + // contract, and the bubble and quick views already have their own. + if (isPetView) { + return ( + + + + ); + } if (isQuickView) { return (