feat: show session name on HUD line 1 - #1
Merged
Conversation
Append the current session name as a trailing segment on line 1, so the status line reads e.g. `[Model] │ folder git:(branch*) │ session: name`. The segment is omitted entirely when the session has no title. The name is resolved from the transcript by get_session_name(): the last `custom-title` entry's customTitle (set via the built-in /rename action), falling back to the last `ai-title` entry's aiTitle (auto-generated). This matches the UI's getCustomTitle semantics. Title entries are read via a full-file `grep -E 'custom-title|ai-title'` rather than the 800-line tail window, since a rename can fall outside that window in a long session and title entries are sparse. As with the rest of the script, any failure (missing file, grep timeout) returns '' and the segment is omitted — the status line never crashes. The `session:` label is CYAN (matching line-1 structural labels `folder` and `git:`) and the name is MAGENTA, keeping it distinct from the YELLOW branch. Tests: 8 unit tests for get_session_name (missing file, empty, no titles, custom returned, last custom wins, ai fallback, custom preferred over ai, empty custom falls back to ai) plus 3 end-to-end tests. 41 tests pass. Signed-off-by: staryxchen <staryxchen@tencent.com>
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.
What
Append the current session name as a trailing segment on HUD line 1, so the status line reads e.g.:
The
session: <name>segment is omitted entirely when the session has no title, so existing sessions render unchanged.Why
CodeBuddy Code tracks a per-session title (set via the built-in
/renameaction, or auto-generated as anai-title), but this information wasn't surfaced in the HUD. Showing it lets you tell sessions apart at a glance in the status line.How
New
get_session_name(transcript_path)inhud.pyresolves the name from the same transcript already read for tool stats, but via a separategrep -E 'custom-title|ai-title'pass rather than the 800-linetailwindow — a rename can fall outside that window in a long session, and title entries are sparse so a full-file grep is cheap.Resolution matches the UI's
getCustomTitlesemantics:custom-titleentry'scustomTitle(set via/rename).ai-titleentry'saiTitle(auto-generated).''when neither exists → the line-1 segment is omitted.As with the rest of the script, any failure (missing file, grep timeout) returns
''— the status line never crashes.Coloring
The
session:label is CYAN, matching line-1 structural labels (folder,git:). The name is MAGENTA, keeping it visually distinct from the YELLOW branch insidegit:(...).Tests
get_session_name: missing file, empty transcript, no title entries, custom-title returned, last custom wins, ai-title fallback, custom preferred over ai, empty custom falls back to ai.session: <name>; line 1 omits the segment when unnamed; ai-title shown end-to-end.Full suite: 41 passed.
Notes
grepis added to README Requirements (the script now shells out togit,tail, andgrep).session_id), so the name is derived from the transcript.custom-titlesession shows│ session: PR#30777; anai-title-only session shows the auto-generated title; unnamed sessions are unchanged.