Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

- Attribute OpenAI chat `developer` messages to the system segment instead of
the user segment.
- `report --out` to a missing parent directory now exits cleanly with an
`error:` line instead of an unhandled traceback.

## [0.1.1] - 2026-08-06

Expand Down
6 changes: 5 additions & 1 deletion src/ctxlens/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,11 @@ def report(
out = path.with_suffix(path.suffix + default_ext)

if out is not None:
out.write_text(content, encoding="utf-8")
try:
out.write_text(content, encoding="utf-8")
except OSError as exc:
err_console.print(f"[red]error:[/red] {exc}")
raise typer.Exit(EXIT_ERROR) from exc
err_console.print(f"[green]Wrote[/green] {out}")
else:
sys.stdout.write(content + "\n")
Expand Down
8 changes: 8 additions & 0 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,14 @@ def test_report_html_to_file(tmp_path, codex_session):
assert out.read_text().startswith("<!doctype html>")


def test_report_missing_parent_dir(tmp_path, codex_session):
out = tmp_path / "missing" / "dir" / "r.html"
result = runner.invoke(app, ["report", str(codex_session), "--html", "-o", str(out)])
assert result.exit_code == 1
assert "error:" in result.stderr
assert "Traceback" not in result.stderr


def test_diff_json(openai_array, openai_chat):
result = runner.invoke(
app, ["diff", str(openai_array), str(openai_chat), "--json"]
Expand Down
Loading