Conversation
📝 WalkthroughWalkthroughThis pull request adds support for rendering Grep tool inputs in HTML format. The change introduces a new formatter ( Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
📝 Coding Plan
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 Tip CodeRabbit can enforce grammar and style rules using `languagetool`.Configure the |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@claude_code_log/html/tool_formatters.py`:
- Around line 283-294: The current formatter in tool_formatters.py (inside
format_GrepInput / the Grep HTML rendering) only prints a hand-picked subset of
GrepInput fields and hides explicit False values; update the formatter to render
all actual GrepInput attributes (including head_limit, offset and any extra grep
flags defined on GrepInput in claude_code_log/models.py) by iterating the
model's fields (e.g., dataclasses.fields or vars(grep_input)/asdict(grep_input))
and emitting a row for each key/value where None is omitted but booleans are
rendered as true/false explicitly; ensure values are run through escape_html and
preserve the existing label/value HTML structure so the HTML accurately reflects
the real tool invocation.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 2efb6965-797c-43e7-a38a-84f777d3ea4b
📒 Files selected for processing (3)
claude_code_log/html/__init__.pyclaude_code_log/html/renderer.pyclaude_code_log/html/tool_formatters.py
| html_parts = ["<div class='grep-tool-content'>"] | ||
| html_parts.append(f"<div class='grep-tool-field'><span class='grep-tool-label'>pattern:</span> <code>{escape_html(grep_input.pattern)}</code></div>") | ||
| if grep_input.path: | ||
| html_parts.append(f"<div class='grep-tool-field'><span class='grep-tool-label'>path:</span> <code>{escape_html(grep_input.path)}</code></div>") | ||
| if grep_input.glob: | ||
| html_parts.append(f"<div class='grep-tool-field'><span class='grep-tool-label'>glob:</span> <code>{escape_html(grep_input.glob)}</code></div>") | ||
| if grep_input.type: | ||
| html_parts.append(f"<div class='grep-tool-field'><span class='grep-tool-label'>type:</span> <code>{escape_html(grep_input.type)}</code></div>") | ||
| if grep_input.output_mode: | ||
| html_parts.append(f"<div class='grep-tool-field'><span class='grep-tool-label'>mode:</span> <code>{escape_html(grep_input.output_mode)}</code></div>") | ||
| if grep_input.multiline: | ||
| html_parts.append(f"<div class='grep-tool-field'><span class='grep-tool-label'>multiline:</span> <code>true</code></div>") |
There was a problem hiding this comment.
Render the full GrepInput, not just this hand-picked subset.
GrepInput in claude_code_log/models.py (Lines 782-797) also carries head_limit, offset, and extra allowed grep flags, but this formatter drops all of them. Because HtmlRenderer.format_GrepInput() now routes Grep rendering here, those inputs disappear from the transcript entirely, and the if grep_input.multiline: check also hides an explicit False. Please derive the rendered rows from the actual provided fields so the HTML stays faithful to the tool invocation.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@claude_code_log/html/tool_formatters.py` around lines 283 - 294, The current
formatter in tool_formatters.py (inside format_GrepInput / the Grep HTML
rendering) only prints a hand-picked subset of GrepInput fields and hides
explicit False values; update the formatter to render all actual GrepInput
attributes (including head_limit, offset and any extra grep flags defined on
GrepInput in claude_code_log/models.py) by iterating the model's fields (e.g.,
dataclasses.fields or vars(grep_input)/asdict(grep_input)) and emitting a row
for each key/value where None is omitted but booleans are rendered as true/false
explicitly; ensure values are run through escape_html and preserve the existing
label/value HTML structure so the HTML accurately reflects the real tool
invocation.
There was a problem hiding this comment.
Hey @zhouxuan009, thanks a lot for this PR! Can you please check if this comment from Coderabbit is true? Also, please make sure that linting and tests pass.
There was a problem hiding this comment.
Thanks for pointing it out. I will take a look.
There was a problem hiding this comment.
Seems like the humans are having a chat. I'll hop back into my burrow for now. If you need me again, just tag @coderabbitai in a new comment, and I'll come hopping out!
Summary
title_GrepInputshowing🔎 Grep <pattern>in headerformat_GrepInputshowing all fields (pattern, path, glob, type, mode, multiline) on separate linesTest plan
Summary by CodeRabbit