Skip to content

Conversation

@xTonai
Copy link
Contributor

@xTonai xTonai commented Jan 27, 2026

If this PR fixes an issue, link it below. If not, delete these two lines.
Resolves #3029

Description:

Your ELO is now being displayed on the Matchmaking button.

Please complete the following:

  • I have added screenshots for all UI updates
  • I process any text displayed to the user through translateText() and I've added it to the en.json file
  • I have added relevant tests to the test directory
  • I confirm I have thoroughly tested these changes and take full responsibility for any bugs introduced

Please put your Discord username so you can be contacted if a bug or regression is found:

@xTonai

UI updates

Screenshot 2026-01-26 204759 Screenshot 2026-01-26 204823

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 27, 2026

Walkthrough

The pull request adds ELO rating display functionality to the main play page. A new translation key is added, and the PlayPage component is enhanced with state management to listen for user data events, extract the ELO value, and render it in the matchmaking button UI.

Changes

Cohort / File(s) Summary
Translation Resource
resources/lang/en.json
Added new translation key matchmaking_button.elo with label text "ELO: " for internationalization support.
PlayPage Component
src/client/components/PlayPage.ts
Added elo state property initialized to "...". Implemented _onUserMeResponse event handler and lifecycle methods connectedCallback and disconnectedCallback to subscribe/unsubscribe from "userMeResponse" events. Extended render output to display ELO label and value in logged-in matchmaking button.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🎮 Your rating gleams on the main screen's face,
No matchmaking queue to enter this place,
The ELO awaits, displayed with grace,
State listeners whisper throughout the space! ⭐

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the main feature being added: displaying Elo on the PlayPage.
Description check ✅ Passed The description is related to the changeset, explaining that ELO is now being displayed on the Matchmaking button with relevant context.
Linked Issues check ✅ Passed The PR successfully implements the feature requested in #3029: displaying user's ranked ELO on the main menu's Matchmaking button, making it visible without entering matchmaking.
Out of Scope Changes check ✅ Passed All changes are directly scoped to implementing the ELO display feature: translation string addition, state management, event handling, and UI rendering for Elo.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds visibility of the player’s ranked ELO directly on the Play page’s “Ranked Matchmaking” button (addresses #3029).

Changes:

  • Listen for userMeResponse on PlayPage and store the player’s 1v1 ELO in reactive state.
  • Render an “ELO” line (label + value) beneath the Ranked Matchmaking button text.
  • Add a new English translation key for the ELO label.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
src/client/components/PlayPage.ts Subscribes to userMeResponse and displays the user’s ELO on the matchmaking button.
resources/lang/en.json Adds matchmaking_button.elo label text for the new UI line.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +189 to +193
<span>
<span
class="relative z-10 text-xs font-medium text-purple-100 opacity-90 group-hover:opacity-100 transition-opacity"
data-i18n="matchmaking_button.elo"
></span>
Copy link

Copilot AI Jan 27, 2026

Choose a reason for hiding this comment

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

The ELO label/value is split across two s and the translation string includes formatting ("ELO: ") to create spacing. This makes localization harder (languages may need to reorder or format the whole "ELO: {value}" differently) and relies on trailing whitespace in the translation.

Consider rendering a single localized string with an ICU placeholder (similar to matchmaking_modal.elo in src/client/Matchmaking.ts) and passing the current elo as a param, or otherwise avoid encoding spacing/punctuation in the translation.

Copilot uses AI. Check for mistakes.
},
"matchmaking_button": {
"play_ranked": "1v1 Ranked Matchmaking",
"elo": "ELO: ",
Copy link

Copilot AI Jan 27, 2026

Choose a reason for hiding this comment

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

matchmaking_button.elo has a trailing space ("ELO: "). Trailing whitespace in translations is fragile and makes it harder for translators/tools to manage spacing/punctuation.

Prefer removing the trailing space and handling spacing in markup/CSS, or switch this string to a placeholder format (e.g., "ELO: {elo}") and render it as a single translated string.

Suggested change
"elo": "ELO: ",
"elo": "ELO:",

Copilot uses AI. Check for mistakes.
Copy link
Collaborator

Choose a reason for hiding this comment

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

please fix, instead use vairables "ELO: {elo}"

Comment on lines +7 to +8
@state() private elo: string = "...";
private _onUserMeResponse: (e: Event) => void;
Copy link

Copilot AI Jan 27, 2026

Choose a reason for hiding this comment

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

PR description indicates relevant tests were added, but this change set only updates PlayPage.ts and en.json with no corresponding test changes. If the intent is to add coverage, please include a client/component test that verifies the ELO text updates when a userMeResponse event is dispatched.

Copilot uses AI. Check for mistakes.
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@src/client/components/PlayPage.ts`:
- Around line 10-26: PlayPage.connectedCallback currently only sets this.elo in
the userMeResponse event handler (_onUserMeResponse) and misses the value if the
event already fired; update the flow so PlayPage reads a cached last userMe
response from Main before attaching the listener: add a simple cache accessor in
Main (e.g., store the last response when getUserMe resolves and expose
getLastUserMeResponse or a module-level variable) and in
PlayPage.connectedCallback call that getter (or read the exported cached value)
to initialize this.elo the same way as in _onUserMeResponse (using
event.detail.player.leaderboard.oneVone.elo) as a fallback, then attach
document.addEventListener for future events.
🧹 Nitpick comments (2)
resources/lang/en.json (1)

971-971: Drop the trailing space in the ELO label.

Line 971 ends with a space. Trailing spaces are easy to lose and make spacing hard to control. Prefer ELO: and add the gap in markup.

♻️ Proposed change
-    "elo": "ELO: ",
+    "elo": "ELO:"
src/client/components/PlayPage.ts (1)

189-199: Add spacing in markup instead of relying on label text.

The label and value are separate spans, but spacing currently depends on the translation string. Add a small gap in markup so translators don’t need trailing spaces.

♻️ Proposed change
-              <span>
+              <span class="inline-flex items-center gap-1">

Comment on lines +10 to +26
connectedCallback() {
super.connectedCallback();

this._onUserMeResponse = (e: Event): void => {
const event = e as CustomEvent<UserMeResponse | false>;

if (!event.detail) {
this.elo = "...";
return;
}

this.elo =
event.detail?.player?.leaderboard?.oneVone?.elo?.toString() ?? "...";
};

document.addEventListener("userMeResponse", this._onUserMeResponse);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

rg -n 'userMeResponse' --type ts --type js -C 3

Repository: openfrontio/OpenFrontIO

Length of output: 17824


🏁 Script executed:

rg -n 'dispatchEvent' --type ts --type js | grep -i 'usermeresp\|userme'

Repository: openfrontio/OpenFrontIO

Length of output: 49


🏁 Script executed:

fd -e ts -e js | xargs grep -l 'dispatchEvent.*userMeResponse\|new CustomEvent.*[Uu]serMe'

Repository: openfrontio/OpenFrontIO

Length of output: 85


🏁 Script executed:

rg -n 'onUserMe\s*=' src/client/Main.ts -A 30 | head -80

Repository: openfrontio/OpenFrontIO

Length of output: 1247


🏁 Script executed:

rg -n 'onUserMe\s*\(' src/client/Main.ts -B 5 -A 2

Repository: openfrontio/OpenFrontIO

Length of output: 246


🏁 Script executed:

sed -n '440,550p' src/client/Main.ts

Repository: openfrontio/OpenFrontIO

Length of output: 3619


🏁 Script executed:

rg -n 'getUserMe' src/client/Main.ts -B 2 -A 5

Repository: openfrontio/OpenFrontIO

Length of output: 641


🏁 Script executed:

rg -n 'window.showPage\|page-matchmaking' src/client/Main.ts | head -20

Repository: openfrontio/OpenFrontIO

Length of output: 49


🏁 Script executed:

find src -name "*.ts" -type f | xargs grep -l 'page-matchmaking' | head -5

Repository: openfrontio/OpenFrontIO

Length of output: 111


🏁 Script executed:

cat -n src/client/Api.ts | grep -A 10 'export function getUserMe'

Repository: openfrontio/OpenFrontIO

Length of output: 49


🏁 Script executed:

sed -n '1,50p' src/client/PlayPage.ts

Repository: openfrontio/OpenFrontIO

Length of output: 132


🏁 Script executed:

find src -name "*PlayPage*" -o -name "*playpage*" -o -name "*play-page*"

Repository: openfrontio/OpenFrontIO

Length of output: 100


🏁 Script executed:

rg -l 'class PlayPage' --type ts

Repository: openfrontio/OpenFrontIO

Length of output: 100


🏁 Script executed:

rg 'export function getUserMe' -A 15

Repository: openfrontio/OpenFrontIO

Length of output: 49


🏁 Script executed:

rg 'getUserMe' src/client/Api.ts -A 15

Repository: openfrontio/OpenFrontIO

Length of output: 512


🏁 Script executed:

cat -n src/client/components/PlayPage.ts | head -50

Repository: openfrontio/OpenFrontIO

Length of output: 1947


Read ELO from cached state on connect, not just from event listener.

The userMeResponse event is dispatched asynchronously via getUserMe().then(onUserMe) in Main.ts line 510. If PlayPage connects after this event fires, the listener will miss it and elo stays as "...". Store the last userMeResponse in Main.ts and read it in PlayPage's connectedCallback as fallback.

🤖 Prompt for AI Agents
In `@src/client/components/PlayPage.ts` around lines 10 - 26,
PlayPage.connectedCallback currently only sets this.elo in the userMeResponse
event handler (_onUserMeResponse) and misses the value if the event already
fired; update the flow so PlayPage reads a cached last userMe response from Main
before attaching the listener: add a simple cache accessor in Main (e.g., store
the last response when getUserMe resolves and expose getLastUserMeResponse or a
module-level variable) and in PlayPage.connectedCallback call that getter (or
read the exported cached value) to initialize this.elo the same way as in
_onUserMeResponse (using event.detail.player.leaderboard.oneVone.elo) as a
fallback, then attach document.addEventListener for future events.

@github-project-automation github-project-automation bot moved this from Triage to Development in OpenFront Release Management Jan 27, 2026
@xTonai
Copy link
Contributor Author

xTonai commented Jan 27, 2026

The trailing whitespace after the "ELO:" in en.json is with intent

},
"matchmaking_button": {
"play_ranked": "1v1 Ranked Matchmaking",
"elo": "ELO: ",
Copy link
Collaborator

Choose a reason for hiding this comment

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

please fix, instead use vairables "ELO: {elo}"

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think all this logic should be in Matchmaking.ts

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fair point. I'll fix it tomorrow. I don't have any time today sadly.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The button it is attached to is located in PlayPage.ts. I would have to migrate him to Matchmaking first, unless I am not missing out on something here.

@xTonai xTonai closed this Jan 29, 2026
@github-project-automation github-project-automation bot moved this from Development to Complete in OpenFront Release Management Jan 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Complete

Development

Successfully merging this pull request may close these issues.

Seeing your ranked elo without entering matchmaking

2 participants