veritas-kanban/scripts/dev-clean.sh
Brad Groux eeb11ba219 feat(US-1600): Complete SOP Sprint + fix GH-86 & GH-87
Documentation (8 new files in docs/):
- GETTING-STARTED.md: 5-min quickstart, BoardKit insights, sanity checks
- SOP-agent-task-workflow.md: Full lifecycle (claim → work → complete)
- SOP-sprint-planning.md: Epic → sprint → task hierarchy + estimation
- SOP-multi-agent-orchestration.md: PM + worker roles, handoff patterns
- SOP-cross-model-code-review.md: Claude ↔ GPT gate, checklist, RF-002 ref
- BEST-PRACTICES.md: 10 DOs + 10 DON'Ts based on real usage
- EXAMPLES-agent-workflows.md: 6 copy/pasteable recipes (feature, bug fix, docs, audit, content, research)
- TIPS-AND-TRICKS.md: CLI shortcuts, keyboard shortcuts, integrations (MCP, git worktrees, Obsidian)
- README.md: Added 'Documentation Map' linking all new docs

Bug Fixes:
- fix(GH-86): BulkActionsBar now handles archive errors gracefully
  * Per-task error tracking (replaces Promise.all)
  * Toast notifications on success/partial/failure
  * Logs individual failures to console

- fix(GH-87): Sidebar metrics now stay in sync with board state
  * Invalidate metrics cache when task status changes
  * Prevents up-to-30s lag in sidebar counts
  * Preserves timer state during mutations

Scripts:
- scripts/dev-clean.sh: Added explicit pnpm path resolution for launchd
- scripts/dev-watchdog.sh: Fixed restart storm prevention + pnpm path

BREAKING: None
TESTING:
- Manual: Bulk archive Done column tasks, verify toasts appear
- Manual: Move tasks between columns, verify sidebar counts update <2s
- Unit: Consider regression tests for metrics invalidation
2026-02-04 08:18:01 -06:00

86 lines
2.2 KiB
Bash
Executable file
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/env bash
set -euo pipefail
# Dev safety rail: kill stale VK dev runners + free ports, then restart.
#
# Goals:
# - Prevent “port capture” (something else bound to :3001 / :3000)
# - Prevent duplicate watchers (tsx watch / vite / concurrently)
# - Be SAFE: only target this repos processes + the configured ports
REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
# launchd sessions often have a minimal PATH; resolve pnpm explicitly.
PNPM_BIN="$(command -v pnpm || true)"
if [[ -z "${PNPM_BIN}" && -x "/opt/homebrew/bin/pnpm" ]]; then
PNPM_BIN="/opt/homebrew/bin/pnpm"
fi
if [[ -z "${PNPM_BIN}" ]]; then
echo "[dev-clean] ERROR: pnpm not found in PATH and /opt/homebrew/bin/pnpm missing" >&2
exit 1
fi
SERVER_PORT="${PORT:-3001}"
WEB_PORT="${WEB_PORT:-3000}"
echo "[dev-clean] repo=${REPO_ROOT}"
echo "[dev-clean] ports: server=${SERVER_PORT} web=${WEB_PORT}"
kill_listeners() {
local port="$1"
local pids
pids="$(lsof -nP -iTCP:"${port}" -sTCP:LISTEN -t 2>/dev/null || true)"
if [[ -n "${pids}" ]]; then
echo "[dev-clean] killing listeners on :${port}: ${pids}"
# shellcheck disable=SC2086
kill ${pids} 2>/dev/null || true
fi
}
kill_repo_watchers() {
python3 - <<PY
import os, re, subprocess
repo=os.environ['REPO_ROOT']
pat=re.compile(r'(pnpm\s+dev|concurrently|vite(\.js)?(\s|$)|tsx\s+watch)')
ps=subprocess.check_output(['ps','aux'], text=True).splitlines()[1:]
kill=[]
for line in ps:
if repo not in line:
continue
if not pat.search(line):
continue
try:
pid=int(line.split()[1])
except Exception:
continue
# Don't kill the current python process
if pid == os.getpid():
continue
kill.append(pid)
if kill:
print('[dev-clean] killing repo dev watchers:', kill)
for pid in kill:
try:
os.kill(pid, 15)
except ProcessLookupError:
pass
else:
print('[dev-clean] no repo dev watchers found')
PY
}
export REPO_ROOT
kill_listeners "${SERVER_PORT}"
kill_listeners "${WEB_PORT}"
# Give sockets a moment to release
sleep 0.5
kill_repo_watchers
sleep 0.5
echo "[dev-clean] starting pnpm dev"
cd "${REPO_ROOT}"
exec "${PNPM_BIN}" dev