Skip to content

fix: response handling and terminal-safe TUI attach wrapper#6

Merged
raysonmeng merged 2 commits intomasterfrom
fix/response-handling-and-attach-wrapper
Mar 24, 2026
Merged

fix: response handling and terminal-safe TUI attach wrapper#6
raysonmeng merged 2 commits intomasterfrom
fix/response-handling-and-attach-wrapper

Conversation

@raysonmeng
Copy link
Owner

Summary

Bug investigation with Codex cross-review found 2 fixable issues + 1 upstream bug:

  • Proxy: support numeric-string response IDs, log when response arrives but no TUI connected
  • Terminal: wrapper script saves/restores terminal state around Codex TUI launch
  • Resume hang: confirmed as Codex upstream bug (GitHub #14470, #12382, #12515)

Files changed

  • src/codex-adapter.ts — numeric-string ID support in handleAppServerResponse, TUI-absent response logging
  • scripts/agentbridge-attach.sh — new wrapper that protects terminal from corruption after kill -9

Test plan

  • 61 tests pass
  • TypeScript type check passes
  • bash -n syntax check passes on wrapper
  • Manual: kill -9 Codex TUI via wrapper, verify terminal recovers

Review

Codex reviewed 2 rounds, all findings addressed.

🤖 Generated with Claude Code + Codex

rayson951005@gmail.com and others added 2 commits March 25, 2026 05:54
Bug investigation findings (with Codex cross-review):

1. Proxy response improvements:
   - Support string response IDs in handleAppServerResponse (was
     silently dropping non-numeric IDs)
   - Log when response arrives but no TUI is connected (was silent)

2. Terminal corruption fix:
   - Add scripts/agentbridge-attach.sh wrapper that saves terminal
     state (stty -g) before launching Codex TUI and restores it on
     exit, including raw mode, keyboard enhancement, bracketed paste,
     focus tracking, and alternate screen cleanup
   - Works even after kill -9 of the child process (wrapper survives)

3. Resume hang: confirmed as Codex upstream bug (GitHub #14470,
   #12382, #12515), not a bridge proxy issue.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…nces, trap signals

1. codex-adapter.ts: Replace permissive Number() coercion with /^-?\d+$/ regex
   to prevent Number("") → 0 and Number("1.5") false matches
2. agentbridge-attach.sh: Write escape sequences to /dev/tty when available,
   fall back to stdout only if it's a terminal
3. agentbridge-attach.sh: Trap INT and TERM in addition to EXIT for macOS
   bash 3.2 compatibility

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@raysonmeng raysonmeng merged commit e9db450 into master Mar 24, 2026
@raysonmeng raysonmeng deleted the fix/response-handling-and-attach-wrapper branch March 24, 2026 22:55
raysonmeng pushed a commit that referenced this pull request Mar 26, 2026
- Replace node with bun in package.json scripts and shebang (#1)
- Fix init.md: init is best-effort plugin install, dev handles marketplace (#2)
- Set executable permission on health-check.sh (#4)
- Add squash merge rule to init.md collaboration template (#5)
- Update plugin README to describe dual-mode transport (#6)

Cross-reviewed: Claude ↔ Codex

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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