fix PGN export for force variations by Mephimeow · Pull Request #20150 · lichess-org/lila · GitHub
Skip to content

fix PGN export for force variations#20150

Draft
Mephimeow wants to merge 2 commits intolichess-org:masterfrom
Mephimeow:fix/force-variation-pgn-export
Draft

fix PGN export for force variations#20150
Mephimeow wants to merge 2 commits intolichess-org:masterfrom
Mephimeow:fix/force-variation-pgn-export

Conversation

@Mephimeow
Copy link
Copy Markdown

Fixes #20081

Force variations (created via 'Force variation' context menu action) were not being rendered in PGN brackets. This bug affected both Analysis and Studies pages.

The fix:

  1. Branches.variations now excludes forceVariation nodes
  2. NewTree.apply uses mainlineFirst (non-forceVariation) for mainline
  3. NewTree.apply combines regular variations and forceVariations

Example before fix: 1. e4 c5 1. d4
Example after fix: 1. e4 c5 (1. d4)

Fixes lichess-org#20081

Force variations (created via 'Force variation' context menu action) were
not being rendered in PGN brackets. This bug affected both Analysis and
Studies pages.

The fix modifies:
1. Branches.variations to exclude forceVariation nodes
2. NewTree.apply to use mainlineFirst (non-forceVariation) for mainline
3. NewTree.apply to combine regular variations and forceVariations
@ornicar ornicar force-pushed the fix/force-variation-pgn-export branch from a2ce5a0 to a79863f Compare April 1, 2026 07:28
@Mephimeow
Copy link
Copy Markdown
Author

@ornicar
Copy link
Copy Markdown
Collaborator

ornicar commented Apr 1, 2026

idk how to fix this for that case

You mean for the one case you tested?

That new test looks wrong to me, or I don't understand what you're trying to do.

@Mephimeow
Copy link
Copy Markdown
Author

idk how to fix this for that case

You mean for the one case you tested?

That new test looks wrong to me, or I don't understand what you're trying to do.

that one test is wrong in ci for my update in force variations

@Mephimeow
Copy link
Copy Markdown
Author

The expectation in the test appears logically incorrect from the point of view of chess notation.

@ornicar
Copy link
Copy Markdown
Collaborator

ornicar commented Apr 1, 2026

Indeed. And yet you did write that test.

So how can you say that it "appears logically incorrect"?

I don't get it.

@Mephimeow
Copy link
Copy Markdown
Author

@ornicar ornicar marked this pull request as draft April 3, 2026 07:25
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.

"Force variation" on last move not represented/saved in the PGN

2 participants