Skip to content

Session Monitoring

Session monitoring is the core of navi. It tracks all running Claude Code sessions in real time, displaying their status, working directory, and current message in a styled terminal interface.

When Claude Code fires events (user prompt, tool approval, stop, etc.), hook scripts write status information to JSON files in ~/.claude-sessions/. Each session gets its own JSON file keyed by tmux session name.

The main hook script (notify.sh) receives a status argument and writes a JSON file:

{
"tmux_session": "my-session",
"status": "working",
"message": "Implementing the login feature",
"cwd": "/home/user/projects/app",
"timestamp": 1738972800
}

Navi polls ~/.claude-sessions/*.json every 500ms to detect changes. Each poll cycle:

  1. Reads all JSON status files from the sessions directory
  2. Cross-references with tmux list-sessions to detect stale entries
  3. Removes entries for sessions that no longer exist in tmux
  4. Sorts sessions by priority — attention-needed statuses first (waiting, permission), then by timestamp
StatusIconColorMeaning
waitingYellowAwaiting user input
permissionMagentaNeeds tool approval
working⚙️CyanActively processing
doneGreenTask completed
idleGrayAgent is idle
stoppedGraySession stopped
errorRedError occurred
offline⏹️GrayDisconnected
unknownDimUnknown or stale

Each session row shows:

  • Status icon with color
  • Session name
  • Age (e.g., ”12s ago”, “3m ago”)
  • Working directory (dimmed)
  • Current message (dimmed, italic, truncated)

Sessions that need attention (waiting, permission) sort to the top automatically.