bannzai / bannzai/notification-tmux

調査/検討: iPhone から ssh + TUI で tmux の window/pane を操作する CLI ツール

Open
#4 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
0
Forks
0
Avg merge
1d 23h
Merged PRs (30d)
23

Description

## 構想

iPhone から Tailscale VPN 経由で作業マシンに ssh し、ターミナル上で起動する専用 CLI (TUI) で tmux の window/pane をグラフィカルに行き来したい。pane を選択してコマンドを送りたい。Claude Code の通知 (Stop イベント) が来た window に素早く飛びたい。マシンへのログインは Tailscale 前提。

## 最初に決める分岐: 自作するか、Moshi を使うか

構想とほぼ同一の課題を解決した商用ネイティブ iOS アプリ **Moshi** が既に存在する (mosh ネイティブ + tmux ピッカー + Claude Code hooks 通知 + Live Activity/Apple Watch 連携。Pro $7.99/月 or $199 買い切り)。

- 単に困りごとを解消したいだけなら Moshi 採用が最短
- 「自分好みの TUI」「NTMUX 資産 (hook / バッジ概念) との一体運用」「学習」が目的なら自作 TUI
- https://getmoshi.app/ / https://getmoshi.app/docs/hooks

## 調査結果の要点

### iPhone 側クライアント

