Skip to content

Start dev and demo with bun run --parallel instead of the fish script - #86

Merged
firsttris merged 2 commits into
masterfrom
dev-parallel
Nov 4, 2026
Merged

firsttris merged 2 commits into
masterfrom
dev-parallel

Conversation

@firsttris

Copy link
Copy Markdown
Owner

Replaces the closed #85: no hand-written process supervision, and no start script at all.

bun run dev and bun run demo are now plain scripts in the root package.json:

"dev": "mkdir -p snapraid && SNAPRAID_BASE_PATH=$PWD/snapraid bun run --parallel dev:server dev:web",
"demo": "bash scripts/dev/setup.sh && SNAPRAID_BASE_PATH=$PWD/scripts/dev/sandbox SNAPRAID_BIN=$PWD/scripts/dev/bin/snapraid SNAPRAID_EXTRA_ARGS=--test-skip-device SNAPRAID_DEMO=1 bun run --parallel dev:server dev:web",
"dev:server": "bun run --cwd apps/server dev",
"dev:web": "bun run --cwd apps/web dev"

They behave like scripts/start.sh: absolute paths for the data directory and the binary, and the sandbox setup runs first, so a failure there aborts. bun run --parallel (Foreman-style output) stops the other script when one fails. The terminal sends Ctrl+C, Ctrl+Z and hangup to the whole foreground process group, so nothing needs to forward them.

  • scripts/start.sh deleted, fish removed from README and docs/development.md; the docs describe the two scripts and Ctrl+C / Ctrl+Z / fg
  • comments that mention start.sh updated (.gitignore, scripts/dev/setup.sh, apps/server/src/system/demo.ts, e2e/harness/demo-setup.ts)

Verified in a real pty (interactive bash, Bun 1.4.4)

  • bun run dev: server on 8080 and web on 3000 answer; Ctrl+C: no process of the tree left, exit code 130
  • Ctrl+Z: all 7 processes of the tree in state T, the shell takes input; fg: all running again, both ports answer; Ctrl+C afterwards: nothing left
  • bun run dev: SNAPRAID_BASE_PATH=/…/snapraid-ui/snapraid in /proc/<pid>/environ of the server and the Vite processes
  • bun run demo: all four SNAPRAID_* variables (absolute paths) in /proc/<pid>/environ of the server and the Vite processes
  • setup.sh failing (temporary exit 1): demo exits with 1, no server starts
  • Note: when the backend crashes (e.g. port 8080 busy), bun --watch waits for a file change instead of exiting, so the web server keeps running. start.sh behaved the same way.

Checks: bun install --frozen-lockfile, server bun test (236 tests, 0 fail) and typecheck, web biome check, typecheck and build.


Generated by Claude Code

`bun run dev` and `bun run demo` are now plain package.json scripts: they set
SNAPRAID_BASE_PATH (absolute, from $PWD) and, for the demo, run
scripts/dev/setup.sh first and set SNAPRAID_BIN, SNAPRAID_EXTRA_ARGS and
SNAPRAID_DEMO, then start `dev:server` and `dev:web` with Bun's built-in
`bun run --parallel`, which stops the other script when one fails.

No process supervision of our own: the terminal sends Ctrl+C, Ctrl+Z and
hangup to the whole foreground process group, so Ctrl+C stops both
servers, Ctrl+Z suspends both and fg resumes them. scripts/start.sh and
the fish requirement are gone; README, docs and comments updated.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Y3rdfbWb1xDUdPRng7TX9Z

Copy link
Copy Markdown
Owner Author

TDD review: 1 finding

bun run dev / bun run demo lose the colours of Vite and the backend

File: package.json, scripts dev and demo (line 13/14)

bun run --parallel pipes each script's output through itself (for the dev:web | prefix) and gives it /dev/null as stdin. The servers therefore no longer see a TTY, and Vite's colours (picocolors: TTY or FORCE_COLOR) are gone. scripts/start.sh on master started both in the background of the terminal, with the terminal as stdout.

