Skip to content

feat(goose2): add cross-worktree kill support with running/kill-all recipes#8768

Merged
matt2e merged 1 commit into
mainfrom
kill-autocomplete
Apr 23, 2026
Merged

feat(goose2): add cross-worktree kill support with running/kill-all recipes#8768
matt2e merged 1 commit into
mainfrom
kill-autocomplete

Conversation

@matt2e
Copy link
Copy Markdown
Collaborator

@matt2e matt2e commented Apr 23, 2026

Summary

  • Add just running recipe to list worktrees with active dev servers
  • Extend just kill with optional branch parameter to kill another worktree's dev process
  • Kill entire process group (not just the node PID) so goose-tauri and backend also stop
  • Add just kill-all recipe to stop all dev servers across all worktrees
  • Fix pre-commit hook and biome config to skip justfile (not a biome-processable file)

🤖 Generated with Claude Code

Co-Authored-By: Claude Opus 4.6 (1M context) noreply@anthropic.com

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 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".

Comment thread ui/goose2/justfile Outdated
running:
#!/usr/bin/env bash
git worktree list --porcelain | awk '
/^worktree / { wt=$2 }
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge 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 👍 / 👎.

Comment thread ui/goose2/justfile
' | 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
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge 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>
@matt2e matt2e force-pushed the kill-autocomplete branch from 0c9f619 to 7376819 Compare April 23, 2026 15:34
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 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".

Comment thread ui/goose2/justfile
if [[ -n "{{ branch }}" ]]; then
WORKTREE_PATH=$(git worktree list --porcelain \
| awk '{{ _worktree_awk }}' \
| awk -F'\t' -v branch="{{ branch }}" '$2 == branch { print $1; exit }')
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge 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 👍 / 👎.

@matt2e matt2e added this pull request to the merge queue Apr 23, 2026
Merged via the queue into main with commit 18e0668 Apr 23, 2026
23 of 24 checks passed
@matt2e matt2e deleted the kill-autocomplete branch April 23, 2026 15:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants