From bae26d6302de5ac70e0c29f640f6df3ac94ebdd8 Mon Sep 17 00:00:00 2001 From: Matt Toohey Date: Thu, 16 Apr 2026 10:08:58 +1000 Subject: [PATCH] chore(goose2): `just goose2 ` with the addition of `just goose2 kill` (#8570) Signed-off-by: Matt Toohey Co-authored-by: Claude Opus 4.6 (1M context) --- Justfile | 2 ++ ui/goose2/justfile | 34 ++++++++++++++++++++++++++++------ 2 files changed, 30 insertions(+), 6 deletions(-) diff --git a/Justfile b/Justfile index db8e811549..67a2c7cdfa 100644 --- a/Justfile +++ b/Justfile @@ -1,5 +1,7 @@ # Justfile +mod goose2 'ui/goose2' + # list all tasks default: @just --list diff --git a/ui/goose2/justfile b/ui/goose2/justfile index 97b6d6de4d..68d997bd9c 100644 --- a/ui/goose2/justfile +++ b/ui/goose2/justfile @@ -1,3 +1,7 @@ +# Derive a stable port from the working directory so the same worktree +# always gets the same port. +vite_port := `python3 -c "import hashlib,os; h=int(hashlib.sha256(os.getcwd().encode()).hexdigest(),16); print(10000 + h % 55000)"` + # Default recipe default: @just --list @@ -74,11 +78,7 @@ dev: #!/usr/bin/env bash set -euo pipefail - # Derive a stable port from the working directory so the same worktree - # always gets the same port. This avoids changing TAURI_CONFIG between - # runs, which would invalidate Cargo's build cache and trigger a full - # Rust rebuild every time. - VITE_PORT=$(python3 -c "import hashlib,os; h=int(hashlib.sha256(os.getcwd().encode()).hexdigest(),16); print(10000 + h % 55000)") + VITE_PORT={{ vite_port }} export VITE_PORT PROJECT_DIR=$(pwd) TAURI_CONFIG="{\"build\":{\"devUrl\":\"http://localhost:${VITE_PORT}\",\"beforeDevCommand\":{\"script\":\"cd ${PROJECT_DIR} && exec pnpm exec vite --port ${VITE_PORT} --strictPort\",\"cwd\":\".\",\"wait\":false}}}" @@ -108,7 +108,7 @@ dev-debug: #!/usr/bin/env bash set -euo pipefail - VITE_PORT=$(python3 -c "import hashlib,os; h=int(hashlib.sha256(os.getcwd().encode()).hexdigest(),16); print(10000 + h % 55000)") + VITE_PORT={{ vite_port }} export VITE_PORT EXTRA_CONFIG="--config {\"build\":{\"devUrl\":\"http://localhost:${VITE_PORT}\",\"beforeDevCommand\":{\"script\":\"exec ./node_modules/.bin/vite --port ${VITE_PORT} --strictPort\",\"cwd\":\"..\",\"wait\":false}}}" @@ -136,6 +136,28 @@ dev-debug: dev-frontend: pnpm dev +# Kill the dev process (if running) +kill: + #!/usr/bin/env bash + set -euo pipefail + + VITE_PORT={{ vite_port }} + PID=$(lsof -ti :"$VITE_PORT" 2>/dev/null | head -1) || true + + if [[ -z "$PID" ]]; then + echo "No process found on port $VITE_PORT" + exit 0 + fi + + PROC_NAME=$(ps -p "$PID" -o comm= 2>/dev/null) || true + if [[ "$PROC_NAME" != "node" ]]; then + echo "Process on port $VITE_PORT is '$PROC_NAME', not 'node' — refusing to kill" + exit 1 + fi + + echo "Killing node (PID $PID) on port $VITE_PORT" + kill -9 "$PID" + # ── Utilities ──────────────────────────────────────────────── # Clean build artifacts