Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

desktop: maximized state lost when saved bounds exceed the display

未关闭 适合新手
#58,247 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 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 内容生成。

描述

reproduced

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 --version on 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

  1. Use a display whose height in Electron DIP is below 800 (e.g. 1366×768; Electron reports 1388×781 here).
  2. Launch the desktop app with a fresh profile (default window size is 1280×800).
  3. Maximize the window.
  4. 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

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

anomalyco/opencode 的其他 Issue

查看 anomalyco/opencode 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。