aiwatch

Crates.ioaiwatch
lib.rsaiwatch
version0.2.0
created_at2026-01-16 00:07:34.097784+00
updated_at2026-01-17 16:27:16.764601+00
descriptionA TUI tool for monitoring Claude Code and OpenCode AI agent activity in real-time
homepagehttps://github.com/nyanko3141592/subagent-viewer
repositoryhttps://github.com/nyanko3141592/subagent-viewer
max_upload_size
id2047357
size162,846
Naoki Takahashi / 電電猫猫 (nyanko3141592)

documentation

https://github.com/nyanko3141592/subagent-viewer#readme

README

aiwatch

A TUI (Terminal UI) tool for monitoring Claude Code and OpenCode AI agent activity in real-time.

Crates.io License: MIT Rust

Features

  • Real-time monitoring - Auto-refreshes every 300ms + file change detection
  • Card-style display - Each project shown as a bordered card (kanban-style)
  • Compact status icons - Status shown with icons only (⟳ ✓ ⏸ ⏹)
  • Input-waiting alert - Red border + ⏹ icon for projects waiting for user input
  • Multi-column layout - 2 columns at 120+ width, 3 columns at 180+ width
  • Project summary bar - Quick overview of recent projects (last 5 min) with status icons
  • Agent emoji indicators - Shows running agents (🔍 Explore, 📝 Plan, 💻 Bash, etc.)
  • Compact mode - Summary-only display when terminal height ≤ 5 lines
  • Session state detection - Shows completion, waiting for bash/input, running states
  • Project-based grouping - Shows recently active projects with session counts
  • Recent sessions only - Displays sessions from the last hour
  • Max 20 projects - Shows up to 20 recent projects
  • Tool usage tracking - Color-coded display of tools (Bash, Read, Write, Task, etc.)
  • Todo progress - Shows current todos with completion status
  • Active session indicators - Green border for active sessions (within 30 seconds)
  • TODOリスト詳細表示 - 各プロジェクトのTODOリストをツリー形式で表示(✓完了, ▶進行中, ○待機)
  • Git Branch表示 - プロジェクト名の横に🌿アイコンとブランチ名を表示
  • サブエージェント進捗表示 - Task(サブエージェント)の詳細情報(タイプ、ステータス、実行時間、ツール数)
  • スクロール機能 - j/k, d/u, g/G キーで上下スクロール
  • コンテキスト使用量表示 - 200kに対する使用率をパーセント表示
  • 入力待ち検知 - 入力待ち状態は赤枠 + ⏹アイコンで強調表示
  • アラート機能 - プロジェクトがアクティブ→待機に変わったときにターミナルベルで通知
  • 自動並べ替え - 1分以上放置されたプロジェクトは自動的に下に移動
  • マウススクロール対応 - マウスホイールでスクロール可能
  • Multi-tool support - Supports both Claude Code (🤖) and OpenCode (🔓)

Installation

From crates.io (Recommended)

cargo install aiwatch

From source

# Clone the repository
git clone https://github.com/nyanko3141592/subagent-viewer.git
cd subagent-viewer

# Build in release mode
cargo build --release

# Run directly
./target/release/aiwatch

Install from source to PATH

cargo install --path .

Now you can run aiwatch from anywhere.

Dependencies

  • Rust 1.56 or later
  • Claude Code CLI and/or OpenCode installed and used

Usage

Run the viewer in a separate terminal while using Claude Code or OpenCode:

aiwatch

The viewer will automatically:

  • Monitor both Claude Code (~/.claude/) and OpenCode (~/.local/share/opencode/) directories
  • Display projects with recent activity (within the last hour)
  • Show up to 20 most active projects
  • Refresh automatically every 300ms or when files change
  • Alert you with a terminal bell when a project becomes idle (waiting for input)

Quick Start

  1. Start Claude Code or OpenCode in one terminal
  2. In another terminal, run aiwatch
  3. Watch your AI assistant's activity in real-time
  4. Use q to quit when done

Example Output

 ⏹ 1 入力待ち 2分  ⏸ 1 承認待ち  ● 2 実行中
 ProjectA ●  | ProjectB ✓  | ProjectC !       <- Summary bar
