{"record":{"id":"2d55ecb1d8f29b91","repo":"libnyanpasu/clash-nyanpasu","slug":"failed-to-get-miniaturize-button","errorCode":null,"errorMessage":"failed to get miniaturize button","messagePattern":"failed to get miniaturize button","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"backend/tauri/src/utils/resolve.rs","lineNumber":76,"sourceCode":"        unix_time_millis().saturating_add(duration_ms),\n        Ordering::Release,\n    );\n}\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;","sourceCodeStart":58,"sourceCodeEnd":94,"githubUrl":"https://github.com/libnyanpasu/clash-nyanpasu/blob/f7dbce2997c633e484f54788035e770b3ee99773/backend/tauri/src/utils/resolve.rs#L58-L94","documentation":"Same mechanism as the close-button failure: standardWindowButton(NSWindowButton::MiniaturizeButton) returned None while repositioning the macOS window control buttons, so the code raises this error. It means AppKit could not provide the minimize button for the window.","triggerScenarios":"Calling set_window_controls_pos on a window created without a miniaturize button (e.g. style mask lacking NSWindowStyleMask::Miniaturizable, or buttons already hidden/removed).","commonSituations":"Windows configured without minimize capability; calling before window decoration is realized; custom titlebar setups that removed native buttons; macOS-only code path invoked during early setup.","solutions":["Ensure the window's style mask includes miniaturizable before calling","Call after the window is fully created/shown","If buttons are intentionally hidden, skip the call instead of erroring","Fetch all three buttons and log which are missing to diagnose the style-mask issue"],"exampleFix":"// before: hard error on any missing button\nlet miniaturize = window\n    .standardWindowButton(NSWindowButton::MiniaturizeButton)\n    .ok_or(anyhow::anyhow!(\"failed to get miniaturize button\"))?;\n// after: reposition only the buttons that exist\nlet buttons = [close, miniaturize, zoom].into_iter().flatten();","handlingStrategy":"fallback","validationCode":"if window.standardWindowButton(NSWindowButton::MiniaturizeButton).is_none() {\n    log::warn!(\"miniaturize button unavailable; skip reposition\");\n    return Ok(());\n}","typeGuard":null,"tryCatchPattern":"match set_window_controls_pos(&win, x, y).await {\n    Ok(()) => {},\n    Err(e) => log::debug!(\"button reposition skipped: {e:#}\"),\n}","preventionTips":["Ensure the window style mask includes miniaturizable if repositioning is required","Reposition all buttons that exist rather than hard-failing on one","Call after window realization, not in early setup"],"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"}