Skip to content

desktop: remember window position and size across restarts #56970

Open

Description

@jayeunn-hub

Summary

The OpenCode desktop app on Windows does not remember the window position or
size between restarts. Users must move/resize the window after every relaunch.

Environment

  • opencode version: 2.0.26 (desktop app, latest)
  • OS: Windows_NT 10.0.19045 (win32 x64)
  • Terminal: Unavailable: desktop app, not run from a terminal
  • Shell: C:\Windows\system32\cmd.exe
  • Install/channel: latest
  • Active plugins: none (global opencode.jsonc contains only $schema)

Reproduction

  1. Launch the OpenCode desktop app.
  2. Move and resize the window (e.g., free-form size or maximize).
  3. Close the app.
  4. Launch the app again.

Expected Behavior

The app reopens at the last-used window position and size (and remembers the
maximized/restored state).

Actual Behavior

The window reopens at a default position and default size; adjusted geometry
is lost.

Additional Context

  • Reproducible consistently.
  • No in-app setting exists, and the V2 docs (cli.json, opencode.json(c))
    have no window-geometry option — currently a feature request.
  • Workaround: keep the window maximized.
  • Suggestion: persist window bounds on close and restore on next launch,
    optionally with a "remember window geometry" toggle in desktop settings.

Activity

  1. opencode-agent commented on Oct 19, 2026

    @opencode-agent
    Contributor

    Thanks for the detailed report. The desktop app is supposed to remember the window position, size and maximized state between launches, so this looks like a bug rather than a missing feature.

    I couldn't run the Windows desktop app here, but I tested the code that restores the saved window position. It only reuses the saved position if the whole window fits inside a display. Windows reports a window snapped to the screen edge a few pixels off-screen (e.g. x = -7) because of its invisible borders. When I gave it a saved position like that, it threw the position away and used the default 1280×800 window instead. That would explain the problem for snapped or edge-aligned windows.

    To help a maintainer with a Windows machine narrow it down, could you say:

    • Does it also happen when the window is placed freely in the middle of the screen, not snapped or touching an edge?
    • Do you use more than one monitor, or display scaling other than 100%?
    • After you close the app, is there a window-state-*.json file in %APPDATA%\OpenCode (or the app's userData folder), and what does it contain?

    Related: #47534 (window position/size not restored on multi-monitor setups, reported on the older Tauri-based app).

  2. LeON-Nie-code commented on Oct 19, 2026

    @LeON-Nie-code

    I would like to take this. The edge-snapped case looks reproducible with a unit test around within() in window-state.ts: Windows reports the window a few pixels off-screen, so the full-containment check falls back to defaults. I will add a small tolerance for those borders and cover both snapped and genuinely off-screen cases. Should I target dev?

  3. LeON-Nie-code commented on Oct 19, 2026

    @LeON-Nie-code

    I installed 2.0.32 on a Windows 11 machine and tried snapping, free-moving, and maximizing the window. All three restored correctly, and the saved bounds were normalized (x=1 for the snapped window, x=307 for the free one), not negative. I could not reproduce the Windows 10 report here.

    I opened #57088 as a defensive fix for the negative-bounds path. If you are still on Windows 10, could you share your window-state-*.json or retest on 2.0.32?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions