Skip to content

Fix deep link loop for imported games with anonymous players#3046

Merged
veloce merged 1 commit into
lichess-org:mainfrom
berenbums:fix/anonymous-game-deeplink-loop
Apr 27, 2026
Merged

Fix deep link loop for imported games with anonymous players#3046
veloce merged 1 commit into
lichess-org:mainfrom
berenbums:fix/anonymous-game-deeplink-loop

Conversation

@berenbums

Copy link
Copy Markdown

Summary

Imported PGNs without a [Result] tag and without [White]/[Black] tags fall into an infinite deep-link loop when shared into the Lichess mobile app. This PR routes those games to the analysis screen instead.

Reproducible by hitting POST /api/import with a PGN that lacks a result and player tags and then opening the returned https://lichess.org/{id}.

Root cause

When a PGN is imported without a Result tag, Lichess records the game with status: "started". When [White]/[Black] tags are missing too, the players come back anonymous ({"name": "?"} with no user).

_tryResolveGameLink in app_links_service.dart then returns null, because both, the AnalysisScreen (game.finished) and TvScreen (game.playerOf(orientation).user) checks fail.

handleAppLink falls through to launchUrl(uri), which the OS routes back into the app via the verified lichess.org/{id} intent filter, looping indefinitely.

Fix

Open the game in AnalysisScreen whenever it's finished or has no real player on the orientation side. Open in TvScreen otherwise.

@berenbums

Copy link
Copy Markdown
Author

Just noticed that #3043 was opened and merged while I was working on my PR. You guys are fast :). This one might not be required anymore.

@HaonRekcef

Copy link
Copy Markdown
Collaborator

@berenbums I see you added a test case that is useful so you could create a new PR with the test :)

@veloce

veloce commented Apr 25, 2026

Copy link
Copy Markdown
Contributor

The PR is still useful imo, can you solve the conflict @berenbums ? Thanks!

@berenbums berenbums marked this pull request as draft April 25, 2026 10:54
@berenbums berenbums force-pushed the fix/anonymous-game-deeplink-loop branch 2 times, most recently from da4d367 to 500471f Compare April 25, 2026 11:25
@berenbums berenbums marked this pull request as ready for review April 25, 2026 11:33
@berenbums

Copy link
Copy Markdown
Author

Combined the changes and updated the test case. Thank you for the quick feedback!

@HaonRekcef

HaonRekcef commented Apr 25, 2026

Copy link
Copy Markdown
Collaborator

Hmm, I am not sure we want the proposed changes: When getting a live game link of a game between two anon users we would end in the analysis board, where there wont be any move updates. Ideally we should open it in the tvScreen.
The loop is already prevented by #3036

@veloce

veloce commented Apr 26, 2026

Copy link
Copy Markdown
Contributor

I see. I didn't get that, thanks for the insight @HaonRekcef .

So we only want the test in this PR @berenbums

@berenbums berenbums force-pushed the fix/anonymous-game-deeplink-loop branch from 500471f to 2b64bc8 Compare April 26, 2026 16:27
@berenbums

Copy link
Copy Markdown
Author

Makes sense to me, thanks @HaonRekcef . Updated the PR so it only adds a new test case: A https://lichess.org/{id} link for a game with status: "started", source: "import", and anonymous players resolves to AnalysisScreen.

@veloce veloce merged commit 6c9f43f into lichess-org:main Apr 27, 2026
1 check passed
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.

3 participants