Skip to content

Conversation

@voloder
Copy link

@voloder voloder commented Nov 6, 2025

Description:

After accidentally pressing the back button on my mouse mid game, I got frustrated with the fact that there's no confirmation before the game closes abruptly

In this PR I have added confirmation, but only when the user is in an active game. It's disabled in dev mode to prevent annoyances with hot reload and debugging.

image

I hope this PR helps someone.

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:

ado1928

@voloder voloder requested a review from a team as a code owner November 6, 2025 00:57
@CLAassistant
Copy link

CLAassistant commented Nov 6, 2025

CLA assistant check
All committers have signed the CLA.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 6, 2025

Warning

Rate limit exceeded

@ryanbarlow97 has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 3 minutes and 8 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between c4a12fe and 2615296.

📒 Files selected for processing (1)
  • src/client/Main.ts (1 hunks)

Walkthrough

The PR enhances browser lifecycle event handling in the client by adding a development-mode guard to the beforeunload handler to prevent unintended page navigation when games are active, and introducing a pagehide handler to gracefully stop games when the page becomes hidden.

Changes

Cohort / File(s) Summary
Browser Lifecycle Event Handlers
src/client/Main.ts
Enhanced beforeunload event with event parameter and development-mode guard to prevent page unload when a game is active. Added new pagehide event handler that logs a message and stops the active game when the page is hidden.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

  • Verify the development-mode guard logic is correct and doesn't interfere with intended unload behavior
  • Confirm the pagehide handler executes reliably across browser contexts
  • Check that gameStop is consistently set/cleared throughout the application lifecycle

Suggested reviewers

  • evanpelle

Poem

🎮 When browsers close and pages fade away,
The game stops safely, come what may,
Dev mode flows free, production stays true,
Lifecycle events keep the session through! ✨

Pre-merge checks

✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: adding confirmation when closing the game in production.
Description check ✅ Passed The description is well-related to the changeset, explaining the motivation, implementation details, and testing approach.

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.

@VariableVince
Copy link
Contributor

@voloder Sorry but there are 2 PRs for this already, linked to issue #1877. This could mean your PR won't be accepted

Comment on lines +173 to +174
event.returnValue = "";
return event.returnValue;
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't understand why these lines are necessary?

this.publicLobby = document.querySelector("public-lobby") as PublicLobby;

window.addEventListener("beforeunload", () => {
window.addEventListener("beforeunload", (event) => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

singpleplayer has a beforeunload hook to save the game, so just want to make sure they don't conflict.

Copy link
Collaborator

Choose a reason for hiding this comment

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

When clicking the exit button in game, there is a prompt, will this cause duplicate prompts?

@github-actions
Copy link

This pull request is stale because it has been open for fourteen days with no activity. If you want to keep this pull request open, add a comment or update the branch.

@github-actions github-actions bot added the Stale PRs that haven't been touched for over two weeks. label Nov 26, 2025
@github-actions github-actions bot removed the Stale PRs that haven't been touched for over two weeks. label Dec 3, 2025
@github-actions
Copy link

This pull request is stale because it has been open for fourteen days with no activity. If you want to keep this pull request open, add a comment or update the branch.

@github-actions github-actions bot added the Stale PRs that haven't been touched for over two weeks. label Dec 17, 2025
@Lavodan
Copy link
Contributor

Lavodan commented Dec 21, 2025

@voloder Are you still interested in finishing this PR up?

@github-actions github-actions bot removed the Stale PRs that haven't been touched for over two weeks. label Dec 22, 2025
@iiamlewis iiamlewis added good first issue Good for new contributors. Stale PRs that haven't been touched for over two weeks. labels Dec 23, 2025
@iiamlewis iiamlewis moved this from Triage to Development in OpenFront Release Management Dec 23, 2025
@iiamlewis iiamlewis moved this from Development to Stalled in OpenFront Release Management Dec 23, 2025
@iiamlewis iiamlewis added this to the Backlog milestone Dec 23, 2025
@iiamlewis
Copy link
Contributor

Stale PR that is now orphaned. If anyone wants to pick this up, feel free!

@github-actions github-actions bot removed the Stale PRs that haven't been touched for over two weeks. label Dec 24, 2025
@deshack
Copy link
Contributor

deshack commented Jan 3, 2026

Stale PR that is now orphaned. If anyone wants to pick this up, feel free!

I opened PR #2777. It's up-to-date with latest changes to main and takes a completely different approach.

@iiamlewis
Copy link
Contributor

Stale PR that is now orphaned. If anyone wants to pick this up, feel free!

I opened PR #2777. It's up-to-date with latest changes to main and takes a completely different approach.

Amazing, I'll close this down

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

Labels

good first issue Good for new contributors.

Projects

Status: Complete

Development

Successfully merging this pull request may close these issues.

8 participants