Skip to content

TUI spontaneously stops with SIGTTOU or SIGTTIN on macOS Bash #51600

Closed as not planned

Description

@djbclark

Description

The TUI renders normally, then becomes job-control stopped after several
seconds without pressing Ctrl-Z. Bash returns to the prompt while OpenCode
remains stopped, and moving the mouse produces SGR mouse-reporting fragments
such as 35;52;22M.

This reproduces with the raw executable, not only through a shell alias or
function.

Plugins

openusage-telemetry.ts and orca-opencode-status.js, but the failure also
reproduces with --pure.

OpenCode version

1.18.32 (latest release). The Homebrew 1.18.30 binary also reproduces.

Steps to reproduce

  1. Start an interactive Bash shell with job control enabled.

  2. Run command opencode --auto.

  3. Wait approximately 10-20 seconds without pressing Ctrl-Z.

  4. Bash reports:

    [1]+ 31119 Stopped (tty output): 22   command opencode --auto
    
  5. Moving the mouse now writes SGR mouse events into the shell.

The same test with command opencode attach http://127.0.0.1:4096 stops with:

[1]+ 43595 Stopped (tty input): 21    command opencode attach http://127.0.0.1:4096

After the default-mode stop, process state was:

PID    PPID   PGID   TPGID  STAT  COMMAND
28778  79088  28778  28778  Ss+   -bash
31119  28778  31119  28778  T     opencode --auto

OpenCode initially owns the foreground TTY, then Bash reclaims it after the
stop. This suggests a foreground-process-group problem followed by SIGTTOU or
SIGTTIN, rather than an intentional suspend.

Isolation performed:

  1. Reproduces in Ghostty directly and in a Herdr-managed PTY.

  2. Reproduces with OpenCode 1.18.30 and 1.18.32.

  3. Reproduces with --pure, ruling out configured plugins.

  4. Reproduces in both the combined default TUI and attach mode.

  5. Running the interactive TUI with Bash monitor mode temporarily disabled
    keeps Bash and OpenCode in the same foreground PGID and remains stable:

    set +m
    command opencode --auto
    set -m

Expected behavior

OpenCode should remain the foreground job until explicitly exited or
suspended, and it should restore terminal mouse/input modes whenever stopped.

Related issues

  1. bug: mouse garbling after inactivity — missing SIGTSTP handler #20506 and bug: missing SIGTSTP handler causes mouse garbling when process is externally suspended opentui#906 cover missing terminal cleanup after an
    external stop, but not the spontaneous stop or foreground-PGID loss.
  2. bug: mouse escape sequences garbled after TUI exit #20458 covers leaked mouse sequences after exit.
  3. opencode (default mode) closes entire terminal window on Linux / i3wm #24077 may involve the same combined TUI startup area, but reports the
    terminal closing rather than Bash receiving SIGTTIN/SIGTTOU.
  4. Bun.spawn crashes when running bash interactive oven-sh/bun#17500 describes a related foreground-process-group failure in
    Bun.

Operating System

macOS 27.0 (26A428), arm64

Terminal

Ghostty 1.3.1 and Herdr 0.7.5-preview.2026-07-29-44b3adb12552, TERM=xterm-256color

Shell: GNU Bash 5.3.20

Activity

  1. github-actions commented on Sep 27, 2026

    @github-actions
    Contributor

    For keybind-related issues, please also check our pinned keybinds documentation: #4997

  2. djbclark commented on Sep 27, 2026

    @djbclark
    Author

    Two additional results:

    1. opencode2 v2.0.18 remained foreground for 20 seconds in the same Bash/PTY setup where v1 consistently stops within 10-20 seconds. Its PGID and the TTY foreground PGID both remained 59659. This suggests the v2 TUI architecture may already avoid the initiating job-control failure.
    2. The local workaround also stabilizes v1 attach mode when monitor mode is disabled around the TUI. After 25 seconds, Bash and opencode attach shared foreground PGID 62945; without the workaround, attach stopped with SIGTTIN (21).

    No authentication setup was needed for the v2 test because existing provider credentials were detected.

  3. simonklee commented on Sep 27, 2026

    @simonklee
    Member

    @djbclark thanks, ill have a look at this.

  4. thdxr commented on Oct 11, 2026

    @thdxr
    Member

    Thanks for the report! OpenCode 2.0 is now out and development is focused on V2, so we're closing issues filed against OpenCode 1. Please upgrade (opencode upgrade --major, details: https://anoma.ly/notes/opencode-2-0), and if this is still relevant on 2.0, reopen this issue or open a new one with your 2.0 version.

    — from 𝕺𝖕𝖊𝖓𝕮𝖔𝖉𝖊

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions