{"record":{"id":"79939f469793e12b","repo":"Hmbown/CodeWhale","slug":"terminal-restore-was-not-observed-before-the-deadline","errorCode":null,"errorMessage":"terminal restore was not observed before the deadline","messagePattern":"terminal restore was not observed before the deadline","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tui/src/tui/window_control.rs","lineNumber":410,"sourceCode":"            // Retire geometry only when the original owner is gone. A failed\n            // observation must preserve it for the next restore attempt.\n            *state = State::new();\n            PINNED.store(false, Ordering::Release);\n            return Err(error);\n        }\n        let before = observe(host)?;\n        if !restoring {\n            state.host = Some(host);\n            state.was_maximized = before.maximized;\n            state.saved_rect = Some(before.rect);\n            if before.maximized {\n                if !unsafe { ShowWindowAsync(host.hwnd()?, SW_RESTORE) }.as_bool() {\n                    bail!(\"terminal restore request was rejected\");\n                }\n                if !wait_for(host, Duration::from_millis(800), |observed| {\n                    !observed.maximized\n                })? {\n                    bail!(\"terminal restore was not observed before the deadline\");\n                }\n                state.saved_rect = Some(observe(host)?.rect);\n            }\n        }\n\n        let saved = state\n            .saved_rect\n            .context(\"terminal restore geometry is unavailable\")?;\n        let target = Observation {\n            topmost: !restoring,\n            maximized: restoring && state.was_maximized,\n            rect: if restoring {\n                saved\n            } else {\n                RECT {\n                    left: saved.left,\n                    top: saved.top,\n                    right: saved.left + PINNED_W,","sourceCodeStart":392,"sourceCodeEnd":428,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/tui/window_control.rs#L392-L428","documentation":"After issuing SW_RESTORE, toggle_pin waits up to 800ms via wait_for for the window's maximized state to clear. If the timeout elapses without observing !maximized, it bails: the restore was requested but never took effect, so saved geometry cannot be trusted.","triggerScenarios":"ShowWindowAsync(SW_RESTORE) reported success but wait_for(host, 800ms, |observed| !observed.maximized) timed out — the window stayed maximized (or polling couldn't observe the change) before the deadline.","commonSituations":"Slow or busy window manager delaying the restore; the terminal re-maximizes immediately (window-management policy); heavy system load making the 800ms deadline too tight; polling GetWindowPlacement returning stale maximized state.","solutions":["Retry the toggle; transient scheduling delays commonly exceed the 800ms deadline under load.","Manually restore (un-maximize) the terminal, then re-run toggle_pin so the restore branch is skipped.","If this recurs, increase the restore wait deadline in window_control.rs (toggle_pin)."],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"match toggle_pin() {\n    Err(e) if e.to_string().contains(\"not observed before the deadline\") => retry_once_after_delay(),\n    other => other?,\n}","preventionTips":["Retry under light system load; the 800ms deadline is tight.","Treat repeated deadline misses as a signal to raise the timeout.","Don't invoke toggle during heavy window-manager activity.","Fall back to non-pinned mode if restore cannot be confirmed."],"tags":["windows","win32","timeout","terminal-window"],"backgroundTag":"request-timeout","analyzedSha":"73e0f67d83c59909b571efdfc88c4bc28c309cb1","analyzedAt":"2026-09-22T01:30:00.501Z","contentChangedAt":"2026-09-22T01:30:00.501Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}