desktop: maximized state lost when saved bounds exceed the display
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 新手友好度
- 74/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- electron, typescript
- 领域
- desktop
调研方向
阅读 packages/desktop/src/main/windows/window-state.ts,从 resolveWindowState() 和 manageWindowState.update() 开始。检查 within() 如何处理短于显示器的边界,以及回退逻辑如何保留最大化和全屏标志。当最大化窗口能在短于其已保存正常边界的显示器上恢复时,即为完成;如有窗口状态测试,请用它们验证。
由索引模型根据 Issue 内容生成。
描述
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 WindowState
The 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.
- 主要语言
- TypeScript
- 星标
- 215k
- 派生
- 28.9k
- 平均合并
- 4 小时 21 分钟
- 30 天内合并 PR
- 476
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
anomalyco/opencode 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 68/100
anomalyco/opencode#58216 · 1 条评论 ·
维护者通常 1 天内回复
-
pending close triaging
难度 2/5 1-3 小时 新手友好度 65/100
anomalyco/opencode#58181 · 1 条评论 ·
维护者通常 1 天内回复
-
Opencde Github Actions Bot Cannot Install可能已有人在做 @zzz-creator 今天认领。 未关闭reproduced
难度 2/5 1-3 小时 新手友好度 65/100
anomalyco/opencode#57911 · 2 条评论 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 82/100
anomalyco/opencode#57855 · 1 条评论 ·
维护者通常 1 天内回复
-
opencode.tools adds the execute / session_move hint even when Code Mode is denied可能已有人在做 @Yun-0000 于 1 天前认领。 未关闭reproduced
难度 2/5 1-3 小时 新手友好度 67/100
anomalyco/opencode#57711 · 1 条评论 ·
维护者通常 1 天内回复
查看 anomalyco/opencode 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 66/100
db-ux-design-system/core-web#8613 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 82/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 62/100
维护者通常 1 天内回复
-
bug internal-plugin pr-welcome upstream
难度 2/5 1-3 小时 新手友好度 78/100
dsh-tauri-desk/deepseek-harness-desktop#1225 · 1 条评论 ·
-
enhancement
难度 2/5 1-3 小时 新手友好度 68/100
unjs/unhead#1027 · 1 个 reaction ·
维护者通常 1 天内回复