Skip to content

Clear screen when switching tabs in snapshot editor#45

Merged
fullstackjam merged 1 commit intomainfrom
claude/fix-tab-switching-render-dISRL
Apr 22, 2026
Merged

Clear screen when switching tabs in snapshot editor#45
fullstackjam merged 1 commit intomainfrom
claude/fix-tab-switching-render-dISRL

Conversation

@fullstackjam
Copy link
Copy Markdown
Collaborator

What does this PR do?

Add screen clearing when navigating between tabs in the snapshot editor to prevent visual artifacts.

Why?

When switching tabs using Tab/Shift+Tab or arrow keys, the screen wasn't being cleared, which could leave remnants of the previous tab's content visible. This change ensures a clean visual transition between tabs by calling tea.ClearScreen after updating the active tab and resetting the cursor/scroll position.

Testing

  • go vet ./... passes
  • Tested locally with tab navigation in snapshot editor

Notes for reviewer

The fix is minimal and focused—it simply adds the missing screen clear command to both tab navigation code paths (forward and backward). This is consistent with proper TUI practices for tab switching.

https://claude.ai/code/session_01BRAD9BubM3QKwbm5BUFLL5

Returning tea.ClearScreen on Tab/ShiftTab forces bubbletea to erase
the alt-screen buffer and do a full repaint before rendering the new
tab. This eliminates stale cursor-indicator lines (e.g. cirruslabs/cli)
that persisted when switching from a short-list tab (Taps) to a
longer-list tab (macOS Prefs).

Root cause: bubbletea v1.1.0 was written against charmbracelet/x/ansi
v0.2.3 but openboot resolves to v0.4.2, which swapped the argument
order of MoveCursor(col, row). In alt-screen mode this places the
cursor at (row=1, col=N) instead of (row=N, col=0) after each flush,
causing the renderer's erase loop to stay clamped at row=1 and never
clear rows below it on the next render.

https://claude.ai/code/session_01BRAD9BubM3QKwbm5BUFLL5
@github-actions
Copy link
Copy Markdown

👋 Thanks for opening this pull request!

Before merging:

  • Code follows existing patterns in the codebase
  • go build ./... and go vet ./... pass
  • Commit message is clear and descriptive

@fullstackjam will review this soon. Thanks for contributing! 🚀

@github-actions github-actions Bot added the ui Terminal UI label Apr 22, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 22, 2026

Codecov Report

❌ Patch coverage is 50.00000% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
internal/ui/snapshot_editor.go 50.00% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@fullstackjam fullstackjam merged commit a221f92 into main Apr 22, 2026
10 checks passed
@fullstackjam fullstackjam deleted the claude/fix-tab-switching-render-dISRL branch April 22, 2026 13:20
fullstackjam pushed a commit that referenced this pull request Apr 22, 2026
PR #45 forced a full repaint via tea.ClearScreen on Tab/Shift-Tab to
mask a ghost-text bug whose actual root cause was bubbletea v1.1.0
silently miscalling x/ansi v0.4.2's MoveCursor and EraseEntireDisplay
after MVS upgraded the latter via lipgloss. With bubbletea bumped to
v1.3.0 in the previous commit, the renderer uses ansi.CursorPosition
and ansi.EraseEntireScreen directly, so incremental diff rendering
now clears rows correctly.

The forced full repaint is therefore redundant (just extra flicker on
every tab switch). Removing it.
fullstackjam added a commit that referenced this pull request Apr 22, 2026
…47)

* fix(deps): upgrade bubbletea v1.1.0 → v1.3.0 to repair tab-switch ghost text

Root cause of the cirruslabs/cli ghost row on the macOS Prefs tab:
bubbletea v1.1.0 was written against x/ansi v0.2.3, but MVS resolved
x/ansi v0.4.2 via lipgloss v1.0.0. v0.4.2 silently broke two APIs that
v1.1.0's standard renderer depends on:

  1. MoveCursor(row, col) → MoveCursor(col, row) — arguments swapped.
     The post-flush "return cursor to last row" call landed the cursor
     at row=1 instead of row=linesRendered, so the next render's
     bottom-up EraseEntireLine/CursorUp1 loop could only clear row 1.

  2. EraseEntireDisplay constant changed from "\x1b[2J" (clear visible)
     to "\x1b[3J" (clear scrollback only). tea.ClearScreen therefore
     left the alt-screen buffer untouched, making the PR #45 workaround
     a no-op on the visible frame.

bubbletea v1.3.0 calls ansi.CursorPosition(col, row) and
ansi.EraseEntireScreen directly, matching the v0.4+ API. Tab switching
now clears and redraws correctly; the row-one-only erase artefact is
gone at its source.

* refactor(ui): drop tea.ClearScreen workaround on tab switch

PR #45 forced a full repaint via tea.ClearScreen on Tab/Shift-Tab to
mask a ghost-text bug whose actual root cause was bubbletea v1.1.0
silently miscalling x/ansi v0.4.2's MoveCursor and EraseEntireDisplay
after MVS upgraded the latter via lipgloss. With bubbletea bumped to
v1.3.0 in the previous commit, the renderer uses ansi.CursorPosition
and ansi.EraseEntireScreen directly, so incremental diff rendering
now clears rows correctly.

The forced full repaint is therefore redundant (just extra flicker on
every tab switch). Removing it.

---------

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

Labels

ui Terminal UI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants