Hmbown/CodeWhale · error
terminal restore request was rejected
Error message
terminal restore request was rejected
What it means
During toggle_pin's un-maximize (restore) step, ShowWindowAsync(hwnd, SW_RESTORE) returned false, meaning Windows rejected the async restore request for the host window. The code bails instead of continuing to move/resize a window that could not be restored.
Solutions
- Retry toggle_pin; transient ShowWindowAsync failures often succeed on a second attempt.
- Un-maximize the terminal manually before toggling pin, avoiding the restore path.
- Check for elevated (admin) vs non-elevated process mismatch — UIPI can block window manipulation of an elevated window.
- Verify the host window still exists (hwnd() succeeded here, so re-capture if owner changed).
Defensive patterns
Strategy: retry
Try / catch
match toggle_pin() {
Err(e) if e.to_string().contains("restore request was rejected") => retry_with_backoff(2),
other => other?,
} Prevention
- Retry ShowWindowAsync once before failing; rejections are often transient.
- Check process integrity levels (elevated vs non-elevated) before manipulating the window.
- Avoid toggling while the user is actively resizing/maximizing the terminal.
- Offer a manual 'un-maximize first' hint when restore is rejected.
When it happens
Trigger: toggle_pin restoring a maximized window when the Win32 ShowWindowAsync(SW_RESTORE) call returns FALSE — e.g. the window is in a state that cannot be restored or is owned/protected by another process.
Common situations: The terminal is maximized in a way the window manager refuses to undo (fullscreen/secure desktop, elevated vs non-elevated process mismatch); another application holds the window; a race with the user's own window actions.
Understand the failure class
Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.
Related errors
- terminal maximize request was rejected
- terminal host window no longer exists
- terminal host window owner changed
- terminal restore was not observed before the deadline
- terminal window change was not observed before the deadline
AI-assisted analysis of Hmbown/CodeWhale@73e0f67d83 (2026-09-22).
Data as JSON: /api/errors/d8588c94f3f390b3.
Report an issue: GitHub.
Appendix: source
Thrown at crates/tui/src/tui/window_control.rs:405
// An unconfirmed request keeps its original target and restore data.
// The next request restores that window, even if focus has changed.
let restoring = state.host.is_some();
let host = state.host.unwrap_or(captured_host);
if let Err(error) = host.hwnd() {
// Retire geometry only when the original owner is gone. A failed
// observation must preserve it for the next restore attempt.
*state = State::new();
PINNED.store(false, Ordering::Release);
return Err(error);
}
let before = observe(host)?;
if !restoring {
state.host = Some(host);
state.was_maximized = before.maximized;
state.saved_rect = Some(before.rect);
if before.maximized {
if !unsafe { ShowWindowAsync(host.hwnd()?, SW_RESTORE) }.as_bool() {
bail!("terminal restore request was rejected");
}
if !wait_for(host, Duration::from_millis(800), |observed| {
!observed.maximized
})? {
bail!("terminal restore was not observed before the deadline");
}
state.saved_rect = Some(observe(host)?.rect);
}
}
let saved = state
.saved_rect
.context("terminal restore geometry is unavailable")?;
let target = Observation {
topmost: !restoring,
maximized: restoring && state.was_maximized,
rect: if restoring {
savedView on GitHub (pinned to 73e0f67d83)