Skip to content

Enrich fork-point and branch nav labels with message summaries#212

Open
cboos wants to merge 1 commit into
mainfrom
dev/label-fork-points-and-branches
Open

Enrich fork-point and branch nav labels with message summaries#212
cboos wants to merge 1 commit into
mainfrom
dev/label-fork-points-and-branches

Conversation

@cboos

@cboos cboos commented Jun 7, 2026

Copy link
Copy Markdown
Collaborator

Problem

Fork points and branches whose anchor message isn't user/assistant text
rendered with an empty preview — Fork point (2 branches) and Branch • <uuid8>
— which makes a session's fork structure hard to follow (especially the
tool-flow forks that dominate long, tool-heavy sessions).

What this does

Give fork points and branches a type-aware label:

  • Fork point on a tool_use / thinking message →
    Fork point • Bash — <description> / … • Thinking.
    (_fork_point_preview previously returned "" for any non-text content.)
  • Branch whose first message has no user text → fall back to a type-aware
    summary of its first meaningful message (Bash — <description> / Thinking),
    while still preferring the branch-local user text when present — preserving
    the /exit ("No response requested.") case and the spawned-agent inner-prompt
    exclusion (the existing test_branch_label_source invariants stay green).

Adds two small helpers (_tool_summary_label, _entry_nav_summary). This is
pure labeling — no change to fork detection.

Tests

test/test_fork_branch_labels.py covers the helpers plus the tool_use/thinking
fork-point and branch cases.

Context

Split out of the investigation into a DAG "branch-happy" staircasing issue
(spurious forks from max_tokens assistant continuations). The fork-detection
fix is a separate follow-up; this legibility improvement stands on its own.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Improved navigation previews for branches and fork points with type-aware labels that better handle tool usage, thinking content, and descriptions.
    • Enhanced branch preview computation with intelligent fallback to display meaningful summaries for all content types.
  • Tests

    • Added comprehensive test coverage for navigation label generation and type-aware fork point preview functionality.

…follow-up)

Fork points and branches whose anchor message isn't user/assistant text rendered
with an empty preview ("Fork point (2 branches)" / "Branch • <uuid8>"), making
the fork structure hard to follow. Give them a type-aware label:

- Fork point on a tool_use / thinking message → "Fork point • Bash — <desc>" /
  "… • Thinking" (extends _fork_point_preview, which previously returned "" for
  any non-text content).
- Branch whose first message has no user text → fall back to a type-aware
  summary of its first meaningful message ("Bash — <desc>" / "Thinking"),
  while still preferring the branch-local user text when present (preserves the
  /exit "No response requested." case and the spawned-agent prompt exclusion).

Adds _tool_summary_label + _entry_nav_summary helpers. Pure labeling — no change
to fork detection (that's the follow-up). Tests cover the helpers + the
tool_use/thinking fork-point and branch cases.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jun 7, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: fdc4dec7-8de9-4ac6-acb0-756d1220dc05

📥 Commits

Reviewing files that changed from the base of the PR and between 0e478be and c3a1b34.

📒 Files selected for processing (2)
  • claude_code_log/renderer.py
  • test/test_fork_branch_labels.py

📝 Walkthrough

Walkthrough

This PR enhances transcript navigation labels in the renderer by introducing type-aware summary generation. New helper functions _tool_summary_label() and _entry_nav_summary() format tool-based and thinking-based labels. These are integrated into _fork_point_preview() and _build_branch_header() to improve preview text for branches and fork points that originate from tool calls or thinking content rather than user text.

Changes

Type-aware transcript navigation labels

Layer / File(s) Summary
Summary label helper functions
claude_code_log/renderer.py
Two new helpers generate type-aware preview labels: _tool_summary_label() formats tool-based labels as Tool — description with truncation; _entry_nav_summary() selects summaries from transcript entries based on content type (tool use, thinking, or text).
Tests for summary label helpers
test/test_fork_branch_labels.py
Comprehensive unit tests validate helper functions, including test utilities _meta() and _entry(). Tests cover tool-label formatting, description omission rules, truncation behavior, and entry-type-specific summary output for tool, thinking, and text entries.
Fork-point preview type-aware refactor
claude_code_log/renderer.py, test/test_fork_branch_labels.py
_fork_point_preview() is refactored to apply the new helpers: tool-based fork points now produce Tool — description labels; thinking fork points show a fixed "Thinking" label; tool-result fork points show tool-name-based result text. Tests verify formatted labels for tool-use fork points and unchanged output for text/thinking fork points.
Branch header fallback and documentation
claude_code_log/renderer.py
Inline documentation clarifies preferred scanning behavior in _build_branch_header(). A fallback path is added: when no user-text preview is found, _entry_nav_summary() derives the branch preview from the first branch DAG-line entry that yields a summary, enabling informative labels for branches starting with tool or thinking content.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • daaain/claude-code-log#184: Both PRs modify the branch-header preview logic in _build_branch_header(), with this PR adding type-aware fallback via _entry_nav_summary() after the DAG-based scan from #184.
  • daaain/claude-code-log#131: Both PRs update renderer-level fork-point and branch preview label generation in _fork_point_preview() and _build_branch_header() for within-session navigation, extending prior fork rendering changes.

Poem

🐰 Types of summaries, neat and clear,
Tools and thoughts now appear!
Preview labels, branching true,
One-line wisdom for the review.
Fork points navigate the way,
Through the transcript, come what may! 🌿

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 27.78% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Enrich fork-point and branch nav labels with message summaries' directly and clearly reflects the main change: improving navigation labels with type-aware message summaries for fork points and branches.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch dev/label-fork-points-and-branches

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant