Skip to content

Comments

Fix: reset puzzle streak correctly when failing the first puzzle#2452

Merged
veloce merged 6 commits intolichess-org:mainfrom
sam-baumann:streak-restart
Dec 23, 2025
Merged

Fix: reset puzzle streak correctly when failing the first puzzle#2452
veloce merged 6 commits intolichess-org:mainfrom
sam-baumann:streak-restart

Conversation

@sam-baumann
Copy link
Contributor

@sam-baumann sam-baumann commented Dec 21, 2025

#1951 had a previous fix but issue has returned.

Previous fix checked if the puzzle id is the same or has changed, but there seems to be a separate issue where the same puzzle streak re-plays sometimes if you fail early. I logged that as a separate issue at #2455

I replaced the puzzle id check with a check for if the value of finished is going from true to false. Also wrote a unit test to prevent further regression

@sam-baumann sam-baumann marked this pull request as ready for review December 21, 2025 18:05
Copy link
Contributor

@veloce veloce left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure to understand why there was a regression, and the fix. Could you explain more? thank.

@sam-baumann
Copy link
Contributor Author

I'm not sure to understand why there was a regression, and the fix. Could you explain more? thank.

@veloce
The previous fix only applied when the previous puzzle is different from the new one being loaded. It did a check for previous.puzzle.id != next.puzzle.id in a listener on puzzleStreakControllerProvider

It seems that if you fail a puzzle streak very soon after starting, the lichess API will send back the exact same puzzle streak. This behavior is reproducible on https://lichess.org/streak

When you fail on the first puzzle of the streak, and the server sends back the exact same streak, it causes the previous fix for this issue not to work, because the puzzle you failed on is the same as the one it's trying to load.

My fix replaces the puzzle.id equivalence check with a check for previous.streak.finished == true && next.streak.finished == false, as this condition will always be true after hitting the 'new streak' button.

Copy link
Contributor

@veloce veloce left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@veloce veloce merged commit 494614c into lichess-org:main Dec 23, 2025
1 check passed
@sam-baumann sam-baumann deleted the streak-restart branch December 23, 2025 16:26
tom-anders pushed a commit to tom-anders/lichess-mobile that referenced this pull request Jan 5, 2026
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.

2 participants