Skip to content

fix(ui): restore tea.ClearScreen on tab switch to eliminate ghost text#49

Closed
fullstackjam wants to merge 3 commits intomainfrom
claude/hopeful-kowalevski-5297e2
Closed

fix(ui): restore tea.ClearScreen on tab switch to eliminate ghost text#49
fullstackjam wants to merge 3 commits intomainfrom
claude/hopeful-kowalevski-5297e2

Conversation

@fullstackjam
Copy link
Copy Markdown
Collaborator

Summary

  • Restores return m, tea.ClearScreen on Tab/ShiftTab in the snapshot editor to eliminate ghost text (e.g. cirruslabs/cli appearing on the macOS Prefs tab)
  • Adds TestSnapshotEditorTabSwitchReturnsClearScreenCmd — asserts Tab and ShiftTab return a non-nil cmd
  • Adds TestSnapshotEditorViewTabIsolation — asserts View() output for macOS Prefs never contains tap items, and Taps tab never contains pref items

Root cause analysis

PR #47 removed tea.ClearScreen on tab switch, believing bubbletea v1.3.0's incremental diff renderer would correctly clear changed rows on its own. In theory this is correct: v1.3.0 calls ansi.CursorPosition and ansi.EraseEntireScreen directly (matching x/ansi v0.4+ API), fixing the MoveCursor argument-swap bug that existed in v1.1.0.

In practice, ghost text still appears across terminals when switching from a tab with fewer items (Taps, 8 items) to one with more (macOS Prefs, 45 items). Restoring the explicit tea.ClearScreen forces bubbletea to erase the entire alt-screen buffer and do a full repaint before rendering the new tab — the safest and most portable guarantee against stale rows.

Note: with bubbletea v1.3.0 + x/ansi v0.8.0, tea.ClearScreen is now fully functional (in v1.1.0 + x/ansi v0.4.2 the EraseEntireDisplay constant had been silently changed to \x1b[3J which only clears scrollback, making it a no-op on the visible frame).

Test plan

  • make test-unit passes (all packages)
  • go test ./internal/ui/... — all 50+ snapshot editor tests pass including the two new ones
  • Interactive: make build && ./openboot snapshot → navigate to macOS Prefs tab — cirruslabs/cli should no longer appear there

…editor

A corrupted or old-format snapshot file can contain a MacOSPref entry
with an empty Key (e.g. Domain="cirruslabs/cli", Key=""), which would
render as "cirruslabs/cli." in the macOS Prefs tab instead of in Taps.

Filter out any MacOSPref entry where Domain or Key is empty in
NewSnapshotEditor, since every valid macOS preference requires both.
The tap itself is already correctly shown in the Taps tab.
bubbletea v1.3.0 + x/ansi v0.8.0 made tea.ClearScreen fully functional
again (it was effectively a no-op in v1.1.0 because x/ansi v0.4.2 had
silently changed EraseEntireDisplay to clear only the scrollback buffer
rather than the visible frame).

PR #47 removed the tea.ClearScreen workaround under the assumption that
v1.3.0's incremental diff renderer would clear rows correctly on its own,
but the ghost-text symptom (cirruslabs/cli appearing at the top of the
macOS Prefs tab after switching from the Taps tab) persists in practice
across tested terminals. Restoring the explicit clear is the safest and
most portable fix: tea.ClearScreen forces bubbletea to erase the
alt-screen buffer and do a full repaint before rendering the new tab,
guaranteeing no stale rows survive the transition.

Also adds two tests:
- TestSnapshotEditorTabSwitchReturnsClearScreenCmd: asserts Tab and
  ShiftTab return a non-nil cmd (the ClearScreen cmd).
- TestSnapshotEditorViewTabIsolation: asserts that View() for the macOS
  Prefs tab never contains tap-item text, and vice-versa, locking in
  cross-tab isolation at the logic level.
@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 tests Tests only ui Terminal UI labels Apr 22, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 22, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

tests Tests only ui Terminal UI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant