feat(cli): set terminal tab title from session title via OSC 0 - #17398
Closed
rumbin wants to merge 1 commit into
Closed
feat(cli): set terminal tab title from session title via OSC 0#17398rumbin wants to merge 1 commit into
rumbin wants to merge 1 commit into
Conversation
Update the terminal tab/window title whenever the Hermes session title
changes, using the standard OSC 0 escape sequence supported by Ghostty,
iTerm2, Kitty, GNOME Terminal, and most modern terminals.
Changes:
- Add HermesCLI._set_terminal_title(title) that emits ESC]0;Hermes: <title>BEL
- Wire it into all 5 title-setting paths:
1. Auto-generated title after first exchange (background thread via
maybe_auto_title / auto_title_session on_title callback)
2. /title command — immediate update on manual title set
3. Pending title flush — when a /title set before first message is
committed to the DB on session creation
4. /resume command — sets the tab title of the resumed session
5. Startup --continue resume — sets the tab on launch
Users with multiple Hermes tabs open can now distinguish sessions at a
glance instead of seeing 'Hermes' on every tab.
Collaborator
Collaborator
Author
|
Thanks for the pointers @alt-glitch. After reviewing #10013, I can see tsemana's implementation is considerably more complete — dedicated module, persona-aware title format, sanitisation/injection protection, TTY guards, ACP no-op, and 16 unit tests. Our PR covers the same ground but less thoroughly. Closing in favour of #10013. Hopefully that one lands soon! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
When running multiple Hermes sessions in separate terminal tabs (e.g. Ghostty, iTerm2, Kitty), every tab shows the generic title
Hermes. This PR makes each tab reflect the actual session title, so users can distinguish sessions at a glance.What changes
agent/title_generator.pyon_titlecallback parameter toauto_title_sessionandmaybe_auto_titlecli.pyHermesCLI._set_terminal_title(title)— emits the standard OSC 0 escape sequenceESC]0;Hermes: <title>BELto stdout, which all modern terminals interpret as a tab/window title updateon_titlecallback tomaybe_auto_titleso the background thread updates the tab once the LLM-generated title is ready/titlecommand — immediately updates the tab after saving a manually set title/titleset before the first message is finally committed to the DB on session creation/resumecommand — sets the tab title when switching to an existing titled session mid-conversation--continueresume — fetches and sets the tab title immediately on launch when loading an existing sessionBehaviour
Hermes→ switches toHermes: <generated title>a few seconds after the first exchangehermes -c "my project": tab showsHermes: my projectimmediately on startup/title My Project: tab updates instantlysys.stdoutdirectly — same approach as the existing_write_osc52_clipboardhelperCompatibility
OSC 0 is supported by virtually all modern terminal emulators (Ghostty, iTerm2, Kitty, GNOME Terminal, Windows Terminal, WezTerm, Alacritty, xterm). There is no visible side-effect in terminals that don't support it (the sequence is silently ignored).