fix: add 'Spiel starten' button to admin lobby after Rematch (#228)#230
fix: add 'Spiel starten' button to admin lobby after Rematch (#228)#230
Conversation
Root cause: the lobby section in admin.html had no way to call /beatify/api/start-gameplay. The StartGameplayView (LOBBY → PLAYING) existed on the backend but was unreachable from the admin page. After Revanche the admin was left in the lobby with only 'Join as Player', requiring them to re-enter their name and re-join — admin session effectively lost. Fix: - admin.html: add #start-gameplay-btn (▶️ Spiel starten) above #participate-btn in the sticky lobby-actions bar; demote 'Join as Player' to btn-secondary - admin.js: wire DOMContentLoaded listener + add startGameplay() that POSTs /beatify/api/start-gameplay and calls loadStatus() on success - i18n (en/de/es/fr): add admin.startGameplay translation key - tests/unit/test_state.py: add TestRematchGame (5 tests) covering LOBBY phase, new game_id, join_url presence, player preservation, and song restoration after rematch
Summary of ChangesHello @mholzi, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request resolves a critical usability issue for administrators who previously could not directly start a new game from the lobby after initiating a rematch, forcing them to re-enter their name and lose their admin session. By introducing a dedicated 'Start Gameplay' button on the admin lobby page, the changes enable a seamless and direct transition from the lobby to the playing phase, significantly enhancing the admin's workflow and overall experience. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request effectively resolves the issue where admins were unable to start a game directly from the lobby after a rematch. The implementation correctly wires the 'Start Game' button to the backend API and handles the UI state transitions appropriately. The added unit tests provide good coverage for the rematch logic. I have noted a couple of minor points regarding i18n consistency and localization that could be improved.
| <!-- Start Gameplay: transitions LOBBY → PLAYING without requiring admin to join as player (Issue #228) --> | ||
| <button id="start-gameplay-btn" class="btn btn-primary btn-large btn-full-width"> | ||
| <span class="btn-icon" aria-hidden="true">▶️</span> | ||
| <span data-i18n="admin.startGameplay">Spiel starten</span> |
There was a problem hiding this comment.
The default text for this button is in German ("Spiel starten"), while the rest of the document uses English defaults (e.g., line 276 "Join as Player"). For consistency with the document's lang="en" attribute and other UI elements, the default text should be in English.
| <span data-i18n="admin.startGameplay">Spiel starten</span> | |
| <span data-i18n="admin.startGameplay">Start Game</span> |
|
|
||
| btn.disabled = true; | ||
| const originalText = btn.innerHTML; | ||
| btn.innerHTML = '<span class="btn-icon" aria-hidden="true">⏳</span> Starting...'; |
There was a problem hiding this comment.
Root cause: after rematch_game() resets phase to LOBBY, admin was shown showLobbyView() with a 'Join as Player' modal. But the admin was already registered as a player (session preserved) — no way to start the game. Fix (3 changes in admin.js): 1. confirmRematch(): after successful rematch API call, if sessionStorage has beatify_admin_name + API returns new_game_id → redirect directly to /beatify/play?game=NEW_ID (skip lobby view entirely). 2. showLobbyView(): if admin already has a stored name, update the participate button label to '▶️ Spiel starten' instead of 'Join as Player'. 3. openAdminJoinModal(): if beatify_admin_name is in sessionStorage and currentGame.game_id is known → redirect directly without showing the name-entry modal. Result: admin who clicks Revanche lands back on the player page in LOBBY state with the Start Game button visible immediately. Fixes #228
Problem
After clicking Revanche (Rematch), the admin is redirected to the lobby view on the admin page — but the lobby had no 'Spiel starten' (Start Gameplay) button. The only option was 'Join as Player', which required re-entering the admin name, effectively losing the admin session.
Root cause:
StartGameplayView(POST/beatify/api/start-gameplay, LOBBY → PLAYING) exists on the backend but was never wired to a button on the admin page. The comment inloadStatus()even says "with QR code and start button", but the button was missing from the HTML.Fix
admin.html#start-gameplay-btn(btn-secondary(still accessible for admins who want to participate)admin.js#start-gameplay-btninDOMContentLoadedstartGameplay(): POSTs/beatify/api/start-gameplay, callsloadStatus()on success to transition to the existing-game viewi18n
admin.startGameplaykey inen,de,es,frTests
TestRematchGame(5 tests): LOBBY phase after rematch, new game_id,join_urlpresent in state, players preserved, songs restoredBehavior after fix
Tests
Closes #228