lencx/ChatGPT · error
[view:ask] Failed to get webview window
Error message
[view:ask] Failed to get webview window
What it means
Panic from win.get_webview("ask") returning None in the Resized handler. The ask webview (the command palette overlay) is added via add_child(ask_view, ...) — first on non-macOS, last on macOS — and the resize handler unconditionally expects it. Any Resized event outside the lifetime of that webview (before its add_child, or during window destruction once children are dropped) returns None and the .expect() panics inside on_window_event.
Source
Thrown at src-tauri/src/core/setup.rs:196
};
win.on_window_event(move |event| {
let conf = &AppConf::load(&handle).unwrap();
let ask_mode_height = if conf.ask_mode { ASK_HEIGHT } else { 0.0 };
let ask_height = (scale_factor * ask_mode_height).round() as u32;
if let WindowEvent::Resized(size) = event {
let win = window_clone.lock().unwrap();
let main_view = win
.get_webview("main")
.expect("[view:main] Failed to get webview window");
let titlebar_view = win
.get_webview("titlebar")
.expect("[view:titlebar] Failed to get webview window");
let ask_view = win
.get_webview("ask")
.expect("[view:ask] Failed to get webview window");
#[cfg(target_os = "macos")]
{
set_view_properties(
&main_view,
LogicalPosition::new(0.0, TITLEBAR_HEIGHT),
PhysicalSize::new(
size.width,
size.height - (titlebar_height + ask_height),
),
);
set_view_properties(
&titlebar_view,
LogicalPosition::new(0.0, 0.0),
PhysicalSize::new(size.width, titlebar_height),
);
set_view_properties(
&ask_view,View on GitHub (pinned to a6de9a8b61)
Solutions
- Replace .expect() with let-else and return early from the handler
- Guard the whole block: only relayout when get_webview succeeds for main, titlebar, and ask together
- Register the event handler after all add_child calls in the platform cfg block
- Ignore events once WindowEvent::Destroyed/CloseRequested begins teardown
Example fix
// before
let ask_view = win
.get_webview("ask")
.expect("[view:ask] Failed to get webview window");
// after
if let (Some(main_view), Some(titlebar_view), Some(ask_view)) = (
win.get_webview("main"),
win.get_webview("titlebar"),
win.get_webview("ask"),
) {
// set_view_properties(...) calls here
} else {
eprintln!("[view:resize] one or more webviews missing; skipping");
} Defensive patterns
Strategy: type-guard
Validate before calling
// gate the whole relayout on the full view set
if let (Some(_main), Some(_titlebar), Some(_ask)) = (
win.get_webview("main"),
win.get_webview("titlebar"),
win.get_webview("ask"),
) {
// safe to relayout
} Type guard
fn webviews_attached(win: &tauri::Window) -> bool {
["main", "titlebar", "ask"].iter().all(|l| win.get_webview(l).is_some())
} Try / catch
if let (Some(main_view), Some(titlebar_view), Some(ask_view)) = (
win.get_webview("main"),
win.get_webview("titlebar"),
win.get_webview("ask"),
) {
// set_view_properties(...) calls
} else {
eprintln!("[view:resize] webviews missing; skipping");
} Prevention
- Make the resize handler idempotent and tolerant of partial view sets
- Defer handler registration until after the platform cfg block adds all children
- Skip relayout when size.width/height are 0 (minimized) to avoid degenerate layouts
When it happens
Trigger: A Resized event during startup before add_child(ask_view) registers the label; resize during teardown/close after child webviews are dropped; the ask webview's add_child .unwrap() failing earlier so the label never existed; WM-level resize storms (tiling, maximize on map).
Common situations: Same class as the main/titlebar lookups: lifecycle races between the async setup task and the main-thread event loop; also triggered when the ask-mode feature config (conf.ask_mode) changes expected heights while the view set is incomplete.
Related errors
- [view:main] Failed to get webview window
- [view:titlebar] Failed to get webview window
- [core:window] Failed to build window
- [core:window] Failed to get window size
- [view:download] Failed to get download directory
AI-assisted analysis of lencx/ChatGPT@a6de9a8b61 (2026-08-16).
Data as JSON: /api/errors/8633f5fad693d983.
Report an issue: GitHub.