Skip to content

bugfix: hide account button and token modal login on game start - #1986

Merged
evanpelle merged 1 commit into
v25from
evan-hide-login-button
Sep 1, 2025
Merged

evanpelle merged 1 commit into
v25from
evan-hide-login-button

Conversation

@evanpelle

@evanpelle evanpelle commented Sep 1, 2025 •

Copy link
Copy Markdown
Collaborator

Description:

The account button persisted after game starting

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:

evan

@coderabbitai

coderabbitai Bot commented Sep 1, 2025 •

Copy link
Copy Markdown
Contributor

Walkthrough

Adds a visibility flag and a public close() method to AccountButton. Updates end-of-game cleanup in Main.ts to also close/hide "account-button" and "token-login" modals alongside existing ones.

Changes

Cohort / File(s) Summary
Account button visibility & API
src/client/AccountModal.ts
Introduces private isVisible flag (default true). render() returns nothing when false. Adds public close() that sets isVisible to false, closes AccountModal, and calls requestUpdate. No change to AccountModal’s public API.
End-of-game modal cleanup
src/client/Main.ts
Extends modal-closing loop to include "account-button" and "token-login" selectors, invoking close() or existing checks to ensure these modals are closed on game end.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor Player
  participant Game as Game Loop
  participant Main as Main.ts
  participant Modals as Modal Elements
  participant AccountBtn as AccountButton

  Player->>Game: Triggers end-of-game
  Game->>Main: onGameEnd()
  Main->>Modals: Iterate selectors (..., "account-button", "token-login")
  alt Element is AccountButton
    Main->>AccountBtn: close()
    note right of AccountBtn: Sets isVisible=false<br/>Closes AccountModal<br/>requestUpdate()
  else Other modal
    Main->>Modals: if isModalOpen then close/hide
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested labels

UI/UX

Suggested reviewers

  • scottanderson

Poem

A button learns to quietly hide,
With close() it slips to the side.
Game over calls, the curtains fall,
Main sweeps through, dismissing all.
Modals hush, the stage is clean—
Ready for the next bright scene.


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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore or @coderabbit ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@evanpelle evanpelle added this to the v25 milestone Sep 1, 2025
@evanpelle
evanpelle merged commit acd65e3 into v25 Sep 1, 2025
@evanpelle
evanpelle deleted the evan-hide-login-button branch September 1, 2025 18:34
@github-project-automation github-project-automation Bot moved this from Triage to Complete in OpenFront Release Management Sep 1, 2025

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (2)
src/client/AccountModal.ts (1)

238-239: Prefer reactive state or codebase’s “hidden” pattern for visibility

Use Lit reactivity instead of a manual flag + requestUpdate, or align with the app-wide classList.add("hidden") convention for transitions.

Apply if staying with a flag:

-  private isVisible = true;
+  @state() private isVisible = true;

Then you can drop explicit requestUpdate() calls tied only to this flag.

src/client/Main.ts (1)

531-533: Restore AccountButton after game ends; verify TokenLogin close() exists

  • If AccountButton is hidden on start via close(), make sure you show it again on leave. Otherwise, players lose access to account UI outside games.
  • Please confirm token-login exposes close(); if not, the fallback path won’t trigger here.

Example restoration on leave (add inside handleLeaveLobby):

const ab = document.querySelector("account-button") as HTMLElement & { show?: () => void };
ab?.show?.(); // if you add AccountButton.show()

Optional consistency tweak: If you want to stick to the codebase’s transition convention, consider adding/removing the "hidden" class for non-modal elements like account-button instead of relying on component APIs.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between d655d03 and 2d26e94.

📒 Files selected for processing (2)
  • src/client/AccountModal.ts (3 hunks)
  • src/client/Main.ts (1 hunks)
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: VariableVince
PR: openfrontio/OpenFrontIO#1110
File: src/client/Main.ts:293-295
Timestamp: 2025-06-09T02:20:43.637Z
Learning: In src/client/Main.ts, during game start in the handleJoinLobby callback, UI elements are hidden using direct DOM manipulation with classList.add("hidden") for consistency. This includes modals, buttons, and error divs. The codebase follows this pattern rather than using component APIs for hiding elements during game transitions.
📚 Learning: 2025-06-09T02:20:43.637Z
Learnt from: VariableVince
PR: openfrontio/OpenFrontIO#1110
File: src/client/Main.ts:293-295
Timestamp: 2025-06-09T02:20:43.637Z
Learning: In src/client/Main.ts, during game start in the handleJoinLobby callback, UI elements are hidden using direct DOM manipulation with classList.add("hidden") for consistency. This includes modals, buttons, and error divs. The codebase follows this pattern rather than using component APIs for hiding elements during game transitions.

Applied to files:

  • src/client/Main.ts
🔇 Additional comments (2)
src/client/AccountModal.ts (2)

271-274: Render short‑circuit is fine

Early return cleanly removes the subtree. No functional issues spotted here.


323-327: Ignore show/reset suggestion – AccountButton.close is never called and closing the modal uses AccountModal.close, so the account button never hides.

Likely an incorrect or invalid review comment.

This branch was previously deployed

1 inactive deployment
staging — 2d26e94e Deployed Sep 1, 2025 by openfrontio[bot]
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.

1 participant