libnyanpasu/clash-nyanpasu · error · anyhow::Error
failed to get zoom button
Error message
failed to get zoom button
What it means
During set_window_controls_pos, standardWindowButton(NSWindowButton::ZoomButton) returned None, so the code raises this error. AppKit could not supply the zoom (maximize) button for the window, which the function needs to compute the title bar layout.
Source
Thrown at backend/tauri/src/utils/resolve.rs:79
}
#[cfg(target_os = "macos")]
fn set_window_controls_pos(
window: objc2::rc::Retained<objc2_app_kit::NSWindow>,
x: f64,
y: f64,
) -> anyhow::Result<()> {
use objc2_app_kit::NSWindowButton;
use objc2_foundation::NSRect;
let close = window
.standardWindowButton(NSWindowButton::CloseButton)
.ok_or(anyhow::anyhow!("failed to get close button"))?;
let miniaturize = window
.standardWindowButton(NSWindowButton::MiniaturizeButton)
.ok_or(anyhow::anyhow!("failed to get miniaturize button"))?;
let zoom = window
.standardWindowButton(NSWindowButton::ZoomButton)
.ok_or(anyhow::anyhow!("failed to get zoom button"))?;
let title_bar_container_view = unsafe {
close
.superview()
.and_then(|view| view.superview())
.ok_or(anyhow::anyhow!("failed to get title bar container view"))?
};
let close_rect = close.frame();
let button_height = close_rect.size.height;
let title_bar_frame_height = button_height + y;
let mut title_bar_rect = title_bar_container_view.frame();
title_bar_rect.size.height = title_bar_frame_height;
title_bar_rect.origin.y = window.frame().size.height - title_bar_frame_height;
unsafe {
title_bar_container_view.setFrame(title_bar_rect);
}View on GitHub (pinned to f7dbce2997)
Solutions
- Verify the window style mask allows a zoom button before calling
- Call the function after the window is shown
- Skip repositioning (log warn) when the button is intentionally hidden
- Treat the buttons as optional and reposition whichever exist
Example fix
// before
let zoom = window
.standardWindowButton(NSWindowButton::ZoomButton)
.ok_or(anyhow::anyhow!("failed to get zoom button"))?;
// after: optional zoom button
if let Some(zoom) = window.standardWindowButton(NSWindowButton::ZoomButton) {
// position zoom
} Defensive patterns
Strategy: fallback
Validate before calling
if window.standardWindowButton(NSWindowButton::ZoomButton).is_none() {
log::warn!("zoom button unavailable; skip reposition");
return Ok(());
} Try / catch
if let Err(e) = set_window_controls_pos(&win, x, y).await {
log::warn!("zoom button reposition failed: {e:#}");
} Prevention
- Verify the style mask allows a zoom button before repositioning
- Treat individual buttons as optional in custom titlebar layouts
- Test on each supported macOS version since button availability can vary
When it happens
Trigger: Calling set_window_controls_pos on a window whose zoom button is absent — style mask lacking NSWindowStyleMask::Resizable/FullSizeContentView customization, or buttons hidden/removed before the call.
Common situations: Windows created without a maximize button; custom titlebar configs; calls made before window realization; fullscreen-only or utility-style windows.
Understand the failure class
Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.
Related errors
- failed to get close button
- failed to get miniaturize button
- failed to get close button
- failed to get miniaturize button
- failed to get zoom button
AI-assisted analysis of libnyanpasu/clash-nyanpasu@f7dbce2997 (2026-09-08).
Data as JSON: /api/errors/75d5769b788a878c.
Report an issue: GitHub.