Skip to content

Fix TUI flickering by removing tea.ClearScreen on navigation events#7

Open
Copilot wants to merge 1 commit intomainfrom
copilot/research-bubletea-best-practices
Open

Fix TUI flickering by removing tea.ClearScreen on navigation events#7
Copilot wants to merge 1 commit intomainfrom
copilot/research-bubletea-best-practices

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 12, 2026

Every arrow key press, scroll wheel tick, and page up/down returned tea.ClearScreen, forcing a full terminal wipe and redraw. Bubbletea's renderer already diffs View() output and updates only changed lines — ClearScreen bypasses this entirely.

Changes

  • Remove all 10 tea.ClearScreen returns across handleMouse, handleKey, and updateWorkspaceInputs — scroll wheel, raw wheel direction, navigation keys, and page up/down all now return nil or the textarea's own command
  • Clamp View() output to exactly m.height lines — pad short frames, trim long ones, so the diff renderer always compares equal-height frames with no drift artifacts
  • Remove dead isNavigationKey helper — only existed to gate the ClearScreen logic

Before

m.scrollTextArea(&m.editor, direction, 3)
return true, tea.ClearScreen  // blanks terminal, redraws everything

After

m.scrollTextArea(&m.editor, direction, 3)
return true, nil  // diff renderer handles the update

… height

Remove all tea.ClearScreen commands that were returned on every navigation
key press and scroll wheel event. Bubbletea's built-in diff-based renderer
efficiently updates only changed lines without clearing the screen. The
ClearScreen calls were forcing full terminal redraws on every cursor
movement, causing significant visible flicker.

Also add defensive height padding/clamping in View() to ensure the rendered
output always has exactly m.height lines, preventing any rendering drift
that could cause artifacts with the diff renderer.

Remove the now-unused isNavigationKey helper function.

Agent-Logs-Url: https://github.com/UnitVectorY-Labs/goauthorllm/sessions/7366f989-34c8-46bc-8ae1-54a1ba2486b0

Co-authored-by: JaredHatfield <208119+JaredHatfield@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

2 participants