#!/usr/bin/env bash # dev-all.sh — deterministic dev loop: Python API server (auto-reload on .py # changes) + esbuild watch (rebuilds static/dist/js on every .ts/.js save). # # This is what `make dev` runs. It exists so the dev server can NEVER serve a # stale static/dist/ — the JS watcher is part of the dev loop, not an optional # step an agent/human has to remember. # # Ctrl+C terminates both processes. set -u # Same build as `make dev-js`, through the shared scripts/build-js.sh. # --watch=forever: a plain `--watch` exits immediately when stdin closes, and # background jobs (this `&` below) get stdin from /dev/null — without # "forever" the JS watcher would die on startup and `make dev` would serve a # stale static/dist forever. `--watch=forever` still honours SIGINT/SIGTERM, # so the trap below keeps Ctrl+C cleanup working. esbuild_args=(bash scripts/build-js.sh static/dist/js --watch=forever) # Same server invocation as the old `make dev` (must stay in sync with the Makefile). # The watch paths are explicit: only what the server imports can change it, and # an unwatched save under tests/, scratch/ or scripts/ used to cost a cold start # (~2 s `_create_unified_view` + ~4 s DuckDB setup) and drop every # RealtimeSignalsService accumulator, for a file the process never imports. server_args=(uv run watchfiles --filter python 'python app.py' app core modules app.py config.py) trap 'kill 0' EXIT INT TERM echo "==> dev-all: esbuild watch (JS) + watchfiles (Python API)" echo " JS save -> rebuilds static/dist/js (browser refresh still manual)" echo " .py save -> API server auto-reloads" echo " watching: app core modules app.py config.py (tests/, scratch/, scripts/ do not reload)" "${esbuild_args[@]}" & "${server_args[@]}"