Fix Shift+Enter not working in macos-container TUI #246
Reference in New Issue
Block a user
Delete Branch "fix-macos-container-shift-enter"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Closes #245.
Summary
Apple's
container exec --interactive --ttydoes not put the host terminal into raw mode before starting its I/O relay. In cooked (canonical) mode the kernel line discipline buffers modifier-key escape sequences — e.g. Shift+Enter inmodifyOtherKeysmode generates\x1b[13;2~— until a carriage-return arrives, so they never reach Claude Code inside the container.Two changes land together:
pty_forward.py— a new stdlib-only wrapper (modelled on the existingsmolmachines/pty_resize.py) that sets the host terminal to raw mode viatty.setraw(), spawns thecontainer execcommand, and restores the original terminal attributes on exit. Falls back to a baresubprocess.runwhen stdin is not a TTY (piped invocations, CI) or whentermiosoperations fail.--env TERM=<host>— retained from the first attempt: withoutTERMinside the container session, Claude Code cannot determine which modifier-key protocol to enable (modifyOtherKeys, kitty keyboard protocol) even with raw mode correctly set.Changed files:
bot_bottle/backend/macos_container/pty_forward.py— new raw-mode wrapperbot_bottle/backend/macos_container/bottle.py—agent_argvwraps TTY execs withpty_forward.pyand forwardsTERMtests/unit/test_macos_container_bottle.py— updated argv assertionstests/unit/test_macos_container_pty_forward.py— 8 new tests covering argv parsing, non-TTY fallback, and raw-mode setup/restore