{"record":{"id":"493414fba0c10be4","repo":"libnyanpasu/clash-nyanpasu","slug":"failed-to-get-miniaturize-button-493414","errorCode":null,"errorMessage":"failed to get miniaturize button","messagePattern":"failed to get miniaturize button","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"warning","filePath":"backend/tauri/src/window.rs","lineNumber":916,"sourceCode":"\n    impl From<Position> for (f64, f64) {\n        fn from(value: Position) -> Self {\n            (value.x, value.y)\n        }\n    }\n\n    fn set_traffic_lights_pos(\n        window: objc2::rc::Retained<objc2_app_kit::NSWindow>,\n        pos: Position,\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 + pos.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":898,"sourceCodeEnd":934,"githubUrl":"https://github.com/libnyanpasu/clash-nyanpasu/blob/f7dbce2997c633e484f54788035e770b3ee99773/backend/tauri/src/window.rs#L898-L934","documentation":"Same traffic-light repositioning path as the close button, but for the miniaturize button: NSWindow.standardWindowButton(.miniaturizeButton) returned nil. The code needs all three buttons to compute the title-bar container, so it aborts with this error.","triggerScenarios":"set_traffic_lights_pos called on a window whose style mask lacks .miniaturizable, an undecorated/borderless Tauri window, or before the window is visible so AppKit hasn't created the buttons.","commonSituations":"Windows created with decorations:false; style masks customized to remove the minimize button; calling the API during window setup before performDrag/appearance; dialogs/utility windows with restricted button sets.","solutions":["Ensure the window style mask includes .miniaturizable (Tauri: default decorations, not decorations:false)","Call set_traffic_lights_pos after the window is shown and retry if buttons are not yet available","Degrade gracefully: if any button is nil, skip repositioning with a warning rather than erroring","Verify with Objective-C that buttons exist: [window standardWindowButton:] before applying offsets"],"exampleFix":"// before\nlet miniaturize = window\n    .standardWindowButton(NSWindowButton::MiniaturizeButton)\n    .ok_or(anyhow::anyhow!(\"failed to get miniaturize button\"))?;\n// after\nlet Some(miniaturize) = window.standardWindowButton(NSWindowButton::MiniaturizeButton) else {\n    log::warn!(\"miniaturize button unavailable; skipping traffic light reposition\");\n    return Ok(());\n};","handlingStrategy":"fallback","validationCode":"if window.standardWindowButton(NSWindowButton::MiniaturizeButton).is_none() {\n    return Ok(()); // window lacks miniaturize; skip repositioning\n}","typeGuard":"fn has_miniaturize(window: &NSWindow) -> bool {\n    window.standardWindowButton(NSWindowButton::MiniaturizeButton).is_some()\n}","tryCatchPattern":"match apply_traffic_lights_pos(window, pos) {\n    Err(e) => log::warn!(\"traffic light reposition skipped: {e}\"),\n    Ok(()) => {}\n}","preventionTips":["Keep .miniaturizable in the window style mask when repositioning traffic lights","Invoke after window shown; AppKit creates buttons lazily","Design set_traffic_lights_pos to degrade to partial repositioning"],"tags":["macos","appkit","window"],"backgroundTag":"window-button-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"}