Commit 306f11f
Yogthos
fix(ui): route reasoning through buffered render path to fix streaming staircase
Closes dirge-ypg (CRLF fix in 6172c4e didn't take effect — user
reproduced staircase post-fix; deeper root cause).
The Reasoning stream was using `renderer.write()` to paint chunks
inline via per-segment `MoveTo(indent + self.col, r)` calls. Under
the current LLM streaming cadence — DeepSeek-V4-pro reasoning
chunks arriving rapidly — that path produces a staircase: each
chunk on a new row, offset by the previous chunk's end-column.
Couldn't isolate the exact failure mode from static analysis
(MoveTo should reset col, CRLF emit should defeat raw-mode
LF-without-CR, neither helped).
Refactor: route reasoning through the same buffered render path
the content stream uses. Add `reasoning_buf: String` +
`reasoning_start_line: Option<usize>` mirrors of the existing
`response_buf`/`response_start_line` pair. On each Reasoning
event:
1. Append text to `reasoning_buf` (sanitized)
2. `wrap::soft_wrap` to line entries with DarkMagenta color
3. Prepend `<dirge> ` to the first entry
4. `renderer.replace_from(reasoning_start_line, styled)` —
replaces the previously-rendered reasoning lines with the
updated set
5. `renderer.render_viewport()` — paints buffer rows via
per-row `MoveTo(0, i)` — explicitly anchored, no col drift
possible
The Token handler already uses this pattern (user confirmed
content text doesn't staircase). Reasoning now inherits the
same guarantee.
Clear sites: `reasoning_buf` + `reasoning_start_line` are reset
alongside `response_buf` + `response_start_line` at the 6
existing transition points (Token-after-Reasoning, ToolCall,
Done, Interjected, ContextOverflow, Error).
The CRLF fix in 6172c4e stays — it's defensive correct for raw
mode and benefits any other code path using `write`/`write_line`
streaming (e.g., chamber rendering's `write_line` for borders).
Tests: 1214/1215 pass (1 pre-existing Clojure failure). Binary
at ~/bin/dirge.1 parent 3d26737 commit 306f11f
1 file changed
Lines changed: 80 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
685 | 685 | | |
686 | 686 | | |
687 | 687 | | |
| 688 | + | |
| 689 | + | |
| 690 | + | |
| 691 | + | |
| 692 | + | |
| 693 | + | |
| 694 | + | |
| 695 | + | |
| 696 | + | |
| 697 | + | |
| 698 | + | |
| 699 | + | |
| 700 | + | |
| 701 | + | |
| 702 | + | |
688 | 703 | | |
689 | 704 | | |
690 | 705 | | |
| |||
2051 | 2066 | | |
2052 | 2067 | | |
2053 | 2068 | | |
2054 | | - | |
2055 | | - | |
2056 | | - | |
2057 | | - | |
| 2069 | + | |
| 2070 | + | |
| 2071 | + | |
| 2072 | + | |
| 2073 | + | |
| 2074 | + | |
| 2075 | + | |
2058 | 2076 | | |
2059 | | - | |
| 2077 | + | |
| 2078 | + | |
| 2079 | + | |
| 2080 | + | |
| 2081 | + | |
| 2082 | + | |
| 2083 | + | |
| 2084 | + | |
| 2085 | + | |
| 2086 | + | |
| 2087 | + | |
| 2088 | + | |
| 2089 | + | |
| 2090 | + | |
| 2091 | + | |
| 2092 | + | |
| 2093 | + | |
| 2094 | + | |
| 2095 | + | |
| 2096 | + | |
| 2097 | + | |
| 2098 | + | |
| 2099 | + | |
| 2100 | + | |
| 2101 | + | |
| 2102 | + | |
| 2103 | + | |
| 2104 | + | |
| 2105 | + | |
| 2106 | + | |
| 2107 | + | |
| 2108 | + | |
| 2109 | + | |
| 2110 | + | |
| 2111 | + | |
| 2112 | + | |
| 2113 | + | |
| 2114 | + | |
2060 | 2115 | | |
2061 | 2116 | | |
2062 | 2117 | | |
| |||
2067 | 2122 | | |
2068 | 2123 | | |
2069 | 2124 | | |
| 2125 | + | |
| 2126 | + | |
| 2127 | + | |
| 2128 | + | |
| 2129 | + | |
| 2130 | + | |
| 2131 | + | |
| 2132 | + | |
| 2133 | + | |
| 2134 | + | |
2070 | 2135 | | |
2071 | 2136 | | |
2072 | 2137 | | |
| |||
2165 | 2230 | | |
2166 | 2231 | | |
2167 | 2232 | | |
| 2233 | + | |
| 2234 | + | |
2168 | 2235 | | |
2169 | 2236 | | |
2170 | 2237 | | |
| |||
2689 | 2756 | | |
2690 | 2757 | | |
2691 | 2758 | | |
| 2759 | + | |
| 2760 | + | |
2692 | 2761 | | |
2693 | 2762 | | |
2694 | 2763 | | |
| |||
3010 | 3079 | | |
3011 | 3080 | | |
3012 | 3081 | | |
| 3082 | + | |
| 3083 | + | |
3013 | 3084 | | |
3014 | 3085 | | |
3015 | 3086 | | |
| |||
3076 | 3147 | | |
3077 | 3148 | | |
3078 | 3149 | | |
| 3150 | + | |
| 3151 | + | |
3079 | 3152 | | |
3080 | 3153 | | |
3081 | 3154 | | |
| |||
3264 | 3337 | | |
3265 | 3338 | | |
3266 | 3339 | | |
| 3340 | + | |
| 3341 | + | |
3267 | 3342 | | |
3268 | 3343 | | |
3269 | 3344 | | |
| |||
0 commit comments