Skip to content

remove spawn ad#1482

Merged
evanpelle merged 1 commit intomainfrom
evan-remove-sa
Jul 18, 2025
Merged

remove spawn ad#1482
evanpelle merged 1 commit intomainfrom
evan-remove-sa

Conversation

@evanpelle
Copy link
Collaborator

@evanpelle evanpelle commented Jul 18, 2025

Description:

It is not being destroyed on start for some users.

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
  • I have read and accepted the CLA aggreement (only required once).

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

evan

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jul 18, 2025

Walkthrough

The tick() method in the SpawnAd.ts file was updated to stop showing the spawn ad during the game's spawn phase. The code that triggered the ad display was commented out and replaced with a console log. All other logic, including hiding the ad, remains unchanged.

Changes

File(s) Change Summary
src/client/graphics/layers/SpawnAd.ts Disabled spawn ad display in tick() by commenting out the call to this.show() and adding a log message. No changes to public exports.

Possibly related PRs

  • add spawn ads #1228: Previously added the spawn ad feature and its display logic in the same file and context, directly related to this change.

Poem

The spawn ad waits, but does not show,
Its moment paused, the code says "no."
Instead, a message logs the plan—
"Not showing spawn ad," as only code can.
The game moves on, the ad takes a rest,
For now, the players are not a guest.

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

npm error Exit handler never called!
npm error This is an error with npm itself. Please report this error at:
npm error https://github.com/npm/cli/issues
npm error A complete log of this run can be found in: /.npm/_logs/2025-07-18T15_40_34_453Z-debug-0.log


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.
    • Explain this complex logic.
    • 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. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • 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 src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

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

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai 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

Documentation and Community

  • 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.

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

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a221fee and c311dac.

📒 Files selected for processing (1)
  • src/client/graphics/layers/SpawnAd.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.
src/client/graphics/layers/SpawnAd.ts (1)
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.
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: 🏗️ Build
  • GitHub Check: Analyze (javascript-typescript)
  • GitHub Check: Deploy to openfront.dev

Comment on lines +58 to +59
console.log("not showing spawn ad");
// this.show();
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

Mismatch between PR objective and implementation approach.

The PR states the issue is that spawn ads are "not being destroyed on start for some users," but this change prevents ads from showing entirely rather than fixing the destruction issue. This approach might mask the underlying problem instead of solving it.

Consider these alternatives:

  1. Fix the destruction issue directly - Investigate why destroyAd() isn't working for some users and fix that specific problem
  2. Add better error handling - Enhance the destroyAd() method with more robust cleanup
  3. Remove the console log - This will fire repeatedly during tick cycles and create console noise

The destroyAd() method looks properly implemented with error handling, so the real issue might be in timing or external dependencies (like window.ramp availability).


🏁 Script executed:

#!/bin/bash
# Search for other spawn ad related code to understand the destruction issue
echo "=== Searching for spawn ad destruction patterns ==="
rg -A 5 -B 5 "destroyAd|destroy.*ad" --type ts

echo "=== Looking for game start/initialization patterns ==="
rg -A 5 -B 5 "handleJoinLobby|game.*start|init.*game" --type ts

echo "=== Checking for other ad-related cleanup ==="
rg -A 3 -B 3 "classList.*add.*hidden|hide.*ad" --type ts

Length of output: 27558


Ensure spawn ad is destroyed at game start instead of simply disabling it.

The change in SpawnAd.ts comments out this.show() and adds a console log, which stops the ad from ever showing but does not address the underlying destruction issue. To fix this properly:

• File: src/client/graphics/layers/SpawnAd.ts
Method: tick() (around lines 58–64)

• Instead of disabling show(), call your existing hide() (or directly destroyAd()) at the start of the spawn phase. That will:

  1. Destroy any leftover ad units via window.ramp.destroyUnits("all")
  2. Clean up component state (isVisible = false, adLoaded = false)
  3. Align with the codebase pattern of using hide()/classList.add("hidden") for UI transitions

• Remove the repeated console log to avoid noise.

Suggested diff:

--- a/src/client/graphics/layers/SpawnAd.ts
+++ b/src/client/graphics/layers/SpawnAd.ts
@@ -55,9 +55,9 @@ export class SpawnAd extends LitElement {
       if (game.phase() === GamePhase.Spawn && this.ticks > 10 && metrics.gamesPlayed > 5) {
-        console.log("not showing spawn ad");
-        // this.show();
+        // ensure any existing ad is destroyed at spawn start
+        this.hide();
       } else {
         this.hide();
       }

This will destroy the ad cleanly when the spawn phase begins and avoid masking the real issue.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
console.log("not showing spawn ad");
// this.show();
if (game.phase() === GamePhase.Spawn && this.ticks > 10 && metrics.gamesPlayed > 5) {
// ensure any existing ad is destroyed at spawn start
this.hide();
} else {
this.hide();
}
🤖 Prompt for AI Agents
In src/client/graphics/layers/SpawnAd.ts around lines 58 to 59 within the tick()
method, replace the console.log and commented out this.show() with a call to the
existing hide() method (or directly call destroyAd()) at the start of the spawn
phase. This will properly destroy any leftover ad units using
window.ramp.destroyUnits("all") and reset component state like isVisible and
adLoaded, following the codebase pattern for UI cleanup. Also, remove the
console.log statement to prevent unnecessary log noise.

@github-project-automation github-project-automation bot moved this from Triage to Development in OpenFront Release Management Jul 18, 2025
@evanpelle evanpelle merged commit d4755a7 into main Jul 18, 2025
10 of 22 checks passed
@evanpelle evanpelle deleted the evan-remove-sa branch July 18, 2025 15:47
@github-project-automation github-project-automation bot moved this from Development to Complete in OpenFront Release Management Jul 18, 2025
@coderabbitai coderabbitai bot mentioned this pull request Jul 31, 2025
5 tasks
@coderabbitai coderabbitai bot mentioned this pull request Oct 23, 2025
4 tasks
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