Skip to content

feat/shimmer text - #1769

Open
Ricardo-M-L wants to merge 2 commits into
charmbracelet:mainfrom
Ricardo-M-L:feat/shimmer-text
Open

feat/shimmer text#1769
Ricardo-M-L wants to merge 2 commits into
charmbracelet:mainfrom
Ricardo-M-L:feat/shimmer-text

Conversation

@Ricardo-M-L

Copy link
Copy Markdown
Contributor

Summary

Adds a shimmer text animation utility to Bubble Tea v2 — a character-by-character sweep highlight effect inspired by Claude Code's terminal UI.

What's included

  • ShimmerText() — pure function that renders text with a sweep highlight. Takes progress (0.0-1.0), shimmer color, and optional zone width.
  • NewShimmer() — returns a Cmd that fires ShimmerMsg at a configurable interval for easy animation loop integration.
  • ShimmerState — convenience struct that wraps ShimmerText + NewShimmer to eliminate Update/View boilerplate.
  • examples/shimmer/ — a runnable demo showing the effect in action.

Why

Bubble Tea already has tea.View, tea.Cmd, and tea.Msg — this adds the missing visual effect primitives that terminal UIs need for polish. Users can use the pure ShimmerText function inline or wrap it in ShimmerState for zero-boilerplate shimmer animations.

Design notes

  • Zero new dependencies — uses only existing charmbracelet/x/ansi for width calculation
  • ANSI 24-bit color (\x1b[38;2;R;G;Bm) for smooth shimmer color rendering
  • Supports wide/CJK characters correctly via ansi.StringWidth

Ricardo-M-L added 2 commits July 14, 2026 14:43
Program.Run reads the terminal size once at startup via term.GetSize
and trusts the result, checking only the error. Some terminals — tmux
is the common case, before the pty size is negotiated — return (0, 0)
with no error. Run then resizes the renderer to 0x0 and the event loop,
which only paints after a message, renders the first frame into a 0x0
viewport: the whole screen is blank until a real SIGWINCH (a resize or
keypress) arrives. This looks like the program hung, and it happens
regardless of the model's View() — even a width-agnostic view renders
blank because the renderer viewport is 0.

Fall back to a standard 80x24 for any zero dimension so the first frame
paints; the genuine size still arrives via WindowSizeMsg a moment later
and re-renders correctly.

Adds fallbackZeroSize + a unit test.
Adds ShimmerMsg/NewShimmer/ShimmerText for character-by-character
sweep highlight effects, inspired by Claude Code's TUI.

Includes:
- ShimmerText: pure function for shimmer rendering
- NewShimmer: Cmd for timed tick messages
- ShimmerState: convenience state wrapper
- examples/shimmer: demo program
@codecov

codecov Bot commented Aug 15, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 72.34043% with 26 lines in your changes missing coverage. Please review.
✅ Project coverage is 57.59%. Comparing base (fc707bb) to head (8664684).
⚠️ Report is 13 commits behind head on main.

Files with missing lines Patch % Lines
shimmer.go 71.26% 22 Missing and 3 partials ⚠️
tea.go 85.71% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1769      +/-   ##
==========================================
+ Coverage   56.34%   57.59%   +1.24%     
==========================================
  Files          25       26       +1     
  Lines        1315     1408      +93     
==========================================
+ Hits          741      811      +70     
- Misses        483      504      +21     
- Partials       91       93       +2     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant