Skip to content

fix(codex): handle native Windows PIDs in bridge liveness checks#323

Open
Tlryd wants to merge 1 commit into
fujibee:mainfrom
Tlryd:fix/codex-windows-pid-liveness
Open

fix(codex): handle native Windows PIDs in bridge liveness checks#323
Tlryd wants to merge 1 commit into
fujibee:mainfrom
Tlryd:fix/codex-windows-pid-liveness

Conversation

@Tlryd

@Tlryd Tlryd commented Jul 5, 2026

Copy link
Copy Markdown

Summary

  • Add compatibility helpers for native Windows PID liveness and termination under MSYS/Git Bash
  • Use them in Codex bridge/app-server status, reuse, and stop paths
  • Canonicalize Codex bridge metadata project paths before comparing

Verification

  • Manually exercised the affected Codex bridge flow on Windows/Git Bash; no issue observed
  • git diff --cached --check
  • bash -n on changed shell scripts
  • Not run locally: bats tests/ because bats is not installed locally
  • GitHub Actions will run the full bats suite on Linux/macOS; Windows CI is currently limited to focused install-
    helper tests

Copilot AI review requested due to automatic review settings July 5, 2026 01:36

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves Codex bridge robustness on Windows/MSYS by introducing cross-platform PID liveness/termination helpers, applying them to Codex bridge/app-server lifecycle checks, and making Codex bridge metadata comparisons tolerant of path aliases via canonicalization.

Changes:

  • Add compat_pid_alive / compat_kill_pid for Windows-native PID handling under MSYS/Git Bash.
  • Use these helpers across Codex monitor/launcher/session-start/delivery status/stop paths.
  • Canonicalize Codex bridge metadata project= before comparing, with a new Bats test covering the alias-path case.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
tests/test_delivery.bats Adds a regression test ensuring canonicalized project metadata matches are accepted.
scripts/lib/compat.sh Introduces PID liveness/kill helpers for MSYS/Windows native PIDs.
scripts/drivers/types/codex/codex-monitor.sh Uses compat PID helpers when reusing/killing the Codex app-server.
scripts/drivers/types/codex/codex-bridge-launcher.sh Sources compat and uses compat PID helpers for bridge reuse/teardown.
scripts/drivers/types/codex/_session-start.sh Uses compat PID liveness checks when deciding whether to reuse an existing bridge.
scripts/drivers/types/codex/_delivery.sh Canonicalizes metadata project paths; uses compat PID liveness for status.
scripts/delivery.sh Uses compat PID helpers when stopping Codex bridge and app-server processes.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread scripts/lib/compat.sh
Comment on lines +80 to +90
local psw
psw=$(ps -W 2>/dev/null || true)
if [ -n "$psw" ]; then
printf '%s\n' "$psw" | awk -v pid="$pid" 'NR > 1 && $4 == pid { found=1 } END { exit found ? 0 : 1 }' && return 0
return 1
fi
psbin=$(_compat_powershell_bin) || return 1
"$psbin" -NoProfile -Command \
"\$p = Get-Process -Id $pid -ErrorAction SilentlyContinue; if (\$null -eq \$p) { exit 1 } else { exit 0 }" \
>/dev/null 2>&1
;;
Comment thread scripts/lib/compat.sh
Comment on lines +103 to +114
local msys_pid psw
psw=$(ps -W 2>/dev/null || true)
if [ -n "$psw" ]; then
msys_pid=$(printf '%s\n' "$psw" | awk -v pid="$pid" 'NR > 1 && $4 == pid { print $1; exit }')
[ -n "$msys_pid" ] && kill "$msys_pid" 2>/dev/null && return 0
return 1
fi
psbin=$(_compat_powershell_bin) || return 1
"$psbin" -NoProfile -Command \
"Stop-Process -Id $pid -ErrorAction Stop" \
>/dev/null 2>&1
;;
Comment thread tests/test_delivery.bats
Comment on lines +1500 to +1501
local dead_pid=999999
printf '%s\n' "$dead_pid" > "$TEST_SKILL_DIR/run/codex-bridge.team.alice.pid"
@Tlryd

Tlryd commented Jul 5, 2026

Copy link
Copy Markdown
Author

AI review comments are left unresolved for maintainers' judgment.
If you think any of them should be addressed before merge, I can update the PR.

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.

2 participants