perf(ui): fix timer accumulation on repeated session enter/exit#153
Merged
renato0307 merged 1 commit intomainfrom Mar 19, 2026
Merged
perf(ui): fix timer accumulation on repeated session enter/exit#153renato0307 merged 1 commit intomainfrom
renato0307 merged 1 commit intomainfrom
Conversation
Each call to SessionList.Init() was starting new tea.Tick timers without invalidating the previous ones. After multiple attach/detach cycles, tens of concurrent poll timers would be running simultaneously, flooding the Bubble Tea message queue with checkStateMsg, showTipMsg, and hideTipMsg, causing progressive UI slowdown. Fix using the generation counter pattern: Init() increments pollGen and tipGen; each timer closure captures the current generation. The message handlers discard any message whose generation does not match the current one, ensuring only the latest Init() cycle drives the poll loop. Also fixes TestGetWorktreeForBranch_WorktreeExists to resolve symlinks before comparing paths, handling the macOS /var/folders symlink.
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
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.
Summary
Init()call was starting newtea.Ticktimers without canceling the previous ones, causing stale timers to accumulate across attach/detach cyclesInit()incrementspollGen/tipGen; handlers discard messages from old generationsTestGetWorktreeForBranch_WorktreeExists) caused by the macOS/var/folders→/private/var/folderssymlinkTest plan
go test ./internal/...— all tests passrocha-fix/timer-accumulation-on-session-reattach-v1 run --dev