Skip to content

Interactive services: run -i (PTY + holder), log-view input, attach, send, reload (#68) - #76

Merged
Buchi-dev-dzn merged 11 commits into
mainfrom
feat/68-interactive-input
Nov 26, 2026
Merged

Buchi-dev-dzn merged 11 commits into
mainfrom
feat/68-interactive-input

Conversation

@Buchi-dev-dzn

@Buchi-dev-dzn Buchi-dev-dzn commented Nov 26, 2026 •

Copy link
Copy Markdown
Owner

Closes #68. Windows follow-up: #79.

Lets dev servers that take keys while they run (flutter run: r hot reload, R hot restart; Vite: r + Enter, h + Enter) be driven through taba, by people (log view / attach / taba ui) and by agents (taba reload, taba send).

Review hardening (64f6480)

  • Rechecks ownership and the live service and FIFO identities before writing interactive input. Tightens argv detection so commands are not classified from incidental arguments, and cleans up the service and holder if interactive startup fails.
  • Automatic Flutter reload signals go only to a verified flutter run process leader on Linux. On macOS, taba reload and taba reload --restart return E_NO_RELOAD without sending a signal. Use taba attach S/N and press r (reload) or R (restart), or use taba send S/N --key r / --key R.
  • If an unsupported wrapper or legacy record leaves the service without usable input, run taba stop S/N, then rerun the original command with the same name, options and arguments, adding --interactive before the service command (replace --no-interactive if present). Then attach or send the key. This restores manual input; it does not make a wrapper a supported signal target.
  • Windows 11 at 64f6480: cargo fmt --check, cargo clippy --all-targets -- -D warnings, and cargo test -- --test-threads=1 with a disposable TABA_HOME all passed (198 tests passed, 3 ignored).

Owner decisions (final, 2026-11-26, see #68)

  • Flag --interactive / -i, plus --no-interactive. Not --input.
  • A small per-service holder process is allowed, for interactive services only. Non-interactive services are unchanged (stdin /dev/null, no extra process).
  • flutter run and vite are interactive automatically, and run says interactive: yes.

Design

 taba send / attach / log-view input ──write──▶ $TABA_HOME/inputs/<scope>/<name>.fifo
                                                      │ read (opened O_RDWR: never EOF)
                                              holder: taba __hold
                                                      │ write
                                                 PTY master ══▶ PTY slave = service stdin
 service stdout + stderr ──────────────────────▶ logs/<scope>/<name>.log (as before)
  • PTY on stdin only. Vite only binds its shortcuts when process.stdin.isTTY, so a FIFO does not work for it. Flutter accepts a FIFO, but one mechanism for everything is simpler and behaves like a terminal for every tool, so every interactive service uses the PTY. The FIFO is still there, as the holder's input channel. stdout and stderr still go to the log file, so logs look the same as for any other service (tools see a non-terminal stdout and keep their output plain).
  • Holder (taba __hold MASTER FIFO PID PGID START): run starts it right after the service, in its own session, with the PTY master and the FIFO's read end as its only inherited descriptors. It copies the FIFO into the master, drains the master (echo is off, so this is normally empty), and exits as soon as the service's process group is gone (it checks every 200 ms with the same pid + start-time identity check that stop uses). Its pid and start time are in the service record (input.holder_pid, input.holder_start_time). If the holder cannot start, run stops the service and fails.
  • Echo off on the PTY, so typed keys never show up anywhere. Window size 120x40.
  • Not the controlling terminal. The service stays in its own session with no controlling terminal, as before. A crashed holder therefore does not SIGHUP the service, and Ctrl+C typed into it is not turned into SIGINT (the README says to use taba stop). A dead holder is reported as E_NO_INPUT ("its input holder (pid N) is gone").
  • Ownership. Watching a log is free. Typing (send, attach, i), reload and signal use the same rules as stop: the owning scope under its lease, or the holder of an exclusive borrow; anyone else gets E_NOT_OWNER unless --force --reason (recorded as force_send, force_attach, force_reload, force_signal). The owner gets E_LOCKED while another scope holds &mut.
  • Auto-detection (input::detect): flutter … run (also fvm flutter run, a full path, flutter.bat), vite / vite preview / npx vite / node …/vite.js (not vite build), words inside sh -c '…', and one level of package.json scripts for npm run X / npm start / pnpm X / yarn X / bun run X. Only on macOS and Linux; on Windows they start as before.

User-facing changes

taba run -i / --no-interactive Reply: "interactive": true (JSON) / interactive: yes (type: taba attach S/N; i in taba logs -f) (text). Re-running with a different interactive mode is E_CONFLICT.
taba logs -f S/N On a terminal, for an interactive service: read-only log view; i enters input mode (a bar says INPUT MODE), Ctrl+] goes back to read-only, q / Ctrl+C quits. The service keeps running. Unchanged for pipes and for non-interactive services.
taba attach S/N The same view, starting in input mode. From a pipe: forwards stdin until EOF (for scripts).
taba ui i on an interactive service (list or its log view): the log view in input mode; Ctrl+] returns to the UI. Footer shows i input when it applies.
taba reload S/N [--restart] Linux only for a verified flutter run leader: SIGUSR1 (hot reload) / SIGUSR2 (--restart, hot restart); no stdin needed. macOS Flutter: E_NO_RELOAD, use r / R instead. Vite dev: r + Enter (restarts the server; open pages reload). Vite preview and unsupported targets: E_NO_RELOAD. JSON: kind, method.
taba send S/N TEXT [--no-newline] / --key K Unchanged from the draft, except --key enter now sends CR, as a terminal's Enter key does (the PTY turns it into \n for line readers).
taba signal S/N USR1|USR2|HUP Unchanged (main process only).
taba.toml / taba up Merged with main's #75: a service takes interactive = true/false (unset: detected as for run, in the service's cwd).
ps --json "interactive": true/false (renamed from the draft's input, to match the flag).
New error codes E_NO_RELOAD (3). From the draft: E_NO_INPUT (3), E_NOT_RUNNING (3), E_INPUT_BLOCKED (1), E_UNSUPPORTED (1).

Earlier Mac smoke tests (before review hardening)

macOS, Flutter 3.50.0, Vite 8.3.8, Node 26; throwaway TABA_HOME.

Flutter web: flutter create --platforms web, then taba run --name app --wait=240 --ready "log:Flutter run key commands" -- flutter run -d chrome --web-browser-flag=--headless=new:

  • Auto-detected: interactive: yes; ready check passed after 48 s.
  • taba send app --key r → Performing hot reload...; --key R → Restarted application in 327ms.
  • Before the policy change, taba reload app and taba reload app --restart signaled successfully in this setup. The current macOS behavior is E_NO_RELOAD; use the keys above.
  • taba logs -f app in a real PTY (driven by a Python pty.fork script): r in read-only mode was ignored, i → INPUT MODE, r → Reloaded application in 299ms, Ctrl+] → read-only again, r ignored, q → exit 0, app still running.
  • taba stop app: the holder, flutter_tools, the frontend server and headless Chrome were all gone afterwards (pgrep).
  • Finding: Flutter run key commands is printed before the browser's debug client connects. The first r sent right after the ready check only recompiled (Recompile complete. No client connected.). The README and SKILL.md keep the requested --ready "log:Flutter run key commands", and say to wait for log:Dart VM Service on Chrome is available when a script reloads right after start.

