Skip to content

Fix Windows second-instance window focus - #4403

Merged
Jinwoo-H merged 1 commit into
mainfrom
Jinwoo-H/fix-single-instance-window-focus
Jun 1, 2026
Merged

Jinwoo-H merged 1 commit into
mainfrom
Jinwoo-H/fix-single-instance-window-focus

Conversation

@Jinwoo-H

@Jinwoo-H Jinwoo-H commented Jun 1, 2026

Copy link
Copy Markdown
Contributor

Summary

  • extract second-instance window focusing into a testable main-process helper
  • make repeat launches reopen a missing ready window and more aggressively foreground the existing window on Windows
  • use a short Windows always-on-top pulse plus retry focus to handle taskbar/foreground activation cases where BrowserWindow.focus() alone is not enough

Diagnosis

On the installed Windows RC, clicking Orca again did launch a second process, but it exited after failing the single-instance lock:

[startup] single-instance-lock-result acquired=false
[single-instance] Another Orca instance is already running; exiting secondary process

The primary process was still alive and had a visible Chrome_WidgetWin_1 window titled Orca, so this was not the Codex SQLite/runtime-home crash path. The bad behavior was that the primary instance did not reliably surface its existing window, making the app look like it failed to launch.

Verification

  • pnpm vitest run --config config/vitest.config.ts src/main/window/focus-existing-window.test.ts src/main/startup/single-instance-lock.test.ts
  • pnpm exec oxlint src/main/window/focus-existing-window.ts src/main/window/focus-existing-window.test.ts src/main/index.ts
  • pnpm exec tsgo --noEmit -p config/tsconfig.node.json --pretty false

Local note: these commands pass with existing machine warnings for Node v25 vs repo Node v24 and an unset ${GITHUB_TOKEN} placeholder in C:\Users\jinwo\.npmrc.

@Jinwoo-H

Jinwoo-H commented Jun 1, 2026

Copy link
Copy Markdown
Contributor Author

Additional validation after opening the PR:

  • pnpm run build:electron-vite passes on this branch.
  • I launched the built app through pnpm exec electron . --serve with an isolated ORCA_E2E_USER_DATA_DIR and ORCA_STARTUP_DIAGNOSTICS=1; startup diagnostics showed the real single-instance lock path was active: acquired=true, skippedForDev=false.
  • That serve path does not create a visible top-level Orca window, so it is not a full visual click-to-focus proof. The visual failure was reproduced earlier on the installed RC; the PR locks the fix down at the extracted focus helper seam with unit coverage.

@Jinwoo-H
Jinwoo-H merged commit 57bae08 into main Jun 1, 2026
2 checks passed
@Jinwoo-H
Jinwoo-H deleted the Jinwoo-H/fix-single-instance-window-focus branch June 1, 2026 20:42
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant