# compose_diff_lines

> **Function** in `deepagents_code`

📖 [View in docs](https://reference.langchain.com/python/deepagents-code/tui/widgets/diff/compose_diff_lines)

Yield syntax-highlighted widgets for a unified diff.

## Signature

```python
compose_diff_lines(
    diff: str,
    max_lines: int | None = 100,
    *,
    path: str = '',
    before: str = '',
    after: str = '',
    show_numbers: bool = True,
) -> ComposeResult
```

## Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `diff` | `str` | Yes | Unified diff string. |
| `max_lines` | `int \| None` | No | Maximum number of *rendered rows* to show (None for unlimited). Rows are not diff lines: file and hunk headers are dropped and hunk separators added, so this does not correspond to a line count in `diff`. Rows are dropped from the end; emphasis is computed after the drop, so splitting a removed/added run costs the whole run its word emphasis, not just the clipped half. (default: `100`) |
| `path` | `str` | No | Path of the diffed file, used to pick a syntax highlighter. (default: `''`) |
| `before` | `str` | No | Source aligned to the diff's *old* line numbers. May be a truncated prefix or empty; rows whose text does not match the lexed source are left unhighlighted (logged once per side at warning). (default: `''`) |
| `after` | `str` | No | Source aligned to the diff's *new* line numbers, same contract. Context rows are read from here, not from `before` — see `_Row.number`. (default: `''`) |
| `show_numbers` | `bool` | No | Whether to render the line-number gutter. Pass `False` when the diff's line numbers are not the file's — e.g. a diff of edit fragments, whose hunks always start at 1. (default: `True`) |

---

[View source on GitHub](https://github.com/langchain-ai/deepagents/blob/caaa7e7c12d214afa5cf0a1afed8eb6232aa6f7b/libs/code/deepagents_code/tui/widgets/diff.py#L684)