Repository navigation
Description
Description
On Linux/X11, the desktop app does not restore a maximized window on displays shorter than the default 800px window height (for example 1366×768). It opens unmaximized at the default size on every launch, even though it was closed maximized.
resolveWindowState() discards the entire saved state — including isMaximized — when the saved normal bounds do not fit inside a display. manageWindowState.update() intentionally leaves the normal bounds untouched while maximized, so those bounds can remain at the 1280×800 default (or WM-adjusted values taller than the screen). The state is therefore rejected on every restart, and the maximized flag never survives.
Environment
- OpenCode version: desktop app 2.1.3 (bundled CLI 2.1.3);
opencode --versionon PATH reports 2.1.0 - OS: CachyOS (Arch-based), Linux 7.2.11-1-cachyos, x86_64, XFCE 4.20 / xfwm4 4.20.0, X11
- Display: 1366×768; Electron reports bounds 1388×781 at scale 0.984375
- Terminal: Unavailable: desktop app, launched from the desktop/Plank entry
- Shell: /bin/fish
- Install/channel: Homebrew cask
opencode-desktop, latest (AppImage) - Plugins: none
Steps to reproduce
- Use a display whose height in Electron DIP is below 800 (e.g. 1366×768; Electron reports 1388×781 here).
- Launch the desktop app with a fresh profile (default window size is 1280×800).
- Maximize the window.
- Quit and relaunch the app.
Expected behavior
The window opens maximized again. If the saved normal bounds are unusable, the app may fall back to the default size but should still restore isMaximized / isFullScreen.
Actual behavior
The window opens unmaximized at 1280×800. This repeats on every launch. The state file stays invalid, so the maximized state is never restored; a workaround is to force maximize from outside after the window maps, which causes a visible resize.
Observed state before the workaround:
{"width":1284,"height":783,"x":2,"y":34,"displayBounds":{"x":0,"y":0,"width":1388,"height":781},"isMaximized":true,"isFullScreen":false}y + height = 34 + 783 = 817 > 781, so within() fails.
Additional context
In packages/desktop/src/main/windows/window-state.ts (current main), the invalid-bounds fallback drops the maximize/fullscreen flags:
// resolveWindowState, lines 38-49
if (!state.displayBounds) return state
const visible = displays.all().some((bounds) => within(state, bounds))
if (visible) return state
return {
width: defaults.width,
height: defaults.height,
x: 0,
y: 0,
displayBounds: displays.primary(),
} satisfies WindowStateThe fallback's own default bounds (1280×800) also do not fit a 768px-tall display. Meanwhile manageWindowState.update() (lines 80-89) skips updating x/y/width/height while maximized but still writes isMaximized and displayBounds, so the stale oversized normal bounds persist.
Suggested fix: keep isMaximized / isFullScreen in the fallback branch, clamp the restored bounds to the display, and/or avoid persisting stale normal bounds while maximized.
Related: #56970 (remember window position and size), #12413 (restoring maximized state, closed), #15165 (window state reset, closed).
Workaround used locally: remove displayBounds from the state file (then resolveWindowState returns the state as-is) and set valid bounds with isMaximized: true; the app then maximizes while the window is still hidden, before first paint.
Activity
opencode-agent commentedon Oct 22, 2026
Thanks for the detailed report and the analysis. I could reproduce this with the window-state logic from v2.1.3, and it still happens on the latest
dev(d93568f). I didn't run the desktop app itself here. Instead I ran the realwindow-state.tswith a stubbed window on a single 1388×781 display.What I saw:
x: 2, y: 34, 1284×783). It's then maximized and the app quits. The saved file hasisMaximized: truealong with those bounds, which are taller than the display (34 + 783 > 781).resolveWindowState()rejects the state and returns the 1280×800 fallback at 0,0 with noisMaximized, so the window never reopens maximized.isMaximizeddropped.The code's own comment says a saved maximized or fullscreen state should be kept, so this looks like a bug, not intended behaviour. The fallback's 1280×800 size doesn't fit a 781px-tall display either.
The script below reproduces it. Run it as
REPO=<opencode checkout> ./repro.sh <git-ref>.Related: #56970 (window position and size not remembered on Windows) and PR #57088 (adds a tolerance to the bounds check and keeps the maximized/fullscreen flags only when the state file is invalid, so it doesn't cover this case).
Reproduction script (repro.sh)
Run it:
bash repro.shtneemo commentedon Oct 23, 2026
I'd like to take this one. The fallback in
resolveWindowStatedropsisMaximized/isFullScreenwhen the saved bounds don't fit the display. I have a fix with regression tests ready and will open a PR shortly.