Vite: package.json with "dev": "vite", taba run --name web --port auto --wait=30 -- npm run dev -- --port '{port}' --strictPort:

  • Auto-detected through the npm script: interactive: yes; Vite printed press h + enter to show help, which it only does when stdin is a TTY.
  • taba send web h → the shortcut list; taba reload web → [vite] server restarted.
  • taba stop web: holder gone.

The draft's earlier finding still holds and is the reason for the PTY: with only a FIFO, Vite never binds its shortcuts (process.stdin.isTTY is undefined).

Tests

tests/input.rs (Unix; a Windows test checks E_UNSUPPORTED):

  • send reaches stdin; stdin is a TTY with echo off; no EOF without a writer or between sends; attach from a pipe; signal; already_running vs E_CONFLICT on a different interactive mode; after stop the holder exits and send is E_NOT_RUNNING; rm removes the FIFO.
  • not interactive → E_NO_INPUT for send/attach; signal still works.
  • ownership: E_NOT_OWNER for send/attach/signal/reload, --force needs --reason, forced send recorded, exclusive borrower may send, owner E_LOCKED.
  • a fake flutter (cbreak keys, SIGUSR1/SIGUSR2): auto-interactive, interactive: yes in the text reply, a single key arrives without Enter, Linux signal reload/restart vs. macOS E_NO_RELOAD, and --no-interactive (stdin EOF, E_NO_INPUT).
  • a fake vite (line shortcuts): auto-interactive, stdin is a TTY, reload sends r; a plain service gives E_NO_RELOAD.
  • the log view in a real PTY: read-only drops keys, i types, Ctrl+] stops typing, q quits, the service keeps running.
  • Unit tests: detection (flutter/vite/wrappers/sh -c/package scripts), keys, CRLF; taba ui: i only on a running interactive service.

