# Display and streaming-Markdown layout fixture.
#
#   HAX_PROVIDER=mock HAX_MOCK_SCRIPT=scripts/mock/layout.txt build/hax
#
# Turns 1–7 assume a 100-cell window. Their shell control flow forces the
# verbose bash-header path; read-only commands normally use a silent header.

# Turn 1: bash header fits on one row.
text Short bash command first, for a baseline.
tool bash {"command":"for d in src; do echo $d; done"}
usage in=80 out=10
end-turn

# Turn 2: bash header reflows across two rows.
text Medium-length bash command — should wrap across two rows.
tool bash {"command":"for f in src/providers/openai.c src/providers/codex.c src/providers/llamacpp.c; do echo $f; done"}
usage in=160 out=18
end-turn

# Turn 3: bash header fills three rows without truncation.
text Long bash command — should fill all 3 rows without truncation.
tool bash {"command":"for f in src/providers/openai.c src/providers/codex.c src/providers/llamacpp.c src/providers/openrouter.c src/providers/openai_compat.c src/providers/mock.c; do echo \"== $f ==\"; wc -l \"$f\"; head -1 \"$f\"; tail -1 \"$f\"; done"}
usage in=260 out=20
end-turn

# Turn 4: bash header truncates at the three-row budget.
text Very long bash command — should overflow and truncate.
tool bash {"command":"for f in src/providers/openai.c src/providers/codex.c src/providers/llamacpp.c src/providers/openrouter.c src/providers/openai_compat.c src/providers/mock.c src/providers/probe.c; do echo \"== $f ==\"; wc -l \"$f\"; head -3 \"$f\"; tail -3 \"$f\"; echo \"-- lines summary --\"; awk '{c++} END {print c}' \"$f\"; echo \"-- words summary --\"; awk '{w+=NF} END {print w}' \"$f\"; done"}
usage in=320 out=24
end-turn

# Turn 5: long output lines truncate inside an intact gutter.
text Long-line bash output — should show per-row "..." truncation.
tool bash {"command":"for i in 1 2 3; do printf 'X%.0s' $(seq 1 200); echo; printf 'short line\\n'; done"}
usage in=380 out=14
end-turn

# Turn 6: tabs expand to four spaces without breaking the gutter.
text Tab-laden output — gutter should stay intact and tabs render as 4 spaces.
tool bash {"command":"printf '\\t\\t// a long comment with enough text after the leading tabs that the row needs per-cell truncation at the right margin\\n\\t\\tlong_function_call(first_argument, second_argument, third_argument);\\n\\thello from a less-indented line\\nno-tab line at column zero\\n'"}
usage in=400 out=18
end-turn

# Turn 7: read uses a one-line silent header.
text Read with a deeply nested path.
tool read {"path":"src/providers/this/is/an/intentionally/very/deeply/nested/imaginary/path/to/some/test_fixture.c","offset":30,"limit":31}
usage in=400 out=12
end-turn

text Done — that covers verbose-header reflow, per-row truncation, tab expansion, and the silent path.
usage in=440 out=14
end-turn


# Turns 8–28 assume HAX_DISPLAY_WIDTH=80 for reproducible wrapping.

# Turn 8: long unwrapped paragraph.
text Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
usage in=480 out=40
end-turn

# Turn 9: model-narrow lines soft-join and reflow.
text Lorem ipsum dolor sit amet, consectetur
text \nadipiscing elit, sed do eiusmod tempor
text \nincididunt ut labore et dolore magna
text \naliqua. Ut enim ad minim veniam, quis
text \nnostrud exercitation ullamco laboris.
usage in=520 out=42
end-turn

# Turn 10: paragraph break remains hard.
text First paragraph with enough content to almost fill a single 80-cell row of output.
text \n\nSecond paragraph after a blank line — this should render as a separate block, not joined.
usage in=560 out=20
end-turn

# Turn 11: bullet list uses hanging indentation.
text Here is a list:
text \n* alpha beta gamma delta epsilon zeta eta theta iota kappa lambda mu nu xi
text \n* one two three four five six seven eight nine ten eleven twelve thirteen
text \n* short item that fits
usage in=620 out=36
end-turn

# Turn 12: numbered markers use matching hanging indentation.
text Numbered list:
text \n1. First item with enough words to require wrapping at the configured display width
text \n2. Second item also long enough that it spills onto a continuation row indented under 2
text \n10. Larger marker — 4-cell prefix, continuation should still align cleanly
usage in=680 out=40
end-turn

# Turn 13: soft-wrapped list items reflow.
text Same list, this time soft-wrapped by the model:
text \n* alpha beta gamma delta epsilon
text \nzeta eta theta iota kappa lambda mu nu xi
text \n* one two three four five six
text \nseven eight nine ten eleven twelve thirteen
text \n* short item that fits
usage in=700 out=40
end-turn

