Skip to content

when I start a new browser use desktop instance, I shouldnt get a "wi…#398

Merged
Cheggin merged 5 commits intomainfrom
reagan/fix-duplicate-instance-opening
May 6, 2026
Merged

when I start a new browser use desktop instance, I shouldnt get a "wi…#398
Cheggin merged 5 commits intomainfrom
reagan/fix-duplicate-instance-opening

Conversation

@Cheggin
Copy link
Copy Markdown
Collaborator

@Cheggin Cheggin commented May 6, 2026

…ndow already opened error".

also, when I need to update and double click a new dmg or something if I install a separate one, then it should auto-update current window.

Summary

Test plan

  • npm run lint passes
  • npm run typecheck passes
  • npm run test passes (unit + integration)
  • New code has tests (per D1 directive — TDD, ≥80% coverage on new src/main/src/shared modules)
  • Python changes: pytest + ruff check + mypy pass
  • Manual QA in npm run dev for UI-facing changes

Screenshots / recordings

Risk + rollback


Summary by cubic

Stops the “window already opened” alert on duplicate launches. Second launches now exit, and the primary instance focuses an existing window or recreates the right one.

  • Bug Fixes

    • Enforce single instance via electron’s app.requestSingleInstanceLock; lock loser calls app.exit(0).
    • On second-instance, focus the best available window (shell, onboarding, or last focused); if none exist, open shell or create onboarding based on account state.
  • Refactors

    • Remove version-aware takeover; duplicate-launch handling is version-agnostic for predictable macOS behavior.

Written for commit 7e41114. Summary will update on new commits.

…ndow already opened error".

also, when I need to update and double click a new dmg or something if I install a separate one, then it should auto-update current window.
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 3 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="app/src/main/startup/singleInstance.ts">

<violation number="1" location="app/src/main/startup/singleInstance.ts:71">
P1: Prerelease versions are compared lexically instead of SemVer precedence, which can misidentify which instance is newer (e.g., `beta.10` vs `beta.2`).</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review, or fix all with cubic.

Comment thread app/src/main/startup/singleInstance.ts Outdated
Cheggin added 3 commits May 5, 2026 18:27
The version-aware handoff depended on a newer app process reliably reaching Electron's second-instance path, which is not guaranteed for normal macOS app launches. Keep duplicate launches simple: the lock loser exits, and the primary instance restores or recreates the appropriate window.

Constraint: macOS may activate the existing app instead of starting a second packaged app process
Rejected: Newer-binary handoff | relies on launch behavior we cannot prove with unit tests
Confidence: high
Scope-risk: narrow
Directive: Keep duplicate-launch handling version-agnostic unless packaged two-version smoke tests cover takeover behavior
Tested: npm run typecheck
Tested: npm run lint
Tested: npm run test
@Cheggin
Copy link
Copy Markdown
Collaborator Author

Cheggin commented May 6, 2026

@cubic review this entire pr pls

@cubic-dev-ai
Copy link
Copy Markdown

cubic-dev-ai Bot commented May 6, 2026

@cubic review this entire pr pls

@Cheggin I have started the AI code review. It will take a few minutes to complete.

Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 3 files (changes from recent commits).

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="app/src/main/index.ts">

<violation number="1" location="app/src/main/index.ts:46">
P1: This change removes newer-instance handoff and always keeps the currently running instance, so manual installs/updates cannot take over when an older process is already open.</violation>
</file>

Tip: Review your code locally with the cubic CLI to iterate faster.
Fix all with cubic.

Comment thread app/src/main/index.ts
// start, surface the existing window instead.
// Enforce a single running instance. The lock loser exits, while the primary
// process handles `second-instance` by focusing or recreating its main window.
if (!app.requestSingleInstanceLock()) {
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai Bot May 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1: This change removes newer-instance handoff and always keeps the currently running instance, so manual installs/updates cannot take over when an older process is already open.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At app/src/main/index.ts, line 46:

<comment>This change removes newer-instance handoff and always keeps the currently running instance, so manual installs/updates cannot take over when an older process is already open.</comment>

<file context>
@@ -48,22 +41,9 @@ crashReporter.start({
-if (!app.requestSingleInstanceLock(singleInstanceLaunchData)) {
+// Enforce a single running instance. The lock loser exits, while the primary
+// process handles `second-instance` by focusing or recreating its main window.
+if (!app.requestSingleInstanceLock()) {
   app.exit(0);
 }
</file context>

Tip: Review your code locally with the cubic CLI to iterate faster.

Fix with Cubic

Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 1 file

@Cheggin Cheggin merged commit 80a5b77 into main May 6, 2026
9 checks passed
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