Skip to content

Commit 7ebad63

Browse files
btuckerclaude
andcommitted
Add test for JSONL parsing preserving toolUseResult
Ensures the toolUseResult field (containing originalFile content) is preserved when parsing JSONL files, which is needed for remote session code reconstruction. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent a86705f commit 7ebad63

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

tests/test_generate_html.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1041,6 +1041,36 @@ def test_jsonl_generates_html(self, output_dir, snapshot_html):
10411041
assert "hello world" in index_html.lower()
10421042
assert index_html == snapshot_html
10431043

1044+
def test_jsonl_preserves_tool_use_result(self, tmp_path):
1045+
"""Test that toolUseResult field is preserved in parsed entries.
1046+
1047+
This is needed for originalFile content used in remote session code reconstruction.
1048+
"""
1049+
# Create a JSONL file with toolUseResult
1050+
jsonl_content = """{"type":"user","timestamp":"2025-01-01T10:00:00Z","message":{"role":"user","content":"Edit the file"}}
1051+
{"type":"assistant","timestamp":"2025-01-01T10:00:05Z","message":{"role":"assistant","content":[{"type":"tool_use","id":"toolu_001","name":"Edit","input":{"file_path":"/test.py","old_string":"old","new_string":"new"}}]}}
1052+
{"type":"user","timestamp":"2025-01-01T10:00:10Z","toolUseResult":{"originalFile":"original content here","filePath":"/test.py"},"message":{"role":"user","content":[{"type":"tool_result","tool_use_id":"toolu_001","content":"File edited"}]}}"""
1053+
1054+
jsonl_file = tmp_path / "test.jsonl"
1055+
jsonl_file.write_text(jsonl_content)
1056+
1057+
result = parse_session_file(jsonl_file)
1058+
1059+
# Find the tool result entry (last user message)
1060+
tool_result_entry = [
1061+
e
1062+
for e in result["loglines"]
1063+
if e["type"] == "user" and "tool_result" in str(e)
1064+
][-1]
1065+
1066+
# toolUseResult should be preserved
1067+
assert "toolUseResult" in tool_result_entry
1068+
assert (
1069+
tool_result_entry["toolUseResult"]["originalFile"]
1070+
== "original content here"
1071+
)
1072+
assert tool_result_entry["toolUseResult"]["filePath"] == "/test.py"
1073+
10441074

10451075
class TestGetSessionSummary:
10461076
"""Tests for get_session_summary which extracts summary from session files."""

0 commit comments

Comments
 (0)