┌─ ▼ SubagentViewer ● ──────────────────────────┐  <- Green border (active)
│ 🤖 🌿main 45% ✓2○3                            │  <- Info line (compact)
│ ▶ Implementing feature X                      │  <- In-progress TODO (heading)
│  ├ 📋 Plan         ✓ 25s  Read Edit           │  <- Completed agent (gray)
│  ├ 🔍 Explore      ✓  1m  Grep Glob           │  <- Tree structure
│  └ 🤖 Agent        ●  2m  Bash Read +2        │  <- Running agent (green)
│ ✓3 ○Add tests ○Update docs                    │  <- TODO summary (horizontal)
└───────────────────────────────────────────────┘
┌─ ▼ OtherProject ⏸ ────────────────────────────┐  <- Yellow (approval waiting)
│ 🤖 🌿main 50% ✓1○2 ⚠Bash待ち[2m]             │  <- Waiting info in collapsed
│ ⚠ BASH待ち: git push origin [2m]             │  <- Alert banner (yellow bg)
│ ▶ Deploy to production                        │
│  └ 🔍 Explore      ● 30s  Grep Glob           │
└───────────────────────────────────────────────┘
┌─ ▶ IdleProject ! ─────────────────────────────┐  <- Red border (input waiting)
│ 🤖 5m 50% ⏹入力待ち[5m]                      │  <- Collapsed with wait info
└───────────────────────────────────────────────┘
 j/k nav ⏎ toggle c[ ]cwd v[ ]compact q quit

Card display features:

  • Green border: Active project (activity within 30 seconds)
  • Red border: Waiting for user input (⏹ icon)
  • Yellow background banner: Waiting for Bash/File approval (⚠ icon)
  • Gray border: Idle project
  • ▼/▶ icons: Expanded/collapsed state

Hybrid layout (agents + TODOs):

  • Agents displayed in one line each with tree structure (├ └)
  • Running agents shown in green (●), completed in gray (✓)
  • Tool names displayed inline (max 3, with +N for extras)
  • TODO summary in horizontal layout at bottom

Multi-column layout (wide terminal):

┌─ ▼ ProjectA ● ─────┐  ┌─ ▼ ProjectB ✓ ─────┐  ┌─ ▶ ProjectC ⏸ ─────┐
│ 🤖 45% ✓2○3        │  │ 🤖 80%             │  │ 🤖 50% ⚠Bash待ち   │
│ ▶ Task in progress │  │ All done!          │  └─────────────────────┘
│  └ 🔍 Explore ● 2m │  └─────────────────────┘
│ ✓2 ○Task1 ○Task2   │
└─────────────────────┘

Key Bindings

Key Action
j / Select next project
k / Select previous project
Enter / Space Toggle expand/collapse selected project
e Toggle expand/collapse all projects
c Toggle current directory filter
v Toggle compact mode (summary only)
d Scroll down 10 lines
u Scroll up 10 lines
g Go to top
G Go to bottom
r Refresh
q Quit
Mouse scroll Up/Down 3 lines

How It Works

The viewer monitors internal data from both Claude Code and OpenCode:

Claude Code (🤖):

  • ~/.claude/projects/ - Session logs (JSONL files)
  • ~/.claude/todos/ - Todo lists per session

OpenCode (🔓):

  • ~/.local/share/opencode/storage/project/ - Project metadata
  • ~/.local/share/opencode/storage/session/ - Session metadata
  • ~/.local/share/opencode/storage/message/ - Message/token data
  • ~/.local/share/opencode/storage/todo/ - Todo lists

It parses tool_use events from session logs and displays them grouped by project.

Display Legend

Card Border Colors

Color Meaning Details
Green Active Project had activity within the last 30 seconds
Red Input Waiting Project is waiting for user input (⏹ status)
Gray Idle No recent activity or other states

Status Icons (Compact)

Icon Meaning Color Details
Active/Running Green/Cyan Project is actively running
Completed Green Session completed successfully
Waiting Yellow Waiting for Bash/File approval
! Input Waiting Red Waiting for user input (highlighted)
? Unknown Gray Status could not be determined

Project Card Symbols

Symbol Meaning Details
Expanded Project card is expanded, showing details
Collapsed Project card is collapsed, showing only header
🤖 Claude Code This project is being monitored from Claude Code's session logs
🔓 OpenCode This project is being monitored from OpenCode's storage
🌿 Git Branch Shows the current git branch name for this project (e.g., 🌿main)
📊 Context Usage Token usage display with percentage (e.g., 45k(22%))
Completed Todos Number of completed todo items (e.g., ✓2)
Pending Todos Number of pending/in-progress todo items (e.g., ○3)

Context Usage Colors

Color Threshold Meaning
Red > 150k tokens Context window nearly full (75%+)
Yellow > 100k tokens Context usage moderate (50%+)
Gray ≤ 100k tokens Context usage safe (50% or less)

Waiting State Indicators

Projects waiting for user input are highlighted with a red border and the ⏹ (stop) icon.

State Icon Border Color Description
Input Waiting Red Waiting for user input - requires attention
Bash Waiting Yellow (gray border) Waiting for Bash command approval
File Waiting Yellow (gray border) Waiting for file change approval
Running Green/Cyan Currently executing

