opencode icon indicating copy to clipboard operation
opencode copied to clipboard

fix(desktop): add single-instance plugin to prevent multiple windows

Open Junseo5 opened this issue 3 months ago • 2 comments

Problem

When launching the desktop app on Windows with plugins that take time to load (like oh-my-opencode), multiple instances spawn continuously because there's no single-instance guard. This causes 10+ windows to open.

Solution

Add tauri-plugin-single-instance which:

  • Prevents multiple app instances from running simultaneously
  • Focuses existing window when user tries to launch another instance
  • Unminimizes window if it was minimized

Changes

  • packages/desktop/src-tauri/Cargo.toml: Add tauri-plugin-single-instance = "2"
  • packages/desktop/src-tauri/src/lib.rs: Initialize single-instance plugin with focus handler

Testing

  1. Build desktop app with slow-loading plugins
  2. Try launching app multiple times quickly
  3. Expected: Only one window opens, subsequent launches focus existing window

Fixes #6965

Junseo5 avatar Jan 05 '26 17:01 Junseo5

The following comment was made by an LLM, it may be inaccurate:

Potential Duplicate Found

PR #6926 - "fix(desktop): add single-instance protection to prevent multiple app spawns" https://github.com/anomalyco/opencode/pull/6926

Why they're related:

Both PRs are addressing the same problem: preventing multiple instances of the desktop app from spawning simultaneously. They appear to be implementing the same solution using the tauri-plugin-single-instance plugin to prevent multiple windows and ensure the existing window is focused when a launch is attempted.

Action required: Check if PR #6926 is already merged or open, and consolidate efforts if both are addressing the same issue.

github-actions[bot] avatar Jan 05 '26 17:01 github-actions[bot]

cc @Brendonovich

adamdotdevin avatar Jan 05 '26 18:01 adamdotdevin