added support for codex provider. fixed bug in claude code export (lines split when shouldn't be)
This commit is contained in:
@@ -20,7 +20,11 @@ def _write_session(tmp_path, records, project_dir="-home-jesse-myproj", name="ab
|
||||
proj = tmp_path / project_dir
|
||||
proj.mkdir(parents=True, exist_ok=True)
|
||||
f = proj / f"{name}.jsonl"
|
||||
f.write_text("\n".join(json.dumps(r) for r in records), encoding="utf-8")
|
||||
# ensure_ascii=False so raw U+0085/U+2028 reach the parser — see
|
||||
# TestExoticLineBreaks.
|
||||
f.write_text(
|
||||
"\n".join(json.dumps(r, ensure_ascii=False) for r in records), encoding="utf-8"
|
||||
)
|
||||
return f
|
||||
|
||||
|
||||
@@ -501,3 +505,29 @@ class TestMultiRoot:
|
||||
monkeypatch.setenv("CLAUDE_CONFIG_DIR", str(tmp_path / "cfg"))
|
||||
roots = resolve_roots()
|
||||
assert (tmp_path / "cfg" / "projects") in roots
|
||||
|
||||
|
||||
class TestExoticLineBreaks:
|
||||
"""Same U+0085 hazard as the Codex provider — see its TestExoticLineBreaks."""
|
||||
|
||||
# C0 controls (\x0b, \x0c) are excluded: JSON requires them escaped, so they
|
||||
# never reach the splitter literally. These three do.
|
||||
@pytest.mark.parametrize("sep", ["\x85", "
", "
"])
|
||||
def test_record_with_exotic_break_survives(self, tmp_path, sep):
|
||||
records = [
|
||||
{
|
||||
"type": "user",
|
||||
"cwd": "/home/jesse/myproj",
|
||||
"timestamp": "2026-05-01T10:00:00.000Z",
|
||||
"message": {"role": "user", "content": f"before{sep}after"},
|
||||
},
|
||||
]
|
||||
_write_session(tmp_path, records)
|
||||
prov = ClaudeCodeProvider(projects_dir=tmp_path)
|
||||
prov.list_conversations()
|
||||
conv = prov.normalize_conversation(prov.get_conversation("abc-123"))
|
||||
texts = [
|
||||
b["text"] for m in conv["messages"] for b in m["blocks"]
|
||||
if b["type"] == BLOCK_TYPE_TEXT
|
||||
]
|
||||
assert f"before{sep}after" in texts
|
||||
|
||||
Reference in New Issue
Block a user