{"record":{"id":"75d5769b788a878c","repo":"libnyanpasu/clash-nyanpasu","slug":"failed-to-get-zoom-button","errorCode":null,"errorMessage":"failed to get zoom button","messagePattern":"failed to get zoom button","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"backend/tauri/src/utils/resolve.rs","lineNumber":79,"sourceCode":"}\n\n#[cfg(target_os = \"macos\")]\nfn set_window_controls_pos(\n    window: objc2::rc::Retained<objc2_app_kit::NSWindow>,\n    x: f64,\n    y: f64,\n) -> anyhow::Result<()> {\n    use objc2_app_kit::NSWindowButton;\n    use objc2_foundation::NSRect;\n    let close = window\n        .standardWindowButton(NSWindowButton::CloseButton)\n        .ok_or(anyhow::anyhow!(\"failed to get close button\"))?;\n    let miniaturize = window\n        .standardWindowButton(NSWindowButton::MiniaturizeButton)\n        .ok_or(anyhow::anyhow!(\"failed to get miniaturize button\"))?;\n    let zoom = window\n        .standardWindowButton(NSWindowButton::ZoomButton)\n        .ok_or(anyhow::anyhow!(\"failed to get zoom button\"))?;\n\n    let title_bar_container_view = unsafe {\n        close\n            .superview()\n            .and_then(|view| view.superview())\n            .ok_or(anyhow::anyhow!(\"failed to get title bar container view\"))?\n    };\n\n    let close_rect = close.frame();\n    let button_height = close_rect.size.height;\n\n    let title_bar_frame_height = button_height + y;\n    let mut title_bar_rect = title_bar_container_view.frame();\n    title_bar_rect.size.height = title_bar_frame_height;\n    title_bar_rect.origin.y = window.frame().size.height - title_bar_frame_height;\n    unsafe {\n        title_bar_container_view.setFrame(title_bar_rect);\n    }","sourceCodeStart":61,"sourceCodeEnd":97,"githubUrl":"https://github.com/libnyanpasu/clash-nyanpasu/blob/f7dbce2997c633e484f54788035e770b3ee99773/backend/tauri/src/utils/resolve.rs#L61-L97","documentation":"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.","triggerScenarios":"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.","commonSituations":"Windows created without a maximize button; custom titlebar configs; calls made before window realization; fullscreen-only or utility-style windows.","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"],"exampleFix":"// before\nlet zoom = window\n    .standardWindowButton(NSWindowButton::ZoomButton)\n    .ok_or(anyhow::anyhow!(\"failed to get zoom button\"))?;\n// after: optional zoom button\nif let Some(zoom) = window.standardWindowButton(NSWindowButton::ZoomButton) {\n    // position zoom\n}","handlingStrategy":"fallback","validationCode":"if window.standardWindowButton(NSWindowButton::ZoomButton).is_none() {\n    log::warn!(\"zoom button unavailable; skip reposition\");\n    return Ok(());\n}","typeGuard":null,"tryCatchPattern":"if let Err(e) = set_window_controls_pos(&win, x, y).await {\n    log::warn!(\"zoom button reposition failed: {e:#}\");\n}","preventionTips":["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"],"tags":["macos","window","appkit","traffic-light-buttons"],"backgroundTag":"resource-not-found","analyzedSha":"f7dbce2997c633e484f54788035e770b3ee99773","analyzedAt":"2026-09-08T01:24:59.197Z","contentChangedAt":"2026-09-08T01:24:59.197Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}