Skip to content

Fix: Keep a wide-glyph row from leaving stale text on agentop's screen - #1464

Merged
esnible merged 1 commit into
rossoctl:mainfrom
esnible:fix/agentop-pane-repaint
Oct 21, 2026
Merged

esnible merged 1 commit into
rossoctl:mainfrom
esnible:fix/agentop-pane-repaint

Conversation

@esnible

@esnible esnible commented Oct 21, 2026

Copy link
Copy Markdown
Member

Fixes #1461.

The bug

The sessions pane's divider row showed a line of an unrelated session's tool result, \n and \t included, 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:

  • A row the terminal draws wider than bubbletea measured. bubbletea pads and truncates every row to the width x/ansi reports. वि (Devanagari letter plus a spacing vowel sign) is 1 column to x/ansi and 2 to go-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.
  • bubbletea skips any row equal to the one it drew there last (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

  1. Autowrap (DECAWM) off while agentop holds the terminal (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 new autowrapCmd wraps every command agentop lends the terminal to, and cursorKeysCmd now wraps autowrapCmd rather than *exec.Cmd.
  2. A full repaint on every pane change, as a backstop. Update now wraps the dispatch (renamed update) and adds tea.ClearScreen whenever m.pane changed. That covers all 31 places that assign m.pane, and any added later. Messages that leave the pane alone don't repaint, so ticks and stream events don't flicker.

Tests

  • TestUpdate_PaneChangeRepaintsScreen drives P through Update and asserts the returned command clears the screen. With the wrapper's Batch removed, 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.
  • The two cursorKeysCmd tests now assert the combined sequence: autowrap on, the command's output, autowrap off, cursor keys back on.

GOWORK=off go test ./..., go vet ./... and go mod tidy -diff pass in cmd/agentop. gofmt -l is clean on the changed files.

Not verified

Neither the bug nor the fix has been tested in Terminal.app. These two things are unconfirmed:

  • that Terminal.app draws वि 2 columns wide
  • that autowrap off stops the scroll

printf 'ab|\nवि|\n' in Terminal.app shows the first: the two | won't line up if it does. To check the fix:

  1. Open an event whose tool result contains Devanagari, at a width where that row fills the pane exactly.
  2. Scroll it into view, then press Esc back to the sessions list.
  3. Without the fix, a detail row stays on the divider. With it, the divider should be intact.

The repaint fixes the symptom either way.

Assisted-By: Claude (Anthropic AI) noreply@anthropic.com

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>
@coderabbitai

coderabbitai Bot commented Oct 21, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You'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.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: d0d249ed-4de7-478e-b73d-5c535faaeaa8
📥 Commits

Reviewing files that changed from the base of the PR and between 952db09 and 5ed45bd.

📒 Files selected for processing: 4
  • cmd/agentop/README.md
  • cmd/agentop/tui/app.go
  • cmd/agentop/tui/cursor_keys_test.go
  • cmd/agentop/tui/repaint_test.go
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@mrsabath mrsabath left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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/ResetModeAutoWrap are real constants (\x1b[?7h/\x1b[?7l, DECAWM) in charmbracelet/x/ansi v0.11.9.
  • tea.ClearScreen() returns clearScreenMsg{}, a comparable empty struct, so the new test's msg == want equality check is sound.
  • tea.Batch's compactCmds drops nil commands and returns the single survivor directly rather than wrapping it in BatchMsg — which is exactly why clearsScreen() checks both the direct and batched cases.
  • "31 places assign m.pane" checks out exactly (grep -c 'pane *=' app.go on main = 31).
  • Update's pointer receiver mutates m in place and returns it as the tea.Model, so reading m.pane after calling the renamed update() 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.

@esnible
esnible merged commit 723f175 into rossoctl:main Oct 21, 2026
30 checks passed
@esnible
esnible deleted the fix/agentop-pane-repaint branch October 21, 2026 17:36
@github-project-automation github-project-automation Bot moved this from New/ToDo to Done in Rossoctl Issue Prioritization Oct 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Fix: agentop leaves a stale detail-pane row over the sessions divider after a wide-glyph row wraps

2 participants