Skip to content

Conversation

@SiriusXT
Copy link
Member

@SiriusXT SiriusXT commented Nov 2, 2025

Before fix: When opening a new window from the taskbar or trying to activate an existing window, a “port in use” dialog would pop up.
After fix: A new window is opened directly or the existing window is activated without showing the window.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request refactors the error handling for EADDRINUSE to prevent showing a 'port in use' dialog when opening a new window or activating an existing one. The change simplifies the conditional logic by combining nested if statements into a single if-else block, which improves code clarity and maintainability. Additionally, it updates a loose equality check (==) to a strict one (===), which is a good practice. The fix appears correct and makes the code easier to understand. I have one suggestion to further improve readability.

console.error(message);
process.exit(1);
}
if ("code" in error && error.code === "EADDRINUSE" && (process.argv.includes("--new-window") || !app.requestSingleInstanceLock())) {
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The condition for this if statement is quite long and combines multiple checks. To improve readability and make the code more self-documenting, you could extract this logic into a helper function. For example, a function named isSecondInstanceLaunch would make the intent of this conditional block immediately clear.

@dosubot dosubot bot added the size:S This PR changes 10-29 lines, ignoring generated files. label Nov 2, 2025
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @SiriusXT, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request resolves an issue where an erroneous 'port in use' dialog would appear when users attempted to open a new application window or activate an existing one. The changes refine the server's error handling to correctly identify these scenarios and suppress the dialog, ensuring a smoother user experience by either opening a new window directly or focusing on the existing instance without interruption.

Highlights

  • Error Handling Refinement: The error handling logic within the startHttpServer function has been refactored to specifically address the EADDRINUSE error.
  • Suppressed 'Port In Use' Dialog: The 'port in use' dialog will no longer appear when opening a new Electron window via the --new-window argument or when attempting to activate an existing application instance.
  • Correct Dialog Display: The dialog for server initialization errors, including EADDRINUSE in other contexts, will now only be shown when appropriate, preventing unnecessary pop-ups.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@eliandoran eliandoran merged commit 421c1f2 into main Nov 4, 2025
10 checks passed
@eliandoran eliandoran deleted the electron_newwindow branch November 4, 2025 17:29
@eliandoran eliandoran added this to the v0.99.4 milestone Nov 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:S This PR changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants