{"record":{"id":"00797f765e61a1b6","repo":"libnyanpasu/clash-nyanpasu","slug":"failed-to-get-zoom-button-00797f","errorCode":null,"errorMessage":"failed to get zoom button","messagePattern":"failed to get zoom button","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"warning","filePath":"backend/tauri/src/window.rs","lineNumber":919,"sourceCode":"            (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;\n        unsafe {\n            title_bar_container_view.setFrame(title_bar_rect);\n        }","sourceCodeStart":901,"sourceCodeEnd":937,"githubUrl":"https://github.com/libnyanpasu/clash-nyanpasu/blob/f7dbce2997c633e484f54788035e770b3ee99773/backend/tauri/src/window.rs#L901-L937","documentation":"Third traffic-light lookup in set_traffic_lights_pos: NSWindow.standardWindowButton(.zoomButton) returned nil, so repositioning the zoom (fullscreen/green) button fails. All three buttons are required to derive the title bar container view.","triggerScenarios":"set_traffic_lights_pos called on a window without the .resizable/.fullScreenButton style components that create the zoom button, borderless windows, or windows where the zoom button was explicitly removed/hidden by prior native code.","commonSituations":"Tauri windows with decorations:false; apps that removed the zoom button to prevent fullscreen; kiosk-style windows with restricted style masks; calling before the window appears on screen.","solutions":["Keep the default decorations (or .fullScreenContentView-related masks) so the zoom button is installed","If the zoom button was intentionally removed, adjust the code to tolerate its absence instead of failing","Invoke after window visibility and retry once; AppKit creates buttons lazily","Fall back to repositioning only close/miniaturize when zoom is missing"],"exampleFix":"// before\nlet zoom = window\n    .standardWindowButton(NSWindowButton::ZoomButton)\n    .ok_or(anyhow::anyhow!(\"failed to get zoom button\"))?;\n// after\nlet Some(zoom) = window.standardWindowButton(NSWindowButton::ZoomButton) else {\n    log::warn!(\"zoom button unavailable; skipping traffic light reposition\");\n    return Ok(());\n};","handlingStrategy":"fallback","validationCode":"if window.standardWindowButton(NSWindowButton::ZoomButton).is_none() {\n    return Ok(()); // zoom button removed; skip repositioning\n}","typeGuard":"fn has_zoom(window: &NSWindow) -> bool {\n    window.standardWindowButton(NSWindowButton::ZoomButton).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":["Avoid stripping the zoom button from windows whose traffic lights you reposition","Test traffic-light positioning on each supported macOS version","Reposition after the window appears; retry once if buttons are nil"],"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"}