# Turn 14: code fence remains verbatim.
text Code block follows:
text \n```python
text \ndef long_function_name_that_makes_the_line_quite_wide(parameter_one, parameter_two, parameter_three):
text \n    return parameter_one + parameter_two + parameter_three
text \n```
text \nText after the fence resumes normal wrap behaviour.
usage in=740 out=44
end-turn

# Turn 15: tabs in a code fence expand to four spaces.
text Tab-indented code fence — indent depth should be consistent (4 spaces per level):
text \n```c
text \nint main(int argc, char **argv)
text \n{
text \n\tif (argc > 1) {
text \n\t\tprintf("hello %s\\n", argv[1]);
text \n\t}
text \n\treturn 0;
text \n}
text \n```
usage in=780 out=48
end-turn

# Turn 16: bold styling spans a wrap break.
text Some preamble, then **alpha beta gamma delta epsilon zeta eta theta iota kappa lambda mu nu xi** and a tail.
usage in=820 out=22
end-turn

# Turn 17: inline code spans a wrap break.
text See `function_with_a_long_name(arg one, arg two, arg three)` for details and check the docs.
usage in=860 out=20
end-turn

# Turn 18: heading does not affect following prose.
text ## A medium-length heading that probably fits one row but not always
text \nFollow-up paragraph: enough content to demonstrate that wrap behaviour resumes immediately under the heading without spillover.
usage in=900 out=28
end-turn

# Turn 19: separately streamed table rows form an aligned grid.
text Here's a small table:
text \n| Tool | What it does |
text \n|---|---|
text \n| read | Read files from disk |
text \n| bash | Run shell commands via /bin/sh -c |
usage in=940 out=30
end-turn

# Turn 20: cell widths account for accents and CJK.
text Café résumé naïveté is the prose; 中文字符 占两个单元格 each, so a row mixing them computes width per codepoint correctly.
usage in=940 out=22
end-turn

# Turn 21: CommonMark hard breaks remain inside a list item.
text - **First finding with a hard-broken title**  \n  `identifier_or_location`  \n  A longer explanation that follows on its own line and flows across the configured display width, wrapping under the list item while the two short lines above each keep their own row.
usage in=980 out=64
end-turn

# Turn 22: nested list continuations and fences preserve indentation.
text - **First item** with a header line  \n  a label line  \n  and a longer explanation that flows across the configured display width and must keep its two-space hanging indent on every continuation row, not just the first.\n\n- **Second item** with a fenced block\n\n  ```\n  function example(value) {\n      return value + 1;\n  }\n  ```\n  Closing prose after the block, also indented under the item and long enough to wrap so the hanging indent shows here too.
usage in=1040 out=120
end-turn

# Turn 23: thematic break becomes a short spaced-dot divider.
text Above the divider — a short intro paragraph before the section break.
text \n\n---\n\nBelow the divider — the rule should be a short dim row of spaced dots, with one blank line of separation on each side.
usage in=980 out=40
end-turn

# Turn 24: table alignment and inline styles compose.
text A table with mixed alignment and inline styling in the cells:
text \n| File | Lines | Note |
text \n|:-----|------:|:----:|
text \n| `markdown.c` | 1900 | the **streaming** renderer |
text \n| `ansi.h` | 47 | _SGR_ constants |
text \n| `util.h` | 300 | `buf` + helpers |
usage in=1000 out=60
end-turn

# Turn 25: wide table reflows to a record list.
text This one is too wide to align at 80 cells, so it reflows to a list:
text \n| Component | Responsibility | Notes |
text \n|---|---|---|
text \n| provider adapter | Translate native SSE events into the unified stream_event vocabulary | one per backend, lives in src/providers |
text \n| turn state machine | Assemble one streamed response into the flat item sequence | pure, no I/O, driven by turn_on_event |
usage in=1080 out=90
end-turn

# Turn 26: padded list markers collapse to one space.
text Padded markers — the extra spaces after the marker should collapse:
text \n-   alpha beta gamma delta epsilon zeta eta theta iota kappa lambda mu nu xi
text \n-   short padded bullet
text \n1.   First padded ordered item, long enough to wrap so the continuation aligns under the digit
text \n2.   Second padded ordered item
usage in=1020 out=44
end-turn

# Turn 27: runs of blank lines collapse to one gap.
text First block, then several blank lines before the next.
text \n\n\n\n\nSecond block after the collapsed run — the gap above should be a single blank line, same as a normal paragraph break.
usage in=1060 out=28
end-turn

# Turn 28: tight prose em dashes gain spaces but code remains unchanged.
text Tight clause dash—like this one—gets spaced on both sides, and GPT-5—this one—is spaced the same way.
text \n\nAlready spaced — unchanged, and `a—b` inside code is quoted source, so it stays tight too.
text \n\n```text\nfence—content is verbatim\n```
usage in=1040 out=52
end-turn

text Done — markdown wrap demo complete.
usage in=980 out=18
end-turn
