claude-code - 💡(How to fix) Fix Add focus-change hooks (SessionFocus / SessionBlur) for the agents view

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

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.

Root Cause

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.

Fix Action

Fix / Workaround

Workaround today

RAW_BUFFERClick to expand / collapse

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."

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

claude-code - 💡(How to fix) Fix Add focus-change hooks (SessionFocus / SessionBlur) for the agents view