Windows

  • run -i, send, attach, reload, signal return E_UNSUPPORTED, and the message points to Interactive services on Windows (ConPTY): run -i, send, attach, reload #79 (ConPTY follow-up). Auto-detection is off on Windows, so flutter run / vite start as before.
  • The windows-latest failure (constant WRITE_TIMEOUT is never used) is fixed with a Unix-only constant. Windows CLI parsing also needed an explicit 8 MiB dispatch-thread stack: the expanded Clap command tree overflowed the default Windows main-thread stack in integration tests. CI now builds, runs Clippy and passes all tests on Windows.

Limits and follow-ups

  • Windows / ConPTY: Interactive services on Windows (ConPTY): run -i, send, attach, reload #79.
  • Logs are not cleaned: the design note mentioned stripping ANSI codes and collapsing \r progress lines in taba logs (with --raw for the original). Because stdout is still a file, Flutter and Vite already write plain text, so this is left out of this PR; worth a separate issue if colored tools show up.
  • Ctrl+C typed into a service is not delivered as SIGINT (no controlling terminal); taba stop is the way to stop it.
  • reload knows Flutter and Vite only; other tools use taba send --key.

🤖 Generated with Claude Code

Update to main (4e3e7b7, Windows/WSL owner: N.A.V.i)

Merged origin/main (3f2e388: short taba run CMD form #74, discovered_ports, sha2 bump #81, action bumps) into this branch; merge commit, no force-push, no history rewritten. Conflicts resolved so both sides keep working:

  • RunArgs: main's terminal-confirmation flag (interactive: bool, "offer the corrected command") is renamed prompt; this PR's interactive: Option<bool> (-i / --no-interactive / detected) keeps its name. Interactive detection runs in main's new run_service, so it applies to the short form, the explicit form and taba up.
  • Service keeps both discovered_ports and input; run --json has both discovered_ports and interactive.
  • Windows: the 8 MiB taba-main thread stays and wraps main's new runform::prepare + try_parse_from.
  • runform knows -i, --interactive, --no-interactive as run switches, so taba run "flutter run" -i and taba run -i vite parse like other taba options (new unit test; runform_knows_every_run_flag now also checks short switches).
  • The short form's text reply also prints interactive: yes (type: taba attach NAME; i in taba logs -f).
  • tests/short_run.rs: the explicit-form JSON key list includes interactive.

Checks at 4e3e7b7

  • CI run 45809600214: macos-latest, ubuntu-latest, windows-latest all passed (fmt, build, Clippy -D warnings, all tests). tests/input.rs: 7/7 on macOS and Ubuntu (incl. the real-PTY log-view test), 1/1 on Windows (E_UNSUPPORTED). Release candidate run 45809600343: all package jobs, advisories and archive verification passed.
  • Windows 11 (local): cargo fmt --check, cargo clippy --all-targets -- -D warnings, cargo test (all suites pass). Disposable TABA_HOME: run -i → E_UNSUPPORTED (points to Interactive services on Windows (ConPTY): run -i, send, attach, reload #79), send → E_UNSUPPORTED, reload of a plain service → E_NO_RELOAD, short and explicit forms start non-interactive (interactive: false), stop works.
  • WSL2 Ubuntu 24.04 (local, Linux PTY): cargo fmt --check, Clippy, cargo test (all suites; input 7/7). Plus a disposable smoke script (throwaway TABA_HOME in /tmp, fake vite as a package.json script and a fake flutter in Python; no real Flutter/Vite, no installed binary):
    • taba run npm run dev (short form) and taba run --name web --port auto -- npm run dev -- --port '{port}': auto-interactive, interactive: yes printed, ps --json interactive: true; the fake Vite saw isTTY=true.
    • send web h → help; reload web → method: stdin, [vite] server restarted.
    • Another scope: send / reload → E_NOT_OWNER (exit 3), --force without --reason → E_FORCE_NEEDS_REASON; viewing its log works.
    • Fake flutter: send --key r arrives as one key without Enter; reload → SIGUSR1, reload --restart → SIGUSR2.
    • taba logs -f app in a real PTY (pty.fork): key in read-only mode dropped, i shows INPUT MODE and types, Ctrl+] stops typing, q exits 0, service still running.
    • stop: every holder pid gone, send → E_NOT_RUNNING, no leftover processes from the fixture.

Platform limits (unchanged)

  • macOS and Linux (incl. WSL2) only. On Windows interactive mode is E_UNSUPPORTED and detection is off; ConPTY is Interactive services on Windows (ConPTY): run -i, send, attach, reload #79.
  • macOS was not re-run on real hardware for this merge; the macOS CI job runs the full PTY test suite, and the real Flutter/Vite runs above are from the earlier Mac pass.
  • Note for Windows test runs (the test and Windows spawning come from main; this PR does not change them): tests/project.rs::up_stops_at_first_failure_and_keeps_earlier_services leaves its python -m http.server running on Windows; it inherits the test's output pipe, so cargo test | grep waits until it is killed. Redirecting to a file avoids the hang.

Owner review required before merge.

Previous validation (ac8e6d4)
  • CI workflow run 45759184542 passed on macOS, Ubuntu and Windows (format, build, Clippy, tests) via workflow dispatch at the PR head.
  • Local cargo fmt --check, git diff --check, and cargo test --test input (7 passed). Full local builds were stopped when available disk fell below 2 GiB; CI provided the full cross-platform validation. No local Flutter service was started during the final Windows fix; the real Flutter and Vite runs documented above were completed earlier on this PR.

FIFO-based stdin for services started with --interactive/-i (Unix): the
service reads the FIFO read-only and inherits an extra write end, so it never
sees EOF and no taba process stays behind. taba send, taba attach and
taba signal follow the stop ownership rules (owner, exclusive borrow, or
--force --reason). ps --json reports "input". taba ui: i attaches.

Design under review on #68 (PTY + holder); not ready to merge.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…#68)

- Interactive services get a pseudo-terminal as stdin (stdout/stderr still
  go to the log). A per-service holder (`taba __hold`) keeps the PTY master
  open, forwards the input FIFO into it, drains it and exits with the
  service. Echo is off; the PTY is not the controlling terminal.
- `run -i/--interactive`, `--no-interactive`; `flutter run` and `vite`
  (also via npm/pnpm/yarn/bun scripts) are interactive by default and the
  reply says `interactive: yes`.
- `taba logs -f` on a terminal is read-only until `i`; Ctrl+] stops typing,
  q quits. `taba attach` opens it in input mode; `i` in `taba ui` too.
- `taba reload [--restart]`: Flutter SIGUSR1/SIGUSR2, Vite `r` + Enter;
  E_NO_RELOAD otherwise.
- `ps --json` field is `interactive`. Windows: E_UNSUPPORTED (#79); fixes
  the unused-constant build error on windows-latest.
- Tests, README section, SKILL.md hot-reload section.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Buchi-dev-dzn Buchi-dev-dzn changed the title Interactive input for services: run --input, send, attach (#68) Interactive services: run -i (PTY + holder), log-view input, attach, send, reload (#68) Nov 26, 2026
@Buchi-dev-dzn
Buchi-dev-dzn marked this pull request as ready for review November 26, 2026 17:15
@Buchi-dev-dzn
Buchi-dev-dzn merged commit 4faa945 into main Nov 26, 2026
10 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.

Let interactive dev servers take input: run --input, taba send, taba attach (Flutter hot reload)

1 participant