Repository navigation
(Claude) Session previews: skip leading YAML front matter - #355
Conversation
A session's preview is the first user message's label in the table of contents, the index cards and the TUI. For a message opening with front matter, the preview showed the YAML block. It now starts at the body, using the same detector the rendering uses. A `---` followed by a blank line is still a horizontal rule and stays. A message holding only front matter gives an empty preview, so the next user message supplies it, as for any empty first message. Previews already stored in the cache keep their front matter until the session is cached again. There is no cache invalidation for this: the case is rare. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
utils is imported by nearly every module. A top-level import of the detector loaded PyYAML and wenmode's front-matter plugin on every CLI start: about +54 ms, or +23% on `import claude_code_log.cli`. It is now imported inside create_session_preview, and only for text that starts with `---`, as the other front-matter call sites do. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📒 Files selected for processing (2)
Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 2 remain after this review. 📝 WalkthroughWalkthroughSession previews now skip recognized leading YAML front matter after system reminders are removed. Tests cover preview content and verify that cached session data and session navigation use the expected first-user-message preview. ChangesSession preview front matter
Priority: ⬇️ Low Estimated code review effort: 2 (Simple) | ~10 minutes Change: Bug fix Suggested reviewers: Merge Risk: ⚪ Minimal · up to The preview change appears mergeable after normal checks. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
What
A session's preview is the first user message's label in the table of contents, the index cards and the TUI. When that message opened with YAML front matter (a pasted note, a skill or memory file), the preview showed the YAML block, starting with
---.utils.create_session_previewnow skips leading front matter, so the preview starts at the body. It uses the same detector as the rendering since #351 (frontmatter.split_frontmatter), so the two agree on what front matter is:---followed by a blank line stays a horizontal rule, and the preview keeps it as before.The detector is imported lazily, and only for text that starts with
---, so CLI start-up doesn't load PyYAML for it.A message holding only front matter gives an empty preview. The next user message then supplies the preview, as it already does for any empty first message.
Accepted limitation: cached previews
The preview is also stored in the SQLite cache (
first_user_message). This change adds no cache invalidation: nobreaking_changesentry, no migration, no cache version change. A preview cached before this change keeps its front matter until that session is cached again. The case is rare, so it's accepted. New and re-cached sessions get the fixed preview.Tests
test/test_session_preview_frontmatter.py:create_session_previewskips front matter; front matter only gives an empty preview; front matter after a system reminder is skipped too. A leading horizontal rule, a---block later in the text, and ordinary text are unchanged.compute_session_dataand the session navigation's_collect_session_info: a front-matter first message previews its body; a front-matter-only first message takes the next message's text; an ordinary session is unchanged.The front-matter tests (7 of 11) fail without the change. No snapshot changes.
🤖 Generated with Claude Code
Summary by CodeRabbit