Skip to content

Commit f605414

Browse files
NagyViktNagyVikt
andauthored
fix(codex-fleet-demo): guard attach behind TTY check, drop exec (#168)
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. Co-authored-by: NagyVikt <nagy.viktordp@gmail.com>
1 parent 47439e6 commit f605414

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

  • scripts/codex-fleet/demo

scripts/codex-fleet/demo/up.sh

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,16 @@ echo "demo up. session=$SESSION socket=$SOCKET plan=$PLAN_SLUG"
210210
echo "attach: tmux -L $SOCKET attach -t $SESSION"
211211
echo "tear down: bash scripts/codex-fleet/demo/down.sh"
212212

213+
# Attach only when stdin + stdout are real TTYs. Without that, `exec tmux
214+
# attach` aborts with "open terminal failed: not a terminal" and strands the
215+
# parent — observed to lock up the kitty launcher / session picker that
216+
# spawned up.sh. Drop `exec` so the shell returns cleanly even if tmux's
217+
# attach fails for some other reason. Print the attach command when we skip.
213218
if [[ "$attach" -eq 1 ]]; then
214-
exec tmux -L "$SOCKET" attach -t "$SESSION"
219+
if [[ -t 0 && -t 1 ]]; then
220+
tmux -L "$SOCKET" attach -t "$SESSION"
221+
else
222+
echo "demo: no TTY available, skipping auto-attach" >&2
223+
echo " run from a terminal: tmux -L $SOCKET attach -t $SESSION" >&2
224+
fi
215225
fi

0 commit comments

Comments
 (0)