Skip to content

fix(linux): bells over SSH no longer muted by tmux or silent terminals - #149

Merged
mohak34 merged 10 commits into
mainfrom
fix/v2-bell-ssh-focus
Nov 1, 2026
Merged

mohak34 merged 10 commits into
mainfrom
fix/v2-bell-ssh-focus

Conversation

@mohak34

@mohak34 mohak34 commented Nov 1, 2026

Copy link
Copy Markdown
Owner

Fixes the two causes traced for #147: on OpenCode 2 over SSH, the terminal bell never rang. The reporter has not replied, so neither cause is confirmed on their machine.

What was broken

  • tmux or Zellij over SSH muted every alert. With no desktop window to check, Linux focus detection falls back to tmux or Zellij pane state. Over SSH, an attached, active pane counted as "focused" even with the user's local terminal tab in the background, so suppressWhenFocused (on by default) dropped every bell.
  • A silent V2 terminal could block one that would alert. V2 terminals on one machine claim each event so only one alerts. A terminal whose config turns off every channel for the event still took the claim, and then nothing rang anywhere.
  • The CONTRIBUTING recipe didn't load the plugin on OpenCode 2. V2 loads a local directory plugin from root index.js/tui.js, not from package.json exports.

How the fix works

  • On Linux, when SSH_CONNECTION or SSH_TTY is set and no desktop window was captured, tmux and Zellij pane state no longer counts as focus, so alerts are delivered (AGENTS.md: fail open). Local sessions, and SSH sessions where a desktop window was detected, behave as before. This applies to V1 and V2.
  • A V2 terminal claims an event only if its config enables some channel for it. Focus and minDuration are still checked after the claim, as before, so only the winning terminal runs focus probes and short sessions clear deferred completions as before.
  • CONTRIBUTING now shows a private shim directory for testing a local build on V2.

The reporter's theory that process.stdout.isTTY is false in the V2 TUI does not hold. In a sandboxed OpenCode v2.0.32 run it was true, and the bell reached the terminal.

Surfaces: V1 and V2 for the SSH focus rule; V2 terminal only for the claim change; Linux only (macOS and Windows focus paths unchanged); channels unchanged. README, SPEC and CHANGELOG updated.

Proof

Focused tests, with typecheck clean:

$ bun test src/v2.regression.test.ts src/focus.test.ts src/delivery.focus.test.ts src/delivery.click.test.ts src/notifier.children.test.ts src/tui.routing.test.ts src/terminal-clients.test.ts src/index.never-throws.test.ts
 126 pass
 0 fail

Both new tests fail against main's notifier.ts, delivery.ts and focus.ts:

(fail) isLinuxTerminalFocused > over SSH without a window id, an active tmux or Zellij pane does not count as focus
(fail) a terminal with nothing to deliver leaves the event to another terminal

Real app: OpenCode v2.0.32 in an isolated temp home with --standalone, the plugin loaded through the new CONTRIBUTING shim recipe, and the bell enabled for client_connected only. OpenCode logged loading plugin id=<shim>, and exactly one bare BEL reached the pty.

Not tested: a real SSH session from another machine into tmux. To check it yourself, SSH into a Linux box, start tmux, run OpenCode 2 with bell: true for complete, switch your local terminal to another tab, and let a session finish. Before this change it stays silent; after it, the tab gets the bell. macOS and Windows behavior is untouched.

Known gap: a tmux server started locally, then attached over SSH, has no SSH variables in its panes, so it still mutes alerts as before.

Reviewed with review-loop: 4 rounds with GPT-6.1 Terra. Terra verdict: approved

Generated with Claude Code using Claude Opus 5.5

mohak34 and others added 9 commits November 1, 2026 03:19
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…tions

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…erminal

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <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