Repository navigation
fix(tui): wrap the live work log instead of clipping it - #3004
kovtcharov wants to merge 3 commits into
Conversation
A long line in the agent's work log lost its tail. A shell command showed up to its first flags and stopped; a failed tool call showed "permission denied writing to..." and cut off before the sentence that says what to do about it. Turns run 25-160s, so this log is most of what a user looks at while they wait, and the clipped half was routinely the actionable half. The lines wrap now, reusing the transcript's own wrap (components.WrapText) rather than a third wrapping path. The region's height ceiling is unchanged - still min(workLogMaxRows, viewport/2) - so a wrapped line costs older HISTORY, never height: on a 12-row terminal the log still gets two rows. Per-action row caps stop one 300-character command from spending the whole region on itself, and what those caps do cut ends in an ellipsis. Three things fell out of doing it properly: - WrapText only breaks on spaces, so a URL or a Windows path - the lines most likely to run long - had no break to wrap at and overran the pane. Rows wider than the measure are now hard-broken at a column boundary. - Text was being cut to one row's width at CAPTURE time, before the renderer ever saw it: at 74 columns for a narration, at 66 for a tool error's own message, at 60 on the legacy transport. Those bounds now sit where the renderer can still use them, so the wrap decides where a line ends. A tool error keeps its second line, which is where the remedy is. - The old height trim dropped the NEWEST action when it alone exceeded the budget, so a wrapped command on a short terminal rendered an empty region. It is clipped to fit and marked instead. The region's height is also held at each turn's peak. It grows as work happens, which reads as progress, but shrinking dropped the transcript above back down mid-sentence - and wrapping makes those swings bigger. Covered by table-driven tests at 60x12, 80x24, 100x40 and 200x50: tail survival on both event dialects and both failure paths, height within budget and under half the viewport, no row wider than the terminal, one long action unable to fill the region, and the height never shrinking mid-turn.
|
Verdict: Approve with suggestions The work log in the TUI used to cut every line at the pane edge, so the end of a long shell command — and the sentence at the end of a failure that tells you how to fix it — was simply thrown away. This PR makes those lines wrap onto a second and third row instead, caps how tall any one action can get, and holds the region's height steady so the transcript above doesn't jump around while you're reading it. The reasoning is sound and the height and width budgets still hold; I found nothing blocking. Two things worth a look before merge, neither of them serious:
Real-world evidenceNone available in this run. No This is a user-visible surface, so the evidence that fits is a before/after capture of a turn with a long shell command and a failing tool, at two geometries — 80x24 and the 60x12 case the new clip-and-mark path exists for. If the PR description already carries that, treat this as satisfied. 🔍 Technical detailsIssues found🟢 The untyped error path still first-lines its message (
( 🟢 A live action's continuation rows reserve room for a clock they don't carry (
Not worth contorting 🟢 The clip marker lands after the elapsed clock (
Verified, not flagged
Strengths
|
Review follow-ups on the wrap change, all in what the log actually shows: - A cut on the live row put its ellipsis after the elapsed clock, where it read as part of the timer. The row budget now reaches renderActivityItem, so the cut is made in the text before the clock is ever appended - and the marker no longer spends two columns of the viewport's edge reserve. - Only the live row carries the clock, but every wrapped row of that action was paying the eight columns it takes. Continuations use the full measure, which gives a long command back about two words a row. - A long argument could push the words that follow it out of its own phrase: "Looking for <query> in your documents" rendered without "in your documents". The argument is budgeted against the template now. - A tool error's second line survives on both error paths, not just the one that goes through a render card. A `summary` stays first-line-only: one that runs to several lines is a payload dump, not a sentence. - The held height pads above the log rather than below, so the blank rows land in the space that already separates it from the transcript instead of opening a gap between the log and the answer streaming under it. Each fix has a test that fails without it - verified by reverting the behaviour and watching the test go red.
|
Verdict: Approve
The work-log wrapping change is correct and well-tested. The fix to the trimming loop that previously produced an empty region when a single group exceeded the budget ( One thing worth a look (non-blocking): Everything else is solid: 🔍 Technical details
Old:
Trimming loop correctness ( |
|
Verdict: Approve with suggestions The work log now wraps rather than clips, the height is held at its turn peak to prevent mid-read jumps, and the test suite covers the edge cases that motivated the change. No correctness issues found; two small suggestions below. 🟢 🟢 Vacuous suffix-position assertion in 🔍 Technical details
The function handles three distinct shapes: (a) text+suffix fits within func TestWrapLogLead(t *testing.T) {
// Short text fits on the narrowed first row.
got := wrapLogLead("hello", " x2", 10, 74, 3)
if got[0] != "hello x2" { t.Errorf(...) }
// Long text: first row uses lead, rest uses full width.
got = wrapLogLead(longShell, " x2", 60, 74, 3)
if len(got) < 2 { t.Errorf("expected continuation row") }
if strings.Contains(got[0], "x2") { t.Errorf("counter on first row, not last") }
}would catch a regression in the Vacuous For the "past the row cap" and "an exactly-full cut row" cases, |
On a wide terminal the work log stopped drawing at the same column an 80-column terminal did, so every extra column of window was wasted on the one thing a user stares at for a 25-160s turn. A 240-column window now draws a 238-column tool line instead of 78. Prose is deliberately excluded: an answer still lays out at 88 columns, because for a paragraph the extra width just loses the eye on the carriage return, while for a single row it is simply more of that row — and for the rows whose tail carries the reason or the remedy, the tail is the point. Stacked on amd#3005 and amd#3004, in that order. Until both merge, the diff here shows their commits too; mine are the two on top. <details> <summary>🔍 Technical details</summary> **Functions changed** - `logWidth()` — dropped the `narrationWidth` (74) ceiling, so the measure is `m.width - 6`, clamped to `m.width - logGutter` so the floor of 16 cannot overrun a cramped window. - `narrate.go` constants — `narrationWidth = 74` became `widestLogMeasure`, derived from the widest window the TUI accepts anywhere (`control/server.go`'s `"cols must be 20-500"`). amd#3004 already derives `narrationMax`/`detailMax` from the row measure; that reasoning is kept, but the basis has to be the widest window the text might *later* be rendered into, since capture happens before any width is known and the user can widen mid-turn. - `devPayloadWidth` — same basis, for the same reason. - `wrapLog()` — its floor raised any measure under 8 back to 8, overriding the caller's budget, so a 20-column terminal drew a 21-column row. A measure is what the caller can afford; floored at 1 now, never raised. - `renderLiveRegion()` — two rows went through no measure at all: the "still working" hint (a fixed 50 columns) and the idle live line. The latter is the *opening frame of every turn*, and `"Thinking about the next step"` drew 39 columns, shearing anything narrower. - `resize()` — releases amd#3004's peak-height hold on a **width** change. A resize reflows the log, which it could not before this branch; holding a peak measured at another width stranded blank rows for the rest of the turn. Guarded on width so the composer growing a row does not release it. - `handleCanonicalEvent` — `setLiveStatus` was the one agent-supplied string with no capture bound at all. `answerWidth()`, `wrapForPane()`, `wrapProse()`, `cardWidth()` and `answerMeasure` are unchanged. `answerMeasure` and `logWidth` now cross-reference each other so the split reads as chosen rather than overlooked. **Assumptions about the other two branches** - amd#3004 owns the wrapping. Its `wrapLog`, `logHeadRows`/`logDetailRows`, `elapsedReserve` and `liveRegionView` are taken as-is. The two compose: amd#3004 wraps a tail that does not fit, this makes it less likely to need to. Rebased onto its current head (`54a80d3d`), including its own review follow-up. - amd#3005 touches disjoint parts of `model.go`. - Verified rather than assumed: merging `amd#3005 → amd#3004 → this` onto `9c89cb47` in a scratch worktree merges with no conflicts, builds, vets, and passes. **The root cause, for the record** `logWidth` was the visible suspect but not the cause. `toolNarration`/`toolResultDetail` cut text to 74/66 columns *when the event arrived*, before any width was known, so widening the layout alone would have shown nothing new. Capture bounds now exist only to stop a runaway agent payload living in the model; layout decides what prints. </details> ## Test plan - [ ] `cd tui && go build ./... && go vet ./... && go test ./internal/...` - [ ] `widthlayout_test.go` is table-driven over **24, 40, 60, 80, 120, 160 and 240** columns, plus a per-width sweep from the declared minimum of 20 up. It asserts at every size that no rendered row exceeds the terminal, that `logWidth` grows with the window, and that `answerWidth` never exceeds 88. - [ ] The cramped-terminal test **renders** every row type — idle, live, wrapped, outcome, `--dev` payload, repeat counter — rather than checking `logWidth`'s arithmetic. An earlier version did the arithmetic only, and certified a property the rendered rows did not have. - [ ] Every fix was confirmed by reverting it and watching the suite fail: reverting the `wrapLog` floor gives `21 columns wide on a 20-column terminal`; reverting the idle-line measure gives `39 columns wide on a 20-column terminal`. - [ ] amd#3004's `worklogwrap_test.go` passes unchanged against the dynamic measure — the check that the wrapping and the width work compose rather than fight. - [ ] `internal/control` passes, so the `resize_exceeds_terminal` guard from amd#2932 is intact; that file is untouched. - [ ] Eyeball on a wide window: run a turn with a long shell command and confirm the log line runs to the window edge while the answer below it stays at 88. Not run: `tui/test` (daemon integration). It needs a live GAIA daemon and the machine was running demos. --------- Co-authored-by: Ovtcharov <[email protected]>
|
Closed as superseded: the live work log already wraps instead of clipping on current main (landed via #3026), verified by driving the TUI rather than by reading the diff. |
While the agent works a turn, the TUI's live work log was clipping each line to the pane width, so the user lost the tail — and for the lines that carry a reason or a remedy, the tail IS the remedy. A shell command showed its first flags and stopped; a failed tool call showed
permission denied writing to…and cut off before the sentence saying what to do about it. Turns run 25-160s, so this log is most of what a user looks at while they wait. It wraps now instead of truncating, and the region is no taller than it was before: the height ceiling is unchanged, so a wrapped line costs older history, never height — on a 12-row terminal the log still gets two rows.For the branches touching the same file
claudia/task-34b41d95(responsive TUI width) andclaudia/task-2a0113e3(Claude model picker) both editchat/model.go. What moved here, so their rebase is cheap:logWidth()— signature and return value unchanged (m.width - 6, capped atnarrationWidth, floor 16). Its meaning changed: it is now a wrap measure, not a clip budget. Making it track the terminal instead of capping at 74 composes with this as-is — rows get wider and fewer, and no other call site needs to know.wrapForPane,wrapProse,answerWidth,cardWidth: not touched. I reused the existing wrap rather than adding a third path, so a width change there flows through both the transcript and the work log.renderActivityItem()— signature unchanged,(item, live, elapsed) []string; internals rewritten to wrap and return several rows per action.renderLiveRegion()— its height-trim loop was rewritten.updateViewport()— one line: it now callsliveRegionView()instead ofrenderLiveRegion().model.go:wrapLog,hardBreak,splitAtWidth,clipTail,clipRows,liveRegionView; constslogHeadRows,logDetailRows,elapsedReserve; fieldChatModel.logPeakRows(reset instartTurnandrequestCancel).elapsedReserve = 8columns for the spinner's trailing clock, so anything that changes what trails that row has to move with it.Test plan
cd tui && go build ./... && go vet ./... && go test ./...— note./test/...fails on an unrelated daemon start-lock in some environments;go test ./internal/...is the part this change affects.cd tui && go test ./internal/ui/chat/ -run 'TestWorkLog|TestWrapLog|TestOneLongAction|TestRepeatCounter' -v— table-driven at 60x12, 80x24, 100x40 and 200x50: the tail survives on both event dialects and both failure paths, the region stays within its height budget and under half the viewport, no row exceeds the terminal width, one long action cannot fill the region, and the height never shrinks mid-turn.gh issue list … --jq …), confirm the command reads to its end and the log stays under half the pane. Resize to ~12 rows mid-turn and confirm the transcript is still readable.