Add focus-change hooks (SessionFocus / SessionBlur) for the agents view

Resolved 💬 2 comments Opened May 15, 2026 by pumanitro Closed Jun 20, 2026

Summary

Add hook events that fire when the user changes focus between agents in the claude agents (FleetView) multi-agent view — e.g. SessionFocus and SessionBlur — receiving the usual JSON payload (session_id, cwd, model, etc.) of the agent gaining/losing focus.

Motivation

Today, hooks only fire on things that happen inside a session (SessionStart, UserPromptSubmit, PostToolUse, Stop, CwdChanged, etc.). There is no signal when the user merely switches which agent they are looking at in FleetView. This makes it impossible to drive focus-aware external UI from outside Claude Code.

Concrete use case

I want a right-hand pane in my terminal (zellij / tmux) that shows a live file tree of the currently-focused agent's working directory. With the current hooks I can approximate this by writing cwd to a file on every UserPromptSubmit + SessionStart + CwdChanged, but the panel only updates when I interact with a chat, not when I switch focus to look at another one. So the sidebar lags behind what I'm actually reading.

Other obvious use cases:

  • External status displays / Stream Deck buttons that reflect the focused agent
  • Auto-switching IDE / editor workspace to match the focused chat's cwd
  • Per-agent ambient signals (LEDs, "now working on X" announcements)
  • Logging / analytics on which agents the user actually attends to

Proposed API

Two new hook events:

  • SessionFocus — fires when an agent becomes the focused one in FleetView. Payload includes session_id, cwd, model, title.
  • SessionBlur — fires when the previously focused agent loses focus. Same payload shape.

Both should debounce trivially-fast focus toggles (e.g. ≥150ms).

Related

This was raised as option 3 inside #58523 (the primary ask there is a per-turn statusLine refresh). Filing as a dedicated issue so it can be tracked independently and so the agents-view focus lifecycle has its own home — separate from #58454, #59262, #59263 which cover adjacent sleep/wake/keep-alive lifecycle in the same area.

Workaround today

UserPromptSubmit + SessionStart + CwdChanged hooks writing cwd to ~/.claude/state/active-cwd, watched by the side panel. Works for "follow last interaction" but not "follow current focus."

View original on GitHub ↗

This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