Skip to content

fix(codex-fleet-demo): guard attach behind TTY check, drop exec#168

Merged
NagyVikt merged 1 commit into
mainfrom
fix/demo-tty-guard
May 16, 2026
Merged

fix(codex-fleet-demo): guard attach behind TTY check, drop exec#168
NagyVikt merged 1 commit into
mainfrom
fix/demo-tty-guard

Conversation

@NagyVikt
Copy link
Copy Markdown
Contributor

Bug

`scripts/codex-fleet/demo/up.sh` ended with:
```bash
exec tmux -L "$SOCKET" attach -t "$SESSION"
```

`exec` replaces the calling shell with tmux. When up.sh is launched without a controlling terminal — kitty launcher, command picker, non-interactive shell, Claude Code's bash tool, etc. — the attach aborts with "open terminal failed: not a terminal" and the parent process is left in a broken state.

Observed: locks up the kitty session selector that spawned up.sh.

Fix

  • Guard the attach behind `[[ -t 0 && -t 1 ]]` so it only runs when stdin AND stdout are real TTYs.
  • Drop `exec` so the shell returns cleanly whether tmux's attach succeeds or not.
  • Print the manual attach command when we skip, so the user knows what to run from a real terminal.

Test plan

  • `bash -n` clean
  • In a TTY: `bash scripts/codex-fleet/demo/up.sh` — auto-attaches as before
  • Without a TTY (e.g. piped, nohup, headless): `bash scripts/codex-fleet/demo/up.sh </dev/null` — exits cleanly, prints attach command, no hang

up.sh ended with 'exec tmux attach' which replaces the calling shell with
tmux. When the script is launched without a controlling terminal (kitty
launcher, command picker, non-interactive shell, etc.), the attach
aborts with 'open terminal failed: not a terminal' and the parent
process is left in a broken state -- observed to lock up the kitty
session selector that spawned up.sh.

Guard the attach behind '[[ -t 0 && -t 1 ]]' and drop the 'exec' so the
shell returns cleanly whether or not the attach actually happens. When
no TTY is present, print the manual attach command and exit 0 normally.

Tear-down + re-up is the recovery path if you hit this in the wild.
@NagyVikt NagyVikt merged commit f605414 into main May 16, 2026
2 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