fix(session): skip turn_meta block when deriving session title

`SessionManager::create_saved_session_with_id_and_mode` picks the
first `ContentBlock::Text` off the user's message via `find_map`
and uses that as the session title. The engine prepends a synthetic
`<turn_meta>...</turn_meta>` block (Block 0) ahead of the real user
text (Block 1), so the `/sessions` picker was rendering the metadata
blob as the session name.

Guard the find_map filter on `!text.starts_with("<turn_meta>")` so
titles fall through to the actual user input. Existing sessions
without the prefix block are unaffected (the guard is a no-op when
no metadata block is present); the existing `truncate_title` long-
input handling continues to apply.

Harvested from PR #1498 by @wdw8276

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Hunter Bown
2026-05-12 01:23:14 -05:00
parent 2a306d2b0f
commit f60a77e191
2 changed files with 12 additions and 1 deletions
+9
View File
@@ -16,6 +16,15 @@ real world uses."
### Fixed
- **`/sessions` picker no longer shows `<turn_meta>` as the
session title** (harvested from PR #1498 by **@wdw8276**).
`session_manager::create_saved_session_with_id_and_mode`
picked the first text content block off the user message via
`find_map`; the engine prepends an internal `<turn_meta>` block
ahead of the real user text, so the picker rendered that
metadata blob as the session name. Guard added so titles fall
through to the actual user input. Existing sessions without
the prefix block are unaffected.
- **Kitty keyboard protocol now activates on Windows (VSCode +
Windows Terminal), so `Shift+Enter` inserts a newline instead
of submitting** (#1359, harvested from PR #1483 by
+3 -1
View File
@@ -674,7 +674,9 @@ pub fn create_saved_session_with_id_and_mode(
.find(|m| m.role == "user")
.and_then(|m| {
m.content.iter().find_map(|block| match block {
ContentBlock::Text { text, .. } => Some(truncate_title(text, 50)),
ContentBlock::Text { text, .. } if !text.starts_with("<turn_meta>") => {
Some(truncate_title(text, 50))
}
_ => None,
})
})