Test: a pty script (ttyprobe.py) starts the command in an interactive bash on a pseudo terminal, waits for :8080 and :3000, reads /proc/<pid>/fd/{0,1} and FORCE_COLOR of bun --bun vite and bun --watch src/main.ts, and checks the Vite banner for ANSI escapes. Passes when both see a TTY or get FORCE_COLOR=1, and the banner is coloured.

master, fish scripts/start.sh (green):

bun --bun vite dev --port 3000 stdin=/dev/pts/4 stdout=/dev/pts/4 FORCE_COLOR=None
bun --watch src/main.ts        stdin=/dev/pts/4 stdout=/dev/pts/4 FORCE_COLOR=None
Vite banner: ['  \x1b[32m\x1b[1mVITE\x1b[22m v8.3.5\x1b[39m  \x1b[2mready in ...'] coloured: True
PASS

dev-parallel, bun run dev (red):

bun --bun vite dev --port 3000 stdin=/dev/null stdout=socket:[483386] FORCE_COLOR=None
bun --watch src/main.ts        stdin=/dev/null stdout=socket:[483382] FORCE_COLOR=None
Vite banner: ['  VITE v8.3.5  ready in 1610 ms'] coloured: False
FAIL

Fix (follows): set FORCE_COLOR=1 in dev and demo only when the script's own stdout is a terminal (if [ -t 1 ]; then export FORCE_COLOR=1; fi), so piping bun run dev into a file or less stays free of escape codes. No process handling of our own.

Checked and discarded (no red test)

  • $PWD when bun run dev is called from a subfolder without its own package.json (e.g. scripts/) or via bun run --cwd <repo> from /: Bun runs the script in the root, $PWD is the root.
  • Paths with spaces: VAR=$PWD/x is an assignment, not split; a probe in a directory probe dir got the full path.
  • Shell: bun run uses the system bash ($0=/usr/bin/bash), so $PWD, VAR=x cmd and && behave as in sh.
  • Environment: SNAPRAID_BASE_PATH reaches bun --watch src/main.ts and Vite (/proc/<pid>/environ).
  • Ctrl+C stops all processes (none left, exit 130); Ctrl+Z suspends both, the shell takes input, fg resumes, servers answer.
  • One side dies (Vite killed): --parallel stops the backend too, as the docs say. A backend crash (port 8080 taken) leaves bun --watch waiting for changes, as on master.
  • Vite's keyboard shortcuts: not shown on master either (background job), so no regression.
  • Remaining references to start.sh/fish in docs, e2e harness and CI: none.

Generated by Claude Code

bun run --parallel pipes the scripts' output for its name prefix, so Vite
and the backend no longer see a TTY and Vite printed no colours, unlike
scripts/start.sh, which left them on the terminal. Both scripts now set
FORCE_COLOR=1 when their own stdout is a terminal; piped or redirected
output stays free of escape codes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Y3rdfbWb1xDUdPRng7TX9Z

Copy link
Copy Markdown
Owner Author

Fix pushed: cbc98ae (FORCE_COLOR=1 in dev and demo when stdout is a terminal, docs/development.md updated). ttyprobe.py now passes for bun run dev and bun run demo; bun run dev > file has no escape codes. server bun test (236, 0 fail) + typecheck, web build green.


Generated by Claude Code

Copy link
Copy Markdown
Owner Author

TDD-Review abgeschlossen: 1 belegtes Finding (keine Farben unter --parallel) gefixt in cbc98ae. CI grün: backend, frontend, install, e2e local/binary/image je 2/2.

Merge per Squash.


Generated by Claude Code

@firsttris
firsttris merged commit 1ac8c43 into master Nov 4, 2026
9 checks passed
@firsttris
firsttris deleted the dev-parallel branch November 4, 2026 07:20
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