Allow hooks to set the session name (e.g. reset tab title on /clear)

Open 💬 0 comments Opened Jun 11, 2026 by jeantristan

Problem

In the VSCode extension, the tab title reflects the session name. /rename lets me set it interactively, and I use it in a start-issue workflow to label parallel sessions with the branch slug (e.g. 14469-rename-tab).

When I run /clear to start fresh work in the same tab, the old session name (the previous issue's slug) sticks around, which is misleading.

What I tried

  • SessionStart hook with matcher: "clear" does fire correctly.
  • But there's no hook output to rewrite the session name.
  • Emitting an OSC 2 title sequence via terminalSequence works in real terminals but does not affect the VSCode extension's tab title (the tab reflects the internal session name, not the terminal title).
  • /clear itself can't be wrapped/overridden (built-in command).

So there is currently no way to reset/change the tab title programmatically.

Proposed feature

Add a hook output field that sets the session name. For example, a SessionStart (matcher: "clear") hook could reset the tab to a neutral value:

{ "hookSpecificOutput": { "hookEventName": "SessionStart", "sessionName": "🆕 fresh session" } }

Or a start-issue workflow could name the session after the issue it picks up:

{ "hookSpecificOutput": { "hookEventName": "SessionStart", "sessionName": "#14469 rename-tab" } }

This would let teams script session naming (branch slug, issue number, ticket title, etc.) instead of relying on the interactive /rename, and make tab titles stay accurate across /clear.

Environment

  • Claude Code 2.1.170
  • VSCode extension, macOS

View original on GitHub ↗