-
Notifications
You must be signed in to change notification settings - Fork 133
Migrate spinner to Bubble Tea for better terminal state management #4336
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
pietern
wants to merge
13
commits into
main
Choose a base branch
from
cmdio-tea-spinner
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+319
−42
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
Implements spinnerModel with exact Brian Downs charset 11 (⣾ ⣽ ⣻ ⢿ ⡿ ⣟ ⣯ ⣷), 200ms timing, and green color. Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
After sending quitMsg, wait for the Bubble Tea program to fully complete and restore terminal state (including cursor visibility) before the bridge goroutine exits. This fixes the issue where the cursor would disappear after the spinner completed.
Add state tracking to cmdIO to manage Bubble Tea program lifecycle: - Sequential tea.Program execution (queues if one is already running) - Synchronization via cmdio.Wait() to ensure cleanup before exit - Post-run hook in cmd/root waits for active programs This ensures: - Only one tea.Program runs at a time (e.g., sequential spinners queue) - Terminal state (including cursor) is always restored before process exit - No race conditions between program cleanup and command termination Future: Replace chan string API with explicit Close() method for better synchronization without needing sleep() delays. Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
Bubble Tea by default captures SIGINT (Ctrl-C) to gracefully clean up terminal state. For the non-interactive spinner, this prevents users from immediately canceling operations. Using WithoutSignalHandler() restores default OS behavior where Ctrl-C terminates immediately. Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
Use sync.WaitGroup to ensure both the tea.Program goroutine and the bridge goroutine complete before calling releaseTeaProgram(). This makes the cleanup contract explicit and prevents race conditions. Also removes "yet" from signal handling comment - immediate Ctrl-C termination is the desired behavior, not a temporary state. Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
- Group type declarations - Move signal handler comment to be inline with the option Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
- Remove briandowns/spinner (Apache 2.0) - Add charmbracelet/bubbles, bubbletea, lipgloss (MIT) Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
Update comments to describe spinner frames generically rather than referencing the previous implementation. Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
Contributor
Author
|
Tested with #4335. VHS tape: |
Replace wg.Add(1); go func() { defer wg.Done(); ... }() with wg.Go(...)
to comply with linter rules and use the newer WaitGroup.Go() method
introduced in Go 1.24.
Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
andrewnester
approved these changes
Jan 20, 2026
| c := fromContext(ctx) | ||
| c.teaMu.Lock() | ||
| done := c.teaDone | ||
| c.teaMu.Unlock() |
Contributor
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should it be defer unlock?
Collaborator
|
Commit: 19b061d
24 interesting tests: 19 KNOWN, 4 RECOVERED, 1 SKIP
Top 50 slowest tests (at least 2 minutes):
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.


Changes
New spinner that uses the Bubble Tea framework.
This change maintains visual parity with previous spinner (charset, timing, color).
Include explicit synchronization on CLI exit to ensure that terminal state has been restored.
Why
This migration provides a more robust foundation for terminal UI components. The plan is to migrate other interactive elements to Bubble Tea as well for consistent terminal handling across all interactive CLI features.
Tests
See before/after GIFs in PR.
Manual testing on Windows (Powershell, cmd.exe, and Git Bash).
CLI binary size goes from 53.75M to 55.03M (+2.3%).