Fix preview scripts to automatically find available ports instead of requiring manual intervention #13
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
When launching the preview scripts (
preview.sh,preview.bat,preview.ps1), if port 3000 was already in use, users were prompted to manually kill the existing process or the script would exit with an error. This created a poor developer experience and interrupted workflows.Solution
All three preview scripts now automatically search for and use the first available port starting from 3000. If port 3000 is busy, the scripts seamlessly fall back to port 3001, 3002, and so on (up to port 3100).
Changes
Core Functionality
find_available_port()function usinglsofto detect port availabilitynetstatwith label/goto patternFind-AvailablePortfunction usingGet-NetTCPConnectionUser Experience
Documentation
Example
Before:
After:
Benefits
✅ Zero manual intervention required
✅ Works seamlessly when port 3000 is busy
✅ Developers can run multiple instances or work alongside other applications
✅ Cross-platform support maintained (Linux, macOS, Windows)
✅ Professional, polished user experience
✅ Still prefers port 3000 when available (backward compatible)
Testing
Verified behavior across multiple scenarios:
Closes #[issue_number]
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.