feat(goose2): add cross-worktree kill support with running/kill-all recipes#8768
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0c9f619039
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| running: | ||
| #!/usr/bin/env bash | ||
| git worktree list --porcelain | awk ' | ||
| /^worktree / { wt=$2 } |
There was a problem hiding this comment.
Parse worktree paths without whitespace splitting
git worktree list --porcelain emits the full worktree path after worktree , but this parser stores wt=$2, which truncates paths containing spaces. That makes the derived ui/goose2 directory (and therefore hashed port) incorrect, so cross-worktree commands can miss running servers or fail with “No worktree found” for valid branches in space-containing paths. Parse from the full line (or use --porcelain -z) instead of whitespace fields.
Useful? React with 👍 / 👎.
| ' | while IFS=$'\t' read -r wt branch; do | ||
| dir="$wt/ui/goose2" | ||
| port=$(python3 -c "import hashlib; h=int(hashlib.sha256('$dir'.encode()).hexdigest(),16); print(10000 + h % 55000)") | ||
| if lsof -ti :"$port" &>/dev/null; then |
There was a problem hiding this comment.
Restrict
running to actual node dev listeners
This check marks a branch as “running” whenever any process listens on the derived port. If a non-dev process happens to use that port, kill-all will include that branch and then fail in just kill (which rejects non-node), aborting the loop under set -euo pipefail and leaving real dev servers alive. running should validate the listener type (or kill-all should tolerate per-branch failures) before treating it as an active dev server.
Useful? React with 👍 / 👎.
…for cross-worktree dev server management Add recipes to list active dev servers across worktrees (`running`), kill a specific worktree's dev process by branch name (`kill`), and tear down all running dev servers (`kill-all`). Kills target the entire process group so goose-tauri and its backend child are also stopped. Shared awk/port-computation logic is extracted into `_worktree_awk` and `_port_cmd` variables. Worktree paths with spaces are handled correctly and directory paths are passed via sys.argv to avoid shell injection. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
0c9f619 to
7376819
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7376819081
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| if [[ -n "{{ branch }}" ]]; then | ||
| WORKTREE_PATH=$(git worktree list --porcelain \ | ||
| | awk '{{ _worktree_awk }}' \ | ||
| | awk -F'\t' -v branch="{{ branch }}" '$2 == branch { print $1; exit }') |
There was a problem hiding this comment.
Escape branch names before shell interpolation
kill injects {{ branch }} directly into double-quoted shell arguments (notably -v branch="{{ branch }}"), so shell expansion runs before awk receives the literal branch name. Git allows branch names containing $/backticks (for example, git check-ref-format --branch 'foo$(id)' succeeds), which means just kill <branch> can mis-resolve valid worktrees and kill-all can execute unintended command substitutions when iterating branch names. Pass the branch as a positional/env value inside the script instead of templating it directly into shell code.
Useful? React with 👍 / 👎.
Summary
just runningrecipe to list worktrees with active dev serversjust killwith optional branch parameter to kill another worktree's dev processjust kill-allrecipe to stop all dev servers across all worktrees🤖 Generated with Claude Code
Co-Authored-By: Claude Opus 4.6 (1M context) noreply@anthropic.com