Skip to content

Refactor: use promises instead of callbacks for joining a game#3452

Merged
evanpelle merged 1 commit intov30from
promist-join
Mar 17, 2026
Merged

Refactor: use promises instead of callbacks for joining a game#3452
evanpelle merged 1 commit intov30from
promist-join

Conversation

@evanpelle
Copy link
Collaborator

@evanpelle evanpelle commented Mar 17, 2026

Description:

Simplifies the interface a bit.

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
Copy link
Contributor

coderabbitai bot commented Mar 17, 2026

Caution

Review failed

Failed to post review comments

Walkthrough

This PR enhances UI visual weight by increasing background opacity and blur strength across display layers, replaces an in-game header ad component with a new promo component, refactors the lobby join API from callback-based to promise-based pattern, updates map metadata, adjusts game spawn phases and AI behavior for specific game modes, refactors message rate limiting to use cumulative byte tracking, adds IP-based WebSocket rate limiting, and simplifies game difficulty modifier selection logic.

Changes

Cohort / File(s) Summary
UI Styling Enhancement
index.html, src/client/graphics/layers/{AttacksDisplay,EventsDisplay,GameLeftSidebar,GameRightSidebar,PlayerInfoOverlay,ReplayPanel}.ts
Background opacity increased from bg-gray-800/70 to bg-gray-800/92 and blur effect strengthened from backdrop-blur-xs to backdrop-blur-sm across multiple UI components for improved visual prominence.
Lobby Lifecycle Refactoring
src/client/{ClientGameRunner,Main}.ts
joinLobby() API refactored from callback-based (onPrestart, onJoin parameters) to promise-based JoinLobbyResult object with stop(), prestart, and join members; all call sites updated to use new interface.
Ad/Promo Component Replacement
src/client/graphics/{GameRenderer,layers/InGamePromo}.ts, src/client/graphics/layers/InGameHeaderAd.ts
InGameHeaderAd component removed and replaced with new InGamePromo component; imports, DOM queries, and rendering layer updated accordingly.
Rate Limiting Refactoring
src/server/{ClientMsgRateLimiter,Worker}.ts, tests/server/ClientMsgRateLimiter.test.ts
Client rate limiter switched from per-type byte tracking to cumulative totalBytes counter; added IP-based WebSocket rate limiting with per-IP limiters and cleanup interval; test suite reorganized to validate new cumulative byte behavior.
Game Logic & Configuration
src/core/{configuration/DefaultConfig,execution/utils/AiAttackBehavior}.ts, src/server/MapPlaylist.ts
Spawn phase turns now vary with random spawn flag (150 if enabled, else 300); AI donation logic restricted for public HvN games; hard nations probability simplified and unified across game modifier pools.
Map Data Updates
resources/maps/straitofhormuz/manifest.json
Map name capitalized ("straitofhormuz" → "Strait of Hormuz"); height and tile counts adjusted; location name Unicode normalized.

Sequence Diagram(s)

sequenceDiagram
    participant Client as Main (Client)
    participant Lobby as ClientGameRunner
    participant EventBus as EventBus
    
    Client->>Lobby: joinLobby(eventBus, lobbyConfig)
    activate Lobby
    Lobby->>Lobby: Initialize prestartPromise,<br/>joinPromise, resolvers
    Lobby-->>Client: Return JoinLobbyResult {<br/>stop(), prestart, join }
    deactivate Lobby
    
    EventBus->>Lobby: Emit prestart message
    activate Lobby
    Lobby->>Lobby: resolvePrestart()
    deactivate Lobby
    
    Client->>Client: Await lobbyHandle.prestart
    Client->>Client: Run UI/modal setup
    
    EventBus->>Lobby: Emit join message
    activate Lobby
    Lobby->>Lobby: resolveJoin()
    deactivate Lobby
    
    Client->>Client: Await lobbyHandle.join
    Client->>Client: Start game
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🎨 Gray walls grow darker, sharper still,
Lobby promises now flow where callbacks filled,
Ads fade to promos, rates simplify,
Spawn phases dance—hard nations alibi! ✨

🚥 Pre-merge checks | ✅ 1 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 40.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ❓ Inconclusive The description contains only the default PR template with incomplete checklist items and no actual details about the changes, but the PR branch and objectives provide sufficient context that this is a multi-faceted change including UI updates and rate limiting. Add a meaningful description of the key changes, such as: promise-based join flow refactor, HUD styling updates, in-game ad replacement, rate limiting improvements, and spawn phase adjustments. This helps reviewers understand the full scope.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main refactor: replacing callback-based join flow with promise-based approach, which is demonstrated in ClientGameRunner.ts and Main.ts changes.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

📝 Coding Plan
  • Generate coding plan for human review comments

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.

Tip

You can make CodeRabbit's review stricter and more nitpicky using the `assertive` profile, if that's what you prefer.

Change the reviews.profile setting to assertive to make CodeRabbit's nitpick more issues in your PRs.

@evanpelle evanpelle added this to the v30 milestone Mar 17, 2026
@evanpelle evanpelle merged commit cce46ef into v30 Mar 17, 2026
17 of 26 checks passed
@evanpelle evanpelle deleted the promist-join branch March 17, 2026 17:08
@github-project-automation github-project-automation bot moved this from Triage to Complete in OpenFront Release Management Mar 17, 2026
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