Repository navigation
Fix: Keep a wide-glyph row from leaving stale text on agentop's screen - #1464
Conversation
A row the terminal draws wider than bubbletea measured wrapped and scrolled the alt screen up a line. bubbletea skips any row equal to the one it drew there before, and the divider under the spend band is identical on every pane, so text from the event detail pane stayed on it after leaving, until agentop restarted. "वि" is one column to x/ansi and two to go-runewidth; padded to 140 columns, the detail row holding it measures 140 and 141. Turn autowrap (DECAWM) off for the life of the program, so an overwide row loses its last column instead of moving the screen. It is turned back on at exit and around $EDITOR, which draws its own screen: autowrapCmd wraps every command agentop lends the terminal to, and cursorKeysCmd now wraps it. Also repaint the whole screen whenever a message changes panes, decided in Update around the dispatch rather than at the thirty-odd places that assign m.pane, as a backstop for drift from any other cause. Fixes rossoctl#1461 Assisted-By: Claude (Anthropic AI) <noreply@anthropic.com> Signed-off-by: Ed Snible <snible@us.ibm.com>
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 1 minute. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
mrsabath
left a comment
There was a problem hiding this comment.
Approving. A tight, well-documented fix for a real bug (#1461): stale wrapped rows surviving pane changes because bubbletea skips redrawing unchanged rows. The fix layers two independent defenses — DECAWM (autowrap) off for the program's lifetime so an overwide row can't scroll the screen, plus a full repaint on every pane change as a backstop — and both are backed by tests that exercise real code paths (Update, Run's mode toggling) rather than reimplementations.
I verified the central claims against the repo and upstream deps rather than taking them from the description:
ansi.SetModeAutoWrap/ResetModeAutoWrapare real constants (\x1b[?7h/\x1b[?7l, DECAWM) incharmbracelet/x/ansiv0.11.9.tea.ClearScreen()returnsclearScreenMsg{}, a comparable empty struct, so the new test'smsg == wantequality check is sound.tea.Batch'scompactCmdsdrops nil commands and returns the single survivor directly rather than wrapping it inBatchMsg— which is exactly whyclearsScreen()checks both the direct and batched cases.- "31 places assign
m.pane" checks out exactly (grep -c 'pane *=' app.goonmain= 31). Update's pointer receiver mutatesmin place and returns it as thetea.Model, so readingm.paneafter calling the renamedupdate()correctly observes the new value — no aliasing issue in the before/after comparison.
Areas reviewed: Go (bubbletea TUI), tests, docs (README)
Commits: 1, signed off: yes
CI status: passing (29/29 applicable checks; Spellcheck skipped)
No findings — nothing survived verification.
Fixes #1461.
The bug
The sessions pane's divider row showed a line of an unrelated session's tool result,
\nand\tincluded, and it stayed there through pane changes until agentop restarted. It was a wrapped row of the event detail pane, left on screen after leaving that pane. #1461 has the full trace.Two things combine:
x/ansireports.वि(Devanagari letter plus a spacing vowel sign) is 1 column tox/ansiand 2 togo-runewidth. Padded to 140 columns, the detail row holding it measures 140 and 141. If the terminal agrees with the second number, the row wraps, and the alt screen scrolls up a line.standard_renderer.go,canSkip). The divider under the spend band is the same string on every pane, so after a scroll it keeps whatever moved onto it.The fix
Run). An overwide row then loses its last column instead of scrolling the screen. This stops the drift itself, from any character the two width tables disagree on. It applies on every terminal, since the disagreement isn't Terminal.app's alone, and bubbletea never sets the mode. It goes back on at exit and around$EDITOR: the newautowrapCmdwraps every command agentop lends the terminal to, andcursorKeysCmdnow wrapsautowrapCmdrather than*exec.Cmd.Updatenow wraps the dispatch (renamedupdate) and addstea.ClearScreenwheneverm.panechanged. That covers all 31 places that assignm.pane, and any added later. Messages that leave the pane alone don't repaint, so ticks and stream events don't flicker.Tests
TestUpdate_PaneChangeRepaintsScreendrivesPthroughUpdateand asserts the returned command clears the screen. With the wrapper'sBatchremoved, it fails.TestUpdate_SamePaneDoesNotRepaint: a resize on the same pane doesn't clear.TestAutowrapCmd_*: the command runs with autowrap on, and agentop's mode is restored afterward, on success and on failure. The order is asserted, not just the presence of both sequences.cursorKeysCmdtests now assert the combined sequence: autowrap on, the command's output, autowrap off, cursor keys back on.GOWORK=off go test ./...,go vet ./...andgo mod tidy -diffpass incmd/agentop.gofmt -lis clean on the changed files.Not verified
Neither the bug nor the fix has been tested in Terminal.app. These two things are unconfirmed:
वि2 columns wideprintf 'ab|\nवि|\n'in Terminal.app shows the first: the two|won't line up if it does. To check the fix:Escback to the sessions list.The repaint fixes the symptom either way.
Assisted-By: Claude (Anthropic AI) noreply@anthropic.com