Skip to content

feat: add gx run — run scripts with a turbo-style TUI - #30

Merged
reckerp merged 3 commits into
mainfrom
feat-run-scripts
Jul 22, 2026
Merged

feat: add gx run — run scripts with a turbo-style TUI#30
reckerp merged 3 commits into
mainfrom
feat-run-scripts

Conversation

@reckerp

@reckerp reckerp commented Jul 22, 2026

Copy link
Copy Markdown
Owner

What

Adds gx run <script>: user-defined, per-repo run scripts that start multiple long-running services (dev server, API, db, …). On a terminal it opens a turbo-style TUI — service sidebar on the left, live logs on the right; piped/CI, it streams prefixed interleaved output.

Run scripts

Run scripts are per-user (stored alongside the personal setup script, under <config>/repos/<repo-key>/run/), not committed to the repo. A script is a directory of files, one file per service:

run/dev/
├── 01-api.sh      → service "api"
├── 02-web.sh      → service "web"
└── db.sh          → service "db"
  • Each file is one service in the TUI sidebar.
  • Optional leading NN[-_.] prefix sets order and is stripped from the name (01-api.shapi); the extension is stripped too.
  • Executable files run directly (any shebang); others run via sh <file>.
  • Services run with cwd = the workspace gx run was invoked from, and get GX_WORKSPACE_ROOT, GX_MAIN_ROOT, GX_RUN_SCRIPT, GX_SERVICE.

Usage

  • gx run — list available scripts.
  • gx run --edit <name> — scaffold a script directory + template service, open in $EDITOR.
  • gx run <name> — start all services (TUI on a TTY, prefixed stream otherwise).

TUI keys: j/k/1-9 select · Tab focus · r restart · x kill · q/Ctrl-C stop-all · g/G top/follow · h/l horizontal scroll · ? help.

Design

Sync-only, matching the crate: reader threads push lines over one mpsc channel drained in the render loop; exits are reaped by polling try_wait in tick(). On unix each service runs in its own process group so a kill reaches a shell script's children (SIGTERM → SIGKILL escalation). New unix-only libc dep (killpg + a SIGINT flag handler); no tokio/nix/ctrlc.

Commits:

  1. run-script engine (discovery, supervisor, streaming)
  2. turbo-style TUI
  3. gx run command, args, and shell completions

Testing

  • 24 new unit tests (discovery/parsing/ordering, ring buffer + ANSI strip, supervisor spawn/kill/restart incl. a regression test for cancelling a pending restart on quit). Full suite: 290 + 16 pass, clippy clean.
  • Manually smoke-tested the non-TTY stream (interleaved colored output, exit notices, exit codes), listing, --edit, unknown-script error, and completion output.

Note: the interactive TUI was reviewed and type-checked but not driven live in this environment (needs a real terminal) — worth an eyeball on the sidebar/restart/scroll before merge.

reckerp added 3 commits July 22, 2026 17:09
Introduce the `gx run` backend under src/run/:

- discover: resolve `<profile>/run/<script>/` directories, one service per
  file, with optional NN- ordering prefixes stripped from display names.
- buffer: a bounded per-service ring buffer plus an ANSI stripper.
- supervisor: spawn each service in its own process group (unix), stream
  merged stdout/stderr over one mpsc channel, reap via try_wait, and
  kill/restart with SIGTERM->SIGKILL escalation.
- stream: the non-TTY runner that interleaves prefixed, colored output and
  exits non-zero if any service fails.

Adds a unix-only libc dependency for killpg and a SIGINT flag handler.
A full-screen TUI with a service sidebar (status glyphs) on the left and
the selected service's scrollback on the right. Keys switch service, focus
the log pane, restart (r) / kill (x) a service, quit-and-stop-all (q), and
scroll/follow the logs. Modeled on the existing review TUI's event loop,
layout, and terminal handling.
Add the `Run { script, edit }` subcommand and its dispatch. The command
resolves the current workspace + main root, discovers the named script
under the personal profile, and opens the TUI on a terminal or streams
prefixed logs when piped. `gx run` with no args lists available scripts;
`--edit` scaffolds a script directory with a template service.

Adds a RunScripts dynamic-completion kind wired into the zsh/bash/fish
completion helpers.
@reckerp
reckerp merged commit 740c76e into main Jul 22, 2026
6 checks passed
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.

1 participant