feat(scripts): add try-pr.sh for testing PR worktrees locally#254
Open
suraj-markup wants to merge 1 commit intoComposioHQ:mainfrom
Open
feat(scripts): add try-pr.sh for testing PR worktrees locally#254suraj-markup wants to merge 1 commit intoComposioHQ:mainfrom
suraj-markup wants to merge 1 commit intoComposioHQ:mainfrom
Conversation
Adds scripts/try-pr.sh — a helper to switch the global 'ao' command to any session's worktree for manual testing, then restore back to main. Usage: bash scripts/try-pr.sh <session-id> # CLI/core/plugins only bash scripts/try-pr.sh <session-id> --with-web # also builds + starts dashboard bash scripts/try-pr.sh --restore # switch back to main Also fixes isPortAvailable() to use a connect-based probe instead of bind-based. The old approach had false positives on macOS when Next.js listens on :: (IPv6 wildcard) — binding 127.0.0.1 succeeded even though the port was taken. A TCP connect correctly detects any listener regardless of which address it's bound to. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
3b2ed8b to
6603685
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Adds
scripts/try-pr.sh— a helper script for manually testing changes in any agent session's worktree without permanently changing the globalaocommand.Also fixes a false positive bug in
isPortAvailable()that caused port-busy warnings to never fire on macOS.scripts/try-pr.shThe problem it solves
When an agent session finishes work, the global
aocommand still points to main. To test the PR's changes you'd have to manually:cd ~/.worktrees/ao/ao-XXpnpm buildcd packages/cli && pnpm link --globalEasy to forget step 5 and end up running PR code thinking it's main.
Usage
How it works
--with-web)$(which ao)to point at the worktree'sdist/index.js--restorecan put it back exactly--with-web: finds a free port (starting at 3001 to avoid conflicting with the runningao starton 3000), passesAO_CONFIG_PATHpointing at your real config so actual sessions show up in the PR dashboard--with-webif you forgotisPortAvailable()fixProblem: The original implementation probed by binding to
127.0.0.1. On macOS, Next.js /pnpm devlistens on::(IPv6 wildcard) withIPV6_V6ONLY=1, so binding127.0.0.1(IPv4) succeeded even when the port was taken — causing port-busy warnings to never fire.Fix: Switched from bind-based to connect-based detection. A successful TCP connect means something is listening (port in use).
ECONNREFUSEDmeans the port is free. Works regardless of whether the listener is on127.0.0.1,::1,0.0.0.0, or::.🤖 Generated with Claude Code