Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions scripts/spawn.sh
Original file line number Diff line number Diff line change
Expand Up @@ -562,12 +562,20 @@ launch_linux_terminal() {
}

launch_windows_terminal() {
# wt is a native Windows executable, so a bare bash is resolved through the
# Windows PATH and may select WSL's bash.exe. Pin the Bash that is running
# agmsg and convert its MSYS/Cygwin path before crossing the native boundary.
local bash_path
bash_path="$(command -v bash)" || die "current bash executable not found"
if command -v cygpath >/dev/null 2>&1; then
bash_path="$(cygpath -w "$bash_path")" || die "failed to convert bash path for Windows Terminal"
fi
if command -v wt.exe >/dev/null 2>&1; then
wt.exe new-tab bash -l "$BOOT"
wt.exe new-tab "$bash_path" -l "$BOOT"
return 0
fi
if command -v wt >/dev/null 2>&1; then
wt new-tab bash -l "$BOOT"
wt new-tab "$bash_path" -l "$BOOT"
return 0
fi
die "Windows Terminal (wt) not found; set AGMSG_TERMINAL or run inside tmux"
Expand Down
35 changes: 35 additions & 0 deletions tests/test_spawn.bats
Original file line number Diff line number Diff line change
Expand Up @@ -743,6 +743,41 @@ YAML
fi
}

@test "spawn: Windows Terminal receives the current Git Bash executable, not bare bash (#39)" {
bash "$SCRIPTS/join.sh" myteam existing claude-code "$PROJ"
unset AGMSG_TERMINAL

cat > "$STUB_BIN/uname" <<'SH'
#!/usr/bin/env bash
printf '%s\n' MINGW64_NT-10.0
SH
cat > "$STUB_BIN/cygpath" <<'SH'
#!/usr/bin/env bash
if [ "$1" = "-w" ] && [[ "$2" == */bash ]]; then
printf '%s\n' 'C:\Program Files\Git\usr\bin\bash.exe'
else
if [ -x /usr/bin/cygpath ]; then
exec /usr/bin/cygpath "$@"
fi
printf '%s\n' "${!#}"
fi
SH
cat > "$STUB_BIN/wt.exe" <<'SH'
#!/usr/bin/env bash
printf '%s\n' "$@" > "$CAPTURE"
SH
chmod +x "$STUB_BIN/uname" "$STUB_BIN/cygpath" "$STUB_BIN/wt.exe"

run bash "$SCRIPTS/spawn.sh" claude-code alice --project "$PROJ" --no-wait
[ "$status" -eq 0 ]

[ "$(sed -n '1p' "$CAPTURE")" = "new-tab" ]
[ "$(sed -n '2p' "$CAPTURE")" = 'C:\Program Files\Git\usr\bin\bash.exe' ]
[ "$(sed -n '3p' "$CAPTURE")" = "-l" ]
local boot_path; boot_path="$(sed -n '4p' "$CAPTURE")"
[ -f "$boot_path" ]
}

@test "spawn: macOS terminal launch does not steal focus (Terminal and iTerm)" {
# A no-op-Terminal spawn (no $TMUX, no AGMSG_TERMINAL override) exercises
# launch_macos_terminal() itself, which every other test in this file
Expand Down
Loading