- **Blink Shell が第一候補**。iOS で唯一ネイティブ mosh を持ち、**Tailscale + mosh の公式統合手順がある** (https://docs.blink.sh/integrations/tailscale+mosh)。SmartKeys バーで Ctrl/Alt の押しっぱなしが可能
- **タップはマウスイベントとして端末に届く** (メンテナ確認済み: https://github.com/blinksh/blink/discussions/1528)。tmux `set -g mouse on` + TUI 側で SGR マウスを有効にすればタッチで項目選択できる。これが TUI 案の技術的な要
- mosh はスクロール系のマウス報告に制約があるため、スクロールはキー/ページング操作に寄せる

### 既存手段の評価

- 素の tmux (`prefix+w` の choose-tree 等) はソフトキーボードで prefix が打ちにくく、session 40+ / window 100+ ではツリー縦スクロールが非現実的
- **fuzzy 絞り込み (sesh / tmux-fzf 系) は大規模に強く、ソフトキーボードとも相性が良い** → 自作 TUI もツリーではなく fuzzy 主体にすべきという示唆
- tmux control mode (`tmux -CC`) は `%window-add` 等の非同期通知を購読できるがメジャーな消費者は実質 iTerm2 のみ。TUI の状態取得部として内部採用する筋 (参考実装: https://github.com/atomicstack/tmux-popup-control の gotmuxcc)

### 先行 OSS (2026-07-08 時点の実測 star)

| リポジトリ | ★ | 概要 |
| --- | --- | --- |
| smtg-ai/claude-squad | 6800 | AI エージェントを tmux + worktree で管理する TUI。ナビゲータではなくエージェント起動器 |
| steipete/tmuxwatch | 214 | session/window/pane ツリー + capture-pane プレビューの監視ダッシュボード |
| atomicstack/tmux-popup-control | 0 | display-popup 内 TUI。control mode 常時接続・fuzzy・プレビュー。実装参考価値高 |

**「モバイル最適化 × 通知 window への即ジャンプ」を主眼にした OSS は存在しない** = 本構想の空白地帯。

### TUI フレームワーク

- **Go / Bubble Tea が第一候補** (Lip Gloss/Bubbles のエコシステム、claude-squad/tmuxwatch/tmux-popup-control が採用実績)。Rust/ratatui も差分描画で ssh 耐性は同等。いずれもマウス対応

### 通知連携 (NTMUX と共存する設計案)

既存の `scripts/notification-tmux-hook-stop` (URL スキームで macOS アプリへ) はそのまま生かし、**書き込みを 1〜2 行足すだけ**で TUI が同じイベントを消費できる:

- **案 A (最有力): tmux ユーザーオプション** — hook に追記:
```bash
tmux set-option -w -t "$session:$window" @ntmux_unread 1
tmux set-option -g @ntmux_last "$session|$window"
```
TUI は `show-options` で読んで未読バッジ + 「最新通知へジャンプ」を実現、ジャンプ時に unset で既読化。状態が tmux サーバ内に閉じるので**別デーモン不要**、mosh 切断もまたげる
- 案 B: `~/.local/state/ntmux/events.jsonl` に追記 (順序付き履歴・通知一覧向け)。A と併用推奨
- 案 C: Unix ソケット + 常駐デーモン (リアルタイム push が要るなら。Moshi の moshi-hook がこの方式)

## v0 推奨構成

1. **クライアント**: Blink Shell (Tailscale + mosh) → 作業マシン
2. **TUI**: Go / Bubble Tea 製の単一バイナリ。起動直後に session/window の **fuzzy フィルタ**を最前面に。選択で `switch-client` / `select-window -t @n`。状態取得は最初はポーリング、後から control mode に差し替え
3. **通知ジャンプ (v0 の目玉)**: 既存 hook に案 A の 2 行を追記し、TUI 先頭に「最新通知へ」を表示。1 タップでジャンプ
4. **タッチ**: `set -g mouse on` + SGR マウスでタップ選択、スクロールはページング

window/pane の識別子は NTMUX と同じく `@n` / `%n` を SSOT にする (サーバ全体でユニーク、改名・並べ替えに強い)。

## 参照

- https://getmoshi.app/ / https://getmoshi.app/docs/hooks / https://getmoshi.app/pricing
- https://blink.sh/ / https://docs.blink.sh/integrations/tailscale+mosh
- https://github.com/blinksh/blink/discussions/1528
- https://github.com/tmux/tmux/wiki/Control-Mode
- https://github.com/smtg-ai/claude-squad
- https://github.com/steipete/tmuxwatch
- https://github.com/atomicstack/tmux-popup-control
- https://github.com/joshmedeski/sesh / https://github.com/sainnhe/tmux-fzf

## 追記 (2026-07-08): 既存環境でこの問題を解決できる「種」の評価

「session が増えると『どこ見ればいいんだ』になる」問題を、既存の tmux 標準機能・Moshi・手元の資産でどこまで解決できるかを追加調査した。結論: **「通知の受信箱があり、選ぶと該当 window/pane まで開く」を session 横断でやる既存解は無い**。ただし種は 2 つある。

### Moshi の Inbox について (事実訂正)

Moshi は Inbox (受信箱) を**持っている**。公式ドキュメントに「Moshi's inbox keeps one active row per agent session」と明記があり、通知カテゴリは approval_required / task_complete / session_started / tool_running / tool_finished の 5 種。

ただし:

- 行の粒度は**エージェント session 単位**で、window/pane ではない
- 通知タップで tmux の該当 window/pane まで開くという記述は**ドキュメントに無い** (未確認)
- iPhone 側アプリなので、**デスクトップ作業中の「どこ見ればいい」には効かない**。強みは外出時の通知受信

出典: https://getmoshi.app/docs/hooks

### 種 1: tmux 標準のアラート機構 (session 内なら設定だけで使える)

- `monitor-bell` / `monitor-activity` (window option) + `next-window -a` = 「**アラートのある次の window へ移動**」(man tmux で確認。デフォルト bind は `prefix M-n` / `prefix M-p`)
- 既存の Claude hooks は Notification 時に `printf '\a' > /dev/tty` を既に実行しているため、`monitor-bell on` にするだけで「ベルの立った window が status line で光る → M-n で順にジャンプ」が成立する
- 本質的な制約: **同一 session 内しか巡回できない**。履歴・件数バッジは無く、window を見た瞬間にフラグが消える。40+ session 横断の問いには答えられない

### 種 2: 既存 hooks 資産 (@claude-waiting) + 小さなセレクタ

既存 hooks が window に付けている `@claude-waiting` (🔔/🐈 + 時刻) は実質**未読マーカー**として機能している。

```bash
tmux list-windows -a -F '#{E:@claude-waiting}|#{session_name}|#{window_id}|#{window_name}' \
| grep '🔔\|🐈' | fzf | ... # 選択後 switch-client + select-window -t @n
```

10 行程度のスクリプトで「session 横断・通知駆動のセレクタ」の 8 割が既存環境だけで組める。これは本 issue の TUI 構想 (通知連携の案 A = tmux ユーザーオプション方式) の最小版そのものであり、**TUI を作る前の v0 検証としても使える**。

### 整理

| 領域 | 既存の解 |
| --- | --- |
| session 内のアラート巡回 | tmux 標準 (`monitor-bell` + `next-window -a`) が解いている |
| モバイルへの通知配信 | Moshi が解いている (Inbox あり。ただし session 行粒度・ジャンプは未確認) |
| デスクトップの通知センター | cmux (サイドバーバッジ) → NTMUX が置き換え中 (window 粒度 + ジャンプ付き) |
| **session 横断の通知受信箱 + 選択で pane まで開く (ssh/モバイル)** | **既存解なし = 本 issue の空白地帯** |

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reading the existing scripts/notification-tmux-hook-stop and inspect the current @claude-waiting hook state. Validate the proposed smallest v0 with tmux and a selector before choosing between a Go/Bubble Tea TUI, polling, and control mode; done is a session-wide notification selector that opens the selected window or pane over the SSH/mobile workflow.

Written by the indexing model from the issue text.

Assessment

Tech stack
go, shell
Domain
cli, tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Active
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.