Skip to content

Ctrl+Q detach not working (iTerm2 / macOS) — XON/XOFF flow control not cleared on attach PTY #361

@valivishy

Description

@valivishy

Environment

  • agent-deck v0.26.2 and v0.26.3
  • macOS Darwin 25.3.0 (Apple Silicon)
  • iTerm2
  • tmux with set -g mouse on
  • zsh

Problem

Ctrl+Q does not detach from an attached session. The keypress is swallowed before agent-deck can process it. Ctrl+B d (native tmux detach) works fine as a workaround.

Diagnosis

  1. cat -v in a fresh terminal does not print ^Q — confirms the key is intercepted at the TTY level (XON/XOFF flow control)
  2. Running stty -ixon fixes cat -v (^Q appears), but Ctrl+Q still does not work inside agent-deck sessions
  3. stty -ixon added to both .zshrc and .zshenv (which agent-deck sources via shell.init_script) — no effect inside sessions
  4. No Ctrl+Q binding in iTerm2 (checked global and profile key bindings)
  5. No Ctrl+Q binding in tmux (tmux list-keys shows no C-q)

Attempted fix (did not work)

Added explicit IXON/IXOFF clearing via unix.IoctlGetTermios/IoctlSetTermios on os.Stdin.Fd() right after term.MakeRaw() in internal/tmux/pty.go. Built locally and tested — Ctrl+Q still not intercepted.

This suggests the issue is not a simple IXON race. The PTY layer created by pty.Start() may be re-establishing flow control on the slave side, or Bubble Tea's terminal restore/raw cycle around tea.Exec is interfering in a way that persists past MakeRaw.

Related issues

Suggested fixes (any of these would resolve it)

  1. Bind Ctrl+Q as a tmux keybind-key -n C-q detach-client on agent-deck managed sessions, bypassing the PTY stdin interception entirely
  2. Make detach key configurable — the [hotkeys] config from PR feat(ui): add Pi support, configurable hotkeys, and preview notes #285 does not include detach; adding it would let users remap to a key that passes through their terminal
  3. Investigate the PTY stdin pathpty.go:Attach() reads os.Stdin and checks for ASCII 17, but the byte may never arrive despite MakeRaw clearing IXON

Workaround

Ctrl+B d (standard tmux detach) works reliably.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions