Skip to content

Comments

fix: add 'Spiel starten' button to admin lobby after Rematch (#228)#230

Merged
mholzi merged 3 commits intomainfrom
fix/228-revanche-start-button
Feb 20, 2026
Merged

fix: add 'Spiel starten' button to admin lobby after Rematch (#228)#230
mholzi merged 3 commits intomainfrom
fix/228-revanche-start-button

Conversation

@mholzi
Copy link
Owner

@mholzi mholzi commented Feb 20, 2026

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 in loadStatus() even says "with QR code and start button", but the button was missing from the HTML.

Fix

admin.html

  • Add #start-gameplay-btn (▶️ Spiel starten) as a primary CTA in the sticky lobby-actions bar
  • Demote 'Join as Player' to btn-secondary (still accessible for admins who want to participate)

admin.js

  • Wire #start-gameplay-btn in DOMContentLoaded
  • Add startGameplay(): POSTs /beatify/api/start-gameplay, calls loadStatus() on success to transition to the existing-game view

i18n

  • Add admin.startGameplay key in en, de, es, fr

Tests

  • Add TestRematchGame (5 tests): LOBBY phase after rematch, new game_id, join_url present in state, players preserved, songs restored

Behavior after fix

Before After
Admin clicks Revanche → lobby shows with only 'Join as Player' Admin clicks Revanche → lobby shows with ▶️ Spiel starten button
Admin must re-enter name, session lost Admin clicks Spiel starten → game starts immediately from admin page

Tests

129 passed, 2 skipped

Closes #228

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
@gemini-code-assist
Copy link

Summary of Changes

Hello @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

  • Admin Lobby Functionality: Added a 'Spiel starten' (Start Gameplay) button to the admin lobby view, allowing administrators to directly initiate a game after a rematch without needing to re-join as a player.
  • Frontend Implementation: Implemented client-side logic in admin.js to wire the new 'Start Gameplay' button and handle its click event, making a POST request to the backend API to transition the game state.
  • Internationalization Support: Updated internationalization files (de.json, en.json, es.json, fr.json) to include translations for the new 'Start Gameplay' text, ensuring multi-language support.
  • Test Coverage: Introduced a new test suite (TestRematchGame) to thoroughly verify that the rematch_game functionality correctly transitions to the LOBBY phase, generates a new game ID, preserves players and songs, and includes a join_url in the game state.

🧠 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
  • custom_components/beatify/www/admin.html
    • Added a new primary 'Start Gameplay' button.
    • Demoted the 'Join as Player' button to a secondary style.
  • custom_components/beatify/www/i18n/de.json
    • Added the admin.startGameplay key with its German translation.
  • custom_components/beatify/www/i18n/en.json
    • Added the admin.startGameplay key with its English translation.
  • custom_components/beatify/www/i18n/es.json
    • Added the admin.startGameplay key with its Spanish translation.
  • custom_components/beatify/www/i18n/fr.json
    • Added the admin.startGameplay key with its French translation.
  • custom_components/beatify/www/js/admin.js
    • Wired the click event for the new 'start-gameplay-btn'.
    • Implemented the startGameplay asynchronous function to handle the API call and state update.
  • tests/unit/test_state.py
    • Added a new test class TestRematchGame to validate rematch functionality, including phase transition, new game ID generation, join_url presence, and preservation of players and songs.
Activity
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

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>

Choose a reason for hiding this comment

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

medium

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.

Suggested change
<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...';

Choose a reason for hiding this comment

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

medium

The string "Starting..." is hardcoded here. Since the project uses an internationalization system, this text should ideally be localized using utils.t() or BeatifyI18n.t(). You might consider adding a new key to the i18n files or using an existing one like common.loading.

Beatify Dev Agent added 2 commits February 20, 2026 23:00
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
@mholzi mholzi merged commit 6d2ef12 into main Feb 20, 2026
4 of 5 checks passed
@mholzi mholzi deleted the fix/228-revanche-start-button branch February 20, 2026 23:07
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.

bug: Revanche-Button leitet Admin auf Start-Screen ohne "Spiel starten"-Button

1 participant