Todo Item Icons

Icon Meaning Color
Completed Green
In progress Yellow
Pending Dark gray

Subagent Status Icons (Tree View)

Icon Color Meaning When it appears
Gray Completed Subagent finished successfully
Green Running Subagent is currently executing tasks
Gray Unknown Subagent status could not be determined

Agent Type Emoji (Summary Bar)

Emoji Agent Type Description
🔍 Explore Codebase exploration agent
📝 Plan Planning/architecture agent
💻 Bash Command execution agent
🤖 general-purpose General purpose agent
code-simplifier Code simplification agent
📚 claude-code-guide Documentation/guide agent
⚙️ statusline-setup Configuration agent

Card Structure

Each project is displayed as a bordered card with a hybrid layout:

Expanded Card (with approval waiting):

┌─ ▼ ProjectName ⏸ ─────────────┐  <- Title: expand icon + name + status
│ 🤖 🌿branch 45% ✓2○3          │  <- Info line: source, branch, context%, todos
│ ⚠ BASH待ち: git push [2m]    │  <- Alert banner (yellow bg) - if waiting
│ ▶ Implementing feature X      │  <- In-progress TODO as heading
│  ├ 📋 Plan         ✓ 25s  ... │  <- Agent: icon, name, status, duration, tools
│  └ 🔍 Explore      ● 30s  ... │  <- Tree structure with ├ └ connectors
│ ✓3 ○Add tests ○Update docs    │  <- TODO summary (horizontal)
└───────────────────────────────┘

Collapsed Card:

┌─ ▶ ProjectName ● ─────────────┐  <- Collapsed indicator (▶)
│ 🤖 🌿main 45% ✓2○3            │  <- Compact info line
└───────────────────────────────┘

┌─ ▶ ProjectName ⏸ ─────────────┐  <- With waiting status
│ 🤖 🌿main 50% ⚠Bash待ち[2m]  │  <- Shows waiting info inline
└───────────────────────────────┘

Agent Line Format:

 ├ 📋 Plan         ✓ 25s  Read Edit +2
 │  │              │  │    │         │
 │  │              │  │    │         └─ Extra tool count
 │  │              │  │    └─ Tool names (max 3)
 │  │              │  └─ Duration
 │  │              └─ Status (✓=done, ●=running)
 │  └─ Agent type with icon
 └─ Tree connector (├ or └)

Tool Names (color-coded)

Tool Color Description
Task Magenta Subagent/spawned agent tasks
Bash / Write / Edit Yellow Commands and file modifications
Other Gray All other tools (Read, Grep, etc.)

Scroll Indicators

Symbol Meaning
↑↓ scroll Shows that content is scrollable
[X/Y] Current position indicator (X = current page, Y = total pages)

Color Palette

The UI uses a unified 6-color palette for consistency:

Color Usage
Cyan (Primary) Selection, headers, TODO section
Magenta (Secondary) Agents, Task tools
Gray (Muted) Inactive elements, tree lines
Green (Success) Active, completed
Yellow (Warning) Pending, Bash/Write/Edit tools
Red (Alert) Input waiting, context critical

Requirements

  • Rust 1.56+
  • Claude Code CLI and/or OpenCode installed and used
  • macOS or Linux (WSL should work but not tested)

Troubleshooting

No projects shown

  • Make sure you're actively using Claude Code or OpenCode
  • Check that sessions are within the last hour (the viewer only shows recent activity)
  • Verify that ~/.claude/projects/ or ~/.local/share/opencode/storage/ exists and contains data

Terminal size issues

  • Use a terminal with at least 80x24 dimensions for best results
  • Small terminals may truncate tool descriptions and project names

Performance issues

  • The viewer automatically limits display to 20 projects and 50 tools per session
  • Each session shows only the last 15 tools to maintain performance

File watcher errors

  • On macOS, you may need to grant full disk access to your terminal
  • Linux users on WSL may experience file system monitoring delays

FAQ

Q: Does aiwatch modify any files? A: No, it only reads logs and data files from Claude Code/OpenCode directories.

Q: Can I use it with both Claude Code and OpenCode simultaneously? A: Yes, it monitors both and displays projects from either tool with appropriate icons (🤖 for Claude Code, 🔓 for OpenCode).

Q: What does the context usage percentage mean? A: It shows the token usage relative to Claude's 200k context window. Red indicates >150k, yellow indicates >100k.

Q: Why does it only show sessions from the last hour? A: To keep the display focused and performant. Only recent activity is typically relevant.

Q: How often does it refresh? A: Every 300ms automatically, plus immediately when files change (via file system watcher).

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

MIT

Commit count: 11

cargo fmt