feat: auto-discover available ports when defaults are in use#614
feat: auto-discover available ports when defaults are in use#614stefandevo merged 4 commits intov0.13.0rcfrom
Conversation
Instead of prompting the user to kill processes or manually enter alternative ports, the launcher now automatically finds the next available ports when the defaults (3007/3008) are already in use. This enables running the built Electron app alongside web development mode without conflicts - web dev will automatically use the next available ports (e.g., 3009/3010) when Electron is running. Changes: - Add find_next_available_port() function that searches up to 100 ports - Update resolve_port_conflicts() to auto-select ports without prompts - Update check_ports() for consistency (currently unused but kept) - Add safety check to ensure web and server ports don't conflict
When ports are in use, users can now choose: - [Enter] Auto-select available ports (default, recommended) - [K] Kill processes and use default ports - [C] Choose custom ports manually - [X] Cancel Pressing Enter without typing anything will auto-select the next available ports, making it easy to quickly continue when running alongside an existing Electron instance.
|
Note Other AI code review bot(s) detectedCodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review. 📝 WalkthroughWalkthroughA shell script was enhanced to auto-discover and assign free ports. A new Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary of ChangesHello @stefandevo, 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 significantly enhances the user experience when launching Automaker in web mode by introducing intelligent port conflict resolution. It allows developers to seamlessly run the Electron app and web dev mode concurrently without manual intervention, as the system now automatically discovers and assigns available ports if the defaults are occupied. This streamlines development workflows by reducing friction caused by port clashes and provides a clearer, more user-friendly interface for managing conflicts. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Using Gemini Code AssistThe 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
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 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
|
There was a problem hiding this comment.
Code Review
This pull request introduces an excellent feature for automatically handling port conflicts, which significantly improves the developer experience. The implementation is solid, and the new interactive menu for port resolution is well-designed. I've identified a few areas for improvement, primarily concerning code maintainability and readability. My review includes suggestions to remove some dead code, replace a magic number with a constant, and simplify a complex command pipeline. Overall, this is a great enhancement.
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@start-automaker.sh`:
- Around line 456-474: The find_next_available_port function currently echoes
the original start_port on failure which can mislead callers; change
find_next_available_port to suppress any echo when it fails (echo nothing) and
return non‑zero so callers can detect failure, and update any callers that use
find_next_available_port (e.g., places that auto-select or print an
"auto-selected" port) to check the function's exit status or whether the
returned value is empty and then handle the error path explicitly (prompt the
user, abort with a clear error, or retry) instead of assuming a valid port was
returned.
Address PR review feedback: - Extract magic number 100 to PORT_SEARCH_MAX_ATTEMPTS constant - Fix find_next_available_port to return nothing on failure instead of the busy port, preventing misleading "auto-selected" messages - Update all callers to handle port discovery failure with clear error messages showing the searched range - Simplify PID formatting using xargs instead of tr|sed|sed pipeline
Summary
When launching Automaker in web mode while the Electron app is already running (or any other process using ports 3007/3008), the launcher now provides smart port conflict resolution with auto-select as the default option.
This enables seamless development workflows where you can:
Changes
find_next_available_port()function - Searches up to 100 ports in sequence to find an available one[Enter]Auto-select available ports (default, recommended)[K]Kill processes and use default ports[C]Choose custom ports manually[X]CancelUser Experience
When ports 3007/3008 are in use:
Pressing Enter instantly auto-selects the next available ports (e.g., 3009/3010) and continues launching.
Test plan
./start-automaker.shand select web modeSummary by CodeRabbit
New Features
Bug Fixes
✏️ Tip: You can customize this high-level summary in your review settings.